in that case you will have to implement it yourself as follow:
in LoRaWan_APP.h look for downLinkAckHandle and comment it as shown below add the new two lines:
//extern "C" void downLinkAckHandle();
void downLinkAckHandle(McpsConfirm_t *mcpsConfirm);
void downLinkAckHandle(McpsIndication_t *mcpsIndication);
in the LoRaWan_APP.cpp add the following code:
void __attribute__((weak)) downLinkAckHandle(McpsConfirm_t *mcpsConfirm)
{
// printf("\n **** ack received\r\n");
}
void __attribute__((weak)) downLinkAckHandle(McpsIndication_t *mcpsIndication)
{
// printf("\n **** ack received\r\n");
}
and then look for this:
if (mcpsIndication->AckReceived)
{
downLinkAckHandle();
}
and change it to this:
//if (mcpsIndication->AckReceived)
// {
downLinkAckHandle(mcpsIndication);
// }
next look for this:
static void McpsConfirm(McpsConfirm_t *mcpsConfirm)
{
//and add this line on Top
downLinkAckHandle(mcpsConfirm);
if (mcpsConfirm->Status == LORAMAC_EVENT_INFO_STATUS_OK)
{ .....
}
now in your Application layer add the following two functions:
void downLinkAckHandle(McpsIndication_t *mcpsIndication)
{
printf("\nMcpsIndication_t");
printf("\n\t+REV DATA:%s,\n\tRXSIZE %d,\n\tPORT %d, RSSI: %d,\n\t SNR: %d,\n\t DATA_RATE:%d,\n\t AckReceived:%d,\n\t Status:%d,\r\n",
mcpsIndication->RxSlot ? "RXWIN2" : "RXWIN1", mcpsIndication->BufferSize, mcpsIndication->Port,
mcpsIndication->Rssi, (int)mcpsIndication->Snr, (int)mcpsIndication->RxDoneDatarate, mcpsIndication->AckReceived, mcpsIndication->Status);
}
and
void downLinkAckHandle(McpsConfirm_t *mcpsConfirm)
{
printf("\t\n ****\n1484 McpsConfirm_t mcpsConfirm->AckReceived:%d \n mcpsConfirm->Status:%d \n mcpsConfirm->McpsRequest:%d \n mcpsConfirm->NbRetries:%d \n mcpsConfirm->UpLinkCounter:%d \n DATA_RATE:%d \n Channel:%d \n TX Power:%d PRIi8 \n TxTimeOnAir:%d \n*****\r\n",
mcpsConfirm->AckReceived, mcpsConfirm->Status, mcpsConfirm->McpsRequest, mcpsConfirm->NbRetries,
mcpsConfirm->UpLinkCounter, (int)mcpsConfirm->Datarate, mcpsConfirm->Channel, (int)mcpsConfirm->TxPower, mcpsConfirm->TxTimeOnAir);
//react on the timeouts basically a failed join...
switch (mcpsConfirm->Status)
{
case LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT:
case LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT:
case LORAMAC_EVENT_INFO_STATUS_RX1_ERROR:
case LORAMAC_EVENT_INFO_STATUS_RX2_ERROR:
{
// your code here to decide what to do when a join fails...
// note this will get triggered every time a join fails so if ADR is on this will be triggered as it travels through available ADR if you want to act on the last ADR i would suggest you put an if statement here to look for ADR 0 for example:
if (!mcpsConfirm->AckReceived && (int)mcpsConfirm->Datarate == 0)
{
printf("\n failed to get acknowledgement... Force it to re-join\n");
deviceState = DEVICE_STATE_INIT; // force an initialization or restart using the code below
// delay(1000);
// CySoftwareReset(); // restart the board so it can go through the joining process
}
else if (!mcpsConfirm->AckReceived) // failed to join but here we will go to the next ADR set a timer here if you'd like
{
}
break;
}
default:
printf("default state set the default timer here");
break;
}
}
Note: i’m not sure the code above cover all and every situation that could occur in the field so please thinker carefully with it, and share your findings.
if you improve the above please share back here for the community…