I have done some work on Jeshwanth's MQTT port and made it function the way I think it should more or less work. Part of that was to create a simple timer scheduler which will execute a console command every time a timer expires. This is how I get FK to periodically publish something.
I've hooked the MQTT code into the GPIO driver as well as my SI7020 temperature/humidity driver. It should be fairly straight forward to link to the other drivers but I have not done so.
See: i2c_7020.c:do_si7020pub{temp,humidity}()
I also found/fixed a bug in the mkrel code... If there's garbage after the end of the command, it continues reading and generating args.
I have two ESP8266 based devices, on with an SI7020 and another with a couple of 16A relays. Both have been running and bound to my Mosquito broker for over 2 weeks without resetting. With the relay board, I can publish a GPIO message to turn the relay on/off... I can also read the state of the GPIO after the command to ensure that it is asserted/cleared.
every - Execute console cmd every N seconds
every 10 'gpio out 5 1 ; gpio out 5 0'
every 10 $envvar
which can be used to regularly publish an event like so:
setenv pubs 'gpio_pub 5;gpio_pub 4'
every 15 $pubs
I've also added commands:
gpio_pub - Publish GPIO state
gpio_pub
gpio_sub - Subscribe to GPIO
gpio_sub
si7020_pub_humidity - Publish Humidity via MQTT
si7020_pub_temperature - Publish Temperature via MQTT
There are also commands:
mqttsub - Subscribe MQTT
mqttpub - Publish MQTT
stopmqtt - Stop MQTT Service
startmqtt - Start MQTT Service
I have done some work on Jeshwanth's MQTT port and made it function the way I think it should more or less work. Part of that was to create a simple timer scheduler which will execute a console command every time a timer expires. This is how I get FK to periodically publish something.
I've hooked the MQTT code into the GPIO driver as well as my SI7020 temperature/humidity driver. It should be fairly straight forward to link to the other drivers but I have not done so.
See: i2c_7020.c:do_si7020pub{temp,humidity}()
I also found/fixed a bug in the mkrel code... If there's garbage after the end of the command, it continues reading and generating args.
I have two ESP8266 based devices, on with an SI7020 and another with a couple of 16A relays. Both have been running and bound to my Mosquito broker for over 2 weeks without resetting. With the relay board, I can publish a GPIO message to turn the relay on/off... I can also read the state of the GPIO after the command to ensure that it is asserted/cleared.
every - Execute console cmd every N seconds every 10 'gpio out 5 1 ; gpio out 5 0' every 10 $envvar
which can be used to regularly publish an event like so:
setenv pubs 'gpio_pub 5;gpio_pub 4' every 15 $pubs
I've also added commands:
gpio_pub - Publish GPIO state gpio_pub gpio_sub - Subscribe to GPIO gpio_sub
si7020_pub_humidity - Publish Humidity via MQTT si7020_pub_temperature - Publish Temperature via MQTT
There are also commands:
mqttsub - Subscribe MQTT mqttpub - Publish MQTT stopmqtt - Stop MQTT Service startmqtt - Start MQTT Service
Environment variables are how MQTT is configured:
mqtt_device_id RelayPhrob1 mqtt_host 192.168.37.30 mqtt_user myusername mqtt_pass mypasswd
In $bootcmd I have:
pubs gpio_pub 5 bootcmd startmqtt;every 15 $pubs