0

Creating a dynamic group name
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Creating a dynamic group name

by daemach on Sun Nov 01, 2015 12:09 pm

My new project is attempting to use AIO groups, creating both the groups and the 6 feeds that comprise them on the fly. To do this, I need to use a dynamic group name that includes a unique serial number/ID. The ESP.getChipID and ESP.getFlashID functions both return a unique ID that can be concatenated to increase entropy.

The problem is that the group names have to be stored in PROGMEM, and PROGMEM really,really wants to have a specific string to work with - not something concatenated on the fly. How do I get around this issue???

From the group_sensors.ino file (my hack, anyway) - this doesn't work, of course - just demonstrating what I need to do:

Code: Select all | TOGGLE FULL SIZE

// Setup the MQTT client class by passing in the WiFi client and MQTT server and login details.
Adafruit_MQTT_Client mqtt(&client, MQTT_SERVER, AIO_SERVERPORT, MQTT_CLIENTID, MQTT_USERNAME, MQTT_PASSWORD);

/****************************** Feeds ***************************************/

String serialNumber = String(ESP.getChipId()) + String(ESP.getFlashId());

// Setup a group called 'weather' for publishing changes.
// Notice MQTT group CSV paths for AIO follow the form: <username>/groups/<groupname>/csv
const char AQ_FEED[] PROGMEM = AIO_USERNAME "/groups/airQuality_" + serialNumber + "/csv";
Adafruit_MQTT_Publish airQuality = Adafruit_MQTT_Publish(&mqtt, AQ_FEED);
Last edited by daemach on Thu Nov 05, 2015 6:49 pm, edited 1 time in total.

daemach
 
Posts: 146
Joined: Fri Feb 13, 2009 2:07 pm

Re: Creating a dynamic group names

by daemach on Wed Nov 04, 2015 12:02 pm

I could really use an answer for this. I have to be able to use dynamic group names or the project won't fly :/

daemach
 
Posts: 146
Joined: Fri Feb 13, 2009 2:07 pm

Re: Creating a dynamic group names

by jwcooper on Wed Nov 04, 2015 12:07 pm

You might have better luck with this in an ESP specific forum, as it's not really IO specific. Unfortunately, I don't have the answer to this one.

jwcooper
 
Posts: 788
Joined: Tue May 01, 2012 9:08 pm

Re: Creating a dynamic group names

by daemach on Wed Nov 04, 2015 12:18 pm

FWIW, a serial number could come from anywhere. When I did this project with an Uno, I pulled it from a 1MB SPI flash chip.

From the IO side, is there a way to do this without storing this particular string in progmem so we don't have these restrictions out of the gate? Being able to only use a single device on this service without manually modifying and uploading new source code for each device seems limiting :/

daemach
 
Posts: 146
Joined: Fri Feb 13, 2009 2:07 pm

Re: Creating a dynamic group names

by jwcooper on Wed Nov 04, 2015 12:26 pm

I see what you're saying. It does involve the mqtt library due to the PROGMEM. Can you create an issue in that repository?

https://github.com/adafruit/Adafruit_MQTT_Library

I didn't specifically code that library, and others may be able to help out better on this one.

jwcooper
 
Posts: 788
Joined: Tue May 01, 2012 9:08 pm

Please be positive and constructive with your questions and comments.