Jared,
Had a call with Chris Gammell today about the tracker demo. All is good with your tutorial and code but, there are two things I think would improve the project. I thought I might be able to make this change but I am still trying to wrap my head around “what goes where” in Zephyr.
Here is what I am thinking:
- Currently the code updates the cellular and GPS data and publishes to the LiteDB State on the Golioth Platform - this is perfectly fine. So, you can see the current state of the device - but there is no history.
- What would also be nice would be to send a “data stream” to the lightDB Stream so that, over time, you could see the values of GPS and cellular signal and how they changed as you moved around.
- Ideally too, it might be nice to do something with a LED on the feather so you could tell whether data was stored if you were going to carry the feather around without a laptop and serial monitor. Something like “blinking” when connecting and “solid” when data was uploaded then repeat for the next cycle.
I though I understood what was needed after talking to Chris but, alas, it is still not writing to “stream”. Here is what I tried - please don’t hesitate to tell me how I messed up:
1) In tracker/src/backend/app_backend.h - I added a new function prototype:
/**
* @brief Publish to the backend stream
*
* @param topic topic string used
* @param p_data pointer to data structure
* @param len length of data
* @return int 0 on success
*/
int app_backend_publish_stream(char *topic, uint8_t *p_data, size_t len);
2) In /tracker/src/backend/golioth.c - I copied and modified your function that writes to state:
int app_backend_publish_stream(char *p_topic, uint8_t *p_data, size_t len)
{
int err;
char path[128];
err = snprintf(path, sizeof(path), ".s/%s", p_topic); // This is the change .d becomes .s
if (err < 0)
{
LOG_WRN("Failed to encode path. Err: %i", err);
return err;
}
err = golioth_lightdb_set(client,
path,
COAP_CONTENT_FORMAT_APP_CBOR,
p_data, len);
if (err)
{
LOG_WRN("Failed to gps data: %d", err);
}
return err;
}
3) Finally, in your tracker/src/main.c - line 480 - I changed the current call to the backend to the new function:
/* Publish gps data */
err = app_backend_publish_stream("motion", buf, size);
if (err)
{
LOG_ERR("Unable to publish. Err: %i", err);
}
I then did a “build pristine” and saw some warnings about Logging but no errors from my changes. I uploaded via the boot loader but I am still not getting any data in the stream DB.
Since this did not work, I did not attempt the LED thing.
Any pointers on how to accomplish what I am trying to do?
Thanks,
Chip