acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
SX128x_Channel_Activity_Detection.ino (1654B)
1 /* 2 RadioLib SX128x Channel Activity Detection Example 3 4 This example uses SX1280 to scan the current LoRa 5 channel and detect ongoing LoRa transmissions. 6 7 Other modules from SX128x family can also be used. 8 9 For default module settings, see the wiki page 10 https://github.com/jgromes/RadioLib/wiki/Default-configuration#sx128x---lora-modem 11 12 For full API reference, see the GitHub Pages 13 https://jgromes.github.io/RadioLib/ 14 */ 15 16 // include the library 17 #include <RadioLib.h> 18 19 // SX1280 has the following connections: 20 // NSS pin: 10 21 // DIO1 pin: 2 22 // NRST pin: 3 23 // BUSY pin: 9 24 SX1280 radio = new Module(10, 2, 3, 9); 25 26 // or using RadioShield 27 // https://github.com/jgromes/RadioShield 28 //SX1280 radio = RadioShield.ModuleA; 29 30 void setup() { 31 Serial.begin(9600); 32 33 // initialize SX1280 with default settings 34 Serial.print(F("[SX1280] Initializing ... ")); 35 int state = radio.begin(); 36 if (state == RADIOLIB_ERR_NONE) { 37 Serial.println(F("success!")); 38 } else { 39 Serial.print(F("failed, code ")); 40 Serial.println(state); 41 while (true); 42 } 43 } 44 45 void loop() { 46 Serial.print(F("[SX1280] Scanning channel for LoRa transmission ... ")); 47 48 // start scanning current channel 49 int state = radio.scanChannel(); 50 51 if (state == RADIOLIB_LORA_DETECTED) { 52 // LoRa preamble was detected 53 Serial.println(F("detected!")); 54 55 } else if (state == RADIOLIB_CHANNEL_FREE) { 56 // no preamble was detected, channel is free 57 Serial.println(F("channel is free!")); 58 59 } else { 60 // some other error occurred 61 Serial.print(F("failed, code ")); 62 Serial.println(state); 63 64 } 65 66 // wait 100 ms before new scan 67 delay(100); 68 }