To enable encryption: radio.encrypt("ABCDEFGHIJKLMNOP"); To disable encryption: radio.encrypt(null) or radio.encrypt(0) KEY HAS TO BE 16 bytes !!!
| 508 | // To disable encryption: radio.encrypt(null) or radio.encrypt(0) |
| 509 | // KEY HAS TO BE 16 bytes !!! |
| 510 | void 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) |
| 530 | int16_t RFM69::readRSSI(bool forceTrigger) { |
nothing calls this directly
no outgoing calls
no test coverage detected