From 5fb5e20aa00ead18785c14fe788cdfdbced14f63 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 4 Oct 2015 16:46:58 +0200 Subject: o Better firmware info when posting. --- .gitignore | 1 + README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++------ mqtt-bridge/mq.lua | 14 ++++++++++++-- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index c96562a..0218843 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ esptool nodemcu-uploader +*.bin cfg-* .cookie diff --git a/README.md b/README.md index ca445c5..87b6fc0 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ -# Installing `esptool` +# Required Tools + +## Installing `esptool` $ git clone https://github.com/themadinventor/esptool.git $ cd esptool $ python setup.py install -local -# NodeMCU Uploader +## NodeMCU Uploader This tool uploads the Lua files. Requires that the device is runnig the Lua firmware. @@ -13,12 +15,32 @@ This tool uploads the Lua files. Requires that the device is runnig the Lua firm https://github.com/nodemcu/nodemcu-firmware +# Installing Lua Interpreter + +1. Download a release from https://github.com/nodemcu/nodemcu-firmware/releases +1. Check that you have a connection to the board: + + $ esptool.py read_mac + Connecting... + MAC: 18:fe:34:06:59:a5 + +1. Upload firmware + + $ esptool.py write_flash 0x0 nodemcu_integer_0.9.6-dev_20150704.bin + Connecting... + Erasing flash... + Wrote 450560 bytes at 0x00000000 in 43.8 seconds (82.4 kbit/s)... + + Leaving... + +1. Now start talking! + # Talking to the Lua firmware -On unix Screen is a useful tool to talk to serial ports. Usage: +On unix Screen is a useful tool to talk to serial ports. Usage: $ screen - + $ screen /dev/ttyUSB0 9600 After starting screen and pressing reset you should get some output similar to this: @@ -27,7 +49,7 @@ After starting screen and pressing reset you should get some output similar to t NodeMCU 0.9.6 build 20150704 powered by Lua 5.1.4 lua: cannot open init.lua - > + > The first garbage output is expected and is from the bootloader trying to autodetect the baud rate. @@ -41,13 +63,29 @@ Open screen and paste this code: print(ip) -- Configure the device - wifi.setmode(wifi.STATION) + wifi.setmode(wifi.STATION) wifi.sta.config("...", "...") -- Now check that the IP is assigned. It might take some time so try again. ip = wifi.sta.getip() print(ip) +# Building a new Lua firmware + +## Build and install the compiler and SDK + + $ git clone --recursive https://github.com/pfalcon/esp-open-sdk.git + $ cd esp-open-sdk + $ make STANDALONE=n + .. wait a while .. + + Add the compiler to your $PATH (see output) + + $ cd .. + $ git clone https://github.com/nodemcu/nodemcu-firmware + $ cd nodemcu-firmware + $ make + # References * [Lua API](https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en) diff --git a/mqtt-bridge/mq.lua b/mqtt-bridge/mq.lua index da77063..a6ae0b9 100644 --- a/mqtt-bridge/mq.lua +++ b/mqtt-bridge/mq.lua @@ -19,8 +19,18 @@ end local function mq_client_connected(con) p("connected") - local majorVer, minorVer, devVer, chipId, flashId, flashSize, flashMode, flashSpeed = node.info() - payload = '{"version": "'..majorVer..'.'..minorVer..'.'..devVer..'", "chipId":'..chipId..', "flashId":'..flashId..', "flashSize":'..flashSize..', "flashMode":'..flashMode..', "flashSpeed":'..flashSpeed.."}" + local majorVer, minorVer, devVer, chipId, flashId, flashSize, flashMode, flashSpeed, buildDate = node.info() + payload = '{"version": "'..majorVer..'.'..minorVer..'.'..devVer..'", "chipId":'..chipId..', "flashId":'..flashId..', "flashSize":'..flashSize..', "flashMode":'..flashMode..', "flashSpeed":'..flashSpeed + + if buildDate then + payload = payload..', "buildDate": "'..buildDate..'"' + end + + if node.info_versions then + major, minor, dev, buildDate, sdkVersion = node.info_versions() + payload = payload..'", versions": {"major": '..major..', "minor": '..minor..', "dev": '..dev..', "buildDate": "'..buildDate..'", "sdk": "'..sdkVersion..'"}' + end + payload = payload.."}" P.publish("firmware", payload) end -- cgit v1.2.3