void nbrDataCreate(NbrData* nbrDataPtr, const char* name, uint8 size, uint8 value){ uint8 packet, idx; if (nbrDataRFIdx >= NBR_DATA_RF_IDX_MAX) { // too many nbrMsgs error("too many nbr data radio bytes"); return; } //TODO use this line when we bit-pack data //if ((nbrDataRFMessageBitCount + size) >= NBR_DATA_RF_BITS_MAX) { // // too many total bits in the resulting RF message. exit // error("too many nbr data radio bits"); // return; // } // There is enough space. Create and add the message. nbrDataAdd(nbrDataPtr, name, size, value, nbrDataRFIdx, NBR_DATA_TYPE_RF); //TODO enable this when we are bit-packing RF messages. for now, just add 8 bits to the total number of bits //nbrDataRFMessageBitCount+= size; nbrDataRFPacketIndex(nbrDataRFIdx, &packet, &idx); if (idx == 0) { // we need to init a new nbr radio message. we do this dynamically, so that it will // not be sent if it does not need to be sent nbrMsgRadioCreate(&nbrRadioMsgNbrData[packet], "nbrData"); } nbrDataRFIdx++; }
/* * @brief Initializes messages for broadcasting and adds a callback. * * @returns void */ void nbrNbrInit(void) { nbrMsgRadioCreate(&nbrRadioMsgNbrNbr, "nbrNbr"); neighborsAddReceiveCallback(nbrNbrUpdate); }