MQTT name length

Also a second question, is there a method to get the Garadget to send the configuration status when you do not know the current topic value (to trigger it) or have a http message accepted to reconfigure the Garadget. (yes I know you can go back to the unit and reinitialize the unit from there but would like to avoid that method if I can). Obviously, I will know the ip address from my router.

There is a get-config parameter to the command topic.
You can find full details in this post:

I understand and works if I know the topic and have done that. But if I do not know the topic which in my case defaults to garadget/garage - ie I have changed garage to something else and lost the nme how to I do the command to the unit to trigger the message as garadget/garage will not work any more?

Such functionality is not supported at this time.
The name is usually assigned at the setup and not changed frequently. If you are comfortable around source code you can lock the topic to device ID which is permanently assigned.

Thanks, for all the help. I will let you know how my efforts go.

So I am not clear I am doing this correctly but here are my steps before I actually try to reprogram the Garadget device:
download firmware-master.zip from Garadget/firmware github to ~/nymea-testing/Garadget-source
unzip file to ~/nymea-testing/Garadget-source/firmware-master.zip
modify global.h MAXNAMESIZE 34
cd ~/nymea-testing/Garadget-clone
git clone https://github.com/spark/firmware.git
cd firmware/main (I tried module but that failed and doc suggested going to main)
make clean PLATFORM=photon APPDIR=~/nymea-testing/Garadget-source/firmware-master/src/ TARGET_DIR=~/nymea-testing/Garadget-source/ -s program-dfu
and got the following:
~/nymea-testing/Garadget-source/firmware-master/src/nodes/node-relay.cpp: In member function ‘virtual bool c_relay::f_receive(const c_message&)’:
~/nymea-testing/Garadget-source/firmware-master/src/nodes/node-relay.cpp:78:23: warning: this statement may fall through [-Wimplicit-fallthrough=]
78 | n_newStatus = STATUS_OPENING;
| ^~~~
~/nymea-testing/Garadget-source/firmware-master/src/nodes/node-relay.cpp:79:9: note: here
79 | case STATUS_CLOSED:
| ^~~~
dfu-suffix (dfu-util) 0.9

Copyright 2011-2012 Stefan Schmidt, 2013-2014 Tormod Volden
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Suffix successfully added to file
Serial device PARTICLE_SERIAL_DEV : not available
Flashing using dfu:
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: No DFU capable USB device available
make[1]: *** […/…/…/build/module.mk:126: program-dfu] Error 74
make: *** […/build/recurse.mk:12: modules/photon/user-part] Error 2

this creates the directory ~/nymea-testing/Garadget-source/obj/src with 8 files

Ok the last errors are because the laptop is not connected to the Garadget device I believe
but

  1. is the warning above a problem?
  2. Have I actually probably created the correct files for upload to the device (assuming I connect the device to the laptop)

I trying to be careful so I do not destroy my device.

I checked the source and the fall-through in switch statement is intentional so it’s safe to ignore the warning. Also it is safe to upload the firmware. If anything goes wrong the bootloader is not affected and you can restore the stock firmware.

I assume that to restore the stock firmware I first need to do a dfu-util --upload Garadget.

my assumption is based on the fact that I have cut off access to the internet from the device.

Here’s the thread with the binaries and instructions for the stock firmware:

yea I had previously found that link but the link to the binaries is no longer valid
link for system and v1.20 firmware binaries

Here’s the link for latest 1.24 binaries.

Thank you. Appreciate.

I do not know what I have done wrong but I now have a device that is not working.

I did the following: To enter DFU Mode:

  1. Hold down BOTH buttons
  2. Release only the RESET button, while holding down the SETUP button.
  3. Wait for the LED to start flashing yellow (it will flash magenta first)

but the yellow flashing did not ever happen. (tried many times)
What I get is magenta medium flash, green medium flashing, green fast flashing, white medium flashing, white solid, led off, followed by the same sequence over again. (i.e. no yellow).

Also now on just hitting reset or powering off/on, I get a blue slow flash (listening mode?) that I can connect my computer wift to the Photon-PPF2UR wifi and ping the device but the device will NOT allow https://192.168.0.1/ on either safari, firefox, or choromium browsers.

Have not ever gotten to the dfu mode.
What am I doing wrong?
and more importantly How do I get the device working again?

The URL for web interface is http://192.168.0.1/ not https://192.168.0.1/
If you can get your unit online, let me know the device ID and I’ll try to re-flash it remotely.
DFU programming will not work if you can’t get it in DFU mode.
You can re-upload bootloader in setup mode (blinking dark blue on and off) with this command:

