nrf24.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. #include "nrf24.h"
  2. #include <furi.h>
  3. #include <furi_hal.h>
  4. #include <furi_hal_resources.h>
  5. #include <assert.h>
  6. #include <string.h>
  7. void nrf24_init() {
  8. furi_hal_spi_bus_handle_init(nrf24_HANDLE);
  9. furi_hal_spi_acquire(nrf24_HANDLE);
  10. furi_hal_gpio_init(nrf24_CE_PIN, GpioModeOutputPushPull, GpioPullUp, GpioSpeedVeryHigh);
  11. furi_hal_gpio_write(nrf24_CE_PIN, false);
  12. }
  13. void nrf24_deinit() {
  14. furi_hal_spi_release(nrf24_HANDLE);
  15. furi_hal_spi_bus_handle_deinit(nrf24_HANDLE);
  16. furi_hal_gpio_write(nrf24_CE_PIN, false);
  17. furi_hal_gpio_init(nrf24_CE_PIN, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
  18. }
  19. void nrf24_spi_trx(
  20. FuriHalSpiBusHandle* handle,
  21. uint8_t* tx,
  22. uint8_t* rx,
  23. uint8_t size,
  24. uint32_t timeout) {
  25. UNUSED(timeout);
  26. furi_hal_gpio_write(handle->cs, false);
  27. furi_hal_spi_bus_trx(handle, tx, rx, size, nrf24_TIMEOUT);
  28. furi_hal_gpio_write(handle->cs, true);
  29. }
  30. uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data) {
  31. uint8_t tx[2] = {W_REGISTER | (REGISTER_MASK & reg), data};
  32. uint8_t rx[2] = {0};
  33. nrf24_spi_trx(handle, tx, rx, 2, nrf24_TIMEOUT);
  34. return rx[0];
  35. }
  36. uint8_t
  37. nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) {
  38. uint8_t tx[size + 1];
  39. uint8_t rx[size + 1];
  40. memset(rx, 0, size + 1);
  41. tx[0] = W_REGISTER | (REGISTER_MASK & reg);
  42. memcpy(&tx[1], data, size);
  43. nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT);
  44. return rx[0];
  45. }
  46. uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) {
  47. uint8_t tx[size + 1];
  48. uint8_t rx[size + 1];
  49. memset(rx, 0, size + 1);
  50. tx[0] = R_REGISTER | (REGISTER_MASK & reg);
  51. memset(&tx[1], 0, size);
  52. nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT);
  53. memcpy(data, &rx[1], size);
  54. return rx[0];
  55. }
  56. uint8_t nrf24_flush_rx(FuriHalSpiBusHandle* handle) {
  57. uint8_t tx[] = {FLUSH_RX};
  58. uint8_t rx[] = {0};
  59. nrf24_spi_trx(handle, tx, rx, 1, nrf24_TIMEOUT);
  60. return rx[0];
  61. }
  62. uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle) {
  63. uint8_t tx[] = {FLUSH_TX};
  64. uint8_t rx[] = {0};
  65. nrf24_spi_trx(handle, tx, rx, 1, nrf24_TIMEOUT);
  66. return rx[0];
  67. }
  68. uint8_t nrf24_get_maclen(FuriHalSpiBusHandle* handle) {
  69. uint8_t maclen;
  70. nrf24_read_reg(handle, REG_SETUP_AW, &maclen, 1);
  71. maclen &= 3;
  72. return maclen + 2;
  73. }
  74. uint8_t nrf24_set_maclen(FuriHalSpiBusHandle* handle, uint8_t maclen) {
  75. assert(maclen > 1 && maclen < 6);
  76. uint8_t status = 0;
  77. status = nrf24_write_reg(handle, REG_SETUP_AW, maclen - 2);
  78. return status;
  79. }
  80. uint8_t nrf24_status(FuriHalSpiBusHandle* handle) {
  81. uint8_t status;
  82. uint8_t tx[] = {R_REGISTER | (REGISTER_MASK & REG_STATUS)};
  83. nrf24_spi_trx(handle, tx, &status, 1, nrf24_TIMEOUT);
  84. return status;
  85. }
  86. uint32_t nrf24_get_rate(FuriHalSpiBusHandle* handle) {
  87. uint8_t setup = 0;
  88. uint32_t rate = 0;
  89. nrf24_read_reg(handle, REG_RF_SETUP, &setup, 1);
  90. setup &= 0x28;
  91. if(setup == 0x20)
  92. rate = 250000; // 250kbps
  93. else if(setup == 0x08)
  94. rate = 2000000; // 2Mbps
  95. else if(setup == 0x00)
  96. rate = 1000000; // 1Mbps
  97. return rate;
  98. }
  99. uint8_t nrf24_set_rate(FuriHalSpiBusHandle* handle, uint32_t rate) {
  100. uint8_t r6 = 0;
  101. uint8_t status = 0;
  102. if(!rate) rate = 2000000;
  103. nrf24_read_reg(handle, REG_RF_SETUP, &r6, 1); // RF_SETUP register
  104. r6 = r6 & (~0x28); // Clear rate fields.
  105. if(rate == 2000000)
  106. r6 = r6 | 0x08;
  107. else if(rate == 1000000)
  108. r6 = r6;
  109. else if(rate == 250000)
  110. r6 = r6 | 0x20;
  111. status = nrf24_write_reg(handle, REG_RF_SETUP, r6); // Write new rate.
  112. return status;
  113. }
  114. uint8_t nrf24_get_chan(FuriHalSpiBusHandle* handle) {
  115. uint8_t channel = 0;
  116. nrf24_read_reg(handle, REG_RF_CH, &channel, 1);
  117. return channel;
  118. }
  119. uint8_t nrf24_set_chan(FuriHalSpiBusHandle* handle, uint8_t chan) {
  120. uint8_t status;
  121. status = nrf24_write_reg(handle, REG_RF_CH, chan);
  122. return status;
  123. }
  124. uint8_t nrf24_get_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac) {
  125. uint8_t size = 0;
  126. uint8_t status = 0;
  127. size = nrf24_get_maclen(handle);
  128. status = nrf24_read_reg(handle, REG_RX_ADDR_P0, mac, size);
  129. return status;
  130. }
  131. uint8_t nrf24_set_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size) {
  132. uint8_t status = 0;
  133. uint8_t clearmac[] = {0, 0, 0, 0, 0};
  134. nrf24_set_maclen(handle, size);
  135. nrf24_write_buf_reg(handle, REG_RX_ADDR_P0, clearmac, 5);
  136. status = nrf24_write_buf_reg(handle, REG_RX_ADDR_P0, mac, size);
  137. return status;
  138. }
  139. uint8_t nrf24_get_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac) {
  140. uint8_t size = 0;
  141. uint8_t status = 0;
  142. size = nrf24_get_maclen(handle);
  143. status = nrf24_read_reg(handle, REG_TX_ADDR, mac, size);
  144. return status;
  145. }
  146. uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size) {
  147. uint8_t status = 0;
  148. uint8_t clearmac[] = {0, 0, 0, 0, 0};
  149. nrf24_set_maclen(handle, size);
  150. nrf24_write_buf_reg(handle, REG_TX_ADDR, clearmac, 5);
  151. status = nrf24_write_buf_reg(handle, REG_TX_ADDR, mac, size);
  152. return status;
  153. }
  154. uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle) {
  155. uint8_t len = 0;
  156. nrf24_read_reg(handle, RX_PW_P0, &len, 1);
  157. return len;
  158. }
  159. uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len) {
  160. uint8_t status = 0;
  161. status = nrf24_write_reg(handle, RX_PW_P0, len);
  162. return status;
  163. }
  164. uint8_t
  165. nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full) {
  166. uint8_t status = 0;
  167. uint8_t size = 0;
  168. uint8_t tx_pl_wid[] = {R_RX_PL_WID, 0};
  169. uint8_t rx_pl_wid[] = {0, 0};
  170. uint8_t tx_cmd[33] = {0}; // 32 max payload size + 1 for command
  171. uint8_t tmp_packet[33] = {0};
  172. status = nrf24_status(handle);
  173. if(status & 0x40) {
  174. if(full)
  175. size = nrf24_get_packetlen(handle);
  176. else {
  177. nrf24_spi_trx(handle, tx_pl_wid, rx_pl_wid, 2, nrf24_TIMEOUT);
  178. size = rx_pl_wid[1];
  179. }
  180. tx_cmd[0] = R_RX_PAYLOAD;
  181. nrf24_spi_trx(handle, tx_cmd, tmp_packet, size + 1, nrf24_TIMEOUT);
  182. nrf24_write_reg(handle, REG_STATUS, 0x40); // clear bit.
  183. memcpy(packet, &tmp_packet[1], size);
  184. } else if(status == 0) {
  185. nrf24_flush_rx(handle);
  186. nrf24_write_reg(handle, REG_STATUS, 0x40); // clear bit.
  187. }
  188. *packetsize = size;
  189. return status;
  190. }
  191. uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t size, bool ack) {
  192. uint8_t status = 0;
  193. uint8_t tx[size + 1];
  194. uint8_t rx[size + 1];
  195. memset(tx, 0, size + 1);
  196. memset(rx, 0, size + 1);
  197. if(!ack)
  198. tx[0] = W_TX_PAYLOAD_NOACK;
  199. else
  200. tx[0] = W_TX_PAYLOAD;
  201. memcpy(&tx[1], payload, size);
  202. nrf24_spi_trx(handle, tx, rx, size + 1, nrf24_TIMEOUT);
  203. nrf24_set_tx_mode(handle);
  204. while(!(status & (TX_DS | MAX_RT))) status = nrf24_status(handle);
  205. if(status & MAX_RT) nrf24_flush_tx(handle);
  206. nrf24_set_idle(handle);
  207. nrf24_write_reg(handle, REG_STATUS, TX_DS | MAX_RT);
  208. return status & TX_DS;
  209. }
  210. uint8_t nrf24_power_up(FuriHalSpiBusHandle* handle) {
  211. uint8_t status = 0;
  212. uint8_t cfg = 0;
  213. nrf24_read_reg(handle, REG_CONFIG, &cfg, 1);
  214. cfg = cfg | 2;
  215. status = nrf24_write_reg(handle, REG_CONFIG, cfg);
  216. furi_delay_ms(5000);
  217. return status;
  218. }
  219. uint8_t nrf24_set_idle(FuriHalSpiBusHandle* handle) {
  220. uint8_t status = 0;
  221. uint8_t cfg = 0;
  222. nrf24_read_reg(handle, REG_CONFIG, &cfg, 1);
  223. cfg &= 0xfc; // clear bottom two bits to power down the radio
  224. status = nrf24_write_reg(handle, REG_CONFIG, cfg);
  225. //nr204_write_reg(handle, REG_EN_RXADDR, 0x0);
  226. furi_hal_gpio_write(nrf24_CE_PIN, false);
  227. return status;
  228. }
  229. uint8_t nrf24_set_rx_mode(FuriHalSpiBusHandle* handle) {
  230. uint8_t status = 0;
  231. uint8_t cfg = 0;
  232. //status = nrf24_write_reg(handle, REG_CONFIG, 0x0F); // enable 2-byte CRC, PWR_UP, and PRIM_RX
  233. nrf24_read_reg(handle, REG_CONFIG, &cfg, 1);
  234. cfg |= 0x03; // PWR_UP, and PRIM_RX
  235. status = nrf24_write_reg(handle, REG_CONFIG, cfg);
  236. //nr204_write_reg(REG_EN_RXADDR, 0x03) // Set RX Pipe 0 and 1
  237. furi_hal_gpio_write(nrf24_CE_PIN, true);
  238. furi_delay_ms(2000);
  239. return status;
  240. }
  241. uint8_t nrf24_set_tx_mode(FuriHalSpiBusHandle* handle) {
  242. uint8_t status = 0;
  243. uint8_t cfg = 0;
  244. furi_hal_gpio_write(nrf24_CE_PIN, false);
  245. nrf24_write_reg(handle, REG_STATUS, 0x30);
  246. //status = nrf24_write_reg(handle, REG_CONFIG, 0x0E); // enable 2-byte CRC, PWR_UP
  247. nrf24_read_reg(handle, REG_CONFIG, &cfg, 1);
  248. cfg &= 0xfe; // disable PRIM_RX
  249. cfg |= 0x02; // PWR_UP
  250. status = nrf24_write_reg(handle, REG_CONFIG, cfg);
  251. furi_hal_gpio_write(nrf24_CE_PIN, true);
  252. furi_delay_ms(2);
  253. return status;
  254. }
  255. void nrf24_configure(
  256. FuriHalSpiBusHandle* handle,
  257. uint8_t rate,
  258. uint8_t* srcmac,
  259. uint8_t* dstmac,
  260. uint8_t maclen,
  261. uint8_t channel,
  262. bool noack,
  263. bool disable_aa) {
  264. assert(channel <= 125);
  265. assert(rate == 1 || rate == 2);
  266. if(rate == 2)
  267. rate = 8; // 2Mbps
  268. else
  269. rate = 0; // 1Mbps
  270. nrf24_write_reg(handle, REG_CONFIG, 0x00); // Stop nRF
  271. nrf24_set_idle(handle);
  272. nrf24_write_reg(handle, REG_STATUS, 0x1c); // clear interrupts
  273. if(disable_aa)
  274. nrf24_write_reg(handle, REG_EN_AA, 0x00); // Disable Shockburst
  275. else
  276. nrf24_write_reg(handle, REG_EN_AA, 0x1F); // Enable Shockburst
  277. nrf24_write_reg(handle, REG_DYNPD, 0x3F); // enable dynamic payload length on all pipes
  278. if(noack)
  279. nrf24_write_reg(handle, REG_FEATURE, 0x05); // disable payload-with-ack, enable noack
  280. else {
  281. nrf24_write_reg(handle, REG_CONFIG, 0x0C); // 2 byte CRC
  282. nrf24_write_reg(handle, REG_FEATURE, 0x07); // enable dyn payload and ack
  283. nrf24_write_reg(
  284. handle, REG_SETUP_RETR, 0x1f); // 15 retries for AA, 500us auto retransmit delay
  285. }
  286. nrf24_set_idle(handle);
  287. nrf24_flush_rx(handle);
  288. nrf24_flush_tx(handle);
  289. if(maclen) nrf24_set_maclen(handle, maclen);
  290. if(srcmac) nrf24_set_src_mac(handle, srcmac, maclen);
  291. if(dstmac) nrf24_set_dst_mac(handle, dstmac, maclen);
  292. nrf24_write_reg(handle, REG_RF_CH, channel);
  293. nrf24_write_reg(handle, REG_RF_SETUP, rate);
  294. furi_delay_ms(200);
  295. }
  296. void nrf24_init_promisc_mode(FuriHalSpiBusHandle* handle, uint8_t channel, uint8_t rate) {
  297. //uint8_t preamble[] = {0x55, 0x00}; // little endian
  298. uint8_t preamble[] = {0xAA, 0x00}; // little endian
  299. //uint8_t preamble[] = {0x00, 0x55}; // little endian
  300. //uint8_t preamble[] = {0x00, 0xAA}; // little endian
  301. nrf24_write_reg(handle, REG_CONFIG, 0x00); // Stop nRF
  302. nrf24_write_reg(handle, REG_STATUS, 0x1c); // clear interrupts
  303. nrf24_write_reg(handle, REG_DYNPD, 0x0); // disable shockburst
  304. nrf24_write_reg(handle, REG_EN_AA, 0x00); // Disable Shockburst
  305. nrf24_write_reg(handle, REG_FEATURE, 0x05); // disable payload-with-ack, enable noack
  306. nrf24_set_maclen(handle, 2); // shortest address
  307. nrf24_set_src_mac(handle, preamble, 2); // set src mac to preamble bits to catch everything
  308. nrf24_set_packetlen(handle, 32); // set max packet length
  309. nrf24_set_idle(handle);
  310. nrf24_flush_rx(handle);
  311. nrf24_flush_tx(handle);
  312. nrf24_write_reg(handle, REG_RF_CH, channel);
  313. nrf24_write_reg(handle, REG_RF_SETUP, rate);
  314. // prime for RX, no checksum
  315. nrf24_write_reg(handle, REG_CONFIG, 0x03); // PWR_UP and PRIM_RX, disable AA and CRC
  316. furi_hal_gpio_write(nrf24_CE_PIN, true);
  317. furi_delay_ms(100);
  318. }
  319. void hexlify(uint8_t* in, uint8_t size, char* out) {
  320. memset(out, 0, size * 2);
  321. for(int i = 0; i < size; i++)
  322. snprintf(out + strlen(out), sizeof(out + strlen(out)), "%02X", in[i]);
  323. }
  324. uint64_t bytes_to_int64(uint8_t* bytes, uint8_t size, bool bigendian) {
  325. uint64_t ret = 0;
  326. for(int i = 0; i < size; i++)
  327. if(bigendian)
  328. ret |= bytes[i] << ((size - 1 - i) * 8);
  329. else
  330. ret |= bytes[i] << (i * 8);
  331. return ret;
  332. }
  333. void int64_to_bytes(uint64_t val, uint8_t* out, bool bigendian) {
  334. for(int i = 0; i < 8; i++) {
  335. if(bigendian)
  336. out[i] = (val >> ((7 - i) * 8)) & 0xff;
  337. else
  338. out[i] = (val >> (i * 8)) & 0xff;
  339. }
  340. }
  341. uint32_t bytes_to_int32(uint8_t* bytes, bool bigendian) {
  342. uint32_t ret = 0;
  343. for(int i = 0; i < 4; i++)
  344. if(bigendian)
  345. ret |= bytes[i] << ((3 - i) * 8);
  346. else
  347. ret |= bytes[i] << (i * 8);
  348. return ret;
  349. }
  350. void int32_to_bytes(uint32_t val, uint8_t* out, bool bigendian) {
  351. for(int i = 0; i < 4; i++) {
  352. if(bigendian)
  353. out[i] = (val >> ((3 - i) * 8)) & 0xff;
  354. else
  355. out[i] = (val >> (i * 8)) & 0xff;
  356. }
  357. }
  358. uint64_t bytes_to_int16(uint8_t* bytes, bool bigendian) {
  359. uint16_t ret = 0;
  360. for(int i = 0; i < 2; i++)
  361. if(bigendian)
  362. ret |= bytes[i] << ((1 - i) * 8);
  363. else
  364. ret |= bytes[i] << (i * 8);
  365. return ret;
  366. }
  367. void int16_to_bytes(uint16_t val, uint8_t* out, bool bigendian) {
  368. for(int i = 0; i < 2; i++) {
  369. if(bigendian)
  370. out[i] = (val >> ((1 - i) * 8)) & 0xff;
  371. else
  372. out[i] = (val >> (i * 8)) & 0xff;
  373. }
  374. }
  375. // handle iffyness with preamble processing sometimes being a bit (literally) off
  376. void alt_address_old(uint8_t* packet, uint8_t* altaddr) {
  377. uint8_t macmess_hi_b[4];
  378. uint8_t macmess_lo_b[2];
  379. uint32_t macmess_hi;
  380. uint16_t macmess_lo;
  381. uint8_t preserved;
  382. // get first 6 bytes into 32-bit and 16-bit variables
  383. memcpy(macmess_hi_b, packet, 4);
  384. memcpy(macmess_lo_b, packet + 4, 2);
  385. macmess_hi = bytes_to_int32(macmess_hi_b, true);
  386. //preserve least 7 bits from hi that will be shifted down to lo
  387. preserved = macmess_hi & 0x7f;
  388. macmess_hi >>= 7;
  389. macmess_lo = bytes_to_int16(macmess_lo_b, true);
  390. macmess_lo >>= 7;
  391. macmess_lo = (preserved << 9) | macmess_lo;
  392. int32_to_bytes(macmess_hi, macmess_hi_b, true);
  393. int16_to_bytes(macmess_lo, macmess_lo_b, true);
  394. memcpy(altaddr, &macmess_hi_b[1], 3);
  395. memcpy(altaddr + 3, macmess_lo_b, 2);
  396. }
  397. bool validate_address(uint8_t* addr) {
  398. uint8_t bad[][3] = {{0x55, 0x55}, {0xAA, 0xAA}, {0x00, 0x00}, {0xFF, 0xFF}};
  399. for(int i = 0; i < 4; i++)
  400. for(int j = 0; j < 2; j++)
  401. if(!memcmp(addr + j * 2, bad[i], 2)) return false;
  402. return true;
  403. }
  404. bool nrf24_sniff_address(FuriHalSpiBusHandle* handle, uint8_t maclen, uint8_t* address) {
  405. bool found = false;
  406. uint8_t packet[32] = {0};
  407. uint8_t packetsize;
  408. //char printit[65];
  409. uint8_t status = 0;
  410. status = nrf24_rxpacket(handle, packet, &packetsize, true);
  411. if(status & 0x40) {
  412. if(validate_address(packet)) {
  413. for(int i = 0; i < maclen; i++) address[i] = packet[maclen - 1 - i];
  414. /*
  415. alt_address(packet, packet);
  416. for(i = 0; i < maclen; i++)
  417. address[i + 5] = packet[maclen - 1 - i];
  418. */
  419. //memcpy(address, packet, maclen);
  420. //hexlify(packet, packetsize, printit);
  421. found = true;
  422. }
  423. }
  424. return found;
  425. }
  426. uint8_t nrf24_find_channel(
  427. FuriHalSpiBusHandle* handle,
  428. uint8_t* srcmac,
  429. uint8_t* dstmac,
  430. uint8_t maclen,
  431. uint8_t rate,
  432. uint8_t min_channel,
  433. uint8_t max_channel,
  434. bool autoinit) {
  435. uint8_t ping_packet[] = {0x0f, 0x0f, 0x0f, 0x0f}; // this can be anything, we just need an ack
  436. uint8_t ch = max_channel + 1; // means fail
  437. nrf24_configure(handle, rate, srcmac, dstmac, maclen, 2, false, false);
  438. for(ch = min_channel; ch <= max_channel + 1; ch++) {
  439. nrf24_write_reg(handle, REG_RF_CH, ch);
  440. if(nrf24_txpacket(handle, ping_packet, 4, true)) break;
  441. }
  442. if(autoinit) {
  443. FURI_LOG_D("nrf24", "initializing radio for channel %d", ch);
  444. nrf24_configure(handle, rate, srcmac, dstmac, maclen, ch, false, false);
  445. return ch;
  446. }
  447. return ch;
  448. }
  449. bool nrf24_check_connected(FuriHalSpiBusHandle* handle) {
  450. uint8_t status = nrf24_status(handle);
  451. if(status != 0x00) {
  452. return true;
  453. } else {
  454. return false;
  455. }
  456. }