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 |
APRS_Position.ino (3194B)
1 /* 2 RadioLib APRS Position Example 3 4 This example sends APRS position reports 5 using SX1278's FSK modem. The data is 6 modulated as AFSK at 1200 baud using Bell 7 202 tones. 8 9 DO NOT transmit in APRS bands unless 10 you have a ham radio license! 11 12 Other modules that can be used for APRS: 13 - SX127x/RFM9x 14 - RF69 15 - SX1231 16 - CC1101 17 - nRF24 18 - Si443x/RFM2x 19 20 For default module settings, see the wiki page 21 https://github.com/jgromes/RadioLib/wiki/Default-configuration 22 23 For full API reference, see the GitHub Pages 24 https://jgromes.github.io/RadioLib/ 25 */ 26 27 // include the library 28 #include <RadioLib.h> 29 30 // SX1278 has the following connections: 31 // NSS pin: 10 32 // DIO0 pin: 2 33 // RESET pin: 9 34 // DIO1 pin: 3 35 SX1278 radio = new Module(10, 2, 9, 3); 36 37 // or using RadioShield 38 // https://github.com/jgromes/RadioShield 39 //SX1278 radio = RadioShield.ModuleA; 40 41 // create AFSK client instance using the FSK module 42 // pin 5 is connected to SX1278 DIO2 43 AFSKClient audio(&radio, 5); 44 45 // create AX.25 client instance using the AFSK instance 46 AX25Client ax25(&audio); 47 48 // create APRS client isntance using the AX.25 client 49 APRSClient aprs(&ax25); 50 51 void setup() { 52 Serial.begin(9600); 53 54 // initialize SX1278 55 // NOTE: moved to ISM band on purpose 56 // DO NOT transmit in APRS bands without ham radio license! 57 Serial.print(F("[SX1278] Initializing ... ")); 58 int state = radio.beginFSK(434.0); 59 60 // when using one of the non-LoRa modules for AX.25 61 // (RF69, CC1101, Si4432 etc.), use the basic begin() method 62 // int state = radio.begin(); 63 64 if(state == RADIOLIB_ERR_NONE) { 65 Serial.println(F("success!")); 66 } else { 67 Serial.print(F("failed, code ")); 68 Serial.println(state); 69 while(true); 70 } 71 72 // initialize AX.25 client 73 Serial.print(F("[AX.25] Initializing ... ")); 74 // source station callsign: "N7LEM" 75 // source station SSID: 0 76 // preamble length: 8 bytes 77 state = ax25.begin("N7LEM"); 78 if(state == RADIOLIB_ERR_NONE) { 79 Serial.println(F("success!")); 80 } else { 81 Serial.print(F("failed, code ")); 82 Serial.println(state); 83 while(true); 84 } 85 86 // initialize APRS client 87 Serial.print(F("[APRS] Initializing ... ")); 88 // symbol: '>' (car) 89 state = aprs.begin('>'); 90 if(state == RADIOLIB_ERR_NONE) { 91 Serial.println(F("success!")); 92 } else { 93 Serial.print(F("failed, code ")); 94 Serial.println(state); 95 while(true); 96 } 97 } 98 99 void loop() { 100 Serial.print(F("[APRS] Sending position ... ")); 101 102 // send a location without message or timestamp 103 int state = aprs.sendPosition("N0CALL", 0, "4911.67N", "01635.96E"); 104 delay(500); 105 106 // send a location with message and without timestamp 107 state |= aprs.sendPosition("N0CALL", 0, "4911.67N", "01635.96E", "I'm here!"); 108 delay(500); 109 110 // send a location with message and timestamp 111 state |= aprs.sendPosition("N0CALL", 0, "4911.67N", "01635.96E", "I'm here!", "093045z"); 112 delay(500); 113 114 if(state == RADIOLIB_ERR_NONE) { 115 Serial.println(F("success!")); 116 } else { 117 Serial.print(F("failed, code ")); 118 Serial.println(state); 119 } 120 121 // wait one minute before transmitting again 122 delay(60000); 123 }