From 4819168d2ea722156fc254d2206fc8808683a650 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sat, 4 Jul 2020 11:22:47 +0200 Subject: [PATCH] [CC1101] Added links to default config wiki page --- .../CC1101/CC1101_Receive/CC1101_Receive.ino | 22 +++++----- .../CC1101_Receive_Address.ino | 26 ++++++------ .../CC1101_Receive_Interrupt.ino | 42 +++++++++---------- .../CC1101_Settings/CC1101_Settings.ino | 30 +++++++------ .../CC1101_Transmit/CC1101_Transmit.ino | 20 ++++----- .../CC1101_Transmit_Address.ino | 22 +++++----- .../CC1101_Transmit_Interrupt.ino | 24 +++++------ 7 files changed, 86 insertions(+), 100 deletions(-) diff --git a/examples/CC1101/CC1101_Receive/CC1101_Receive.ino b/examples/CC1101/CC1101_Receive/CC1101_Receive.ino index fa8f3aa8..b51bdf20 100644 --- a/examples/CC1101/CC1101_Receive/CC1101_Receive.ino +++ b/examples/CC1101/CC1101_Receive/CC1101_Receive.ino @@ -9,6 +9,9 @@ - frequency deviation - sync word + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -21,23 +24,18 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc = RadioShield.ModuleA; +//CC1101 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -52,12 +50,12 @@ void loop() { // you can receive data as an Arduino String String str; - int state = cc.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = cc.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { @@ -71,13 +69,13 @@ void loop() { // print RSSI (Received Signal Strength Indicator) // of the last received packet Serial.print(F("[CC1101] RSSI:\t\t")); - Serial.print(cc.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print LQI (Link Quality Indicator) // of the last received packet, lower is better Serial.print(F("[CC1101] LQI:\t\t")); - Serial.println(cc.getLQI()); + Serial.println(radio.getLQI()); } else if (state == ERR_CRC_MISMATCH) { // packet was received, but is malformed diff --git a/examples/CC1101/CC1101_Receive_Address/CC1101_Receive_Address.ino b/examples/CC1101/CC1101_Receive_Address/CC1101_Receive_Address.ino index 3e12b6d5..81eac67c 100644 --- a/examples/CC1101/CC1101_Receive_Address/CC1101_Receive_Address.ino +++ b/examples/CC1101/CC1101_Receive_Address/CC1101_Receive_Address.ino @@ -7,6 +7,9 @@ will automatically filter out any packets that do not contain either node address or broadcast addresses. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -19,23 +22,18 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc = RadioShield.ModuleA; +//CC1101 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -52,7 +50,7 @@ void setup() { // When setting two broadcast addresses, 0x00 and // 0xFF will be used. Serial.print(F("[CC1101] Setting node address ... ")); - state = cc.setNodeAddress(0x01, 1); + state = radio.setNodeAddress(0x01, 1); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -66,7 +64,7 @@ void setup() { // set node address /* Serial.print(F("[CC1101] Disabling address filtering ... ")); - state == cc.disableAddressFiltering(); + state == radio.disableAddressFiltering(); if(state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -82,12 +80,12 @@ void loop() { // you can receive data as an Arduino String String str; - int state = cc.receive(str); + int state = radio.receive(str); // you can also receive data as byte array /* byte byteArr[8]; - int state = cc.receive(byteArr, 8); + int state = radio.receive(byteArr, 8); */ if (state == ERR_NONE) { @@ -101,13 +99,13 @@ void loop() { // print RSSI (Received Signal Strength Indicator) // of the last received packet Serial.print(F("[CC1101] RSSI:\t\t")); - Serial.print(cc.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print LQI (Link Quality Indicator) // of the last received packet, lower is better Serial.print(F("[CC1101] LQI:\t\t")); - Serial.println(cc.getLQI()); + Serial.println(radio.getLQI()); } else if (state == ERR_CRC_MISMATCH) { // packet was received, but is malformed diff --git a/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino b/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino index e036d71e..a7228de4 100644 --- a/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino +++ b/examples/CC1101/CC1101_Receive_Interrupt/CC1101_Receive_Interrupt.ino @@ -12,8 +12,11 @@ - frequency deviation - sync word - For full API reference, see the GitHub Pages - https://jgromes.github.io/RadioLib/ + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + + For full API reference, see the GitHub Pages + https://jgromes.github.io/RadioLib/ */ // include the library @@ -24,23 +27,18 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc = RadioShield.ModuleA; +//CC1101 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -51,11 +49,11 @@ void setup() { // set the function that will be called // when new packet is received - cc.setGdo0Action(setFlag); + radio.setGdo0Action(setFlag); // start listening for packets Serial.print(F("[CC1101] Starting to listen ... ")); - state = cc.startReceive(); + state = radio.startReceive(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -67,11 +65,11 @@ void setup() { // if needed, 'listen' mode can be disabled by calling // any of the following methods: // - // cc.standby() - // cc.sleep() - // cc.transmit(); - // cc.receive(); - // cc.readData(); + // radio.standby() + // radio.sleep() + // radio.transmit(); + // radio.receive(); + // radio.readData(); } // flag to indicate that a packet was received @@ -106,12 +104,12 @@ void loop() { // you can read received data as an Arduino String String str; - int state = cc.readData(str); + int state = radio.readData(str); // you can also read received data as byte array /* byte byteArr[8]; - int state = cc.readData(byteArr, 8); + int state = radio.readData(byteArr, 8); */ if (state == ERR_NONE) { @@ -125,13 +123,13 @@ void loop() { // print RSSI (Received Signal Strength Indicator) // of the last received packet Serial.print(F("[CC1101] RSSI:\t\t")); - Serial.print(cc.getRSSI()); + Serial.print(radio.getRSSI()); Serial.println(F(" dBm")); // print LQI (Link Quality Indicator) // of the last received packet, lower is better Serial.print(F("[CC1101] LQI:\t\t")); - Serial.println(cc.getLQI()); + Serial.println(radio.getLQI()); } else if (state == ERR_CRC_MISMATCH) { // packet was received, but is malformed @@ -145,7 +143,7 @@ void loop() { } // put module back to listen mode - cc.startReceive(); + radio.startReceive(); // we're ready to receive more packets, // enable interrupt service routine diff --git a/examples/CC1101/CC1101_Settings/CC1101_Settings.ino b/examples/CC1101/CC1101_Settings/CC1101_Settings.ino index 02394da1..4e4bcfd3 100644 --- a/examples/CC1101/CC1101_Settings/CC1101_Settings.ino +++ b/examples/CC1101/CC1101_Settings/CC1101_Settings.ino @@ -11,6 +11,9 @@ - output power during transmission - sync word + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -23,30 +26,25 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc1 = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio1 = new Module(10, 2, RADIOLIB_NC, 3); // second CC1101 has different connections: // CS pin: 9 // GDO0 pin: 4 // RST pin: unused // GDO2 pin: 5 (optional) -CC1101 cc2 = new Module(9, 4, RADIOLIB_NC, 53); +CC1101 radio2 = new Module(9, 4, RADIOLIB_NC, 53); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc3 = RadioShield.ModuleB; +//CC1101 radio3 = RadioShield.ModuleB; void setup() { Serial.begin(9600); // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc1.begin(); + int state = radio1.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -62,7 +60,7 @@ void setup() { // frequency deviation: 60.0 kHz // Rx bandwidth: 250.0 kHz // sync word: 0xD391 - state = cc2.begin(434.0, 32.0, 60.0, 250.0); + state = radio2.begin(434.0, 32.0, 60.0, 250.0); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -75,13 +73,13 @@ void setup() { // and check if the configuration was changed successfully // set carrier frequency to 433.5 MHz - if (cc1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) { + if (radio1.setFrequency(433.5) == ERR_INVALID_FREQUENCY) { Serial.println(F("[CC1101] Selected frequency is invalid for this module!")); while (true); } // set bit rate to 100.0 kbps - state = cc1.setBitRate(100.0); + state = radio1.setBitRate(100.0); if (state == ERR_INVALID_BIT_RATE) { Serial.println(F("[CC1101] Selected bit rate is invalid for this module!")); while (true); @@ -92,25 +90,25 @@ void setup() { } // set receiver bandwidth to 250.0 kHz - if (cc1.setRxBandwidth(250.0) == ERR_INVALID_RX_BANDWIDTH) { + if (radio1.setRxBandwidth(250.0) == ERR_INVALID_RX_BANDWIDTH) { Serial.println(F("[CC1101] Selected receiver bandwidth is invalid for this module!")); while (true); } // set allowed frequency deviation to 10.0 kHz - if (cc1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) { + if (radio1.setFrequencyDeviation(10.0) == ERR_INVALID_FREQUENCY_DEVIATION) { Serial.println(F("[CC1101] Selected frequency deviation is invalid for this module!")); while (true); } // set output power to 5 dBm - if (cc1.setOutputPower(5) == ERR_INVALID_OUTPUT_POWER) { + if (radio1.setOutputPower(5) == ERR_INVALID_OUTPUT_POWER) { Serial.println(F("[CC1101] Selected output power is invalid for this module!")); while (true); } // 2 bytes can be set as sync word - if (cc1.setSyncWord(0x01, 0x23) == ERR_INVALID_SYNC_WORD) { + if (radio1.setSyncWord(0x01, 0x23) == ERR_INVALID_SYNC_WORD) { Serial.println(F("[CC1101] Selected sync word is invalid for this module!")); while (true); } diff --git a/examples/CC1101/CC1101_Transmit/CC1101_Transmit.ino b/examples/CC1101/CC1101_Transmit/CC1101_Transmit.ino index be530890..3463c6f1 100644 --- a/examples/CC1101/CC1101_Transmit/CC1101_Transmit.ino +++ b/examples/CC1101/CC1101_Transmit/CC1101_Transmit.ino @@ -7,6 +7,9 @@ - null-terminated char array (C-string) - arbitrary binary data (byte array) + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -19,23 +22,18 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc = RadioShield.ModuleA; +//CC1101 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); - // initialize CC1101 + // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -49,12 +47,12 @@ void loop() { Serial.print(F("[CC1101] Transmitting packet ... ")); // you can transmit C-string or Arduino string up to 63 characters long - int state = cc.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); // you can also transmit byte array up to 63 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = cc.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/CC1101/CC1101_Transmit_Address/CC1101_Transmit_Address.ino b/examples/CC1101/CC1101_Transmit_Address/CC1101_Transmit_Address.ino index e584eb7c..430eafd8 100644 --- a/examples/CC1101/CC1101_Transmit_Address/CC1101_Transmit_Address.ino +++ b/examples/CC1101/CC1101_Transmit_Address/CC1101_Transmit_Address.ino @@ -7,6 +7,9 @@ will automatically filter out any packets that do not contain either node address or broadcast addresses. + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -19,23 +22,18 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc = RadioShield.ModuleA; +//CC1101 radio = RadioShield.ModuleA; void setup() { Serial.begin(9600); // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -52,7 +50,7 @@ void setup() { // When setting two broadcast addresses, 0x00 and // 0xFF will be used. Serial.print(F("[CC1101] Setting node address ... ")); - state = cc.setNodeAddress(0x01, 1); + state = radio.setNodeAddress(0x01, 1); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -66,7 +64,7 @@ void setup() { // set node address /* Serial.print(F("[CC1101] Disabling address filtering ... ")); - state == cc.disableAddressFiltering(); + state == radio.disableAddressFiltering(); if(state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -81,12 +79,12 @@ void loop() { Serial.print(F("[CC1101] Transmitting packet ... ")); // you can transmit C-string or Arduino string up to 63 characters long - int state = cc.transmit("Hello World!"); + int state = radio.transmit("Hello World!"); // you can also transmit byte array up to 63 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = cc.transmit(byteArr, 8); + int state = radio.transmit(byteArr, 8); */ if (state == ERR_NONE) { diff --git a/examples/CC1101/CC1101_Transmit_Interrupt/CC1101_Transmit_Interrupt.ino b/examples/CC1101/CC1101_Transmit_Interrupt/CC1101_Transmit_Interrupt.ino index 47991677..c15652b6 100644 --- a/examples/CC1101/CC1101_Transmit_Interrupt/CC1101_Transmit_Interrupt.ino +++ b/examples/CC1101/CC1101_Transmit_Interrupt/CC1101_Transmit_Interrupt.ino @@ -8,6 +8,9 @@ - null-terminated char array (C-string) - arbitrary binary data (byte array) + For default module settings, see the wiki page + https://github.com/jgromes/RadioLib/wiki/Default-configuration#cc1101 + For full API reference, see the GitHub Pages https://jgromes.github.io/RadioLib/ */ @@ -20,11 +23,11 @@ // GDO0 pin: 2 // RST pin: unused // GDO2 pin: 3 (optional) -CC1101 cc = new Module(10, 2, RADIOLIB_NC, 3); +CC1101 radio = new Module(10, 2, RADIOLIB_NC, 3); // or using RadioShield // https://github.com/jgromes/RadioShield -//CC1101 cc = RadioShield.ModuleA; +//CC1101 radio = RadioShield.ModuleA; // save transmission state between loops int transmissionState = ERR_NONE; @@ -34,12 +37,7 @@ void setup() { // initialize CC1101 with default settings Serial.print(F("[CC1101] Initializing ... ")); - // carrier frequency: 868.0 MHz - // bit rate: 4.8 kbps - // frequency deviation: 48.0 kHz - // Rx bandwidth: 325.0 kHz - // sync word: 0xD391 - int state = cc.begin(); + int state = radio.begin(); if (state == ERR_NONE) { Serial.println(F("success!")); } else { @@ -50,20 +48,20 @@ void setup() { // set the function that will be called // when packet transmission is finished - cc.setGdo0Action(setFlag); + radio.setGdo0Action(setFlag); // start transmitting the first packet Serial.print(F("[CC1101] Sending first packet ... ")); // you can transmit C-string or Arduino string up to // 64 characters long - transmissionState = cc.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 64 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x56, 0x78, 0xAB, 0xCD, 0xEF}; - state = cc.startTransmit(byteArr, 8); + state = radio.startTransmit(byteArr, 8); */ } @@ -119,13 +117,13 @@ void loop() { // you can transmit C-string or Arduino string up to // 256 characters long - transmissionState = cc.startTransmit("Hello World!"); + transmissionState = radio.startTransmit("Hello World!"); // you can also transmit byte array up to 256 bytes long /* byte byteArr[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}; - int state = cc.startTransmit(byteArr, 8); + int state = radio.startTransmit(byteArr, 8); */ // we're ready to send more packets,