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

    Hmm I’m looking into changing things up. You’re definitely in the right place doing the right thing though. You’re saying that using your app_backend_publish_stream function doesn’t stream but shows up as state?

    As for the led you can take a look at the Blinky sample. That controls the same LED that you’d want to control. I would control it with a timer with something like:

    K_TIMER_DEFINE(led_timer, led_timer_function, NULL);

    (Much like the other timer definitions)

    /* Timers */
    K_TIMER_DEFINE(activity_timer, activity_expiry_function, NULL);
    K_TIMER_DEFINE(gps_search_timer, gps_expiry_function, NULL);

    You can start a repeating timer like

    k_timer_start(&activity_timer, K_SECONDS(1), K_SECONDS(1));

    Then doing all your gpio manipulation in the led_timer_function itself.

    Hope that helps and didn’t add more to the confusion!

    a month later

    Hey chipmc

    I was able to add indication to the tracker sample. It glows while getting a GPS fix and goes solid when completed. I’m also pushing GPS to a LightDB stream. It should work out of the box for you.

    Have a good week! Let me know if you run into any other snags.

    24 days later

    @jaredwolff ,

    With Chris Gammell’s help, I was able to modify the tracker demo to add data to streams. However, I did not see the updates you indicated even though I did update my local copy of your NFED repo. I will try blowing the whole thing away and reinstalling but, it is encouraging that I can get the streams part working as described above and was able to get a webhook working from Golioth to Ubidots. So, progress!

    Thanks, Chip

    The highlighted commit is the one you want. You can change to the nfed directory and do a git pull. That should update it.

    Terms and Conditions | Privacy Policy