MCPcopy Create free account
hub / github.com/LowPowerLab/RFM69 / encrypt

Method encrypt

RFM69.cpp:510–527  ·  view source on GitHub ↗

To enable encryption: radio.encrypt("ABCDEFGHIJKLMNOP"); To disable encryption: radio.encrypt(null) or radio.encrypt(0) KEY HAS TO BE 16 bytes !!!

Source from the content-addressed store, hash-verified

508// To disable encryption: radio.encrypt(null) or radio.encrypt(0)
509// KEY HAS TO BE 16 bytes !!!
510void RFM69::encrypt(const char* key) {
511#if defined(RF69_LISTENMODE_ENABLE)
512 _haveEncryptKey = key;
513#endif
514 setMode(RF69_MODE_STANDBY);
515 uint8_t validKey = key != 0 && strlen(key)!=0;
516 if (validKey) {
517#if defined(RF69_LISTENMODE_ENABLE)
518 memcpy(_encryptKey, key, 16);
519#endif
520 select();
521 _spi->transfer(REG_AESKEY1 | 0x80);
522 for (uint8_t i = 0; i < 16; i++)
523 _spi->transfer(key[i]);
524 unselect();
525 }
526 writeReg(REG_PACKETCONFIG2, (readReg(REG_PACKETCONFIG2) & 0xFE) | (validKey ? 1 : 0));
527}
528
529// get the received signal strength indicator (RSSI)
530int16_t RFM69::readRSSI(bool forceTrigger) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected