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 |
AX25_Transmit_AFSK.ino (2928B)
1 /* 2 RadioLib AX.25 Transmit AFSK Example 3 4 This example sends AX.25 messages using 5 SX1278's FSK modem. The data is modulated 6 as AFSK at 1200 baud using Bell 202 tones. 7 8 Other modules that can be used for AX.25 9 with AFSK modulation: 10 - SX127x/RFM9x 11 - RF69 12 - SX1231 13 - CC1101 14 - nRF24 15 - Si443x/RFM2x 16 17 For default module settings, see the wiki page 18 https://github.com/jgromes/RadioLib/wiki/Default-configuration 19 20 For full API reference, see the GitHub Pages 21 https://jgromes.github.io/RadioLib/ 22 */ 23 24 // include the library 25 #include <RadioLib.h> 26 27 // SX1278 has the following connections: 28 // NSS pin: 10 29 // DIO0 pin: 2 30 // RESET pin: 9 31 // DIO1 pin: 3 32 SX1278 radio = new Module(10, 2, 9, 3); 33 34 // or using RadioShield 35 // https://github.com/jgromes/RadioShield 36 //SX1278 radio = RadioShield.ModuleA; 37 38 // create AFSK client instance using the FSK module 39 // pin 5 is connected to SX1278 DIO2 40 AFSKClient audio(&radio, 5); 41 42 // create AX.25 client instance using the AFSK instance 43 AX25Client ax25(&audio); 44 45 void setup() { 46 Serial.begin(9600); 47 48 // initialize SX1278 with default settings 49 Serial.print(F("[SX1278] Initializing ... ")); 50 int state = radio.beginFSK(); 51 52 // when using one of the non-LoRa modules for AX.25 53 // (RF69, CC1101,, Si4432 etc.), use the basic begin() method 54 // int state = radio.begin(); 55 56 if(state == RADIOLIB_ERR_NONE) { 57 Serial.println(F("success!")); 58 } else { 59 Serial.print(F("failed, code ")); 60 Serial.println(state); 61 while(true); 62 } 63 64 // initialize AX.25 client 65 Serial.print(F("[AX.25] Initializing ... ")); 66 // source station callsign: "N7LEM" 67 // source station SSID: 0 68 // preamble length: 8 bytes 69 state = ax25.begin("N7LEM"); 70 if(state == RADIOLIB_ERR_NONE) { 71 Serial.println(F("success!")); 72 } else { 73 Serial.print(F("failed, code ")); 74 Serial.println(state); 75 while(true); 76 } 77 78 // Sometimes, it may be required to adjust audio 79 // frequencies to match the expected 1200/2200 Hz tones. 80 // The following method will offset mark frequency by 81 // 100 Hz up and space frequency by 100 Hz down 82 /* 83 Serial.print(F("[AX.25] Setting correction ... ")); 84 state = ax25.setCorrection(100, -100); 85 if(state == RADIOLIB_ERR_NONE) { 86 Serial.println(F("success!")); 87 } else { 88 Serial.print(F("failed, code ")); 89 Serial.println(state); 90 while(true); 91 } 92 */ 93 } 94 95 void loop() { 96 // send AX.25 unnumbered information frame 97 Serial.print(F("[AX.25] Sending UI frame ... ")); 98 // destination station callsign: "NJ7P" 99 // destination station SSID: 0 100 int state = ax25.transmit("Hello World!", "NJ7P"); 101 if (state == RADIOLIB_ERR_NONE) { 102 // the packet was successfully transmitted 103 Serial.println(F("success!")); 104 105 } else { 106 // some error occurred 107 Serial.print(F("failed, code ")); 108 Serial.println(state); 109 110 } 111 112 delay(1000); 113 }