particle flash --serial p1-bootloader@2.0.1+lto.bin

Ok the particle flash you suggested did not do the trick. On the other hand particle setup when the device is plugged into my computer usb did the trick and got me back working (yea).

I finally figured out the the yellow is not a clear yellow but I did get the device in dfu mode but so far am unsuccessful with the compiled version of the garadget code. I did upload but lost control of the device configuration (went to cloud only on mqtt and I could not change that).

OK, Success -FINALLY
MAXNAMESIZE was the wrong variable. It turns out that PORT_BUFFER needed to be increased!
I set it at 0x24 although 0x22 would probably work as well.

Thanks for the help and the patience with me and my fumbling around on this.
now back to nymea.

1 Like

ps as a note to you, Firefox did not work for the setup portion of the configuring. I had to use chromium browser.

Thank you for your write up!

be nice if in your next released version, you opened PORT_BUFFER a little so other users (i.e. nymea will not have to go thru this pain).
thanks

sorry I got the above steps to change nme to 32 characters wrong. these are the correct steps.
Steps I used to create a new version of Garadget on ubuntu 20.04 to increase the allowable length of nme to 32 characters
review Build - Particle Firmware
review MQTT support - #5 by garadget

if ubuntu version of gcc-arm is installed, remove it (I use synaptic to find it) and the sudo apt autoremove to clean all out.
open browser to GNU Toolchain | GNU Arm Embedded Toolchain Downloads – Arm Developer
select GNU Arm Embedded Toolchain: 10-2020-q4-major December 11, 2020
download gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2 to home directory
file-roller gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2
extract to home directory
export PATH="$PATH:/home/homedirectory/gcc-arm-none-eabi-9-2020-q2-update/bin
export PLATFORM=p1
git clone --recursive --branch v2.0.1 https://github.com/particle-iot/firmware.git Particle
cd Particle/user/application
git clone https://github.com/Garadget/firmware garadget
in my case edit garadget/src/global.h
change MINOR_VERSION 25 (changed so you know you have loaded the changes into your device)
change MAXNAMESIZE to 33
change PORT_BUFFER to 0x22
save
cd ~/Particle/modules
make clean all APP=garadget
when finished
sudo apt install mosquitto-clients
connect your device usb to your computer and make sure your broker is up
open terminal
mosquitto_sub -v -h ip of your broker -t garadget/# this is to show you the device is connected
Put your device into the DFU mode by holding down the mode/setup button on the device and then tapping on the RESET button once. Release the MODE/setup button after you start to see the RGB LED flashing in yellow. It’s easy to get this one wrong: Make sure you don’t let go of the MODE/SETUP button until you see flashing yellow, about 3 seconds after you release the RESET button. A flash of white then flashing green can happen when you get this wrong. You want flashing yellow.
dfu-util -l (to make sure device is in dfu mode. My yellow blinking really looked geen to me but have fun here).
dfu-util -d 2b04:d006 -a 0 -s 0x80A0000:leave -D ~/Particle/build/target/user-part/platform-8-m/garadget.bin
I did not update system-part1.bin or system-part2.bin (although I suspect I could have).

I then checked if mosquitto_sub give a line like garadget/garage/config {“sys”:“2.0.1”,“ver”:“1.25”,“id”:“2d0022001447373033383530”,“ssid”:“wifi network name”,“rdt”:1000,“mtt”:10000,“rlt”:300,“rlp”:1000,“srt”:25,“nme”:“garage”,“mqtt”:2,“mqip”:“broker ip address”,“mqpt”:1883,“mqus”:"",“mqto”:5000}
if not Put your unit into listening mode: press and hold “M” button for about 3 seconds until LED starts blinking dark blue.
Connect any WiFi enabled device to PHOTON-XXXX access point.
Open http://192.168.0.1/ in the browser (Firefox failed for me) and (re-)configure WiFi connection, MQTT settings, and topic setting
Submit to save. The device should reconnect to your WiFi network. (did not for me so I hit R to reset device and it came up)
check mosquitto_sub again and should show the config line

final check is
open another terminal and assuming the topic is garage
mosquitto_pub -h ip of your broker -t garadget/garage/command -m “get-status” should immediately responed with a status line
mosquitto_pub -h ip of your broker -t garadget/garage/set-config -m ‘{“nme”:“1234567890123456789012”}’ this number should show up in the config status in the mosquitto_sub terminal
now its accepting 32 characters in the nme that I need for nymea plugin I am developing for NYMEA

have fun

1 Like