We are announcing the ongoing transition of device messages storage and related flespi subsystems granularity from seconds to microseconds.
The transition will take some time which we are unable to precisely calculate at the moment. It can take a few weeks or even a few months, depending on numerous factors. We will notify you once the transition is 100% finished.
Details about the upcoming change
The typical message that the flespi device generates consists of a timestamp and some additional parameters:
{
"timestamp": 1490347944.893743,
"din": 5,
"param1": 1,
...
}
If you look at the timestamp value you will notice that it is already specified in microseconds granularity. For the sample above 1490347944 is the integer part which can be parsed as Friday, 24 March 2017, 9:32:24. And .893743 is the fractional part of that second - microseconds.
Right now this message will be stored under its integer part. And if for some reason another device message in the same second will arrive, for example:
{
"timestamp": 1490347944.900001,
"din": 10,
"param2": 2,
...
}
Right now it will also be stored now under the same integer key - 1490347944.
Current behavior
In that case, once you will have these two messages registered for the device, if you will query its messages with REST API call right now you will end up with just a single message with combined parameters from both initial messages:
{
"timestamp": 1490347944.900001,
"din": 10,
"param1": 1,
"param2": 2,
...
}
New behavior
After we will make the transition of device messages storage from seconds to microseconds with the same REST API call you will get two messages because their fractional part (the storage key) is different and they will be stored separately:
{
"timestamp": 1490347944.893743,
"din": 5,
"param1": 1,
...
},
{
"timestamp": 1490347944.900001,
"din": 10,
"param2": 2,
...
}
What should be adopted on the client side?
You should be aware that REST API call GET /gw/devices/XXX/messages now will return you all messages based on microseconds granularity.
This will also affect all other flespi systems - analytics will be able to generate multiple intervals per second and you should just be prepared for this. If possible - replace you your database keys from uint32_t to the double type and any change will be accepted smoothly.
According to our experience, most devices generate only a single message per second so in most cases you will not notice any difference. But for those who rely on multiple messages per one-second possibility - and there are some cases related to iButton on/off, digital/analog input change, and accelerometer data array on impact - just be prepared that you will be able to access all of them from device storage after the transition.