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 |
CC1101_Transmit.ino (1967B)
1 /* 2 RadioLib CC1101 Transmit Example 3 4 This example transmits packets using CC1101 FSK radio module. 5 Each packet contains up to 64 bytes of data, in the form of: 6 - Arduino String 7 - null-terminated char array (C-string) 8 - arbitrary binary data (byte array) 9 10 For default module settings, see the wiki page 11 https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 12 13 For full API reference, see the GitHub Pages 14 https://jgromes.github.io/RadioLib/ 15 */ 16 17 // include the library 18 #include <RadioLib.h> 19 20 // CC1101 has the following connections: 21 // CS pin: 10 22 // GDO0 pin: 2 23 // RST pin: unused 24 // GDO2 pin: 3 (optional) 25 CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); 26 27 // or using RadioShield 28 // https://github.com/jgromes/RadioShield 29 //CC1101 radio = RadioShield.ModuleA; 30 31 void setup() { 32 Serial.begin(9600); 33 34 // initialize CC1101 with default settings 35 Serial.print(F("[CC1101] Initializing ... ")); 36 int state = radio.begin(); 37 if (state == RADIOLIB_ERR_NONE) { 38 Serial.println(F("success!")); 39 } else { 40 Serial.print(F("failed, code ")); 41 Serial.println(state); 42 while (true); 43 } 44 } 45 46 void loop() { 47 Serial.print(F("[CC1101] Transmitting packet ... ")); 48 49 // you can transmit C-string or Arduino string up to 63 characters long 50 int state = radio.transmit("Hello World!"); 51 52 // you can also transmit byte array up to 63 bytes long 53 /* 54 byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; 55 int state = radio.transmit(byteArr, 8); 56 */ 57 58 if (state == RADIOLIB_ERR_NONE) { 59 // the packet was successfully transmitted 60 Serial.println(F("success!")); 61 62 } else if (state == RADIOLIB_ERR_PACKET_TOO_LONG) { 63 // the supplied packet was longer than 64 bytes 64 Serial.println(F("too long!")); 65 66 } else { 67 // some other error occurred 68 Serial.print(F("failed, code ")); 69 Serial.println(state); 70 71 } 72 73 // wait for a second before transmitting again 74 delay(1000); 75 }