I used DEBUG_PRINT to confirm that everything works well except the p2p callback function.
I'm using the example without modifying it at all, is there any part that I need to set up in the code?
Code: Select all
void p2pcallbackHandler(P2PPacket *p)
{
uint8_t other_id = p->data[0];
char msg[11];
memcpy(&msg, &p->data[1], sizeof(msg));
uint8_t rssi = p->rssi;
DEBUG_PRINT("[RSSI: -%d dBm] Message from CF nr. %d, %s\n",rssi, other_id, msg);
}
void appMain()
{
DEBUG_PRINT("Waiting for activation ...\n");
// Initialize the p2p packet
static P2PPacket p_reply;
p_reply.port=0x00;
uint64_t address = configblockGetRadioAddress();
uint8_t my_id =(uint8_t)((address) & 0x00000000ff);
p_reply.data[0]=my_id;
char str[11]="Hello World";
memcpy(&p_reply.data[1], &str, sizeof(char)*6);
p_reply.size=12;
p2pRegisterCB(p2pcallbackHandler);
while(1) {
DEBUG_PRINT("working\n");
vTaskDelay(M2T(2000));
radiolinkSendP2PPacketBroadcast(&p_reply);
}
}
Is there no problem with my arbitrary port change in the p_reply.port=0x00; code within the appMain() function?
The radiolink.h file describes this port as "Header selecting channel and port."
Is this not related to the channel I specified in the cfclient?