void loadMulticast(); typedef struct{ byte type; byte command; uint32_t btns; int16_t analog[NUM_ANALOG_channels]; }nrfdata; typedef struct{ byte type; //jType_ANALOG_Desc || jType_BUTTON_Desc byte command; //0-31 button channel || 0-11 byte use = 0xff; //0-3 || 0-1 char text[29] = "error"; //Text }Channel_Desc_Send; nrfdata ndata; byte jRCbuff[32]; String SerialOutBuffer = ""; const String b16 = "0123456789abcdef"; void NRFreceive(){ if(radio.available()){ uint8_t payloadSize = radio.getDynamicPayloadSize(); if(payloadSize>=1){ radio.read( &jRCbuff, payloadSize ); switch (jRCbuff[0]) { case 0xff:{ loadMulticast(); }break; case 1: case 2: case 3: { SerialOutBuffer = ""; for (size_t i = 0; i < payloadSize; i++) { SerialOutBuffer+=b16[(jRCbuff[i]>>4)&0xf]; SerialOutBuffer+=b16[jRCbuff[i]&0xf]; } Serial.println(SerialOutBuffer); }break; case 50:{ //jType_ANALOG_Desc SerialOutBuffer = ""; Channel_Desc_Send data; memmove(&data, &jRCbuff, sizeof(data)); SerialOutBuffer+=String(data.command); SerialOutBuffer+="|"; SerialOutBuffer+=String(data.use); SerialOutBuffer+="|"; SerialOutBuffer+=String(data.text); Serial.println(SerialOutBuffer); }break; case 51:{ //jType_BUTTON_Desc SerialOutBuffer = ""; Channel_Desc_Send data; memmove(&data, &jRCbuff, sizeof(data)); SerialOutBuffer+=String(data.command); SerialOutBuffer+="|"; SerialOutBuffer+=String(data.use); SerialOutBuffer+="|"; SerialOutBuffer+=String(data.text); Serial.println(SerialOutBuffer); }break; } } } } typedef struct{ byte type = 0xff; uint64_t pipe; byte channel; }nrfMulticast; void loadMulticast(){ if(NRFisConnected==1)return; nrfMulticast data; memmove(&data, &jRCbuff, sizeof(data)); myPipe = data.pipe; myChannel = data.channel; lastMulticast = millis(); Serial.print(""); Serial.print(myChannel); Serial.print("|"); for (int i = 9; i >=0; i--) { byte id = (myPipe>>(i*4))&0xf; if(id>15){ Serial.print("-"); }else Serial.print(b16[id]); } Serial.println(); } bool sendRCdata(const void* buf, uint8_t length, bool multicast = false){ radio.stopListening(); bool succ = radio.write( buf, length, multicast ); radio.startListening(); return succ; }