Scheduling Transmissions
The Popoto Modem API supports scheduling the transmission of a data packet at a specific time using the PCM sample count for precision.
Understanding PCM Sample Time
Time within the Popoto Modem is measured in PCM samples at a frequency of 102,400 samples per second. The PCMSampleCounter variable holds a 32-bit count of these samples and provides a high-resolution time base for scheduling transmissions.
Querying the PCMSampleCounter
To retrieve the current PCM sample count, use one of the following methods:
- Send
get PCMSampleCounterto the modem. - From pshell, type
PCMSampleCounterand press Enter.
In versions 3.2.6.3, 3.2.8, or later, the PCMSampleCounter at the start of each received packet is reported in a JSON message:
{"PCMSampleCount":4446530}
Scheduling a Transmission
To schedule packet transmission, use the transmitJSON command with a specified departure time in PCM sample count.
pshell> transmitJSON {"Payload":{"Data":"Hello"}, "DepartureTime":30000000}
This command schedules the packet containing Hello to transmit at PCM sample count 30000000.
Transmission Status
After scheduling a transmission, the modem reports status through a series of JSON messages. These messages indicate the scheduled departure time, the actual PCM sample count at transmission, and modem setting adjustments.
{"DepartureTime":150000000}
{"PCMSampleCount":138576000}
{"Info":"Value Set MODEM_Enable=1"}
{"Info":"Value Set MODEM_Enable=1"}
{"Alert":"TxComplete"}
{"Info":"Value Set MODEM_Enable=1"}
{"Info":"Value Set RxEnable=1"}
Handling Early or Past Scheduled Transmissions
Scheduling a transmission too soon or in the past causes the transmission to occur as soon as the hardware is ready. This is because the transmit power amplifier requires approximately 300 ms to power on.
If the requested departure time is too early or has already passed, the modem reports status messages similar to the following:
{"Info":"Requested Departure Time Too Early or in the Past. "}
{"DepartureTime":130555520}
{"PCMSampleCount":130483840}
{"Info":"Value Set MODEM_Enable=1"}
{"Info":"Value Set MODEM_Enable=1"}
{"Alert":"TxComplete"}
{"Info":"Value Set MODEM_Enable=1"}
{"Info":"Value Set RxEnable=1"}