Bc_data_stream documentation

Is there any documentation about data streams? I found only poor description in SDK and the only usage in sigfox climate project. I’m missing more detailed description, maybe simpler example project on developers docs page. Would you provide some? Or can you point me to another example I can study?

Hi,

we have not documented streams in any tutorial yet. Which brings me to idea to add a small article in our Developers How to firmware section…

Basically you create your stream buffer with macro based on your data type. The streams are universal and values are passed always as a void * pointer. This way they support float, int values right now.

Stream functions:
https://sdk.hardwario.com/group__bc__data__stream.html

Stream definition

You need temperature, so you have to use FLOAT in the create macro

BC_DATA_STREAM_FLOAT_BUFFER(stream_buffer_thermometer, SENSOR_DATA_STREAM_SAMPLES)
bc_data_stream_t stream_thermometer;

Stream initialization

The in application_init you initialize the stream and also set how many samples needs to be in the stream to return you any value.

#define SENSOR_DATA_STREAM_SAMPLES 8
...
void application_init() {
   bc_data_stream_init(&stream_thermometer, SENSOR_DATA_STREAM_SAMPLES, &stream_buffer_thermometer);
}

Feeding new data to the strem

Then in your callback you add new data by calling feed function as a pointer to your value.

float temperature;

        if (bc_module_climate_get_temperature_celsius(&temperature))
        {
            bc_data_stream_feed(&stream_thermometer, &temperature);
        }

Getting average,…,. from the stream

Then you can use function to get average, median, min, max by calling functions

float average;
bc_data_stream_get_average(&stream_thermometer, &average)

Let me know if something need more to be explained, I’ll convert this post to Firmware howto page soon.
Martin

You can find other code examples in this search query on github.

We have also this internal search page, that helps us to find code across many repositories https://search.bigclown.com/

Thank you.

Is there any other advantage in using data streams except getting averages? Is the radio capable to send all the data from stream on its own? Something line bc_radio_pub_temperature_from_stream()?

Example use case: the stream is used as fifo stack for measured values. All measurements from it are transmitted once SENSOR_DATA_STREAM_SAMPLES are collected and using one radio message.


I was looking only in bigclownlabs and bigclownprojects orgs and I searched for “data_stream” keyword, which leads to very few results. Your internal search frontend would be very helpful. Maybe you can add this search box to the developer documentation site…

Hi,
the stream has not any other advantage compared to compute averages yourself.
However you can get each value from the stream one by one and send values in a single packet by using publish buffer function https://sdk.hardwario.com/group__bc__radio.html#ga9aba2caec04e19c08f91ba6906bc469d

You’ll need to unpack the data somehow from the buffer again.

We do something similar in Radio infragrid firmware with a 64 float values. We convert them to 6 bit values and then we “glue” individual 6 bits to the bytes.

So first 6 bit value and the 2 bits of next 6 bit values is in the firs byte and so on.

This way we could fit 64 values to radio packet which is around 50 bytes.

I like your idea of sending the stream in a single packet, I’ll discuss that with colleagues.

Please, let me know the result (after that), thanks.