Universal time and #rxframe record

11 views
Skip to first unread message

MPC

unread,
May 27, 2020, 8:15:10 AM5/27/20
to LoRaWAN Server Users
Hi,

Currently adding a user web interface to the LoRaWAN Server and I have come across a strange problem.

LoRaWAN server holds a table for the #rxframe and a table for the #node. I am trying to get the last message sent by the node to update the webpage.


I can get the last datetime a message was sent by searching the node table.

MatchHead = #node{last_rx='$1',devaddr= <<16#26011C6F:32>>, _='_'},
Guard = [],
Result = ['$1'],
[DeviceLastRx]=mnesia:dirty_select(node,[{MatchHead, Guard, Result}]), % Get last data time point

Here I am using a fixed devaddr for development. This gives me a nice clean universal datetime such as {{2020,5,27},{12,5,14}}


If I now search the #rxframe table for this message I find the datetimes stored in the #rxframe table have fractions of a second? such as  {{2020,5,27},{12,4,5.986800e+01}}


Looking through the code for the LoRaWAN server I can not see why there should be fractions of a second. The source code always uses datetime=calendar:universal_time() which should give whole seconds.


Anyone any ideas?

Thanks,

MPC

MPC

unread,
May 27, 2020, 8:31:22 AM5/27/20
to LoRaWAN Server Users
Its okay.

I noticed the source file lorawan_handler.erl uses a routine called precise_universal_time() to save the message datetime.

Not sure how to get the last message sent from the #rxframe table?

Many Thanks,

MPC.

MPC

unread,
May 28, 2020, 5:12:39 AM5/28/20
to LoRaWAN Server Users
For reference I was able to get the last message sent by the following:

MatchHead = #node{last_rx='$1',devaddr= <<16#26011C6F:32>>, _='_'},
Guard = [],
Result = ['$1'],
[DeviceLastRx]=mnesia:dirty_select(node,[{MatchHead, Guard, Result}]), % Get last data time point

MatchHead2 = #rxframe{data='$1',dir= <<"up">>, datetime='$2',devaddr= <<16#26011C6F:32>>, _='_'},
Guard2 = [{'>=','$2',{const,DeviceLastRx}}],
Result2 = ['$1'],
[<<Temperaturex10:16, Levelx10:16, Dummy:8,DataString/binary>>]=mnesia:dirty_select(rxframe,[{MatchHead2, Guard2, Result2}]), % Get last device data

This looks in the node table to get the last rx message time. The Guard2 variable searches the rxframe table for a message with a datetime greater then or equal to the lastrx datetime.

Again the device address has been hard coded in for development.


Reply all
Reply to author
Forward
0 new messages