设备启动后,第一次传输将始终触发 OTAA 加入。在第一次传输中发送坐标 0,0 怎么样?
我总是进行阻塞传输,以确保在我获得新的 GPS 定位并将另一次传输排入队列之前完成传输。进行阻塞传输将保证您在第二次传输排队时已加入网络。还要粗略计算两次传输之间的最小延迟应该是多少,以符合占空比限制,以便 lmic 不会延迟您的传输。
我的 lmic 阻塞 TX 功能如下所示:
static uint8_t txFailedCount = 0;
void tx_blocking(uint8_t* radioPacket, uint8_t packetLength)
{
txFailedCount++;
// If we failed to transmit 6 times, reset LMIC
if(txFailedCount>6) {
Serial.println("LMIC lockup detected, resetting");
setup_lmic();
}
do_send(&sendjob, radioPacket, packetLength);
uint32_t start = millis();
// Wait for join to complete. May take a couple of minutes.
while( LMIC.opmode & OP_JOINING ) {
os_runloop_once();
delay(10);
}
while( (LMIC.opmode & OP_TXDATA) && (millis() - start < TX_TIMEOUT) )
{
os_runloop_once();
delay(10);
// If we are in OP_TXDATA state we are successfully transmitting
txFailedCount = 0;
}
if(millis() - start > TX_TIMEOUT) {
txFailedCount++;
}
Serial.println("TX done");
}