Closed adamgarbo closed 2 years ago
Note to self: don't forget to check that the modem boot is complete and that GPS time is valid: see this part of issue #23
Hi Adam (@adamgarbo ) & Scott (@K4KDR ),
I've got a working "beacon" example for you to try. I'll merge and release it in a few minutes. Sample output is attached below.
I hope this meets your needs, or at least gives you a framework for your own code.
All the best, Paul
Swarm Satellite Beacon
Setting up the $M138 callback
Setting up the $SL callback
Restarting the modem
Modem is restarting...
New $M138 message received: 6 : BOOT RESTART (Modem is restarting)
New $M138 message received: 2 : BOOT POWERON (Power has been applied) : Swarm M138 (M138)
New $M138 message received: 2 : BOOT POWERON (Power has been applied) : Copyright (c) 2019-22 Swarm Technologies, Inc
New $M138 message received: 2 : BOOT POWERON (Power has been applied) : LPWR=n,WWDG=n,IWDG=n,SFT=Y,BOR=n,PIN=Y,OBL=n
New $M138 message received: 5 : BOOT VERSION (Firmware version) : 2022-02-05T00:02:19,v2.0.0
New $M138 message received: 1 : BOOT DEVICEID (Device ID of the modem) : DI=0x001d15
New $M138 message received: 3 : BOOT RUNNING (Boot has completed. Ready to accept commands)
Modem is ready to accept commands
Disabling unsolicited messages
Configuring the GPIO1 pin
Modem is configured
Waiting for valid dateTime and position...
New $M138 message received: 8 : DATETIME (GPS has acquired a valid date/time reference)
New $M138 message received: 9 : POSITION (GPS has acquired a valid position 3D fix)
Modem has valid dateTime and position
Waiting for valid dateTime and 3D position...
Modem has valid dateTime and 3D position
Message is: 2022-06-13T09:22:21Z,V,54.0000,-1.0000,107,27.00
Message has been added to the transmit queue. msg_id is: 4522958258192
The queue contains 3 unsent messages
Waiting for the queue to empty
Timeout has expired. Adding a new message
Waiting for valid dateTime and 3D position...
Modem has valid dateTime and 3D position
Message is: 2022-06-13T10:22:25Z,V,54.0000,-1.0000,118,28.00
Message has been added to the transmit queue. msg_id is: 4522958258212
The queue contains 4 unsent messages
Waiting for the queue to empty
The queue is empty. All messages have been sent
Going to sleep for 98 seconds
New $SL WAKE message received. Cause is: 2 : The S or U parameter time has been reached
The modem is awake!
$SL message seen
Waiting for valid dateTime and 3D position...
Modem has valid dateTime and 3D position
Message is: 2022-06-13T11:22:36Z,V,54.0000,-1.0000,108,28.00
Message has been added to the transmit queue. msg_id is: 4522958258223
The queue contains 1 unsent message
Waiting for the queue to empty
The queue is empty. All messages have been sent
Going to sleep for 3419 seconds
New $SL WAKE message received. Cause is: 2 : The S or U parameter time has been reached
The modem is awake!
$SL message seen
Waiting for valid dateTime and 3D position...
Modem has valid dateTime and 3D position
Message is: 2022-06-13T12:22:46Z,V,54.0000,-1.0000,104,25.00
Message has been added to the transmit queue. msg_id is: 4522958258227
The queue contains 1 unsent message
Waiting for the queue to empty
The queue is empty. All messages have been sent
Going to sleep for 2277 seconds
Hi @PaulZC,
As we discussed, the Swarm library could benefit from an example allowing the modem to operate as a beacon, similar to the IridiumSBD library examples.
This example would use multiple callbacks to retrieve the date, time, and location from the Swarm modem. This data would then be combined into a message, along with measurements from a sensor (e.g., temperature, pressure, etc.). The message would then be queued, transmitted, and the modem would then be put to sleep for a specified interval. This programming logic would then repeat.
You also mentioned providing an example of using the GPIO1 pin as an interrupt to wake the processor, so the processor could go to sleep while the modem is asleep.
Cheers, Adam