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 |
FSK4_Transmit_AFSK.ino (3366B)
1 /* 2 RadioLib FSK4 Transmit AFSK Example 3 4 This example sends an example FSK-4 'Horus Binary' message 5 using SX1278's FSK modem. The data is modulated as AFSK. 6 7 This signal can be demodulated using an FM demodulator (SDR or otherwise), 8 and horusdemodlib: https://github.com/projecthorus/horusdemodlib/wiki 9 10 Other modules that can be used for FSK4: 11 - SX127x/RFM9x 12 - RF69 13 - SX1231 14 - CC1101 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 FSK4 client instance using the AFSK instance 43 FSK4Client fsk4(&audio); 44 45 // An encoded Horus Binary telemetry packet. 46 // Refer here for packet format information: 47 // https://github.com/projecthorus/horusdemodlib/wiki/2---Modem-Details#horus-binary-v1-mode-4-fsk 48 // After demodulation, deinterleaving, and descrambling, this results in a packet: 49 // 00000001172D0000000000000000D20463010AFF2780 50 // This decodes to the Habitat-compatible telemetry string: 51 // $$4FSKTEST,0,01:23:45,0.00000,0.00000,1234,99,1,10,5.00*ABCD 52 int horusPacketLen = 45; 53 byte horusPacket[] = { 54 0x45, 0x24, 0x24, 0x48, 0x2F, 0x12, 0x16, 0x08, 0x15, 0xC1, 55 0x49, 0xB2, 0x06, 0xFC, 0x92, 0xEB, 0x93, 0xD7, 0xEE, 0x5D, 56 0x35, 0xA0, 0x91, 0xDA, 0x8D, 0x5F, 0x85, 0x6B, 0x63, 0x03, 57 0x6B, 0x60, 0xEA, 0xFE, 0x55, 0x9D, 0xF1, 0xAB, 0xE5, 0x5E, 58 0xDB, 0x7C, 0xDB, 0x21, 0x5A, 0x19 59 }; 60 61 void setup() { 62 Serial.begin(9600); 63 64 // initialize SX1278 with default settings 65 Serial.print(F("[SX1278] Initializing ... ")); 66 int state = radio.beginFSK(); 67 68 // when using one of the non-LoRa modules for RTTY 69 // (RF69, CC1101, Si4432 etc.), use the basic begin() method 70 // int state = radio.begin(); 71 72 if(state == RADIOLIB_ERR_NONE) { 73 Serial.println(F("success!")); 74 } else { 75 Serial.print(F("failed, code ")); 76 Serial.println(state); 77 while(true); 78 } 79 80 // initialize FSK4 client 81 // NOTE: Unlike FSK FSK4, AFSK requires no rounding of 82 // the frequency shift. 83 Serial.print(F("[FSK4] Initializing ... ")); 84 // low ("space") frequency: 434.0 MHz 85 // frequency shift: 270 Hz 86 // baud rate: 100 baud 87 state = fsk4.begin(400, 270, 100); 88 if(state == RADIOLIB_ERR_NONE) { 89 Serial.println(F("success!")); 90 } else { 91 Serial.print(F("failed, code ")); 92 Serial.println(state); 93 while(true); 94 } 95 } 96 97 void loop() { 98 Serial.print(F("[FSK4] Sending FSK4 data packet ... ")); 99 100 // send out idle condition for 500 ms 101 fsk4.idle(); 102 delay(1000); 103 104 // FSK4Client supports binary write methods 105 106 // send some bytes as a preamble 107 for(int i = 0; i < 8; i++) { 108 fsk4.write(0x1B); 109 } 110 111 // now send the encoded packet 112 fsk4.write(horusPacket, horusPacketLen); 113 114 Serial.println(F("done!")); 115 116 // wait for a second before transmitting again 117 delay(1000); 118 }