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