Ottawa Bootcamp Publish
Dependencies: SX127x lorawan1v1
Diff: sensorDemoVT100.cpp
- Revision:
- 2:da3c8d5b3f49
- Parent:
- 1:3c1d13a0489e
- Child:
- 3:fc23bbc14475
diff -r 3c1d13a0489e -r da3c8d5b3f49 sensorDemoVT100.cpp --- a/sensorDemoVT100.cpp Thu Mar 01 17:29:50 2018 +0000 +++ b/sensorDemoVT100.cpp Mon Mar 05 16:51:20 2018 -0800 @@ -434,7 +434,6 @@ mcpsReq.Req.fPort = AppPort; mcpsReq.Req.fBuffer = AppData; mcpsReq.Req.fBufferSize = AppDataSize; - mcpsReq.Req.NbTrials = 8; mcpsReq.Req.Datarate = LORAWAN_DEFAULT_DATARATE; } } @@ -451,7 +450,6 @@ vt.printf("sendFrame() %s rx%d\e[K", str, LoRaMacGetRxSlot()); } - return status; } // ..SendFrame() @@ -526,14 +524,14 @@ vt.printf("\e[K"); // clear stale mcpsconf if retrying vt.SetCursorPos( ROW_MCPS_IND, 0); - vt.printf("McpsIndication rx%d ", mcpsIndication->RxSlot); + vt.printf("McpsIndication rx%d ADR_ACK_CNT:%u ", mcpsIndication->RxSlot, mcpsIndication->ADR_ACK_CNT); if (mcpsIndication->Status != LORAMAC_EVENT_INFO_STATUS_OK) { LoRaMacEventInfoStatus_to_string(mcpsIndication->Status, str); - vt.printf("\e[31m%s attempt%u\e[0m\e[K", str, mcpsIndication->attempt); + vt.printf("\e[31m%s\e[0m\e[K", str); return; } - vt.printf("OK \e[K"); + vt.printf("OK\e[K"); switch( mcpsIndication->McpsIndication ) { @@ -1054,6 +1052,7 @@ */ int main() { + LoRaMacStatus_t status; MibRequestConfirm_t mibReq; DeviceState = DEVICE_STATE_INIT; @@ -1085,7 +1084,7 @@ { case DEVICE_STATE_INIT: { - LoRaMacStatus_t status = LoRaMacInitialization( &LoRaMacPrimitives, &LoRaMacCallbacks ); + status = LoRaMacInitialization( &LoRaMacPrimitives, &LoRaMacCallbacks ); if (LORAMAC_STATUS_OK != status) { char str[48]; LoRaMacStatus_to_string(status, str); @@ -1154,12 +1153,12 @@ #if defined(LORAWAN_SNwkSIntKey) && defined(LORAWAN_NwkSEncKey) /* lorawan 1v1 ABP */ mibReq.Type = MIB_NwkSEncKey; - mibReq.Param.NwkSEncKey = NwkSEncKey; + mibReq.Param.key = NwkSEncKey; LoRaMacMibSetRequestConfirm( &mibReq ); SerialDisplayUpdateKey(ROW_NwkSEncKey, NwkSEncKey); mibReq.Type = MIB_SNwkSIntKey; - mibReq.Param.SNwkSIntKey = SNwkSIntKey; + mibReq.Param.key = SNwkSIntKey; LoRaMacMibSetRequestConfirm( &mibReq ); SerialDisplayUpdateKey(ROW_SNwkSIntKey, SNwkSIntKey); @@ -1216,9 +1215,12 @@ SerialDisplayUpdateUplinkAcked( false ); SerialDisplayUpdateDonwlinkRxData( false ); PrepareTxFrame( AppPort ); - /*status =*/ SendFrame(gIsTxConfirmed, gAppDataSize); - /* McpsConfirm or McpsIndication callback will continue */ - DeviceState = DEVICE_STATE_SLEEP; + status = SendFrame(gIsTxConfirmed, gAppDataSize); + if (status == LORAMAC_STATUS_OK) { + /* McpsConfirm or McpsIndication callback will continue */ + DeviceState = DEVICE_STATE_SLEEP; + } else + DeviceState = DEVICE_STATE_TRIGGER; break; case DEVICE_STATE_SLEEP: {