Hi @grizzlyalleyne,
You do not call this function from your code, this function gets invoked when your node receives a downlink from the server. with that said i will assume that you are using TTN and show you how to invoke the function from TTN.
basically you login to TTN console and then click on Applications next you pick your application and click on it, now you click on End devices from the left side Menu, next click on the node in question next click on Messaging and then Downlink here you will have a choice to send a byte to your node or a JSON string… mind you to keep things small below 50 bytes, my recommendation is send a byte. once you click Schedule Downlink. things will be ready … as soon as your node sends an Uplink it will be notified by the server that a downlink is scheduled and will send it to the node and that’s when you function above will get invoked and you will receive the bytes.
so let’s assume we are sending he bytes as shown in the snap shot below: 01 00 00 00 01
to receive the above bytes and interpret them you can use the following code:
void downLinkDataHandle(McpsIndication_t *mcpsIndication)
{
printf("\n\t downLinkDataHandle: ACK Data received\n");
printf("\n\t+REV DATA:%s,\n\tRXSIZE %d,\n\tPORT %d, RSSI: %d,\n\t SNR: %d,\n\t DATA_RATE:%d,\r\n",
mcpsIndication->RxSlot ? "RXWIN2" : "RXWIN1", mcpsIndication->BufferSize, mcpsIndication->Port,
mcpsIndication->Rssi, (int)mcpsIndication->Snr, (int)mcpsIndication->RxDoneDatarate);
if (mcpsIndication->RxData == true)
{
printf("+REV DATA:");
for (uint8_t i = 0; i < mcpsIndication->BufferSize; i++)
{
printf("%02X", mcpsIndication->Buffer[i]);
}
// since the payload is 4 bytes let's reassemble it.
uint32_t data;
data = mcpsIndication->Buffer[1] << 24 | mcpsIndication->Buffer[2] << 16 | mcpsIndication->Buffer[3] << 8 | mcpsIndication->Buffer[4];
if (mcpsIndication->Port == 1) // this is what TTN calls FPort can be used as case switch as well, valid values are 1 to 254
{
switch (mcpsIndication->Buffer[0])
{
case 0x01: // 01 00 00 00 00
{
printf("the data we received is %d", data);
break;
}
case 0x02: // 02 00 00 00 00
{
printf("the data we received is %d", data);
break;
};
default:
printf("unknown code received %d", downLinkConfig.code);
break;
}
}
}
}
I hope this helps,
Jay