コード例 #1
0
ファイル: MyTransportRF24.cpp プロジェクト: beosro/MySensors
bool transportSend(const uint8_t to, const void *data, const uint8_t len, const bool noACK)
{
#if defined(MY_RF24_ENABLE_ENCRYPTION)
	// copy input data because it is read-only
	(void)memcpy(RF24_dataenc,data,len);
	// has to be adjusted, WIP!
	RF24_aes.set_IV(0);
	const uint8_t finalLength = len > 16 ? 32 : 16;
	//encrypt data
	RF24_aes.cbc_encrypt(RF24_dataenc, RF24_dataenc, finalLength / 16);
	return RF24_sendMessage(to, RF24_dataenc, finalLength, noACK);
#else
	return RF24_sendMessage(to, data, len, noACK);
#endif
}
コード例 #2
0
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;
}
コード例 #3
0
bool transportSend(uint8_t to, const void* data, uint8_t len) {
	#if defined(MY_RF24_ENABLE_ENCRYPTION)
		memcpy(_dataenc,data,len); // copy input data because it is read-only

		_aes.set_IV(0);//not sure if necessary
		len = len > 16 ? 32 : 16;
		_aes.cbc_encrypt(_dataenc, _dataenc, len/16); //encrypt
	#endif

	// Make sure radio has powered up

	_rf24.powerUp();
	_rf24.stopListening();
	_rf24.openWritingPipe(TO_ADDR(to));
	#if defined(MY_RF24_ENABLE_ENCRYPTION)
		bool ok = _rf24.write(_dataenc, len, to == BROADCAST_ADDRESS);
	#else
		bool ok = _rf24.write(data, len, to == BROADCAST_ADDRESS);
	#endif
	_rf24.startListening();
	return ok;
}