bool transportInit() { // Start up the radio library _rf24.begin(); if (!_rf24.isPVariant()) { return false; } _rf24.setAutoAck(1); _rf24.setAutoAck(BROADCAST_PIPE,false); // Turn off auto ack for broadcast _rf24.enableAckPayload(); _rf24.setChannel(MY_RF24_CHANNEL); _rf24.setPALevel(_paLevel); if (!_rf24.setDataRate(MY_RF24_DATARATE)) { return false; } _rf24.setRetries(5,15); _rf24.setCRCLength(RF24_CRC_16); _rf24.enableDynamicPayloads(); // All nodes listen to broadcast pipe (for FIND_PARENT_RESPONSE messages) _rf24.openReadingPipe(BROADCAST_PIPE, TO_ADDR(BROADCAST_ADDRESS)); #if defined(MY_RF24_ENABLE_ENCRYPTION) _aes.set_key(_psk, 16); //set up AES-key #endif //_rf24.printDetails(); return true; }
bool transportInit() { #if defined(MY_RF24_ENABLE_ENCRYPTION) hwReadConfigBlock((void*)_psk, (void*)EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 32); //set up AES-key _aes.set_key(_psk, 32); // Make sure it is purged from memory when set memset(_psk, 0, 32); //set up AES IV hwReadConfigBlock((void*)IVCl,(void*)EEPROM_RF_ENCRYPTION_AES_IV_ADDRESS,8); _aes.set_IV(IVCl); #endif return RF24_initialize(); }
bool transportSend(uint8_t recipient, const void* data, uint8_t len) { #if defined(MY_RF24_ENABLE_ENCRYPTION) // copy input data because it is read-only memcpy(_dataenc,data,len); len = len > 16 ? 32 : 16; #if defined(MY_GATEWAY_FEATURE) SdReadNodeData(RF24_getNodeID(), nd); _aes.set_key(nd.AES_256,32); _aes.set_IV(nd.IV); #else #endif //encrypt data _aes.set_IV(IVCl); _aes.cbc_encrypt(_dataenc, _dataenc, len/16); bool status = RF24_sendMessage( recipient, _dataenc, len ); #else bool status = RF24_sendMessage( recipient, data, len ); #endif return status; }
bool transportInit(void) { #if defined(MY_RF24_ENABLE_ENCRYPTION) uint8_t RF24_psk[16]; #ifdef MY_ENCRYPTION_SIMPLE_PASSWD (void)memset(RF24_psk, 0, 16); (void)memcpy(RF24_psk, MY_ENCRYPTION_SIMPLE_PASSWD, strnlen(MY_ENCRYPTION_SIMPLE_PASSWD, 16)); #else hwReadConfigBlock((void *)RF24_psk, (void *)EEPROM_RF_ENCRYPTION_AES_KEY_ADDRESS, 16); #endif //set up AES-key RF24_aes.set_key(RF24_psk, 16); // Make sure it is purged from memory when set (void)memset(RF24_psk, 0, 16); #endif #if defined(MY_RX_MESSAGE_BUFFER_FEATURE) RF24_registerReceiveCallback( transportRxCallback ); #endif return RF24_initialize(); }