A Hardware Hacking Tool with Web-Based CLI That Speaks Every Protocol
C arduinobluetoothcan-busdebuggingeepromesp32flipperzerogpiohardware-hackingi2cjtagopenocdprotocolspwmradiorfidspisubghzuartwifi
add modified lib for cc1101
Geoc9ef2d5f714f
diff --git a/lib/SmartRC-CC1101-Driver-Lib/ELECHOUSE_CC1101_SRC_DRV.cpp b/lib/SmartRC-CC1101-Driver-Lib/ELECHOUSE_CC1101_SRC_DRV.cppnew file mode 100644index 00000000..781f2dac--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/ELECHOUSE_CC1101_SRC_DRV.cpp@@ -0,0 +1,1391 @@+/*+ ELECHOUSE_CC1101.cpp - CC1101 module library+ Copyright (c) 2010 Michael.+ Author: Michael, <www.elechouse.com>+ Version: November 12, 2010++ This library is designed to use CC1101/CC1100 module on Arduino platform.+ CC1101/CC1100 module is an useful wireless module.Using the functions of the+ library, you can easily send and receive data by the CC1101/CC1100 module.+ Just have fun!+ For the details, please refer to the datasheet of CC1100/CC1101.+----------------------------------------------------------------------------------------------------------------+cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and publish Wilson Shen (ELECHOUSE).+----------------------------------------------------------------------------------------------------------------+*/+#include "ELECHOUSE_CC1101_SRC_DRV.h"+#include <Arduino.h>++/****************************************************************/+#define WRITE_BURST 0x40 //write burst+#define READ_SINGLE 0x80 //read single+#define READ_BURST 0xC0 //read burst+#define BYTES_IN_RXFIFO 0x7F //byte number in RXfifo+#define max_modul 6++byte modulation = 2;+byte frend0;+byte chan = 0;+int pa = 12;+byte last_pa;+byte SCK_PIN;+byte MISO_PIN;+byte MOSI_PIN;+byte SS_PIN;+byte GDO0;+byte GDO2;+byte SCK_PIN_M[max_modul];+byte MISO_PIN_M[max_modul];+byte MOSI_PIN_M[max_modul];+byte SS_PIN_M[max_modul];+byte GDO0_M[max_modul];+byte GDO2_M[max_modul];+byte gdo_set=0;+bool __spi = 0;+bool ccmode = 0;+float MHz = 433.92;+byte m4RxBw = 0;+byte m4DaRa;+byte m2DCOFF;+byte m2MODFM;+byte m2MANCH;+byte m2SYNCM;+byte m1FEC;+byte m1PRE;+byte m1CHSP;+byte pc1PQT;+byte pc1CRC_AF;+byte pc1APP_ST;+byte pc1ADRCHK;+byte pc0WDATA;+byte pc0PktForm;+byte pc0CRC_EN;+byte pc0LenConf;+byte trxstate = 0;+byte clb1[2]= {24,28};+byte clb2[2]= {31,38};+byte clb3[2]= {65,76};+byte clb4[2]= {77,79};++/****************************************************************/+uint8_t PA_TABLE[8] {0x00,0xC0,0x00,0x00,0x00,0x00,0x00,0x00};+// -30 -20 -15 -10 0 5 7 10+uint8_t PA_TABLE_315[8] {0x12,0x0D,0x1C,0x34,0x51,0x85,0xCB,0xC2,}; //280 - 348+uint8_t PA_TABLE_433[8] {0x12,0x0E,0x1D,0x34,0x60,0x84,0xC8,0xC0,}; //387 - 464+// -30 -20 -15 -10 -6 0 5 7 10 12+uint8_t PA_TABLE_868[10] {0x03,0x17,0x1D,0x26,0x37,0x50,0x86,0xCD,0xC5,0xC0,}; //779 - 899.99+// -30 -20 -15 -10 -6 0 5 7 10 11+uint8_t PA_TABLE_915[10] {0x03,0x0E,0x1E,0x27,0x38,0x8E,0x84,0xCC,0xC3,0xC0,}; //900 - 928++/****************************************************************+*FUNCTION NAME:setBeginEndLogic+*FUNCTION :set a new state to Begin/End logic, in this logic SPI class uses SPI.begin(...) and SPI.end() logic for backwards compatibility+*INPUT :state: true or false+*OUTPUT :none+****************************************************************/+ void ELECHOUSE_CC1101::setBeginEndLogic(bool state) {+ _begin_end_logic = state;+ }+++/****************************************************************+*FUNCTION NAME:getBeginEndLogic+*FUNCTION :get the state to Begin/End logic, in this logic SPI class uses SPI.begin(...) and SPI.end() logic for backwards compatibility+*INPUT :state: true or false+*OUTPUT :none+****************************************************************/+ bool ELECHOUSE_CC1101::getBeginEndLogic() {+ return _begin_end_logic;+ }++/****************************************************************+*FUNCTION NAME:setSPIinstance+*FUNCTION :Set the SPI Instance to use if needed to share SPI Bus with other devices+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setSPIinstance(SPIClass* sspi)+{+ // Set the SPI instance to use if needed to share SPI Bus with other devices+ cc_spi=sspi;+}+/****************************************************************+*FUNCTION NAME:getSPIinstance+*FUNCTION :Gives the SPI instance in use by CC1101, if none was set, will set the library SPI instance+*INPUT :none+*OUTPUT :none+****************************************************************/+SPIClass* ELECHOUSE_CC1101::getSPIinstance()+{+ if(cc_spi==nullptr) {+ cc_spi=&_cc_spi;+ }+ return cc_spi;+}++/****************************************************************+*FUNCTION NAME:SpiStart+*FUNCTION :spi communication start+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::SpiStart(void)+{+ //End transaction to ensure openin a new session with the right SPISettings+ digitalWrite(SS_PIN, HIGH);+ cc_spi->endTransaction();+ if(_begin_end_logic) cc_spi->end();+ if(_begin_end_logic) cc_spi->begin(SCK_PIN,MISO_PIN,MOSI_PIN,SS_PIN);+ digitalWrite(SS_PIN, LOW);+ cc_spi->beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));+++}+/****************************************************************+*FUNCTION NAME:SpiEnd+*FUNCTION :spi communication disable+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::SpiEnd(void)+{+ // disable SPI+ cc_spi->endTransaction();+ digitalWrite(SS_PIN, HIGH);+ if(_begin_end_logic) cc_spi->end();++}+/****************************************************************+*FUNCTION NAME: GDO_Set()+*FUNCTION : set GDO0,GDO2 pin for serial pinmode.+*INPUT : none+*OUTPUT : none+****************************************************************/+void ELECHOUSE_CC1101::GDO_Set (void)+{+ pinMode(GDO0, OUTPUT);+ pinMode(GDO2, INPUT);+}+/****************************************************************+*FUNCTION NAME: GDO_Set()+*FUNCTION : set GDO0 for internal transmission mode.+*INPUT : none+*OUTPUT : none+****************************************************************/+void ELECHOUSE_CC1101::GDO0_Set (void)+{+ pinMode(GDO0, INPUT);+}++/****************************************************************+*FUNCTION NAME:checkMISO()+*FUNCTION :check MISO Pin for errors+*INPUT :none+*OUTPUT :none+****************************************************************/+bool ELECHOUSE_CC1101::checkMISO (void)+{+ // This function does not with IDF>=5, it delays the communication and makes the CC1101 not responding.+ // So avoid using it in this situation+ #if (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0))+ unsigned long timer = millis();+ while(digitalRead(MISO_PIN)){+ if(millis()-timer>1000) {+ log_e("CC1101: Fail checking MISO pin, check your connections");+ digitalWrite(SS_PIN, HIGH);+ return false;+ }+ }+ #endif+ return true;+}+/****************************************************************+*FUNCTION NAME:Reset+*FUNCTION :CC1101 reset //details refer datasheet of CC1101/CC1100//+*INPUT :none+*OUTPUT :none+****************************************************************/+bool ELECHOUSE_CC1101::Reset (void)+{+ SpiStart();+ digitalWrite(SS_PIN, LOW);+ delay(1);+ digitalWrite(SS_PIN, HIGH);+ delay(1);+ digitalWrite(SS_PIN, LOW);+ if(!checkMISO()) return false;+ cc_spi->transfer(CC1101_SRES);+ if(!checkMISO()) return false;+ digitalWrite(SS_PIN, HIGH);+ return true;+}+/****************************************************************+*FUNCTION NAME:Init+*FUNCTION :CC1101 initialization+*INPUT :none+*OUTPUT :none+****************************************************************/+bool ELECHOUSE_CC1101::Init(void)+{+ // check if SPI Pins are set+ setSpi();+ pinMode(SS_PIN, OUTPUT);+ // If there were no different SPI Instance, use This lib instance+ if(cc_spi==nullptr || _begin_end_logic) {+ DEBUG_CC1101("CC1101: Null pointer SPI instance or Begin/end");+ _begin_end_logic=true;+ cc_spi=&_cc_spi;+ cc_spi->begin(SCK_PIN,MISO_PIN,MOSI_PIN,SS_PIN);+ delay(1);+ } else { DEBUG_CC1101("CC1101: Using other instance"); }++ SpiStart(); //Start SPI Transaction+ digitalWrite(SS_PIN, HIGH);+ if(!Reset()) return false; //CC1101 reset+ RegConfigSettings(); //CC1101 register config+ SpiEnd(); //Stops SPI Transaction+ return true;+}+/****************************************************************+*FUNCTION NAME:SpiWriteReg+*FUNCTION :CC1101 write data to register+*INPUT :addr: register address; value: register value+*OUTPUT :none+****************************************************************/+bool ELECHOUSE_CC1101::SpiWriteReg(byte addr, byte value)+{+ SpiStart();+ if(!checkMISO()) return false;+ cc_spi->transfer(addr);+ cc_spi->transfer(value);+ SpiEnd();+ DEBUG_CC1101("Write reg addr: 0x" + String(addr,HEX) + "=0x" + String(value,HEX));+ return true;+}+/****************************************************************+*FUNCTION NAME:SpiWriteBurstReg+*FUNCTION :CC1101 write burst data to register+*INPUT :addr: register address; buffer:register value array; num:number to write+*OUTPUT :none+****************************************************************/+bool ELECHOUSE_CC1101::SpiWriteBurstReg(byte addr, byte *buffer, byte num)+{+ byte i, temp;+ SpiStart();+ temp = addr | WRITE_BURST;+ if(!checkMISO()) return false;+ DEBUG_CC11012("\nWrite burst addr: 0x" + String(temp,HEX) + "=");+ cc_spi->transfer(temp);+ for (i = 0; i < num; i++)+ {+ cc_spi->transfer(buffer[i]);+ DEBUG_CC11012(" 0x" + String(buffer[i],HEX));+ }+ DEBUG_CC1101()+ SpiEnd();+ return true;+}+/****************************************************************+*FUNCTION NAME:SpiStrobe+*FUNCTION :CC1101 Strobe+*INPUT :strobe: command; //refer define in CC1101.h//+*OUTPUT :none+****************************************************************/+bool ELECHOUSE_CC1101::SpiStrobe(byte strobe)+{+ SpiStart();+ if(!checkMISO()) return false;+ cc_spi->transfer(strobe);+ SpiEnd();+ DEBUG_CC1101("Write Strobe: 0x" + String(strobe,HEX));+ return true;+}+/****************************************************************+*FUNCTION NAME:SpiReadReg+*FUNCTION :CC1101 read data from register+*INPUT :addr: register address+*OUTPUT :register value+****************************************************************/+byte ELECHOUSE_CC1101::SpiReadReg(byte addr)+{+ byte temp, value;+ SpiStart();+ temp = addr| READ_SINGLE;+ if(!checkMISO()) return 0x00;+ cc_spi->transfer(temp);+ value=cc_spi->transfer(0);+ SpiEnd();+ DEBUG_CC1101("Reading addr: 0x" + String(addr,HEX) + " = 0x" + String(value,HEX));+ return value;+}++/****************************************************************+*FUNCTION NAME:SpiReadBurstReg+*FUNCTION :CC1101 read burst data from register+*INPUT :addr: register address; buffer:array to store register value; num: number to read+*OUTPUT :none+****************************************************************/+bool ELECHOUSE_CC1101::SpiReadBurstReg(byte addr, byte *buffer, byte num)+{+ byte i,temp;+ SpiStart();+ temp = addr | READ_BURST;+ if(!checkMISO()) return false;+ DEBUG_CC11012("\nReading addr: 0x" + String(temp,HEX) + " = ");+ cc_spi->transfer(temp);+ for(i=0;i<num;i++)+ {+ buffer[i]=cc_spi->transfer(0);+ DEBUG_CC11012(" " + String(buffer[i],HEX));+ }+ DEBUG_CC1101()+ SpiEnd();+ return true;+}++/****************************************************************+*FUNCTION NAME:SpiReadStatus+*FUNCTION :CC1101 read status register+*INPUT :addr: register address+*OUTPUT :status value+****************************************************************/+byte ELECHOUSE_CC1101::SpiReadStatus(byte addr)+{+ byte value,temp;+ SpiStart();+ temp = addr | READ_BURST;+ if(!checkMISO()) return 0x00;+ cc_spi->transfer(temp);+ value=cc_spi->transfer(0);+ SpiEnd();+ DEBUG_CC1101("Reading Reg addr: 0x" + String(addr,HEX) + " = 0x" + String(value,HEX));+ return value;+}+/****************************************************************+*FUNCTION NAME:SPI pin Settings+*FUNCTION :Set Spi pins+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setSpi(void){+ if (__spi == 0){+ #if defined __AVR_ATmega168__ || defined __AVR_ATmega328P__+ SCK_PIN = 13; MISO_PIN = 12; MOSI_PIN = 11; SS_PIN = 10;+ #elif defined __AVR_ATmega1280__ || defined __AVR_ATmega2560__+ SCK_PIN = 52; MISO_PIN = 50; MOSI_PIN = 51; SS_PIN = 53;+ #elif ESP8266+ SCK_PIN = 14; MISO_PIN = 12; MOSI_PIN = 13; SS_PIN = 15;+ #elif ESP32+ SCK_PIN = 18; MISO_PIN = 19; MOSI_PIN = 23; SS_PIN = 5;+ #else+ SCK_PIN = 13; MISO_PIN = 12; MOSI_PIN = 11; SS_PIN = 10;+ #endif+}+}+/****************************************************************+*FUNCTION NAME:COSTUM SPI+*FUNCTION :set costum spi pins.+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setSpiPin(byte sck, byte miso, byte mosi, byte ss){+ __spi = 1;+ SCK_PIN = sck;+ MISO_PIN = miso;+ MOSI_PIN = mosi;+ SS_PIN = ss;+}+/****************************************************************+*FUNCTION NAME:COSTUM SPI+*FUNCTION :set costum spi pins.+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::addSpiPin(byte sck, byte miso, byte mosi, byte ss, byte modul){+ __spi = 1;+ SCK_PIN_M[modul] = sck;+ MISO_PIN_M[modul] = miso;+ MOSI_PIN_M[modul] = mosi;+ SS_PIN_M[modul] = ss;+}+/****************************************************************+*FUNCTION NAME:GDO Pin settings+*FUNCTION :set GDO Pins+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setGDO(byte gdo0, byte gdo2){+GDO0 = gdo0;+GDO2 = gdo2;+GDO_Set();+}+/****************************************************************+*FUNCTION NAME:GDO0 Pin setting+*FUNCTION :set GDO0 Pin+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setGDO0(byte gdo0){+GDO0 = gdo0;+GDO0_Set();+}+/****************************************************************+*FUNCTION NAME:GDO Pin settings+*FUNCTION :add GDO Pins+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::addGDO(byte gdo0, byte gdo2, byte modul){+GDO0_M[modul] = gdo0;+GDO2_M[modul] = gdo2;+gdo_set=2;+GDO_Set();+}+/****************************************************************+*FUNCTION NAME:add GDO0 Pin+*FUNCTION :add GDO0 Pin+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::addGDO0(byte gdo0, byte modul){+GDO0_M[modul] = gdo0;+gdo_set=1;+GDO0_Set();+}+/****************************************************************+*FUNCTION NAME:set Modul+*FUNCTION :change modul+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setModul(byte modul){+ SCK_PIN = SCK_PIN_M[modul];+ MISO_PIN = MISO_PIN_M[modul];+ MOSI_PIN = MOSI_PIN_M[modul];+ SS_PIN = SS_PIN_M[modul];+ if (gdo_set==1){+ GDO0 = GDO0_M[modul];+ }+ else if (gdo_set==2){+ GDO0 = GDO0_M[modul];+ GDO2 = GDO2_M[modul];+ }+}+/****************************************************************+*FUNCTION NAME:CCMode+*FUNCTION :Format of RX and TX data+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setCCMode(bool s){+ccmode = s;+if (ccmode == 1){+if (!SpiWriteReg(CC1101_IOCFG2, 0x0B)) return;+SpiWriteReg(CC1101_IOCFG0, 0x06);+SpiWriteReg(CC1101_PKTCTRL0, 0x05);+SpiWriteReg(CC1101_MDMCFG3, 0xF8);+SpiWriteReg(CC1101_MDMCFG4,11+m4RxBw);+}else{+if (!SpiWriteReg(CC1101_IOCFG2, 0x0D)) return;+SpiWriteReg(CC1101_IOCFG0, 0x0D);+SpiWriteReg(CC1101_PKTCTRL0, 0x32);+SpiWriteReg(CC1101_MDMCFG3, 0x93);+SpiWriteReg(CC1101_MDMCFG4, 7+m4RxBw);+}+setModulation(modulation);+}+/****************************************************************+*FUNCTION NAME:Modulation+*FUNCTION :set CC1101 Modulation+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setModulation(byte m){+if (m>4){m=4;}+modulation = m;+Split_MDMCFG2();+switch (m)+{+case 0: m2MODFM=0x00; frend0=0x10; break; // 2-FSK+case 1: m2MODFM=0x10; frend0=0x10; break; // GFSK+case 2: m2MODFM=0x30; frend0=0x11; break; // ASK+case 3: m2MODFM=0x40; frend0=0x10; break; // 4-FSK+case 4: m2MODFM=0x70; frend0=0x10; break; // MSK+}+if (!SpiWriteReg(CC1101_MDMCFG2, m2DCOFF + m2MODFM + m2MANCH + m2SYNCM)) return;+SpiWriteReg(CC1101_FREND0, frend0);+setPA(pa);+}+/****************************************************************+*FUNCTION NAME:PA Power+*FUNCTION :set CC1101 PA Power+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setPA(int p)+{+int a;+pa = p;++if (MHz >= 280 && MHz <= 348){+if (pa <= -30){a = PA_TABLE_315[0];}+else if (pa > -30 && pa <= -20){a = PA_TABLE_315[1];}+else if (pa > -20 && pa <= -15){a = PA_TABLE_315[2];}+else if (pa > -15 && pa <= -10){a = PA_TABLE_315[3];}+else if (pa > -10 && pa <= 0){a = PA_TABLE_315[4];}+else if (pa > 0 && pa <= 5){a = PA_TABLE_315[5];}+else if (pa > 5 && pa <= 7){a = PA_TABLE_315[6];}+else if (pa > 7){a = PA_TABLE_315[7];}+last_pa = 1;+}+else if (MHz >= 378 && MHz <= 464){+if (pa <= -30){a = PA_TABLE_433[0];}+else if (pa > -30 && pa <= -20){a = PA_TABLE_433[1];}+else if (pa > -20 && pa <= -15){a = PA_TABLE_433[2];}+else if (pa > -15 && pa <= -10){a = PA_TABLE_433[3];}+else if (pa > -10 && pa <= 0){a = PA_TABLE_433[4];}+else if (pa > 0 && pa <= 5){a = PA_TABLE_433[5];}+else if (pa > 5 && pa <= 7){a = PA_TABLE_433[6];}+else if (pa > 7){a = PA_TABLE_433[7];}+last_pa = 2;+}+else if (MHz >= 779 && MHz <= 899.99){+if (pa <= -30){a = PA_TABLE_868[0];}+else if (pa > -30 && pa <= -20){a = PA_TABLE_868[1];}+else if (pa > -20 && pa <= -15){a = PA_TABLE_868[2];}+else if (pa > -15 && pa <= -10){a = PA_TABLE_868[3];}+else if (pa > -10 && pa <= -6){a = PA_TABLE_868[4];}+else if (pa > -6 && pa <= 0){a = PA_TABLE_868[5];}+else if (pa > 0 && pa <= 5){a = PA_TABLE_868[6];}+else if (pa > 5 && pa <= 7){a = PA_TABLE_868[7];}+else if (pa > 7 && pa <= 10){a = PA_TABLE_868[8];}+else if (pa > 10){a = PA_TABLE_868[9];}+last_pa = 3;+}+else if (MHz >= 900 && MHz <= 928){+if (pa <= -30){a = PA_TABLE_915[0];}+else if (pa > -30 && pa <= -20){a = PA_TABLE_915[1];}+else if (pa > -20 && pa <= -15){a = PA_TABLE_915[2];}+else if (pa > -15 && pa <= -10){a = PA_TABLE_915[3];}+else if (pa > -10 && pa <= -6){a = PA_TABLE_915[4];}+else if (pa > -6 && pa <= 0){a = PA_TABLE_915[5];}+else if (pa > 0 && pa <= 5){a = PA_TABLE_915[6];}+else if (pa > 5 && pa <= 7){a = PA_TABLE_915[7];}+else if (pa > 7 && pa <= 10){a = PA_TABLE_915[8];}+else if (pa > 10){a = PA_TABLE_915[9];}+last_pa = 4;+}+if (modulation == 2){+PA_TABLE[0] = 0;+PA_TABLE[1] = a;+}else{+PA_TABLE[0] = a;+PA_TABLE[1] = 0;+}+SpiWriteBurstReg(CC1101_PATABLE,PA_TABLE,8);+}+/****************************************************************+*FUNCTION NAME:Frequency Calculator+*FUNCTION :Calculate the basic frequency.+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setMHZ(float mhz){+byte freq2 = 0;+byte freq1 = 0;+byte freq0 = 0;++MHz = mhz;++for (bool i = 0; i==0;){+if (mhz >= 26){+mhz-=26;+freq2+=1;+}+else if (mhz >= 0.1015625){+mhz-=0.1015625;+freq1+=1;+}+else if (mhz >= 0.00039675){+mhz-=0.00039675;+freq0+=1;+}+else{i=1;}+}+if (freq0 > 255){freq1+=1;freq0-=256;}++if (!SpiWriteReg(CC1101_FREQ2, freq2)) return;+SpiWriteReg(CC1101_FREQ1, freq1);+SpiWriteReg(CC1101_FREQ0, freq0);++Calibrate();+}+/****************************************************************+*FUNCTION NAME:Calibrate+*FUNCTION :Calibrate frequency+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::Calibrate(void){++if (MHz >= 280 && MHz <= 348){+SpiWriteReg(CC1101_FSCTRL0, map(MHz, 280, 348, clb1[0], clb1[1]));+if (MHz < 322.88){SpiWriteReg(CC1101_TEST0,0x0B);}+else{+SpiWriteReg(CC1101_TEST0,0x09);+int s = ELECHOUSE_cc1101.SpiReadStatus(CC1101_FSCAL2);+if (s<32){SpiWriteReg(CC1101_FSCAL2, s+32);}+if (last_pa != 1){setPA(pa);}+}+}+else if (MHz >= 378 && MHz <= 464){+SpiWriteReg(CC1101_FSCTRL0, map(MHz, 378, 464, clb2[0], clb2[1]));+if (MHz < 430.5){SpiWriteReg(CC1101_TEST0,0x0B);}+else{+SpiWriteReg(CC1101_TEST0,0x09);+int s = ELECHOUSE_cc1101.SpiReadStatus(CC1101_FSCAL2);+if (s<32){SpiWriteReg(CC1101_FSCAL2, s+32);}+if (last_pa != 2){setPA(pa);}+}+}+else if (MHz >= 779 && MHz <= 899.99){+SpiWriteReg(CC1101_FSCTRL0, map(MHz, 779, 899, clb3[0], clb3[1]));+if (MHz < 861){SpiWriteReg(CC1101_TEST0,0x0B);}+else{+SpiWriteReg(CC1101_TEST0,0x09);+int s = ELECHOUSE_cc1101.SpiReadStatus(CC1101_FSCAL2);+if (s<32){SpiWriteReg(CC1101_FSCAL2, s+32);}+if (last_pa != 3){setPA(pa);}+}+}+else if (MHz >= 900 && MHz <= 928){+SpiWriteReg(CC1101_FSCTRL0, map(MHz, 900, 928, clb4[0], clb4[1]));+SpiWriteReg(CC1101_TEST0,0x09);+int s = ELECHOUSE_cc1101.SpiReadStatus(CC1101_FSCAL2);+if (s<32){SpiWriteReg(CC1101_FSCAL2, s+32);}+if (last_pa != 4){setPA(pa);}+}+}+/****************************************************************+*FUNCTION NAME:Calibration offset+*FUNCTION :Set calibration offset+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setClb(byte b, byte s, byte e){+if (b == 1){+clb1[0]=s;+clb1[1]=e;+}+else if (b == 2){+clb2[0]=s;+clb2[1]=e;+}+else if (b == 3){+clb3[0]=s;+clb3[1]=e;+}+else if (b == 4){+clb4[0]=s;+clb4[1]=e;+}+}+/****************************************************************+*FUNCTION NAME:getCC1101+*FUNCTION :Test Spi connection and return 1 when true.+*INPUT :none+*OUTPUT :none+****************************************************************/+bool ELECHOUSE_CC1101::getCC1101(void){+ setSpi();+ byte val=SpiReadStatus(0x31);+ if (val>0){+ DEBUG_CC1101("getCC1101 result: 0x" + String(val,HEX) + " -> Ok");+ return 1;+ }else{+ DEBUG_CC1101("getCC1101 result: 0x" + String(val,HEX) + " -> Not Found");+ return 0;+}+}+/****************************************************************+*FUNCTION NAME:getMode+*FUNCTION :Return the Mode. Sidle = 0, TX = 1, Rx = 2.+*INPUT :none+*OUTPUT :none+****************************************************************/+byte ELECHOUSE_CC1101::getMode(void){+return trxstate;+}+/****************************************************************+*FUNCTION NAME:Set Sync_Word+*FUNCTION :Sync Word+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setSyncWord(byte sh, byte sl){+if(!SpiWriteReg(CC1101_SYNC1, sh)) return;+SpiWriteReg(CC1101_SYNC0, sl);+}+/****************************************************************+*FUNCTION NAME:Set ADDR+*FUNCTION :Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setAddr(byte v){+ if(!SpiWriteReg(CC1101_ADDR, v)) return;+}+/****************************************************************+*FUNCTION NAME:Set PQT+*FUNCTION :Preamble quality estimator threshold+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setPQT(byte v){+Split_PKTCTRL1();+pc1PQT = 0;+if (v>7){v=7;}+pc1PQT = v*32;+SpiWriteReg(CC1101_PKTCTRL1, pc1PQT+pc1CRC_AF+pc1APP_ST+pc1ADRCHK);+}+/****************************************************************+*FUNCTION NAME:Set CRC_AUTOFLUSH+*FUNCTION :Enable automatic flush of RX FIFO when CRC is not OK+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setCRC_AF(bool v){+Split_PKTCTRL1();+pc1CRC_AF = 0;+if (v==1){pc1CRC_AF=8;}+SpiWriteReg(CC1101_PKTCTRL1, pc1PQT+pc1CRC_AF+pc1APP_ST+pc1ADRCHK);+}+/****************************************************************+*FUNCTION NAME:Set APPEND_STATUS+*FUNCTION :When enabled, two status bytes will be appended to the payload of the packet+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setAppendStatus(bool v){+Split_PKTCTRL1();+pc1APP_ST = 0;+if (v==1){pc1APP_ST=4;}+SpiWriteReg(CC1101_PKTCTRL1, pc1PQT+pc1CRC_AF+pc1APP_ST+pc1ADRCHK);+}+/****************************************************************+*FUNCTION NAME:Set ADR_CHK+*FUNCTION :Controls address check configuration of received packages+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setAdrChk(byte v){+Split_PKTCTRL1();+pc1ADRCHK = 0;+if (v>3){v=3;}+pc1ADRCHK = v;+SpiWriteReg(CC1101_PKTCTRL1, pc1PQT+pc1CRC_AF+pc1APP_ST+pc1ADRCHK);+}+/****************************************************************+*FUNCTION NAME:Set WHITE_DATA+*FUNCTION :Turn data whitening on / off.+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setWhiteData(bool v){+Split_PKTCTRL0();+pc0WDATA = 0;+if (v == 1){pc0WDATA=64;}+SpiWriteReg(CC1101_PKTCTRL0, pc0WDATA+pc0PktForm+pc0CRC_EN+pc0LenConf);+}+/****************************************************************+*FUNCTION NAME:Set PKT_FORMAT+*FUNCTION :Format of RX and TX data+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setPktFormat(byte v){+Split_PKTCTRL0();+pc0PktForm = 0;+if (v>3){v=3;}+pc0PktForm = v*16;+SpiWriteReg(CC1101_PKTCTRL0, pc0WDATA+pc0PktForm+pc0CRC_EN+pc0LenConf);+}+/****************************************************************+*FUNCTION NAME:Set CRC+*FUNCTION :CRC calculation in TX and CRC check in RX+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setCrc(bool v){+Split_PKTCTRL0();+pc0CRC_EN = 0;+if (v==1){pc0CRC_EN=4;}+SpiWriteReg(CC1101_PKTCTRL0, pc0WDATA+pc0PktForm+pc0CRC_EN+pc0LenConf);+}+/****************************************************************+*FUNCTION NAME:Set LENGTH_CONFIG+*FUNCTION :Configure the packet length+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setLengthConfig(byte v){+Split_PKTCTRL0();+pc0LenConf = 0;+if (v>3){v=3;}+pc0LenConf = v;+SpiWriteReg(CC1101_PKTCTRL0, pc0WDATA+pc0PktForm+pc0CRC_EN+pc0LenConf);+}+/****************************************************************+*FUNCTION NAME:Set PACKET_LENGTH+*FUNCTION :Indicates the packet length+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setPacketLength(byte v){+SpiWriteReg(CC1101_PKTLEN, v);+}+/****************************************************************+*FUNCTION NAME:Set DCFILT_OFF+*FUNCTION :Disable digital DC blocking filter before demodulator+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setDcFilterOff(bool v){+Split_MDMCFG2();+m2DCOFF = 0;+if (v==1){m2DCOFF=128;}+SpiWriteReg(CC1101_MDMCFG2, m2DCOFF+m2MODFM+m2MANCH+m2SYNCM);+}+/****************************************************************+*FUNCTION NAME:Set MANCHESTER+*FUNCTION :Enables Manchester encoding/decoding+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setManchester(bool v){+Split_MDMCFG2();+m2MANCH = 0;+if (v==1){m2MANCH=8;}+SpiWriteReg(CC1101_MDMCFG2, m2DCOFF+m2MODFM+m2MANCH+m2SYNCM);+}+/****************************************************************+*FUNCTION NAME:Set SYNC_MODE+*FUNCTION :Combined sync-word qualifier mode+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setSyncMode(byte v){+Split_MDMCFG2();+m2SYNCM = 0;+if (v>7){v=7;}+m2SYNCM=v;+SpiWriteReg(CC1101_MDMCFG2, m2DCOFF+m2MODFM+m2MANCH+m2SYNCM);+}+/****************************************************************+*FUNCTION NAME:Set FEC+*FUNCTION :Enable Forward Error Correction (FEC)+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setFEC(bool v){+Split_MDMCFG1();+m1FEC=0;+if (v==1){m1FEC=128;}+SpiWriteReg(CC1101_MDMCFG1, m1FEC+m1PRE+m1CHSP);+}+/****************************************************************+*FUNCTION NAME:Set PRE+*FUNCTION :Sets the minimum number of preamble bytes to be transmitted.+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setPRE(byte v){+Split_MDMCFG1();+m1PRE=0;+if (v>7){v=7;}+m1PRE = v*16;+SpiWriteReg(CC1101_MDMCFG1, m1FEC+m1PRE+m1CHSP);+}+/****************************************************************+*FUNCTION NAME:Set Channel+*FUNCTION :none+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setChannel(byte ch){+chan = ch;+SpiWriteReg(CC1101_CHANNR, chan);+}+/****************************************************************+*FUNCTION NAME:Set Channel spacing+*FUNCTION :none+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setChsp(float f){+Split_MDMCFG1();+byte MDMCFG0 = 0;+m1CHSP = 0;+if (f > 405.456543){f = 405.456543;}+if (f < 25.390625){f = 25.390625;}+for (int i = 0; i<5; i++){+if (f <= 50.682068){+f -= 25.390625;+f /= 0.0991825;+MDMCFG0 = f;+float s1 = (f - MDMCFG0) *10;+if (s1 >= 5){MDMCFG0++;}+i = 5;+}else{+m1CHSP++;+f/=2;+}+}+if(!SpiWriteReg(19,m1CHSP+m1FEC+m1PRE)) return;+SpiWriteReg(20,MDMCFG0);+}+/****************************************************************+*FUNCTION NAME:Set Receive bandwidth+*FUNCTION :none+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setRxBW(float f){+Split_MDMCFG4();+int s1 = 3;+int s2 = 3;+for (int i = 0; i<3; i++){+if (f > 101.5625){f/=2; s1--;}+else{i=3;}+}+for (int i = 0; i<3; i++){+if (f > 58.1){f/=1.25; s2--;}+else{i=3;}+}+s1 *= 64;+s2 *= 16;+m4RxBw = s1 + s2;+SpiWriteReg(16,m4RxBw+m4DaRa);+}+/****************************************************************+*FUNCTION NAME:Set Data Rate+*FUNCTION :none+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setDRate(float d){+Split_MDMCFG4();+float c = d;+byte MDMCFG3 = 0;+if (c > 1621.83){c = 1621.83;}+if (c < 0.0247955){c = 0.0247955;}+m4DaRa = 0;+for (int i = 0; i<20; i++){+if (c <= 0.0494942){+c = c - 0.0247955;+c = c / 0.00009685;+MDMCFG3 = c;+float s1 = (c - MDMCFG3) *10;+if (s1 >= 5){MDMCFG3++;}+i = 20;+}else{+m4DaRa++;+c = c/2;+}+}+if(!SpiWriteReg(16, m4RxBw+m4DaRa)) return;+SpiWriteReg(17, MDMCFG3);+}+/****************************************************************+*FUNCTION NAME:Set Devitation+*FUNCTION :none+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setDeviation(float d){+float f = 1.586914;+float v = 0.19836425;+int c = 0;+if (d > 380.859375){d = 380.859375;}+if (d < 1.586914){d = 1.586914;}+for (int i = 0; i<255; i++){+f+=v;+if (c==7){v*=2;c=-1;i+=8;}+if (f>=d){c=i;i=255;}+c++;+}+SpiWriteReg(21,c);+}+/****************************************************************+*FUNCTION NAME:Split PKTCTRL0+*FUNCTION :none+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::Split_PKTCTRL1(void){+int calc = SpiReadStatus(7);+pc1PQT = 0;+pc1CRC_AF = 0;+pc1APP_ST = 0;+pc1ADRCHK = 0;+for (bool i = 0; i==0;){+if (calc >= 32){calc-=32; pc1PQT+=32;}+else if (calc >= 8){calc-=8; pc1CRC_AF+=8;}+else if (calc >= 4){calc-=4; pc1APP_ST+=4;}+else {pc1ADRCHK = calc; i=1;}+}+}+/****************************************************************+*FUNCTION NAME:Split PKTCTRL0+*FUNCTION :none+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::Split_PKTCTRL0(void){+int calc = SpiReadStatus(8);+pc0WDATA = 0;+pc0PktForm = 0;+pc0CRC_EN = 0;+pc0LenConf = 0;+for (bool i = 0; i==0;){+if (calc >= 64){calc-=64; pc0WDATA+=64;}+else if (calc >= 16){calc-=16; pc0PktForm+=16;}+else if (calc >= 4){calc-=4; pc0CRC_EN+=4;}+else {pc0LenConf = calc; i=1;}+}+}+/****************************************************************+*FUNCTION NAME:Split MDMCFG1+*FUNCTION :none+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::Split_MDMCFG1(void){+int calc = SpiReadStatus(19);+m1FEC = 0;+m1PRE = 0;+m1CHSP = 0;+int s2 = 0;+for (bool i = 0; i==0;){+if (calc >= 128){calc-=128; m1FEC+=128;}+else if (calc >= 16){calc-=16; m1PRE+=16;}+else {m1CHSP = calc; i=1;}+}+}+/****************************************************************+*FUNCTION NAME:Split MDMCFG2+*FUNCTION :none+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::Split_MDMCFG2(void){+int calc = SpiReadStatus(18);+m2DCOFF = 0;+m2MODFM = 0;+m2MANCH = 0;+m2SYNCM = 0;+for (bool i = 0; i==0;){+if (calc >= 128){calc-=128; m2DCOFF+=128;}+else if (calc >= 16){calc-=16; m2MODFM+=16;}+else if (calc >= 8){calc-=8; m2MANCH+=8;}+else{m2SYNCM = calc; i=1;}+}+}+/****************************************************************+*FUNCTION NAME:Split MDMCFG4+*FUNCTION :none+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::Split_MDMCFG4(void){+int calc = SpiReadStatus(16);+m4RxBw = 0;+m4DaRa = 0;+for (bool i = 0; i==0;){+if (calc >= 64){calc-=64; m4RxBw+=64;}+else if (calc >= 16){calc -= 16; m4RxBw+=16;}+else{m4DaRa = calc; i=1;}+}+}+/****************************************************************+*FUNCTION NAME:RegConfigSettings+*FUNCTION :CC1101 register config //details refer datasheet of CC1101/CC1100//+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::RegConfigSettings(void)+{+ if(!SpiWriteReg(CC1101_FSCTRL1, 0x06)) return;+ setCCMode(ccmode);+ setMHZ(MHz);++ SpiWriteReg(CC1101_MDMCFG1, 0x02);+ SpiWriteReg(CC1101_MDMCFG0, 0xF8);+ SpiWriteReg(CC1101_CHANNR, chan);+ SpiWriteReg(CC1101_DEVIATN, 0x47);+ SpiWriteReg(CC1101_FREND1, 0x56);+ SpiWriteReg(CC1101_MCSM0 , 0x18);+ SpiWriteReg(CC1101_FOCCFG, 0x16);+ SpiWriteReg(CC1101_BSCFG, 0x1C);+ SpiWriteReg(CC1101_AGCCTRL2, 0xC7);+ SpiWriteReg(CC1101_AGCCTRL1, 0x00);+ SpiWriteReg(CC1101_AGCCTRL0, 0xB2);+ SpiWriteReg(CC1101_FSCAL3, 0xE9);+ SpiWriteReg(CC1101_FSCAL2, 0x2A);+ SpiWriteReg(CC1101_FSCAL1, 0x00);+ SpiWriteReg(CC1101_FSCAL0, 0x1F);+ SpiWriteReg(CC1101_FSTEST, 0x59);+ SpiWriteReg(CC1101_TEST2, 0x81);+ SpiWriteReg(CC1101_TEST1, 0x35);+ SpiWriteReg(CC1101_TEST0, 0x09);+ SpiWriteReg(CC1101_PKTCTRL1, 0x04);+ SpiWriteReg(CC1101_ADDR, 0x00);+ SpiWriteReg(CC1101_PKTLEN, 0x00);+}+/****************************************************************+*FUNCTION NAME:SetTx+*FUNCTION :set CC1101 send data+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::SetTx(void)+{+ if (!SpiStrobe(CC1101_SIDLE)) return;+ SpiStrobe(CC1101_STX); // start send+ trxstate=1;+}+/****************************************************************+*FUNCTION NAME:SetRx+*FUNCTION :set CC1101 to receive state+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::SetRx(void)+{+ if (!SpiStrobe(CC1101_SIDLE)) return;+ SpiStrobe(CC1101_SRX); // start receive+ trxstate=2;+}+/****************************************************************+*FUNCTION NAME:SetTx+*FUNCTION :set CC1101 send data and change frequency+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::SetTx(float mhz)+{+ if(!SpiStrobe(CC1101_SIDLE)) return;+ setMHZ(mhz);+ SpiStrobe(CC1101_STX); //start send+ trxstate=1;+}+/****************************************************************+*FUNCTION NAME:SetRx+*FUNCTION :set CC1101 to receive state and change frequency+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::SetRx(float mhz)+{+ if(!SpiStrobe(CC1101_SIDLE)) return;+ setMHZ(mhz);+ SpiStrobe(CC1101_SRX); //start receive+ trxstate=2;+}+/****************************************************************+*FUNCTION NAME:RSSI Level+*FUNCTION :Calculating the RSSI Level+*INPUT :none+*OUTPUT :none+****************************************************************/+int ELECHOUSE_CC1101::getRssi(void)+{+int rssi;+rssi=SpiReadStatus(CC1101_RSSI);+if (rssi >= 128){rssi = (rssi-256)/2-74;}+else{rssi = (rssi/2)-74;}+return rssi;+}+/****************************************************************+*FUNCTION NAME:LQI Level+*FUNCTION :get Lqi state+*INPUT :none+*OUTPUT :none+****************************************************************/+byte ELECHOUSE_CC1101::getLqi(void)+{+byte lqi;+lqi=SpiReadStatus(CC1101_LQI);+return lqi;+}+/****************************************************************+*FUNCTION NAME:SetSres+*FUNCTION :Reset CC1101+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setSres(void)+{+ SpiStrobe(CC1101_SRES);+ trxstate=0;+}+/****************************************************************+*FUNCTION NAME:setSidle+*FUNCTION :set Rx / TX Off+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::setSidle(void)+{+ SpiStrobe(CC1101_SIDLE);+ trxstate=0;+}+/****************************************************************+*FUNCTION NAME:goSleep+*FUNCTION :set cc1101 Sleep on+*INPUT :none+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::goSleep(void){+ trxstate=0;+ if(!SpiStrobe(0x36)) return;//Exit RX / TX, turn off frequency synthesizer and exit+ SpiStrobe(0x39);//Enter power down mode when CSn goes high.+}+/****************************************************************+*FUNCTION NAME:Char direct SendData+*FUNCTION :use CC1101 send data+*INPUT :txBuffer: data array to send; size: number of data to send, no more than 61+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::SendData(char *txchar)+{+int len = strlen(txchar);+byte chartobyte[len];+for (int i = 0; i<len; i++){chartobyte[i] = txchar[i];}+SendData(chartobyte,len);+}+/****************************************************************+*FUNCTION NAME:SendData+*FUNCTION :use CC1101 send data+*INPUT :txBuffer: data array to send; size: number of data to send, no more than 61+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::SendData(byte *txBuffer,byte size)+{+ if(!SpiWriteReg(CC1101_TXFIFO,size)) return;+ SpiWriteBurstReg(CC1101_TXFIFO,txBuffer,size); //write data to send+ SpiStrobe(CC1101_SIDLE);+ SpiStrobe(CC1101_STX); //start send+ while (!digitalRead(GDO0)); // Wait for GDO0 to be set -> sync transmitted+ while (digitalRead(GDO0)); // Wait for GDO0 to be cleared -> end of packet+ SpiStrobe(CC1101_SFTX); //flush TXfifo+ trxstate=1;+}+/****************************************************************+*FUNCTION NAME:Char direct SendData+*FUNCTION :use CC1101 send data without GDO+*INPUT :txBuffer: data array to send; size: number of data to send, no more than 61+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::SendData(char *txchar,int t)+{+int len = strlen(txchar);+byte chartobyte[len];+for (int i = 0; i<len; i++){chartobyte[i] = txchar[i];}+SendData(chartobyte,len,t);+}+/****************************************************************+*FUNCTION NAME:SendData+*FUNCTION :use CC1101 send data without GDO+*INPUT :txBuffer: data array to send; size: number of data to send, no more than 61+*OUTPUT :none+****************************************************************/+void ELECHOUSE_CC1101::SendData(byte *txBuffer,byte size,int t)+{+ if(!SpiWriteReg(CC1101_TXFIFO,size)) return;+ SpiWriteBurstReg(CC1101_TXFIFO,txBuffer,size); //write data to send+ SpiStrobe(CC1101_SIDLE);+ SpiStrobe(CC1101_STX); //start send+ delay(t);+ SpiStrobe(CC1101_SFTX); //flush TXfifo+ trxstate=1;+}+/****************************************************************+*FUNCTION NAME:Check CRC+*FUNCTION :none+*INPUT :none+*OUTPUT :none+****************************************************************/+bool ELECHOUSE_CC1101::CheckCRC(void){+byte lqi=SpiReadStatus(CC1101_LQI);+bool crc_ok = bitRead(lqi,7);+if (crc_ok == 1){+return 1;+}else{+SpiStrobe(CC1101_SFRX);+SpiStrobe(CC1101_SRX);+return 0;+}+}+/****************************************************************+*FUNCTION NAME:CheckRxFifo+*FUNCTION :check receive data or not+*INPUT :none+*OUTPUT :flag: 0 no data; 1 receive data+****************************************************************/+bool ELECHOUSE_CC1101::CheckRxFifo(int t){+if(trxstate!=2){SetRx();}+if(SpiReadStatus(CC1101_RXBYTES) & BYTES_IN_RXFIFO){+delay(t);+return 1;+}else{+return 0;+}+}+/****************************************************************+*FUNCTION NAME:CheckReceiveFlag+*FUNCTION :check receive data or not+*INPUT :none+*OUTPUT :flag: 0 no data; 1 receive data+****************************************************************/+byte ELECHOUSE_CC1101::CheckReceiveFlag(void)+{+ if(trxstate!=2){SetRx();}+ if(digitalRead(GDO0)) //receive data+ {+ while (digitalRead(GDO0));+ return 1;+ }+ else // no data+ {+ return 0;+ }+}+/****************************************************************+*FUNCTION NAME:ReceiveData+*FUNCTION :read data received from RXfifo+*INPUT :rxBuffer: buffer to store data+*OUTPUT :size of data received+****************************************************************/+byte ELECHOUSE_CC1101::ReceiveData(byte *rxBuffer)+{+ byte size;+ byte status[2];++ if(SpiReadStatus(CC1101_RXBYTES) & BYTES_IN_RXFIFO)+ {+ size=SpiReadReg(CC1101_RXFIFO);+ SpiReadBurstReg(CC1101_RXFIFO,rxBuffer,size);+ SpiReadBurstReg(CC1101_RXFIFO,status,2);+ SpiStrobe(CC1101_SFRX);+ SpiStrobe(CC1101_SRX);+ return size;+ }+ else+ {+ SpiStrobe(CC1101_SFRX);+ SpiStrobe(CC1101_SRX);+ return 0;+ }+}+ELECHOUSE_CC1101 ELECHOUSE_cc1101;diff --git a/lib/SmartRC-CC1101-Driver-Lib/ELECHOUSE_CC1101_SRC_DRV.h b/lib/SmartRC-CC1101-Driver-Lib/ELECHOUSE_CC1101_SRC_DRV.hnew file mode 100644index 00000000..1c966c21--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/ELECHOUSE_CC1101_SRC_DRV.h@@ -0,0 +1,217 @@+/*+ ELECHOUSE_CC1101.cpp - CC1101 module library+ Copyright (c) 2010 Michael.+ Author: Michael, <www.elechouse.com>+ Version: November 12, 2010++ This library is designed to use CC1101/CC1100 module on Arduino platform.+ CC1101/CC1100 module is an useful wireless module.Using the functions of the+ library, you can easily send and receive data by the CC1101/CC1100 module.+ Just have fun!+ For the details, please refer to the datasheet of CC1100/CC1101.+----------------------------------------------------------------------------------------------------------------+cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and publish Wilson Shen (ELECHOUSE).+----------------------------------------------------------------------------------------------------------------+*/+#ifndef ELECHOUSE_CC1101_SRC_DRV_h+#define ELECHOUSE_CC1101_SRC_DRV_h++//********************* DEBUG Macros ********************/++// Uncomment line below to have Serial messagens about the transactions+//#define CC1101_LIB_DEBUG+#if defined(CC1101_LIB_DEBUG)+ #define DEBUG_CC1101(var) Serial.println(var);+ #define DEBUG_CC11012(var) Serial.print(var);+#else+ #define DEBUG_CC1101(var) yield();+ #define DEBUG_CC11012(var) yield();+#endif++//********************* DEBUG Macros ********************/++#include <Arduino.h>+#include <SPI.h>++//***************************************CC1101 define**************************************************//+// CC1101 CONFIG REGSITER+#define CC1101_IOCFG2 0x00 // GDO2 output pin configuration+#define CC1101_IOCFG1 0x01 // GDO1 output pin configuration+#define CC1101_IOCFG0 0x02 // GDO0 output pin configuration+#define CC1101_FIFOTHR 0x03 // RX FIFO and TX FIFO thresholds+#define CC1101_SYNC1 0x04 // Sync word, high INT8U+#define CC1101_SYNC0 0x05 // Sync word, low INT8U+#define CC1101_PKTLEN 0x06 // Packet length+#define CC1101_PKTCTRL1 0x07 // Packet automation control+#define CC1101_PKTCTRL0 0x08 // Packet automation control+#define CC1101_ADDR 0x09 // Device address+#define CC1101_CHANNR 0x0A // Channel number+#define CC1101_FSCTRL1 0x0B // Frequency synthesizer control+#define CC1101_FSCTRL0 0x0C // Frequency synthesizer control+#define CC1101_FREQ2 0x0D // Frequency control word, high INT8U+#define CC1101_FREQ1 0x0E // Frequency control word, middle INT8U+#define CC1101_FREQ0 0x0F // Frequency control word, low INT8U+#define CC1101_MDMCFG4 0x10 // Modem configuration+#define CC1101_MDMCFG3 0x11 // Modem configuration+#define CC1101_MDMCFG2 0x12 // Modem configuration+#define CC1101_MDMCFG1 0x13 // Modem configuration+#define CC1101_MDMCFG0 0x14 // Modem configuration+#define CC1101_DEVIATN 0x15 // Modem deviation setting+#define CC1101_MCSM2 0x16 // Main Radio Control State Machine configuration+#define CC1101_MCSM1 0x17 // Main Radio Control State Machine configuration+#define CC1101_MCSM0 0x18 // Main Radio Control State Machine configuration+#define CC1101_FOCCFG 0x19 // Frequency Offset Compensation configuration+#define CC1101_BSCFG 0x1A // Bit Synchronization configuration+#define CC1101_AGCCTRL2 0x1B // AGC control+#define CC1101_AGCCTRL1 0x1C // AGC control+#define CC1101_AGCCTRL0 0x1D // AGC control+#define CC1101_WOREVT1 0x1E // High INT8U Event 0 timeout+#define CC1101_WOREVT0 0x1F // Low INT8U Event 0 timeout+#define CC1101_WORCTRL 0x20 // Wake On Radio control+#define CC1101_FREND1 0x21 // Front end RX configuration+#define CC1101_FREND0 0x22 // Front end TX configuration+#define CC1101_FSCAL3 0x23 // Frequency synthesizer calibration+#define CC1101_FSCAL2 0x24 // Frequency synthesizer calibration+#define CC1101_FSCAL1 0x25 // Frequency synthesizer calibration+#define CC1101_FSCAL0 0x26 // Frequency synthesizer calibration+#define CC1101_RCCTRL1 0x27 // RC oscillator configuration+#define CC1101_RCCTRL0 0x28 // RC oscillator configuration+#define CC1101_FSTEST 0x29 // Frequency synthesizer calibration control+#define CC1101_PTEST 0x2A // Production test+#define CC1101_AGCTEST 0x2B // AGC test+#define CC1101_TEST2 0x2C // Various test settings+#define CC1101_TEST1 0x2D // Various test settings+#define CC1101_TEST0 0x2E // Various test settings++//CC1101 Strobe commands+#define CC1101_SRES 0x30 // Reset chip.+#define CC1101_SFSTXON 0x31 // Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL=1).+ // If in RX/TX: Go to a wait state where only the synthesizer is+ // running (for quick RX / TX turnaround).+#define CC1101_SXOFF 0x32 // Turn off crystal oscillator.+#define CC1101_SCAL 0x33 // Calibrate frequency synthesizer and turn it off+ // (enables quick start).+#define CC1101_SRX 0x34 // Enable RX. Perform calibration first if coming from IDLE and+ // MCSM0.FS_AUTOCAL=1.+#define CC1101_STX 0x35 // In IDLE state: Enable TX. Perform calibration first if+ // MCSM0.FS_AUTOCAL=1. If in RX state and CCA is enabled:+ // Only go to TX if channel is clear.+#define CC1101_SIDLE 0x36 // Exit RX / TX, turn off frequency synthesizer and exit+ // Wake-On-Radio mode if applicable.+#define CC1101_SAFC 0x37 // Perform AFC adjustment of the frequency synthesizer+#define CC1101_SWOR 0x38 // Start automatic RX polling sequence (Wake-on-Radio)+#define CC1101_SPWD 0x39 // Enter power down mode when CSn goes high.+#define CC1101_SFRX 0x3A // Flush the RX FIFO buffer.+#define CC1101_SFTX 0x3B // Flush the TX FIFO buffer.+#define CC1101_SWORRST 0x3C // Reset real time clock.+#define CC1101_SNOP 0x3D // No operation. May be used to pad strobe commands to two+ // INT8Us for simpler software.+//CC1101 STATUS REGSITER+#define CC1101_PARTNUM 0x30+#define CC1101_VERSION 0x31+#define CC1101_FREQEST 0x32+#define CC1101_LQI 0x33+#define CC1101_RSSI 0x34+#define CC1101_MARCSTATE 0x35+#define CC1101_WORTIME1 0x36+#define CC1101_WORTIME0 0x37+#define CC1101_PKTSTATUS 0x38+#define CC1101_VCO_VC_DAC 0x39+#define CC1101_TXBYTES 0x3A+#define CC1101_RXBYTES 0x3B++//CC1101 PATABLE,TXFIFO,RXFIFO+#define CC1101_PATABLE 0x3E+#define CC1101_TXFIFO 0x3F+#define CC1101_RXFIFO 0x3F++//************************************* class **************************************************//+class ELECHOUSE_CC1101+{+private:+ void SpiStart(void);+ void SpiEnd(void);+ void GDO_Set (void);+ void GDO0_Set (void);+ bool Reset (void);+ bool checkMISO(void);+ void setSpi(void);+ void RegConfigSettings(void);+ void Calibrate(void);+ void Split_PKTCTRL0(void);+ void Split_PKTCTRL1(void);+ void Split_MDMCFG1(void);+ void Split_MDMCFG2(void);+ void Split_MDMCFG4(void);+ SPIClass _cc_spi;+ SPIClass* cc_spi=nullptr;+ bool _begin_end_logic=false;+public:+ bool Init(void);+ byte SpiReadStatus(byte addr);+ void setBeginEndLogic(bool state);+ bool getBeginEndLogic();+ void setSPIinstance(SPIClass* sspi);+ SPIClass* getSPIinstance();+ void setSpiPin(byte sck, byte miso, byte mosi, byte ss);+ void addSpiPin(byte sck, byte miso, byte mosi, byte ss, byte modul);+ void setGDO(byte gdo0, byte gdo2);+ void setGDO0(byte gdo0);+ void addGDO(byte gdo0, byte gdo2, byte modul);+ void addGDO0(byte gdo0, byte modul);+ void setModul(byte modul);+ void setCCMode(bool s);+ void setModulation(byte m);+ void setPA(int p);+ void setMHZ(float mhz);+ void setChannel(byte chnl);+ void setChsp(float f);+ void setRxBW(float f);+ void setDRate(float d);+ void setDeviation(float d);+ void SetTx(void);+ void SetRx(void);+ void SetTx(float mhz);+ void SetRx(float mhz);+ int getRssi(void);+ byte getLqi(void);+ void setSres(void);+ void setSidle(void);+ void goSleep(void);+ void SendData(byte *txBuffer, byte size);+ void SendData(char *txchar);+ void SendData(byte *txBuffer, byte size, int t);+ void SendData(char *txchar, int t);+ byte CheckReceiveFlag(void);+ byte ReceiveData(byte *rxBuffer);+ bool CheckCRC(void);+ bool SpiStrobe(byte strobe);+ bool SpiWriteReg(byte addr, byte value);+ bool SpiWriteBurstReg(byte addr, byte *buffer, byte num);+ byte SpiReadReg(byte addr);+ bool SpiReadBurstReg(byte addr, byte *buffer, byte num);+ void setClb(byte b, byte s, byte e);+ bool getCC1101(void);+ byte getMode(void);+ void setSyncWord(byte sh, byte sl);+ void setAddr(byte v);+ void setWhiteData(bool v);+ void setPktFormat(byte v);+ void setCrc(bool v);+ void setLengthConfig(byte v);+ void setPacketLength(byte v);+ void setDcFilterOff(bool v);+ void setManchester(bool v);+ void setSyncMode(byte v);+ void setFEC(bool v);+ void setPRE(byte v);+ void setPQT(byte v);+ void setCRC_AF(bool v);+ void setAppendStatus(bool v);+ void setAdrChk(byte v);+ bool CheckRxFifo(int t);+};++extern ELECHOUSE_CC1101 ELECHOUSE_cc1101;++#endifdiff --git a/lib/SmartRC-CC1101-Driver-Lib/LICENSE.txt b/lib/SmartRC-CC1101-Driver-Lib/LICENSE.txtnew file mode 100644index 00000000..a62aa0e4--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/LICENSE.txt@@ -0,0 +1,22 @@+----------------------------------------------------------------------------------------------------------------+cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and publish Wilson Shen (ELECHOUSE).+----------------------------------------------------------------------------------------------------------------+++ ELECHOUSE_CC1101.cpp - CC1101 module library+ Copyright (c) 2010 Michael.+ Author: Michael, <www.elechouse.com>+ Version: November 12, 2010++ This library is designed to use CC1101/CC1100 module on Arduino platform.+ CC1101/CC1100 module is an useful wireless module.Using the functions of the+ library, you can easily send and receive data by the CC1101/CC1100 module.+ Just have fun!+ For the details, please refer to the datasheet of CC1100/CC1101.++notes: The whole stuff that is not directly related to Rc_Switch,+ NewRemoteSwitch or Elechouse_cc1101 Lib is Copyright (c) 2018 - 2020 by Little Satan.+ Example calculator codes in the driver lib.+ And so on...+ You can freely use, edit or distribute it with reference to the source.+ For everything else, the rights of the respective owners apply!\ No newline at end of filediff --git a/lib/SmartRC-CC1101-Driver-Lib/README.md b/lib/SmartRC-CC1101-Driver-Lib/README.mdnew file mode 100644index 00000000..9e3e6eb9--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/README.md@@ -0,0 +1,653 @@+# SmartRC-CC1101-Driver-Lib_V2.5.7++++Note: Find out about the laws in your country.+Use at your own risk.++Attention! in version 2.5.7 there are changes for the internal transfer functions regarding the gdo pin assignment!++---------------------------------------------+Announcements / other+---------------------------------------------++attention: currently i can only answer questions very belatedly.+try to scour existing problems for a solution if possible.+Problems that have not yet been closed are mostly already solved!+thanks for your understanding++For debug and advanced functions: https://github.com/LSatan/CC1101-Debug-Service-Tool++new library Simu_Remote: https://github.com/LSatan/Simu_Remote_CC1101++---------------------------------------------+Install:+---------------------------------------------++Can be downloaded directly from the Arduino library manager. Just search for cc1101.++---------------------------------------------+Foreword:+---------------------------------------------+First of all, thanks to Elechouse that I can make the modified library accessible to everyone.++Link: http://www.elechouse.com/elechouse/++++The library has been redesigned and some improvements have been made.++Among other things, you can now also use the internal send / receive function.++I would be happy to receive your suggestions for further examples from other libraries.++All examples included are listed in the next field.++---------------------------------------------+Containing examples:+---------------------------------------------+1.Elechouse CC1101:+-+Description: CC1101 Internal send / receive examples. Supported modulations 2-FSK, GFSK, ASK/OOK, 4-FSK, MSK.++2.Rc-Switch:+-+<p>Description: Arduino lib to operate 433/315Mhz devices like power outlet sockets.</p>+<p>Link: https://github.com/sui77/rc-switch</p>++3.NewRemoteswitch:+-+<p>Description: This library provides an easy class for Arduino, to send and receive signals used by some common "new style" 433MHz remote control switches.</p>+<p>Link: https://github.com/1technophile/NewRemoteSwitch</p>++4.RemoteSensor library:+-+<p>Description: This library provides an easy class for Arduino, to send and receive signals used by some common weather stations using -remote 433MHz sensors.</p>+<p>Link: https://github.com/mattwire/arduino-dev/tree/master/libraries/RemoteSensor</p>++5.ESPiLight:+-+<p>Description:This Arduino library is a port of the pilight 433.92MHz protocols to the Arduino platform. It was tested with a ESP8266. The aim is to transmit, receive and parse many 433.92MHz protocols, by providing a simple Arduino friendly API. This should help to implement IoT bridges between the 434MHz-RF band and internet protocols.</p>+<p>Link:https://github.com/puuu/ESPiLight</p>++---------------------------------------------+Instructions / Description:+---------------------------------------------+This driver library can be used for many libraries that use a simple RF ASK module,+with the advantages of the cc1101 module.It offers many direct setting options as in+SmartRF Studio and calculates settings such as MHz directly.++The most important functions at a glance:++ELECHOUSE_cc1101.Init(); //Initialize the cc1101. Must be set first!++ELECHOUSE_cc1101.setBeginEndLogic(value) // Set the same logic of begin and end the SPI instance, like the original state++ELECHOUSE_cc1101.getBeginEndLogic() // Gives the actual mode of operation++ELECHOUSE_cc1101.setSPIinstance(&spi_instance); // Used to share SPI bus with other devices (tft, SDCard or other devices)+ // to share SPI cus with a display (TFT_eSPI), use ELECHOUSE_cc1101.setSPIinstance(&tft.getSPIinstance());+ // if sharing with TFT_eSPI device, is neede to call some SPI Function to "release" the CC1101, like tft.+ // like: tft.drawPixel(0,0,0); after finishing setting the CC1101.+ // if none is set, it will use this lib instance, instead++ELECHOUSE_cc1101.getSPIinstance(); // Gets the SPI Instance to use with other object, like SDCard or other thing++ELECHOUSE_cc1101.setPA(PA); //Set transmission power.++ELECHOUSE_cc1101.setMHZ(MHZ); //Set the basic frequency.++ELECHOUSE_cc1101.SetTx(); //Set transmit on.++ELECHOUSE_cc1101.SetTx(MHZ); //Sets transmit on and changes the frequency.++ELECHOUSE_cc1101.SetRX(); //Set receive on.++ELECHOUSE_cc1101.SetRx(MHZ); //Sets receive on and changes the frequency.++ELECHOUSE_cc1101.setRxBW(RXBW); //Set Receive filter bandwidth++ELECHOUSE_cc1101.setGDO(GDO0, GDO2); //Set Gdo0 (tx) and Gdo2 (rx) for serial transmission function.+++ELECHOUSE_cc1101.setSpiPin(SCK, MISO, MOSI, CSN); //custom SPI pins. Set your own Spi Pins.Or to switch between multiple cc1101. Must be set before init and before changing the cc1101.++ELECHOUSE_cc1101.setChannel(chnl); //Set Channel from 0 to 255. default = 0(basic frequency).++ELECHOUSE_cc1101.setClb(fband, cal1, cal2); //Optionally enter Offset Callibration. Requirements: Sketch Calibrate_frequency.ino below [CC1101-Debug-Service-Tool](https://github.com/LSatan/CC1101-Debug-Service-Tool/tree/master/Calibrate_frequency).A SDR receiver and SDR software.++New in V2.5.7++ELECHOUSE_cc1101.setGDO0(GDO0); //Sets Gdo0 for internal transfer function.++ELECHOUSE_cc1101.addGDO0(GDO0, Modul); //Adds Gdo0 for internal transfer function (multiple cc1101).++ELECHOUSE_cc1101.addGDO(GDO0, GDO2, Modul); //Adds Gdo0 (tx) and Gdo2 (rx) for serial transmission function (multiple cc1101).++ELECHOUSE_cc1101.addSpiPin(SCK, MISO, MOSI, CSN, Modul); //Adds Spi Pins for multiple cc1101.++ELECHOUSE_cc1101.setModul(Modul); //Switches between modules. from 0 to 5. So a maximum of 6.+++The new features are not final and can be changed at any time.++All can also be used in a loop and are applied directly.++---------------------------------------------+Wiring:+---------------------------------------------++Notes: A logic level converter is recommended for arduino. It also works well without. Use at your own risk.++<img src="https://github.com/LSatan/SmartRC-CC1101-Driver-Lib/blob/master/img/Nano_CC1101.png"/>++<img src="https://github.com/LSatan/SmartRC-CC1101-Driver-Lib/blob/master/img/MEGA_CC1101.png"/>++<img src="https://github.com/LSatan/SmartRC-CC1101-Driver-Lib/blob/master/img/Esp8266_CC1101.png"/>++<img src="https://github.com/LSatan/SmartRC-CC1101-Driver-Lib/blob/master/img/Esp32_CC1101.png"/>++<img src="https://github.com/LSatan/SmartRC-CC1101-Driver-Lib/blob/master/img/TXS0108E_CC1101.png"/>++<img src="https://github.com/LSatan/SmartRC-CC1101-Driver-Lib/blob/master/img/Wiring_CC1101.png"/>++---------------------------------------------+Donation+---------------------------------------------++If you like the library, I would be happy about a star.++you can support me with a donation.++https://www.paypal.me/LittleSatan666++Thank You!++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.5.7+---------------------------------------------+13.07.2021++Driver Library :Fixed a bug when initalizing multiple cc1101++Driver Library :new commandos for easy handling of multiple cc1101++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.5.6+---------------------------------------------+06.04.2021++Driver Library :Add NUM_PREAMBLE. Sets the minimum number of preamble bytes to be transmitted.++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.5.5+---------------------------------------------+23.01.2021++Driver Library :Error correction for CheckRxFifo and CheckReceiveFlag (reception internal CC1101 function).++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.5.4+---------------------------------------------+23.01.2021++Driver Library :No big frequency jumps over SetRx(freq); Possible. Fixed! Big thanks to NorthernMan54 for testing!++Driver Library :double-initaliesing option from V2.5.3 has been removed. Necessary for SetRx(freq); to use.++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.5.3+---------------------------------------------+22.01.2021++Driver Library :Putting rx tx has no effect if they are already in mode. Prevents unnecessary double-initaliesing.++Driver Library :new command added: ELECHOUSE_cc1101.goSleep(); //Enter power down mode. For wakeup set RX or TX.++Driver Library :new command added: ELECHOUSE_cc1101.getMode(); //Return the Mode. Sidle = 0, TX = 1, Rx = 2.++Driver Library :new command added: ELECHOUSE_cc1101.setSidle(); //Set Rx / Tx Off.++Driver Library :new command added: ELECHOUSE_cc1101.getCC1101(); //Test Spi connection and return 1 when true.++Examples :RcSwitch Repeater_cc1101.ino has been shortened.++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.5.2+---------------------------------------------+01.10.2020++Driver Library :SpiWriteReg, SpiReadReg, SpiWriteBurstReg and SpiReadBurstReg change to public. Allows additional modifications from sketch.++Driver Library :Setrx no longer has to be set to receive.(internal transmission methods)++Driver Library :Gdo pins are now set to input / output with set gdo instead of Init.++Driver Library :Added new sending method. Allows sending without a gdo0 pin.++notes :The new internal send and receive methods now work completely without an additional gdo pin.++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.5.1+---------------------------------------------+18.08.2020++Driver Library :When changing from receiving to sending, the program freezes (internal send functions). fixed!++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.5.0+---------------------------------------------+16.08.2020++Driver Library :Rssi was calculated incorrectly.Fixed Thanks to zapquiyou!++Driver Library :New receiving method for internal examples added. Allows several actions to be carried out in the loop.++Driver Library :Internal Crc check added for internal examples.++Driver Library :Simplification to send char added for internal transfer examples.++Driver Library :A lot of new settings added for internal transmission examples. Everything can be set as in SmartRF Studio and is calculated automatically. An overview: setDeviation, setChsp, setRxBW, setDRate, setSyncMode, setSyncWord, setAdrChk, setAddr, setWhiteData, setPktFormat, setLengthConfig, setPacketLength, setCrc, setCRC_AF, setDcFilterOff, setManchester, setFEC, setPQT, setAppendStatus. description in the examples!++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.4.0+---------------------------------------------+07.05.2020++Driver Library :frequency calculator has been simplified. error-free calculations and less variables.++Driver Library :Added frequency calibration option.++Driver Library :Certain frequencies could not be set. Fixed! Big thanks to gusgorman402!++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.3.5+---------------------------------------------+14.04.2020++Driver Library :setChsp has been removed to save space. This function is available in the Service / Debug Tool as an extended function.++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.3.4+---------------------------------------------+01.04.2020++Driver Library :set AGCCTRL2 from 0x07 to 0xC7. Reception is significantly improved!++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.3.3+---------------------------------------------+01.04.2020++Driver Library :set FSCTRL1 from 0x08 to 0x06. for better receive.++Driver Library :set SpiWriteReg to public. Make it fit for debug tool!++Driver Library :set SpiStrobe to public. Make it fit for debug tool!++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.3.2+---------------------------------------------+24.03.2020++Driver Library :Set gdo2 from input to output. Errors in libraries that use the pins directly.++examples :Set gdo2 from setting 2 to 0 in default examples. Gdo2 is not required for these examples.++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.3.1+---------------------------------------------+18.03.2020++Driver Library :ESP8266/32 core panik. Fixed! The cc1101 must be initialized before setting options!++examples :all examples have been adapted.++examples :internal cc1101 examples have been adapted for esp8266/32.++examples :ESPiLight examples added.++---------------------------------------------+Changelog: SmartRC-CC1101-Driver-Lib_V2.3+---------------------------------------------+18.03.2020++Driver Library :"RcSwitch-cc1101-driver-lib" becomes "SmartRC-cc1101-driver-lib".++Pull request :#20 Removed unnecessary initializations when setting Tx or Rx mode. Agreed / accepted improves speed when changing rx / tx. Special thanks to fleibede.++Pull request :#19 Added spi state after SPI pins have been set for default pins. The problem was solved differently. Special thanks to fleibede.++Pull request :#18 Updated AVR types conditional defines. Agreed / accepted. Special thanks to fleibede.++Driver Library :Frequency calculator certain frequencies were calculated incorrectly. fixed!++Driver Library :Intelligent Pa Table system added. When changing the band The corresponding table is set via setTx / Rx and the frequency set to basic calibrated. All module internal transmission powers can now be set according to the band.++Driver Library :Newly calibrated base frequency on chan 0 according to the SmartRF Studio.++Driver Library :Channel spacing calculator can enter directly the spacing area in khz.++Driver Library :Modulation setting added for internal transmission methods++Driver Library :ESP32 reception improvements.++Driver Library :Direct conversion of the RSSI level in the library.++Driver Library :Correction of version numbering.++examples :New examples added "RemoteSensor library".++examples :New examples added "Elechouse CC1101 default examples"++examples :Remote Fusion has been removed and given an extra library.++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V2.2.1+---------------------------------------------+[Download Release V2.2.1](https://drive.google.com/file/d/1YHFpp2GQC96-GKcg67Tym9wt1E4CBdFc/view?usp=sharing)++20.01.2019++Driver Library :Spi options have been removed. (Problems with ESP32) FIXED!++notes :everything was checked again. D-SUN module on esp8266 / 32 and so on.++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V2.2+---------------------------------------------+17.01.2019++Version notes :Spi was reconfigured for fix some issuses.++Driver Library :HotFix for cc1101 module with "8pins"(example DSun). Transmitting on Esp8266 based bords not work. FIXED!++Driver Library :Change "SpiReadStatus" to public. Now can read RSSI Level!++Driver Library :Spi transfer rate was limited to cc1101 max transfer rate (10mhz).++Driver Library :After using Spi, it will now be disabled. (receive data from serial monitor and rx pin was not working on Esp 8266/32) FIXED!++Add Examples :ReceiveDemo_Simple_with_RSSI_cc1101.ino (Shows reception strength)++Add Examples :Frequency_Scanner_cc1101.ino (Scans Transmitting frequency of your remotes. No good results with cc1101-DSun)++Add Examples :ProtocolAnalyzeDemo_cc1101.ino (for scan unknown protokolls. Requires: link is in sketch!)++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V2.1+---------------------------------------------+3.1.2019++Driver Library :Spi corrections for esp32. Spi Pin changes did not work on esp32. FIXED!++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V2.0+---------------------------------------------+18.12.2018++Driver Library :Own Spi pin settings possible. Allows the use of other microcontrollers. Allows you to use multiple CC1101s. More information in the commands.txt++Add TXT :driver lib commands and examples.txt++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.9.3+---------------------------------------------+27.11.2018++Driver Library :setESP8266 has been removed. Pins are set automatically with the init command.++Driver Library :Arduino mega SPI pins added.++Driver Library :Added setGDO pins (For libraries that directly address the GDO pins).Like this https://github.com/EinfachArne/Somfy_Remote .+ Example ELECHOUSE_CC1101.setGDO(2, 4); // (pin2 = GDO0, pin4 = GDO2).++Add Wiring TXT :WIRING MEGA.txt++Add Wiring JPG :WIRING MEGA.jpg++LICENSE :LICENSE.txt Update.++notes :setGDO is not compatible with RC_Switch / NewRemotSwitch.++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.9.2+---------------------------------------------+16.11.2018++Fixes Remotes Fusion :Receive mode and Repeater mode frequency, changes to the transmitter frequency after pressing on a transmitter. (RemotesFusion.ino)Fixed!++NewRemoteSwitch :LearnCode_cc1101.ino (corrections).++Added :Keywords.txt added.++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.9.1+---------------------------------------------+07.11.2018++New Sketch :Clear_EEPROM.ino (if there are problems with the access point password or if you want to use your ESP for other projects).++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.9+---------------------------------------------+18.10.2018++New Sketch :RemotesFusion.ino.++New Apk´s :RemotesFusion_V1_en.apk / RemotesFusion_V1_de.apk.++Add Docs :Docs and manuals for RemotesFusion.++Changes :channel spacing and channel set was removed from the examples. unnecessary because exact frequency can be set.++notes :RemotesFusion is an application with which Rc-Switch and NewRemoteSwitch can be controlled at the same time.+ A universal remote control APP with many possibilities. Only for Esp 8266/32 modules! For more information, watch the docs.++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.8+---------------------------------------------+[Download Release V1.8](https://drive.google.com/file/d/1ADKOmW0SrUoomeoDskFrm0J2SdwCLB_O/view?usp=sharing)++02.09.2018++Driver Library :Added pin settings for esp32.++Examples :Added pin settings for esp32 examples.++Add Wiring JPG :Add Wiring JPG esp32.++Add Wiring TXT :Add Wiring TXT esp32.++Add Wiring JPG :Add Wiring JPG esp32 for Receive_Send_Decimal_Demo_Simple.ino.++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.7.2+---------------------------------------------+[Download Release V1.7.2](https://drive.google.com/file/d/1sfMvQw2JaGARTaYXZevOjB20BFOMS0tw/view?usp=sharing)++16.08.2018++Examples :All NewRemoteSwitch examples are compatible with ESP. Exception Retransmitter_cc1101.ino.++Driver Library :Frequency calculator calibrated. Difference -0.01 MHz. (Fixed!) Frequency is now accurate.++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.7.1+---------------------------------------------+[Download Release V1.7.1](https://drive.google.com/file/d/1PXa1k0AIDY8bTMxFyyQMbOljijhIn1ke/view?usp=sharing)++10.08.2018++Driver Library :Now you can Switch the frequency in loop. Examples: ELECHOUSE_cc1101.SetTx(433.92); and ELECHOUSE_cc1101.SetRx(433.92);.++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.7+---------------------------------------------+[Download Release V1.7](https://drive.google.com/file/d/1uxACfe1ZUrkL4S3_NPVN0DmUfzbxt6oQ/view?usp=sharing)++09.08.2018++Driver Library :Now you can enter your base frequency directly.The library calculates the settings automatically. example(433.92)++Driver Library :Remove freq2, freq1 and freq0 Settings.++Driver Library :Removed unnecessary entries. the library shrank from 32,8kb(.cpp) and 9,38kb(.h) to 17,0kb(.cpp) and 7,87kb(.h).++New Example :(NewRemoteSwitch Library) NewRemoteRepeater.ino. Repeat the Received signal 1to1. Best thanks to Roman for write it.++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.6.1+---------------------------------------------+[Download Release V1.6.1](https://drive.google.com/file/d/1q8FV5kDnhAj1SMZf6DS0wDcm5xo4E-5-/view?usp=sharing)++05.08.2018++Examples Fix (rc-switch):Fix auto receive pulse. Received pulse don´t transmit. Fixed!(Repeater.ino and Receive_Send_Decimal_Demo_Simple.ino).++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.6+---------------------------------------------+[Download Release V1.6](https://drive.google.com/file/d/1p_iAxh7ZWlNWhFoqMM_tlLTLdyGK07-a/view?usp=sharing)++03.08.2018++Esp8266 :Compatibility for all RC switch examples.++Driver Library :Add the GDO2 pin for Receive. Change GDO0 to send.++Wiring changes :Description in jpg's and txt's.++Examples :All examples have been adjusted.++Examples :Esp and Arduino are set automatically.++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.5+---------------------------------------------+[Download Release V1.5](https://drive.google.com/file/d/1XcGPbvI5v2PcpnVBbjtOFwtuJtx3jMK4/view?usp=sharing)++31.07.2018++New :Supportet NewRemoteSwitch Library. For wireless sockets by trust smart home, Smappee, DI-O Chacon, Intertechno and others.+ You want to use it? Then you need that https://github.com/1technophile/NewRemoteSwitch++Add Examples :NewRemoteSwitch Compatible examples.++Driver Library :You can now switch directly from Tx to Rx in the loop. Without resetting the cc1101.++Add Examples :New Repeater Example for Rc-switch. For example, to increase the range of your remote control.++Example changes :Receive_Send_Decimal_Demo_Simple.ino (remove unnecessary commands).++Examples Fix :Rc-Switch examples fix TypeA, TypeB and TypeD (missing from semicolon to SetTx).++Notes :NewRemoteSwitch examples Retransmitter_cc1101.ino and LightShow_cc1101.ino only Arduino!!!++Notes :Rc-switch example Repeater_cc1101.ino only Arduino!!!++Notes :Rc-switch example Receive_Send_Decimal_Demo_Simple.ino only Arduino!!!++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.4+---------------------------------------------+[Download Release V1.4](https://drive.google.com/file/d/1nAPGeQSutfskirJsng44adB4sXU1YU6A/view?usp=sharing)++26.07.2018++Driver Library :esp8266 Compatibility (Tested with Wemos d1 mini).++Driver Library :Change default Receive filter bandwidth to 812khz (max).++Driver Library :Change default Tx Power to PA10 (max).++Examples :Add set esp command and pin settings.++Examples :Diskription change.++Demo Example :Add auto Recive and Send pulse length. (Receive_Send_Decimal_Demo_Simple.ino)++Add Wiring JPG :Add Wiring JPG esp8266.++Add Wiring TXT :Add Wiring TXT esp8266.++Notes :esp8266 pin D4 don´t work with receive, Transmit and receive is set to D2.++Notes :esp8266 don´t work with Receive_Send_Decimal_Demo_Simple.ino (freezes when reset cc1101).++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.3.1+---------------------------------------------+[Download Release V1.3.1](https://drive.google.com/file/d/1iKmagldd14O1Boa9Z_PDpXbHRECYUPdt/view?usp=sharing)++30.03.2018:++Driver Library Fix :no effect set by transmission power.++Driver Library :Transmitting power can be adjusted via frequency(example in the sketches).++Examples :Command Tx Power cleared.++Examples Fix :set Receive filter bandwidth (command incomplete) Fixed.++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.3+---------------------------------------------+[Download Release V1.3](https://drive.google.com/file/d/1q56Qewk8-Aquv1epss1gd7Gc05q4GrbO/view?usp=sharing)++25.03.2018:++Driver Library :Add Channel List. Now you can set channel numbers 0-255.++Driver Library :Add bandwidth can be adjusted++Driver Library :transmission power can be adjusted++Driver Library :can set your own frequency settings (freq2, freq1, freq0)++Driver Library :Channel spacing can be set.++Examples :Add set new commands++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.2+---------------------------------------------+[Download Release V1.2](https://drive.google.com/file/d/1KLJt8ygszj9rqcttiEMt5zCnJKHc_qe3/view?usp=sharing)++20.03.2018:++Driver Library :Add 315Mhz Support.++Driver Library :Add Channel command for finetune (80khz steps) from 420mhz - 440mhz / 302mhz - 322mhz.++Examples :Add set channel command in examples.++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.1+---------------------------------------------+[Download Release V1.1](https://drive.google.com/file/d/1uZzcY4uoduiUjFZzXdxA-ucLoA_TtC1f/view?usp=sharing)++19.03.2018:++Driver Library Fix :Calibrated Frequency from 433.86 to 433.92 - 433.93 Mhz.++Driver Library :cc1101 reset command added (allows switching between send and receive.)++New Demo Example :Receive_Send_Decimal_Demo_Simple.ino (Sends last received decimal code)+ To illustrate the change between RX and TX (press button = send / do not press button = receive)++Add Wiring JPG :Wiring for Receive_Send_Decimal_Demo_Simple.ino++Add Wiring JPG :Wiring for Nano / Uno+++---------------------------------------------+Changelog: RCSwitch-CC1101-Driver-Lib_V1.0+---------------------------------------------+[Download Release V1.0](https://drive.google.com/file/d/14538RtiEakZ_8yioXJT32XneheSjDqxi/view?usp=sharing)++18.03.2018:++cc1101 Compatibility for RC-Switch.++cc1101 RC-Switch Compatible examples.diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Receive_method_advanced/cc1101_New_Receive_method_advanced.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Receive_method_advanced/cc1101_New_Receive_method_advanced.inonew file mode 100644index 00000000..612a89bf--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Receive_method_advanced/cc1101_New_Receive_method_advanced.ino@@ -0,0 +1,81 @@+//New receiving method. This method checks the Rx Fifo for any data it contains.+//It allows you to do several things in a loop.+//In addition, the gdo0 and gdo2 pin are not required.+//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+//by Little_S@tan+#include <ELECHOUSE_CC1101_SRC_DRV.h>++void setup(){++ Serial.begin(9600);+ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+ ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.+ ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.+ ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.+ ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.+ ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+ ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!+ ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.+ ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)+ ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.+ ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).+ ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.+ ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins.+ ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved+ ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed.+ ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.+ ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.+ ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).+ ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.+ ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable.+ ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24+ ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.+ ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.++ Serial.println("Rx Mode");+}++byte buffer[61] = {0};++void loop(){++ //Checks whether something has been received.+ //When something is received we give some time to receive the message in full.(time in millis)+ if (ELECHOUSE_cc1101.CheckRxFifo(100)){++ //CRC Check. If "setCrc(false)" crc returns always OK!+ if (ELECHOUSE_cc1101.CheckCRC()){++ //Rssi Level in dBm+ Serial.print("Rssi: ");+ Serial.println(ELECHOUSE_cc1101.getRssi());++ //Link Quality Indicator+ Serial.print("LQI: ");+ Serial.println(ELECHOUSE_cc1101.getLqi());++ //Get received Data and calculate length+ int len = ELECHOUSE_cc1101.ReceiveData(buffer);+ buffer[len] = '\0';++ //Print received in char format.+ Serial.println((char *) buffer);++ //Print received in bytes format.+ for (int i = 0; i<len; i++){+ Serial.print(buffer[i]);+ Serial.print(",");+ }+ Serial.println();+ }+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Receive_method_minimal/cc1101_New_Receive_method_minimal.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Receive_method_minimal/cc1101_New_Receive_method_minimal.inonew file mode 100644index 00000000..92f68392--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Receive_method_minimal/cc1101_New_Receive_method_minimal.ino@@ -0,0 +1,51 @@+//New receiving method. This method checks the Rx Fifo for any data it contains.+//It allows you to do several things in a loop.+//In addition, the gdo0 and gdo2 pin are not required.+//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+//by Little_S@tan+#include <ELECHOUSE_CC1101_SRC_DRV.h>++void setup(){++ Serial.begin(9600);++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+ ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.+ ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.+ ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.++ Serial.println("Rx Mode");+}+byte buffer[61] = {0};++void loop(){++ //Checks whether something has been received.+ //When something is received we give some time to receive the message in full.(time in millis)+ if (ELECHOUSE_cc1101.CheckRxFifo(100)){++ if (ELECHOUSE_cc1101.CheckCRC()){ //CRC Check. If "setCrc(false)" crc returns always OK!+ Serial.print("Rssi: ");+ Serial.println(ELECHOUSE_cc1101.getRssi());+ Serial.print("LQI: ");+ Serial.println(ELECHOUSE_cc1101.getLqi());++ int len = ELECHOUSE_cc1101.ReceiveData(buffer);+ buffer[len] = '\0';+ Serial.println((char *) buffer);+ for (int i = 0; i<len; i++){+ Serial.print(buffer[i]);+ Serial.print(",");+ }+ Serial.println();+ }+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Hello_World_advanced/cc1101_New_Transmitt_method_Hello_World_advanced.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Hello_World_advanced/cc1101_New_Transmitt_method_Hello_World_advanced.inonew file mode 100644index 00000000..d83024ee--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Hello_World_advanced/cc1101_New_Transmitt_method_Hello_World_advanced.ino@@ -0,0 +1,67 @@+//New transmission method.+//In addition, the gdo0 and gdo2 pin are not required.+//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+//by Little_S@tan+#include <ELECHOUSE_CC1101_SRC_DRV.h>++byte transmitt_byte[11] = {72,101,108,108,111,32,87,111,114,108,100};+char *transmitt_char = "Hello World";++void setup() {++ Serial.begin(9600);++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+ ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.+ ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.+ ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.+ ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.+ ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+ ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!+ ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.+ ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)+ ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.+ ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).+ ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.+ ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins.+ ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved+ ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed.+ ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.+ ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.+ ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).+ ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.+ ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable.+ ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24+ ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.+ ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.++ Serial.println("Tx Mode");+}++void loop() {++//3 different methods to send data without gdo+//When sending, we give a little time to completely transmit the message (time in millis).+//You can shorten the time. It depends on the data rate and the packet length. Just try it out for fine tuning.++//Transmitt "Hello World" from byte format.+ELECHOUSE_cc1101.SendData(transmitt_byte, 11, 100);+delay(2000);++//Transmitt "Hello World" from char format.+ELECHOUSE_cc1101.SendData(transmitt_char, 100);+delay(2000);++//Transmitt "Hello World" from char format directly.+ELECHOUSE_cc1101.SendData("Hello World", 100);+delay(2000);+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Hello_World_minimal/cc1101_New_Transmitt_method_Hello_World_minimal.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Hello_World_minimal/cc1101_New_Transmitt_method_Hello_World_minimal.inonew file mode 100644index 00000000..ab2b920c--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Hello_World_minimal/cc1101_New_Transmitt_method_Hello_World_minimal.ino@@ -0,0 +1,48 @@+//New transmission method.+//In addition, the gdo0 and gdo2 pin are not required.+//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+//by Little_S@tan+#include <ELECHOUSE_CC1101_SRC_DRV.h>++byte transmitt_byte[11] = {72,101,108,108,111,32,87,111,114,108,100};+char *transmitt_char = "Hello World";++void setup() {++ Serial.begin(9600);++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+ ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.+ ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.+ // ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.++ Serial.println("Tx Mode");+}++void loop() {++//3 different methods to send data without gdo+//When sending, we give a little time to completely transmit the message (time in millis).+//You can shorten the time. It depends on the data rate and the packet length. Just try it out for fine tuning.++//Transmitt "Hello World" from byte format.+ELECHOUSE_cc1101.SendData(transmitt_byte, 11, 100);+delay(2000);++//Transmitt "Hello World" from char format.+ELECHOUSE_cc1101.SendData(transmitt_char, 100);+delay(2000);++//Transmitt "Hello World" from char format directly.+ELECHOUSE_cc1101.SendData("Hello World", 100);+delay(2000);+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Serial_advanced/cc1101_New_Transmitt_method_Serial_advanced.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Serial_advanced/cc1101_New_Transmitt_method_Serial_advanced.inonew file mode 100644index 00000000..c1ca76f0--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Serial_advanced/cc1101_New_Transmitt_method_Serial_advanced.ino@@ -0,0 +1,68 @@+//New transmission method.+//In addition, the gdo0 and gdo2 pin are not required.+//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+//by Little_S@tan++#include <ELECHOUSE_CC1101_SRC_DRV.h>++const int n = 61;+byte buffer[n] = "";++void setup() {++ Serial.begin(9600);++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+ ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.+ ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.+ ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.+ ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.+ ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+ ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!+ ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.+ ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)+ ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.+ ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).+ ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.+ ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins.+ ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved+ ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed.+ ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.+ ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.+ ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).+ ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.+ ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable.+ ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24+ ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.+ ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.++ Serial.println("Tx Mode");+}++void loop() {++//When sending, we give a little time to completely transmit the message (time in millis).+//You can shorten the time. It depends on the data rate and the packet length. Just try it out for fine tuning.++ if (Serial.available()) {+ int len = Serial.readBytesUntil('\n', buffer, n);+ buffer[len] = '\0';+ Serial.println((char *)buffer);+ ELECHOUSE_cc1101.SendData(buffer, len, 100);+ Serial.print("Buffer: ");+ for (int i = 0; i<len; i++){+ Serial.println(buffer[i]);+ }+ Serial.print("len: ");+ Serial.println(len);+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Serial_minimal/cc1101_New_Transmitt_method_Serial_minimal.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Serial_minimal/cc1101_New_Transmitt_method_Serial_minimal.inonew file mode 100644index 00000000..75b9aec3--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Serial_minimal/cc1101_New_Transmitt_method_Serial_minimal.ino@@ -0,0 +1,49 @@+//New transmission method.+//In addition, the gdo0 and gdo2 pin are not required.+//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+//by Little_S@tan++#include <ELECHOUSE_CC1101_SRC_DRV.h>++const int n = 61;+byte buffer[n] = "";++void setup() {++ Serial.begin(9600);++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+ ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.+ ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.+ // ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.++ Serial.println("Tx Mode");+}++void loop() {++//When sending, we give a little time to completely transmit the message (time in millis).+//You can shorten the time. It depends on the data rate and the packet length. Just try it out for fine tuning.++ if (Serial.available()) {+ int len = Serial.readBytesUntil('\n', buffer, n);+ buffer[len] = '\0';+ Serial.println((char *)buffer);+ ELECHOUSE_cc1101.SendData(buffer, len, 100);+ Serial.print("Buffer: ");+ for (int i = 0; i<len; i++){+ Serial.println(buffer[i]);+ }+ Serial.print("len: ");+ Serial.println(len);+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Receive_advanced/cc1101_Receive_advanced.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Receive_advanced/cc1101_Receive_advanced.inonew file mode 100644index 00000000..2526d12d--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Receive_advanced/cc1101_Receive_advanced.ino@@ -0,0 +1,90 @@+// These examples are from the Electronics Cookbook by Simon Monk+//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+// mod by Little_S@tan+#include <ELECHOUSE_CC1101_SRC_DRV.h>++int gdo0;++void setup(){++#ifdef ESP32+gdo0 = 2; // for esp32! GDO0 on GPIO pin 2.+#elif ESP8266+gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1.+#else+gdo0 = 6; // for Arduino! GDO0 on pin 6.+#endif++ Serial.begin(9600);++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+ ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.+ ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.+ ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.+ ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.+ ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.+ ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+ ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!+ ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.+ ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)+ ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.+ ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).+ ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.+ ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins.+ ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved+ ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed.+ ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.+ ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.+ ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).+ ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.+ ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable.+ ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24+ ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.+ ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.++ Serial.println("Rx Mode");+}++byte buffer[61] = {0};++void loop(){++ //Checks whether something has been received.+ if (ELECHOUSE_cc1101.CheckReceiveFlag()){++ //CRC Check. If "setCrc(false)" crc returns always OK!+ if (ELECHOUSE_cc1101.CheckCRC()){++ //Rssi Level in dBm+ Serial.print("Rssi: ");+ Serial.println(ELECHOUSE_cc1101.getRssi());++ //Link Quality Indicator+ Serial.print("LQI: ");+ Serial.println(ELECHOUSE_cc1101.getLqi());++ //Get received Data and calculate length+ int len = ELECHOUSE_cc1101.ReceiveData(buffer);+ buffer[len] = '\0';++ //Print received in char format.+ Serial.println((char *) buffer);++ //Print received in bytes format.+ for (int i = 0; i<len; i++){+ Serial.print(buffer[i]);+ Serial.print(",");+ }+ Serial.println();+ }+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Receive_minimal/cc1101_Receive_minimal.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Receive_minimal/cc1101_Receive_minimal.inonew file mode 100644index 00000000..007c5d56--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Receive_minimal/cc1101_Receive_minimal.ino@@ -0,0 +1,58 @@+// These examples are from the Electronics Cookbook by Simon Monk+//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+// mod by Little_S@tan+#include <ELECHOUSE_CC1101_SRC_DRV.h>++int gdo0;++void setup(){++#ifdef ESP32+gdo0 = 2; // for esp32! GDO0 on GPIO pin 2.+#elif ESP8266+gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1.+#else+gdo0 = 6; // for Arduino! GDO0 on pin 6.+#endif++ Serial.begin(9600);++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+ ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.+ ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.+ ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.+ ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.++ Serial.println("Rx Mode");+}+byte buffer[61] = {0};++void loop(){++ if (ELECHOUSE_cc1101.CheckReceiveFlag()){++ if (ELECHOUSE_cc1101.CheckCRC()){ //CRC Check. If "setCrc(false)" crc returns always OK!+ Serial.print("Rssi: ");+ Serial.println(ELECHOUSE_cc1101.getRssi());+ Serial.print("LQI: ");+ Serial.println(ELECHOUSE_cc1101.getLqi());++ int len = ELECHOUSE_cc1101.ReceiveData(buffer);+ buffer[len] = '\0';+ Serial.println((char *) buffer);+ for (int i = 0; i<len; i++){+ Serial.print(buffer[i]);+ Serial.print(",");+ }+ Serial.println();+ }+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Hello_World_advanced/cc1101_Transmitt_Hello_World_advanced.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Hello_World_advanced/cc1101_Transmitt_Hello_World_advanced.inonew file mode 100644index 00000000..b7255b0e--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Hello_World_advanced/cc1101_Transmitt_Hello_World_advanced.ino@@ -0,0 +1,76 @@+// These examples are from the Electronics Cookbook by Simon Monk+//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+// mod by Little_S@tan+#include <ELECHOUSE_CC1101_SRC_DRV.h>++int gdo0;++byte transmitt_byte[11] = {72,101,108,108,111,32,87,111,114,108,100};+char *transmitt_char = "Hello World";++void setup() {++#ifdef ESP32+gdo0 = 2; // for esp32! GDO0 on GPIO pin 2.+#elif ESP8266+gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1.+#else+gdo0 = 6; // for Arduino! GDO0 on pin 6.+#endif++ Serial.begin(9600);++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+ ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.+ ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.+ ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.+ ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.+ ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.+ ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+ ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!+ ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.+ ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)+ ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.+ ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).+ ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.+ ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins.+ ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved+ ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed.+ ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.+ ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.+ ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).+ ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.+ ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable.+ ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24+ ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.+ ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.++ Serial.println("Tx Mode");+}++void loop() {++//3 different methods to send data++//Transmitt "Hello World" from byte format.+ELECHOUSE_cc1101.SendData(transmitt_byte, 11);+delay(2000);++//Transmitt "Hello World" from char format.+ELECHOUSE_cc1101.SendData(transmitt_char);+delay(2000);++//Transmitt "Hello World" from char format directly.+ELECHOUSE_cc1101.SendData("Hello World");+delay(2000);++}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Hello_World_minimal/cc1101_Transmitt_Hello_World_minimal.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Hello_World_minimal/cc1101_Transmitt_Hello_World_minimal.inonew file mode 100644index 00000000..64ca3e5f--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Hello_World_minimal/cc1101_Transmitt_Hello_World_minimal.ino@@ -0,0 +1,55 @@+// These examples are from the Electronics Cookbook by Simon Monk+//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+// mod by Little_S@tan+#include <ELECHOUSE_CC1101_SRC_DRV.h>++int gdo0;++byte transmitt_byte[11] = {72,101,108,108,111,32,87,111,114,108,100};+char *transmitt_char = "Hello World";++void setup() {++#ifdef ESP32+gdo0 = 2; // for esp32! GDO0 on GPIO pin 2.+#elif ESP8266+gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1.+#else+gdo0 = 6; // for Arduino! GDO0 on pin 6.+#endif++ Serial.begin(9600);++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+ ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.+ ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.+ ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.+ // ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.+ Serial.println("Tx Mode");+}++void loop() {++//3 different methods to send data++//Transmitt "Hello World" from byte format.+ELECHOUSE_cc1101.SendData(transmitt_byte, 11);+delay(2000);++//Transmitt "Hello World" from char format.+ELECHOUSE_cc1101.SendData(transmitt_char);+delay(2000);++//Transmitt "Hello World" from char format directly.+ELECHOUSE_cc1101.SendData("Hello World");+delay(2000);+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Serial_advanced/cc1101_Transmitt_Serial_advanced.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Serial_advanced/cc1101_Transmitt_Serial_advanced.inonew file mode 100644index 00000000..b9dd27af--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Serial_advanced/cc1101_Transmitt_Serial_advanced.ino@@ -0,0 +1,75 @@+// These examples are from the Electronics Cookbook by Simon Monk+//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+// mod by Little_S@tan++#include <ELECHOUSE_CC1101_SRC_DRV.h>++int gdo0;++const int n = 61;+byte buffer[n] = "";++void setup() {++#ifdef ESP32+gdo0 = 2; // for esp32! GDO0 on GPIO pin 2.+#elif ESP8266+gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1.+#else+gdo0 = 6; // for Arduino! GDO0 on pin 6.+#endif++ Serial.begin(9600);++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+ ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.+ ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.+ ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.+ ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.+ ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.+ ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+ ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!+ ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.+ ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)+ ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.+ ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).+ ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.+ ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins.+ ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved+ ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed.+ ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.+ ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.+ ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).+ ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.+ ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable.+ ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24+ ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.+ ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.++ Serial.println("Tx Mode");+}++void loop() {++ if (Serial.available()) {+ int len = Serial.readBytesUntil('\n', buffer, n);+ buffer[len] = '\0';+ Serial.println((char *)buffer);+ ELECHOUSE_cc1101.SendData(buffer, len);+ Serial.print("Buffer: ");+ for (int i = 0; i<len; i++){+ Serial.println(buffer[i]);+ }+ Serial.print("len: ");+ Serial.println(len);+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Serial_minimal/cc1101_Transmitt_Serial_minimal.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Serial_minimal/cc1101_Transmitt_Serial_minimal.inonew file mode 100644index 00000000..c936ac29--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Serial_minimal/cc1101_Transmitt_Serial_minimal.ino@@ -0,0 +1,55 @@+// These examples are from the Electronics Cookbook by Simon Monk+//https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+// mod by Little_S@tan++#include <ELECHOUSE_CC1101_SRC_DRV.h>++int gdo0;++const int n = 61;+byte buffer[n] = "";++void setup() {++#ifdef ESP32+gdo0 = 2; // for esp32! GDO0 on GPIO pin 2.+#elif ESP8266+gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1.+#else+gdo0 = 6; // for Arduino! GDO0 on pin 6.+#endif++ Serial.begin(9600);++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+ ELECHOUSE_cc1101.setGDO0(gdo0); // set lib internal gdo pin (gdo0). Gdo2 not use for this example.+ ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode.+ ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.+ // ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.+ Serial.println("Tx Mode");+}++void loop() {++ if (Serial.available()) {+ int len = Serial.readBytesUntil('\n', buffer, n);+ buffer[len] = '\0';+ Serial.println((char *)buffer);+ ELECHOUSE_cc1101.SendData(buffer, len);+ Serial.print("Buffer: ");+ for (int i = 0; i<len; i++){+ Serial.println(buffer[i]);+ }+ Serial.print("len: ");+ Serial.println(len);+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/Receive_Raw_cc1101/Receive_Raw_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/Receive_Raw_cc1101/Receive_Raw_cc1101.inonew file mode 100644index 00000000..1455ee65--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/Receive_Raw_cc1101/Receive_Raw_cc1101.ino@@ -0,0 +1,65 @@+/*+ Basic ESPiLight receive raw (pulse train) signal example++ https://github.com/puuu/espilight+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <ESPiLight.h>++int RECEIVER_PIN; // any intterupt able pin+int TRANSMITTER_PIN;++ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter++// callback function. It is called on successfully received and parsed rc signal+void rfRawCallback(const uint16_t* codes, size_t length) {+ // print pulse lengths+ Serial.print("RAW signal: ");+ for (unsigned int i = 0; i < length; i++) {+ Serial.print(codes[i]);+ Serial.print(' ');+ }+ Serial.println();++ // format of pilight USB Nano+ String data = rf.pulseTrainToString(codes, length);+ Serial.print("string format: ");+ Serial.print(data);+ Serial.println();+}++void setup() {+ Serial.begin(115200);++#ifdef ESP32+RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.+#elif ESP8266+RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.+#else+RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.SetRx(); // set Receive on++ // set callback funktion for raw messages+ rf.setPulseTrainCallBack(rfRawCallback);+ // inittilize receiver+ rf.initReceiver(RECEIVER_PIN);+}++void loop() {+ // process input queue and may fire calllback+ rf.loop();+ delay(10);+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/Receive_cc1101/Receive_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/Receive_cc1101/Receive_cc1101.inonew file mode 100644index 00000000..e4deb8ca--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/Receive_cc1101/Receive_cc1101.ino@@ -0,0 +1,81 @@+/*+ Basic ESPilight receive example++ https://github.com/puuu/espilight+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <ESPiLight.h>++int RECEIVER_PIN; // any intterupt able pin+int TRANSMITTER_PIN;++ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter++// callback function. It is called on successfully received and parsed rc signal+void rfCallback(const String &protocol, const String &message, int status,+ size_t repeats, const String &deviceID) {+ Serial.print("RF signal arrived [");+ Serial.print(protocol); // protocoll used to parse+ Serial.print("][");+ Serial.print(deviceID); // value of id key in json message+ Serial.print("] (");+ Serial.print(status); // status of message, depending on repeat, either:+ // FIRST - first message of this protocoll within the+ // last 0.5 s+ // INVALID - message repeat is not equal to the+ // previous message+ // VALID - message is equal to the previous message+ // KNOWN - repeat of a already valid message+ Serial.print(") ");+ Serial.print(message); // message in json format+ Serial.println();++ // check if message is valid and process it+ if (status == VALID) {+ Serial.print("Valid message: [");+ Serial.print(protocol);+ Serial.print("] ");+ Serial.print(message);+ Serial.println();+ }+}++void setup() {+ Serial.begin(115200);++#ifdef ESP32+RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.+#elif ESP8266+RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.+#else+RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.SetRx(); // set Receive on++ // set callback funktion+ rf.setCallback(rfCallback);+ // inittilize receiver+ rf.initReceiver(RECEIVER_PIN);+}++void loop() {+ // process input queue and may fire calllback+ rf.loop();+ delay(10);+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/Transmit_Raw_cc1101/Transmit_Raw_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/Transmit_Raw_cc1101/Transmit_Raw_cc1101.inonew file mode 100644index 00000000..68085fd3--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/Transmit_Raw_cc1101/Transmit_Raw_cc1101.ino@@ -0,0 +1,58 @@+/*+ Basic ESPiLight transmit RAW signal example++ https://github.com/puuu/espilight+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <ESPiLight.h>++int TRANSMITTER_PIN;+++void setup() {+ Serial.begin(115200);++#ifdef ESP32+TRANSMITTER_PIN = 2; // for esp32! Transmit on GPIO pin 2.+#elif ESP8266+TRANSMITTER_PIN = 5; // for esp8266! Transmit on pin 5 = D1.+#else+TRANSMITTER_PIN = 6; // for Arduino! Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.SetTx(); // cc1101 set Transmit on++ ESPiLight rf(TRANSMITTER_PIN);++ int length = 0;+ uint16_t codes[MAXPULSESTREAMLENGTH];++ // get pulse train from string (format see: pilight USB Nano)+ length = rf.stringToPulseTrain(+ "c:102020202020202020220202020020202200202200202020202020220020202203;p:"+ "279,2511,1395,9486@",+ codes, MAXPULSESTREAMLENGTH);++ // transmit the pulse train+ rf.sendPulseTrain(codes, length);+}++// Toggle state of elro 800 switch evrey 2 s+void loop() {+ // stop+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/Transmit_cc1101/Transmit_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/Transmit_cc1101/Transmit_cc1101.inonew file mode 100644index 00000000..1966a4cf--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/Transmit_cc1101/Transmit_cc1101.ino@@ -0,0 +1,47 @@+/*+ Basic ESPiLight transmit example++ https://github.com/puuu/espilight+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <ESPiLight.h>++int TRANSMITTER_PIN;++void setup() {+ Serial.begin(115200);++#ifdef ESP32+TRANSMITTER_PIN = 2; // for esp32! Transmit on GPIO pin 2.+#elif ESP8266+TRANSMITTER_PIN = 5; // for esp8266! Transmit on pin 5 = D1.+#else+TRANSMITTER_PIN = 6; // for Arduino! Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.SetTx(); // cc1101 set Transmit on+ }++// Toggle state of elro 800 switch evrey 2 s+void loop() {+ ESPiLight rf(TRANSMITTER_PIN);+ rf.send("elro_800_switch", "{\"systemcode\":17,\"unitcode\":1,\"on\":1}");+ delay(2000);+ rf.send("elro_800_switch", "{\"systemcode\":17,\"unitcode\":1,\"off\":1}");+ delay(2000);+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/pilight_debug_cc1101/pilight_debug_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/pilight_debug_cc1101/pilight_debug_cc1101.inonew file mode 100644index 00000000..f2c45256--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/pilight_debug_cc1101/pilight_debug_cc1101.ino@@ -0,0 +1,107 @@+/*+ Basic ESPiLight pilight_debug example++ This example mimic the output of the piligh_debug tool.++ https://github.com/puuu/espilight+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+----------------------------------------------------------+ Mod by Little Satan. Have Fun!+----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <ESPiLight.h>++#define PULSE_DIV 34++int RECEIVER_PIN; // any intterupt able pin+int TRANSMITTER_PIN;++ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter++unsigned int normalize(unsigned int i, unsigned int pulselen) {+ double x;+ x = (double)i / pulselen;++ return (unsigned int)(round(x));+}++// callback function. It is called on successfully received and parsed rc signal+void rfRawCallback(const uint16_t* pulses, size_t length) {+ uint16_t pulse;+ uint16_t pulselen = pulses[length - 1] / PULSE_DIV;+ if (pulselen > 25) {+ for (unsigned int i = 3; i < length; i++) {+ if ((pulses[i] / pulselen) >= 2) {+ pulse = pulses[i];+ break;+ }+ }+ if (normalize(pulse, pulselen) > 0 && length > 25) {+ /* Print everything */+ Serial.println("--[RESULTS]--");+ Serial.println();+ Serial.print("time:\t\t");+ Serial.print(millis());+ Serial.println(" ms");+ Serial.println("hardware:\tESPiLight");+ Serial.print("pulse:\t\t");+ Serial.println(normalize(pulse, pulselen));+ Serial.print("rawlen:\t\t");+ Serial.println(length);+ Serial.printf("pulselen:\t");+ Serial.println(pulselen);+ Serial.println();+ Serial.println("Raw code:");+ for (unsigned int i = 0; i < length; i++) {+ Serial.print(pulses[i]);+ Serial.print(" ");+ }+ Serial.println();+ }+ }+}++void setup() {+ Serial.begin(115200);++#ifdef ESP32+RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.+#elif ESP8266+RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.+#else+RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.SetRx(); // set Receive on++ // set callback funktion for raw messages+ rf.setPulseTrainCallBack(rfRawCallback);+ // inittilize receiver+ rf.initReceiver(RECEIVER_PIN);++ Serial.println(+ "Press and hold one of the buttons on your remote or wait until");+ Serial.println("another device such as a weather station has sent new codes");+ Serial.println(+ "The debugger will automatically reset itself after one second of");+ Serial.println(+ "failed leads. It will keep running until you explicitly stop it.");+}++void loop() {+ // process input queue and may fire calllback+ rf.loop();+ delay(10);+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/pilight_raw_cc1101/pilight_raw_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/pilight_raw_cc1101/pilight_raw_cc1101.inonew file mode 100644index 00000000..6e40e995--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/ESPiLight examples cc1101/pilight_raw_cc1101/pilight_raw_cc1101.ino@@ -0,0 +1,67 @@+/*+ Basic ESPiLight pilight_raw example++ This example mimic the output of the piligh_raw tool.++ https://github.com/puuu/espilight+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <ESPiLight.h>++int RECEIVER_PIN; // any intterupt able pin+int TRANSMITTER_PIN;++ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter++// callback function. It is called on successfully received and parsed rc signal+void rfRawCallback(const uint16_t* pulses, size_t length) {+ Serial.print("ESPiLight:");+ for (unsigned int i = 0; i < length; i++) {+ Serial.print(" ");+ Serial.print(pulses[i]);+ if (pulses[i] > 5100) {+ Serial.printf(" -# ");+ Serial.println(i);+ }+ }+}++void setup() {+ Serial.begin(115200);++#ifdef ESP32+RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.+#elif ESP8266+RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.+#else+RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.SetRx(); // set Receive on++ // set callback funktion for raw messages+ rf.setPulseTrainCallBack(rfRawCallback);+ // inittilize receiver+ rf.initReceiver(RECEIVER_PIN);+}++void loop() {+ // process input queue and may fire calllback+ rf.loop();+ delay(10);+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/LearnCode_cc1101/LearnCode_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/LearnCode_cc1101/LearnCode_cc1101.inonew file mode 100644index 00000000..e022809c--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/LearnCode_cc1101/LearnCode_cc1101.ino@@ -0,0 +1,85 @@+/*+ * Demo for RF remote switch receiver.+ * This example is for the new KaKu / Home Easy type of remotes!+ *+ * For details, see NewRemoteReceiver.h!+ *+ * With this sketch you can control a LED connected to digital pin 4,+ * after the sketch learned the code. After start, the LED starts to blink,+ * until a valid code has been received. The led stops blinking. Now you+ * can control the LED with the remote.+ *+ * Note: only unit-switches are supported in this sketch, no group or dim.+ *+ * Arduino only!+ *+ * https://github.com/1technophile/NewRemoteSwitch+ * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ * ----------------------------------------------------------+ * Mod by Little Satan. Have Fun!+ * ----------------------------------------------------------+ *+ */+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <NewRemoteReceiver.h>+++int pin = 0; // int for Receive pin.+int led = 4; // pin for Led.++boolean codeLearned = false;+unsigned long learnedAddress;+byte learnedUnit;++void setup() {+++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ ELECHOUSE_cc1101.SetRx(); // set Receive on++ // LED-pin as output+ pinMode(led, OUTPUT);++ // Init a new receiver on interrupt pin 0, minimal 2 identical repeats, and callback set to processCode.+ NewRemoteReceiver::init(pin, 2, processCode);+}++void loop() {+ // Blink led until a code has been learned+ if (!codeLearned) {+ digitalWrite(13, HIGH);+ delay(500);+ digitalWrite(13, LOW);+ delay(500);+ }+}++// Callback function is called only when a valid code is received.+void processCode(NewRemoteCode receivedCode) {+ // A code has been received.+ // Do we already know the code?+ if (!codeLearned) {+ // No! Let's learn the received code.+ learnedAddress = receivedCode.address;+ learnedUnit = receivedCode.unit;+ codeLearned = true;+ } else {+ // Yes!+ // Is the received code identical to the learned code?+ if (receivedCode.address == learnedAddress && receivedCode.unit == learnedUnit) {+ // Yes!+ // Switch the LED off if the received code was "off".+ // Anything else (on, dim, on_with_dim) will switch the LED on.+ if (receivedCode.switchType == NewRemoteCode::off) {+ digitalWrite(13, LOW);+ } else {+ digitalWrite(13, HIGH);+ }+ }+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/LightShow_cc1101/LightShow_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/LightShow_cc1101/LightShow_cc1101.inonew file mode 100644index 00000000..30d795fb--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/LightShow_cc1101/LightShow_cc1101.ino@@ -0,0 +1,81 @@+/**+ * Demo for RF remote switch receiver.+ * For details, see NewRemoteReceiver.h!+ *+ * Connect the transmitter to digital pin 6.+ *+ * This sketch demonstrates the use of the NewRemoteTransmitter class.+ *+ * When run, this sketch switches some pre-defined devices on and off in a loop.+ *+ * NOTE: the actual receivers have the address and group numbers in this example+ * are only for demonstration! If you want to duplicate an existing remote, please+ * try the "retransmitter"-example instead.+ *+ * To use this actual example, you'd need to "learn" the used code in the receivers+ * This sketch is unsuited for that.+ *+ *+ * https://github.com/1technophile/NewRemoteSwitch+ * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ * ----------------------------------------------------------+ * Mod by Little Satan. Have Fun!+ * ----------------------------------------------------------+ *+ */+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <NewRemoteTransmitter.h>++int pin; // int for Transmit pin.++void setup() {++#ifdef ESP32+pin = 2; // for esp32! Transmit on GPIO pin 2.+#elif ESP8266+pin = 5; // for esp8266! Transmit on pin 5 = D1+#else+pin = 6; // for Arduino! Transmit on pin 6.+#endif++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ ELECHOUSE_cc1101.SetTx(); // cc1101 set Transmit on+}++void loop() {++ // Create a transmitter on address 123, using digital pin 6 to transmit,+ // with a period duration of 260ms (default), repeating the transmitted+ // code 2^3=8 times.+ NewRemoteTransmitter transmitter(123, pin, 260, 3);++ // Switch unit 2 off+ transmitter.sendUnit(2, false);++ // Switch all devices in the group off+ transmitter.sendGroup(false);++ // Set unit 1 to dim-level 3 (range 0-15)+ transmitter.sendDim(1, 3);++ // Wait 5 seconds+ delay(5000);+++ // Switch unit 2 on+ transmitter.sendUnit(2, true);++ // Switch all devices in the group on+ transmitter.sendGroup(true);++ // Set unit 1 to dim-level 15, full brightness.+ transmitter.sendDim(1, 15);++ // Wait 5 seconds+ delay(5000);+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/NewRemoteRepeater/NewRemoteRepeater.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/NewRemoteRepeater/NewRemoteRepeater.inonew file mode 100644index 00000000..6fb085dc--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/NewRemoteRepeater/NewRemoteRepeater.ino@@ -0,0 +1,115 @@+/*+ * Demo for RF remote switch receiver.+ * For details, see NewRemoteReceiver.h!+ *+ *+ * When run, this sketch waits for a valid code from a new-style the receiver,+ * decodes it, and retransmits it after 1 seconds.+ *+ *+ * https://github.com/1technophile/NewRemoteSwitch+ * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ * ----------------------------------------------------------+ * Written by Roman.(Arduino Forum) THX!+ * Mod by Little Satan. Have Fun!+ * ----------------------------------------------------------+ */++#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <NewRemoteReceiver.h>+#include <NewRemoteTransmitter.h>++int pinTx; // int for Receive pin.+int pinRx; // int for Receive pin.+int Interr = 2; // Interrupt Numer+int Anz = 3; // number of retransmissions+int Tw = 0; // Wait Miliseconds before sending++int debug = 1; // Debugmode ein (1)/aus(0)++void setup() {+Serial.begin(115200);++#ifdef ESP32+pinRx = 4; pinTx = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.+#elif ESP8266+pinRx = 4; pinTx = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.+#else+pinRx = 0; pinTx = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++++ ELECHOUSE_cc1101.SetRx(); // set Receive on+ // See example ShowReceivedCode for info on this+ NewRemoteReceiver::init(pinRx, Interr, ReTrans);+ if (debug == 1) {Serial.println("Receiver initialized... ");}}++void loop() {+}++ void ReTrans(unsigned int period, unsigned long address, unsigned long groupBit, unsigned long unit, unsigned long switchType){ // Disable the receiver; otherwise it might pick up the retransmit as well.++ if (debug == 1) {+ // Print the received code.+ Serial.print("Receiver: ");+ Serial.print("Code: ");+ Serial.print(address);+ Serial.print(" unit: ");+ Serial.print(unit);+ Serial.print(" switchType: ");+ Serial.print(switchType);+ Serial.print(" Period: ");+ Serial.print(period);+ Serial.print(" groupBit: ");+ Serial.println(groupBit);+ }++++ if (debug == 1) {Serial.print("Send: Receiver disable... ");}+ NewRemoteReceiver::disable();++ // Need interrupts for delay()+ interrupts();++ if (debug == 1) {Serial.print("Wait... ");}++ // Wait 1 seconds before sending.+ delay(Tw);++++ ELECHOUSE_cc1101.SetTx(); // set Transmit on+ // Create a new transmitter with the received address and period, use digital pin as output pin+ NewRemoteTransmitter transmitter(address, pinTx, period, Anz);+ if (debug == 1) {Serial.print("Send: Addr " + String(address) + " unit " + String(unit)+" "+ String(switchType)+", period: "+String(period)+" " );}++ // On/Off signal received+ bool isOn = switchType == NewRemoteCode::on;++ if (groupBit) {+ // Send to the group+ transmitter.sendGroup(isOn);+ }+ else {+ // Send to a single unit+ transmitter.sendUnit(unit, isOn);+ }++ if (debug == 1) {Serial.println("Receiver enable!");}+ ELECHOUSE_cc1101.SetRx(); // set Receive on+ NewRemoteReceiver::enable();+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/Retransmitter_cc1101/Retransmitter_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/Retransmitter_cc1101/Retransmitter_cc1101.inonew file mode 100644index 00000000..ae720d79--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/Retransmitter_cc1101/Retransmitter_cc1101.ino@@ -0,0 +1,80 @@+/*+ * Demo for RF remote switch receiver.+ * For details, see NewRemoteReceiver.h!+ *+ *+ * When run, this sketch waits for a valid code from a new-style the receiver,+ * decodes it, and retransmits it after 5 seconds.+ *+ * Notes: Arduino only!!!+ *+ * https://github.com/1technophile/NewRemoteSwitch+ * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ * ----------------------------------------------------------+ * Mod by Little Satan. Have Fun!+ * ----------------------------------------------------------+ */++#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <NewRemoteReceiver.h>+#include <NewRemoteTransmitter.h>++void setup() {++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ ELECHOUSE_cc1101.SetRx(); // set Receive on++ // See example ShowReceivedCode for info on this+ NewRemoteReceiver::init(0, 2, retransmitter);+}++void loop() {+}++void retransmitter(NewRemoteCode receivedCode) {+ // Disable the receiver; otherwise it might pick up the retransmit as well.+ NewRemoteReceiver::disable();++ // Need interrupts for delay()+ interrupts();++ // Wait 5 seconds before sending.+ delay(5000);++ // Create a new transmitter with the received address and period, use digital pin as output pin++ ELECHOUSE_cc1101.SetTx(); // set Transmit on+ NewRemoteTransmitter transmitter(receivedCode.address, 6, receivedCode.period);++ if (receivedCode.switchType == NewRemoteCode::dim ||+ (receivedCode.switchType == NewRemoteCode::on && receivedCode.dimLevelPresent)) {+ // Dimmer signal received++ if (receivedCode.groupBit) {+ transmitter.sendGroupDim(receivedCode.dimLevel);+ }+ else {+ transmitter.sendDim(receivedCode.unit, receivedCode.dimLevel);+ }+ }+ else {+ // On/Off signal received+ bool isOn = receivedCode.switchType == NewRemoteCode::on;++ if (receivedCode.groupBit) {+ // Send to the group+ transmitter.sendGroup(isOn);+ }+ else {+ // Send to a single unit+ transmitter.sendUnit(receivedCode.unit, isOn);+ }+ }+ ELECHOUSE_cc1101.SetRx(); // set Receive on+ NewRemoteReceiver::enable();+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/ShowReceivedCode_cc1101/ShowReceivedCode_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/ShowReceivedCode_cc1101/ShowReceivedCode_cc1101.inonew file mode 100644index 00000000..7563ea61--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/NewRemoteSwitch examples cc1101/ShowReceivedCode_cc1101/ShowReceivedCode_cc1101.ino@@ -0,0 +1,75 @@+/*+* Demo for RF remote switch receiver.+* For details, see RemoteReceiver.h!+*+* This sketch shows the received signals on the serial port.+* Connect the receiver to digital pin 2 on arduino and digital pin 1 on ESP8266.+*+*+*Detected codes example:+ code: 8233372 Period: 273+ unit: 1+ groupBit: 0+ switchType: 0+*+* https://github.com/1technophile/NewRemoteSwitch+* https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+* ----------------------------------------------------------+* Mod by Little Satan. Have Fun!+* ----------------------------------------------------------+*+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <NewRemoteReceiver.h>++int pin; // int for Receive pin.++void setup() {+ Serial.begin(115200);++#ifdef ESP32+pin = 4; // for esp32! Receiver on GPIO pin 4.+#elif ESP8266+pin = 4; // for esp8266! Receiver on pin 4 = D2.+#else+pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ ELECHOUSE_cc1101.SetRx(); // set Receive on++ NewRemoteReceiver::init(pin, 2, showCode);+ Serial.println("Receiver initialized");+}++void loop() {++}++// Callback function is called only when a valid code is received.+void showCode(unsigned int period, unsigned long address, unsigned long groupBit, unsigned long unit, unsigned long switchType) {++ // Print the received code.+ Serial.print("Code: ");+ Serial.print(address);+ Serial.print(" Period: ");+ Serial.println(period);+ Serial.print(" unit: ");+ Serial.println(unit);+ Serial.print(" groupBit: ");+ Serial.println(groupBit);+ Serial.print(" switchType: ");+ Serial.println(switchType);++}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ProtocolAnalyzeDemo_cc1101/ProtocolAnalyzeDemo_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ProtocolAnalyzeDemo_cc1101/ProtocolAnalyzeDemo_cc1101.inonew file mode 100644index 00000000..2bfb5d83--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ProtocolAnalyzeDemo_cc1101/ProtocolAnalyzeDemo_cc1101.ino@@ -0,0 +1,131 @@+/*+ Example for analyzing and proposing unknown new protocols++ Requires modified rc-switch branch "protocollessreceiver"+ with ReceivedInverted() function exposed.++ https://github.com/Martin-Laclaustra/rc-switch/tree/protocollessreceiver+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib++ ----------------------------------------------------------+ CC1101 Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/++#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <RCSwitch.h>++int pin; // int for Receive pin.++RCSwitch mySwitch = RCSwitch();++void setup() {+ Serial.begin(9600);++#ifdef ESP32+pin = 4; // for esp32! Receiver on GPIO pin 4.+#elif ESP8266+pin = 4; // for esp8266! Receiver on pin 4 = D2.+#else+pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ mySwitch.enableReceive(pin); // Receiver on++ ELECHOUSE_cc1101.SetRx(); // set Receive on++}++void loop() {+ if (mySwitch.available()) {++ int value = mySwitch.getReceivedValue();++ if (value == 0) {+ Serial.print("Unknown encoding");+ } else {++ int databuffer[64]; // get a copy of the received timings before they are overwritten+ int numberoftimings = 2 * mySwitch.getReceivedBitlength() + 2;+ if(numberoftimings > 64) numberoftimings = 64;+ for (int i = 0; i < numberoftimings; i++) {+ databuffer[i] = mySwitch.getReceivedRawdata()[i];+ }++ Serial.print("Received ");+ Serial.print( mySwitch.getReceivedValue() );+ Serial.print(" / ");+ Serial.print( mySwitch.getReceivedBitlength() );+ Serial.print("bit ");+ Serial.print("Protocol: ");+ Serial.println( mySwitch.getReceivedProtocol() );++ unsigned int databitsoffset = abs( (int)mySwitch.getReceivedLevelInFirstTiming() - (int)mySwitch.getReceivedInverted());+ //Serial.println( mySwitch.getReceivedLevelInFirstTiming() );+ //Serial.println( mySwitch.getReceivedInverted() );+ //Serial.println( databitsoffset );+ unsigned long dataduration = 0;+ for (unsigned int i = 1 + databitsoffset; i < numberoftimings - 1 + databitsoffset; i++) {+ dataduration += databuffer[i];+ }+ Serial.print("data bits of pulse train duration: ");+ Serial.println( dataduration );+ unsigned int averagebitduration = (int)(0.5 + ((double)dataduration)/mySwitch.getReceivedBitlength());+ unsigned int protocolratio = (unsigned int)(0.5 + ((double)(averagebitduration - mySwitch.getReceivedDelay())) / (double)mySwitch.getReceivedDelay());+ Serial.print("proposed protocol: { ");+ Serial.print(mySwitch.getReceivedDelay());+ Serial.print(", { ");+ Serial.print( (databitsoffset==0) ?+ (int) (0.5 + (double)databuffer[2*mySwitch.getReceivedBitlength()+1]/(double)mySwitch.getReceivedDelay())+ :+ (int) (0.5 + (double)databuffer[0]/(double)mySwitch.getReceivedDelay())+ );+ Serial.print(", ");+ Serial.print( (databitsoffset==0) ?+ (int) (0.5 + (double)databuffer[0]/(double)mySwitch.getReceivedDelay())+ :+ (int) (0.5 + (double)databuffer[1]/(double)mySwitch.getReceivedDelay())+ );+ Serial.print(" }, { ");+ Serial.print("1");+ Serial.print(", ");+ Serial.print(protocolratio);+ Serial.print(" }, { ");+ Serial.print(protocolratio);+ Serial.print(", ");+ Serial.print("1");+ Serial.print(" }, ");+ Serial.print((mySwitch.getReceivedInverted()) ? "true" : "false" );+ Serial.println(" }");++ // raw signal+ Serial.println("====");+ Serial.print("first level ");+ Serial.println((mySwitch.getReceivedLevelInFirstTiming() == 0) ? "down" : "up" );+ for (int i = 0; i < 2*mySwitch.getReceivedBitlength()+2 - 1 + databitsoffset; i++) {+ Serial.print(databuffer[i]);+ Serial.print(" ");+ if((i - databitsoffset) % 16 == 0) Serial.println("");+ }+ if ((2*mySwitch.getReceivedBitlength()+2 - 1 + databitsoffset - 1) % 16 != 0) Serial.println("");+ if (databitsoffset != 1) Serial.println(databuffer[2*mySwitch.getReceivedBitlength()+1]);+ // plot signal in spreadsheet+ Serial.println("====");++ }++ mySwitch.resetAvailable();+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ReceiveDemo_Advanced_cc1101/ReceiveDemo_Advanced_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ReceiveDemo_Advanced_cc1101/ReceiveDemo_Advanced_cc1101.inonew file mode 100644index 00000000..90c29fae--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ReceiveDemo_Advanced_cc1101/ReceiveDemo_Advanced_cc1101.ino@@ -0,0 +1,52 @@+/*+ Example for receiving++ https://github.com/sui77/rc-switch/+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ If you want to visualize a telegram copy the raw data and+ paste it into http://test.sui.li/oszi/+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <RCSwitch.h>++int pin; // int for Receive pin.++RCSwitch mySwitch = RCSwitch();++void setup() {+ Serial.begin(9600);++#ifdef ESP32+pin = 4; // for esp32! Receiver on GPIO pin 4.+#elif ESP8266+pin = 4; // for esp8266! Receiver on pin 4 = D2.+#else+pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ mySwitch.enableReceive(pin); // Receiver on interrupt 0 => that is pin #2++ ELECHOUSE_cc1101.SetRx(); // set Receive on+}++void loop() {+ if (mySwitch.available()) {+ output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol());+ mySwitch.resetAvailable();+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ReceiveDemo_Advanced_cc1101/output.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ReceiveDemo_Advanced_cc1101/output.inonew file mode 100644index 00000000..31e61ba6--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ReceiveDemo_Advanced_cc1101/output.ino@@ -0,0 +1,70 @@+static const char* bin2tristate(const char* bin);+static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength);++void output(unsigned long decimal, unsigned int length, unsigned int delay, unsigned int* raw, unsigned int protocol) {++ const char* b = dec2binWzerofill(decimal, length);+ Serial.print("Decimal: ");+ Serial.print(decimal);+ Serial.print(" (");+ Serial.print( length );+ Serial.print("Bit) Binary: ");+ Serial.print( b );+ Serial.print(" Tri-State: ");+ Serial.print( bin2tristate( b) );+ Serial.print(" PulseLength: ");+ Serial.print(delay);+ Serial.print(" microseconds");+ Serial.print(" Protocol: ");+ Serial.println(protocol);++ Serial.print("Raw data: ");+ for (unsigned int i=0; i<= length*2; i++) {+ Serial.print(raw[i]);+ Serial.print(",");+ }+ Serial.println();+ Serial.println();+}++static const char* bin2tristate(const char* bin) {+ static char returnValue[50];+ int pos = 0;+ int pos2 = 0;+ while (bin[pos]!='\0' && bin[pos+1]!='\0') {+ if (bin[pos]=='0' && bin[pos+1]=='0') {+ returnValue[pos2] = '0';+ } else if (bin[pos]=='1' && bin[pos+1]=='1') {+ returnValue[pos2] = '1';+ } else if (bin[pos]=='0' && bin[pos+1]=='1') {+ returnValue[pos2] = 'F';+ } else {+ return "not applicable";+ }+ pos = pos+2;+ pos2++;+ }+ returnValue[pos2] = '\0';+ return returnValue;+}++static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength) {+ static char bin[64];+ unsigned int i=0;++ while (Dec > 0) {+ bin[32+i++] = ((Dec & 1) > 0) ? '1' : '0';+ Dec = Dec >> 1;+ }++ for (unsigned int j = 0; j< bitLength; j++) {+ if (j >= bitLength - i) {+ bin[j] = bin[ 31 + i - (j - (bitLength - i)) ];+ } else {+ bin[j] = '0';+ }+ }+ bin[bitLength] = '\0';++ return bin;+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ReceiveDemo_Simple_cc1101/ReceiveDemo_Simple_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ReceiveDemo_Simple_cc1101/ReceiveDemo_Simple_cc1101.inonew file mode 100644index 00000000..0bdfbb2e--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ReceiveDemo_Simple_cc1101/ReceiveDemo_Simple_cc1101.ino@@ -0,0 +1,60 @@+/*+ Simple example for receiving++ https://github.com/sui77/rc-switch/+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <RCSwitch.h>++int pin; // int for Receive pin.++RCSwitch mySwitch = RCSwitch();++void setup() {+ Serial.begin(9600);++#ifdef ESP32+pin = 4; // for esp32! Receiver on GPIO pin 4.+#elif ESP8266+pin = 4; // for esp8266! Receiver on pin 4 = D2.+#else+pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+++ mySwitch.enableReceive(pin); // Receiver on++ ELECHOUSE_cc1101.SetRx(); // set Receive on++}+void loop() {++ if (mySwitch.available()){++ Serial.print("Received ");+ Serial.print( mySwitch.getReceivedValue() );+ Serial.print(" / ");+ Serial.print( mySwitch.getReceivedBitlength() );+ Serial.print("bit ");+ Serial.print("Protocol: ");+ Serial.println( mySwitch.getReceivedProtocol() );++ mySwitch.resetAvailable();+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ReceiveDemo_Simple_with_RSSI_cc1101/ReceiveDemo_Simple_with_RSSI_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ReceiveDemo_Simple_with_RSSI_cc1101/ReceiveDemo_Simple_with_RSSI_cc1101.inonew file mode 100644index 00000000..983af7f2--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/ReceiveDemo_Simple_with_RSSI_cc1101/ReceiveDemo_Simple_with_RSSI_cc1101.ino@@ -0,0 +1,62 @@+/*+ Simple example for receiving with Rssi output.++ https://github.com/sui77/rc-switch/+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <RCSwitch.h>++int pin; // int for Receive pin.++RCSwitch mySwitch = RCSwitch();++void setup() {+ Serial.begin(9600);++#ifdef ESP32+pin = 4; // for esp32! Receiver on GPIO pin 4.+#elif ESP8266+pin = 4; // for esp8266! Receiver on pin 4 = D2.+#else+pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ mySwitch.enableReceive(pin); // Receiver on++ ELECHOUSE_cc1101.SetRx(); // set Receive on++}+void loop() {++ if (mySwitch.available()){++ Serial.print("Received ");+ Serial.print( mySwitch.getReceivedValue() );+ Serial.print(" / ");+ Serial.print( mySwitch.getReceivedBitlength() );+ Serial.print("bit ");+ Serial.print("Protocol: ");+ Serial.println( mySwitch.getReceivedProtocol() );++ Serial.print("RSSI: ");+ Serial.println(ELECHOUSE_cc1101.getRssi());++ mySwitch.resetAvailable();+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING ESP32.png b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING ESP32.pngnew file mode 100644index 00000000..b3968981Binary files /dev/null and b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING ESP32.png differdiff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING ESP8266.png b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING ESP8266.pngnew file mode 100644index 00000000..73a44d46Binary files /dev/null and b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING ESP8266.png differdiff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING NANO_UNO.png b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING NANO_UNO.pngnew file mode 100644index 00000000..69a9647dBinary files /dev/null and b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING NANO_UNO.png differdiff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/Receive_Send_Decimal_Demo_Simple.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/Receive_Send_Decimal_Demo_Simple.inonew file mode 100644index 00000000..19308749--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/Receive_Send_Decimal_Demo_Simple.ino@@ -0,0 +1,118 @@+/*+ Simple example for Receiving and Transmit decimal code for cc1101++ https://github.com/sui77/rc-switch/+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <RCSwitch.h>++int pinRx; // int for Receive pin.+int pinTx; // int for Transmit pin.++RCSwitch mySwitch = RCSwitch();++int buttonPin; // for button pin.+int buttonState = 0; // button state+int ccSetRx = 0; // reset state for Receive+int long value = 5393; // int to save value+int bits = 24; // int to save bit number+int prot = 1; // int to save Protocol number+int puls = 320; // int to save pulse length++void setup() {+ Serial.begin(9600);++#ifdef ESP32+pinRx = 4; pinTx = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.+buttonPin = 34; // set button on GPIO pin 34.+#elif ESP8266+pinRx = 4; pinTx = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.+buttonPin = 16; // set button on pin 16 = D0.+#else+pinRx = 0; pinTx = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.+buttonPin = 4; // set button on pin D4.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ pinMode(buttonPin, INPUT); // set pin4 as input++}+void loop() {++ buttonState = digitalRead(buttonPin); // read digital pin and save the state to int+++ if (buttonState == HIGH) { // the button is pressed. Set transmit on.++ ccSetRx = 0; // set resetstate to 0 for next reinit to Recive+ ELECHOUSE_cc1101.SetTx(); // set Transmit on+ mySwitch.disableReceive(); // Receiver off+ mySwitch.enableTransmit(pinTx); // Transmit on++ mySwitch.setRepeatTransmit(3); // transmission repetitions.+ mySwitch.setProtocol(prot); // send Received Protocol+ mySwitch.setPulseLength(puls);// send Received Delay+ mySwitch.send(value, bits); // send Received value/bits++ Serial.print("Transmit ");+ Serial.print( value );+ Serial.print(" / ");+ Serial.print( bits );+ Serial.print("bit ");+ Serial.print("Protocol: ");+ Serial.print( prot );+ Serial.print(" Delay: ");+ Serial.println( puls );+ }+++ if (buttonState == LOW && ccSetRx == 0){ //the button is not pressed. set cc1101 to Receive.++ ELECHOUSE_cc1101.SetRx(); // set Receive on+ mySwitch.disableTransmit(); // set Transmit off+ mySwitch.enableReceive(pinRx); // Receiver on+ ccSetRx = 1;+ }++ if (buttonState == LOW && ccSetRx == 1) { //the button is not pressed and set receive is finish. Receive values.++++ if (mySwitch.available()){++ Serial.print("Received ");+ Serial.print( mySwitch.getReceivedValue() );+ Serial.print(" / ");+ Serial.print( mySwitch.getReceivedBitlength() );+ Serial.print("bit ");+ Serial.print("Protocol: ");+ Serial.print( mySwitch.getReceivedProtocol() );+ Serial.print(" Delay: ");+ Serial.println( mySwitch.getReceivedDelay() );++ value = mySwitch.getReceivedValue(); // save received Value+ bits = mySwitch.getReceivedBitlength(); // save received Bitlength+ prot = mySwitch.getReceivedProtocol(); // save received Protocol+ puls = mySwitch.getReceivedDelay(); // save received pulse length++ mySwitch.resetAvailable();++ }+ }++}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Repeater_cc1101/Repeater_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Repeater_cc1101/Repeater_cc1101.inonew file mode 100644index 00000000..1ff4e083--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/Repeater_cc1101/Repeater_cc1101.ino@@ -0,0 +1,83 @@+/*+ Simple example for repeating decimal code for cc1101++ https://github.com/sui77/rc-switch/+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <RCSwitch.h>++int pinRx; // int for Receive pin.+int pinTx; // int for Transmit pin.++RCSwitch mySwitch = RCSwitch();++int number = 15; // set number of transmission repetitions.+int TIME = 3000; // set delay befor repeat. For direct repetition after receive set 0.++void setup() {+ Serial.begin(9600);++#ifdef ESP32+pinRx = 4; pinTx = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.+#elif ESP8266+pinRx = 4; pinTx = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.+#else+pinRx = 0; pinTx = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ ELECHOUSE_cc1101.SetRx(); // set Receive on+ mySwitch.enableReceive(pinRx); // Receiver on++}+void loop() {++ if (mySwitch.available()){++ Serial.print("Received ");+ Serial.print( mySwitch.getReceivedValue() );+ Serial.print(" / ");+ Serial.print( mySwitch.getReceivedBitlength() );+ Serial.print("bit ");+ Serial.print("Protocol: ");+ Serial.print( mySwitch.getReceivedProtocol() );+ Serial.print(" Delay: ");+ Serial.println( mySwitch.getReceivedDelay() );++ delay(TIME);+ mySwitch.disableReceive(); // Receiver off+ mySwitch.enableTransmit(pinTx); // Transmit on+ ELECHOUSE_cc1101.SetTx(); // set Transmit on++ Serial.println("Transmit");++ mySwitch.setRepeatTransmit(number); // transmission repetitions.+ mySwitch.setProtocol(mySwitch.getReceivedProtocol()); // send Received Protocol+ mySwitch.setPulseLength(mySwitch.getReceivedDelay()); // send Received Delay+ mySwitch.send(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength()); // send Received value/bits++ ELECHOUSE_cc1101.SetRx(); // set Receive on+ mySwitch.disableTransmit(); // set Transmit off+ mySwitch.enableReceive(pinRx); // Receiver on++ Serial.println("Receive");++ mySwitch.resetAvailable();++ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/SendDemo_cc1101/SendDemo_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/SendDemo_cc1101/SendDemo_cc1101.inonew file mode 100644index 00000000..2d88fb46--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/SendDemo_cc1101/SendDemo_cc1101.ino@@ -0,0 +1,84 @@+/*+ Example for different sending methods++ https://github.com/sui77/rc-switch/+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <RCSwitch.h>++int pin; // int for Transmit pin.++RCSwitch mySwitch = RCSwitch();++void setup() {+ Serial.begin(9600);++#ifdef ESP32+pin = 2; // for esp32! Transmit on GPIO pin 2.+#elif ESP8266+pin = 5; // for esp8266! Transmit on pin 5 = D1+#else+pin = 6; // for Arduino! Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ // Transmitter on+ mySwitch.enableTransmit(pin);++ // cc1101 set Transmit on+ ELECHOUSE_cc1101.SetTx();++ // Optional set protocol (default is 1, will work for most outlets)+ // mySwitch.setProtocol(2);++ // Optional set pulse length.+ // mySwitch.setPulseLength(320);++ // Optional set number of transmission repetitions.+ // mySwitch.setRepeatTransmit(15);++}++void loop() {++ /* See Example: TypeA_WithDIPSwitches */+ mySwitch.switchOn("11111", "00010");+ delay(1000);+ mySwitch.switchOff("11111", "00010");+ delay(1000);++ /* Same switch as above, but using decimal code */+ mySwitch.send(5393, 24);+ delay(1000);+ mySwitch.send(5396, 24);+ delay(1000);++ /* Same switch as above, but using binary code */+ mySwitch.send("000000000001010100010001");+ delay(1000);+ mySwitch.send("000000000001010100010100");+ delay(1000);++ /* Same switch as above, but tri-state code */+ mySwitch.sendTriState("00000FFF0F0F");+ delay(1000);+ mySwitch.sendTriState("00000FFF0FF0");+ delay(1000);++ delay(20000);+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/TypeA_WithDIPSwitches_cc1101/TypeA_WithDIPSwitches_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/TypeA_WithDIPSwitches_cc1101/TypeA_WithDIPSwitches_cc1101.inonew file mode 100644index 00000000..eda71bff--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/TypeA_WithDIPSwitches_cc1101/TypeA_WithDIPSwitches_cc1101.ino@@ -0,0 +1,71 @@+/*+ Example for outlets which are configured with a 10 pole DIP switch.++ https://github.com/sui77/rc-switch/+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <RCSwitch.h>++int pin; // int for Transmit pin.++RCSwitch mySwitch = RCSwitch();++void setup() {+ Serial.begin(9600);++#ifdef ESP32+pin = 2; // for esp32! Transmit on GPIO pin 2.+#elif ESP8266+pin = 5; // for esp8266! Transmit on pin 5 = D1+#else+pin = 6; // for Arduino! Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ // Transmitter on+ mySwitch.enableTransmit(pin);++ // cc1101 set Transmit on+ ELECHOUSE_cc1101.SetTx();+++ // Optional set pulse length.+ // mySwitch.setPulseLength(320);++}++void loop() {++ // Switch on:+ // The first parameter represents the setting of the first 5 DIP switches.+ // In this example it's ON-ON-OFF-OFF-ON.+ //+ // The second parameter represents the setting of the last 5 DIP switches.+ // In this example the last 5 DIP switches are OFF-ON-OFF-ON-OFF.+ mySwitch.switchOn("11001", "01010");++ // Wait a second+ delay(1000);++ // Switch off+ mySwitch.switchOff("11001", "01010");++ // Wait another second+ delay(1000);++}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/TypeB_WithRotaryOrSlidingSwitches_cc1101/TypeB_WithRotaryOrSlidingSwitches_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/TypeB_WithRotaryOrSlidingSwitches_cc1101/TypeB_WithRotaryOrSlidingSwitches_cc1101.inonew file mode 100644index 00000000..66b4d4c3--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/TypeB_WithRotaryOrSlidingSwitches_cc1101/TypeB_WithRotaryOrSlidingSwitches_cc1101.ino@@ -0,0 +1,70 @@+/*+ Example for outlets which are configured with two rotary/sliding switches.++ https://github.com/sui77/rc-switch/+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <RCSwitch.h>++int pin; // int for Transmit pin.++RCSwitch mySwitch = RCSwitch();++void setup() {+ Serial.begin(9600);++#ifdef ESP32+pin = 2; // for esp32! Transmit on GPIO pin 2.+#elif ESP8266+pin = 5; // for esp8266! Transmit on pin 5 = D1+#else+pin = 6; // for Arduino! Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ // Transmitter on+ mySwitch.enableTransmit(pin);++ // cc1101 set Transmit on+ ELECHOUSE_cc1101.SetTx();++ // Optional set pulse length.+ // mySwitch.setPulseLength(320);++}++void loop() {++ // Switch on:+ // The first parameter represents the setting of the first rotary switch.+ // In this example it's switched to "1" or "A" or "I".+ //+ // The second parameter represents the setting of the second rotary switch.+ // In this example it's switched to "4" or "D" or "IV".+ mySwitch.switchOn(1, 4);++ // Wait a second+ delay(1000);++ // Switch off+ mySwitch.switchOff(1, 4);++ // Wait another second+ delay(1000);++}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/TypeC_Intertechno_cc1101/TypeC_Intertechno_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/TypeC_Intertechno_cc1101/TypeC_Intertechno_cc1101.inonew file mode 100644index 00000000..afe45736--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/TypeC_Intertechno_cc1101/TypeC_Intertechno_cc1101.ino@@ -0,0 +1,70 @@+/*+ Example for Intertechno outlets++ https://github.com/sui77/rc-switch/+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <RCSwitch.h>++int pin; // int for Transmit pin.++RCSwitch mySwitch = RCSwitch();++void setup() {+ Serial.begin(9600);++#ifdef ESP32+pin = 2; // for esp32! Transmit on GPIO pin 2.+#elif ESP8266+pin = 5; // for esp8266! Transmit on pin 5 = D1+#else+pin = 6; // for Arduino! Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ // Transmitter on+ mySwitch.enableTransmit(pin);++ // cc1101 set Transmit on+ ELECHOUSE_cc1101.SetTx();++ // Optional set pulse length.+ // mySwitch.setPulseLength(320);++}++void loop() {++ // Switch on:+ // The first parameter represents the familycode (a, b, c, ... f)+ // The second parameter represents the group number+ // The third parameter represents the device number+ //+ // In this example it's family 'b', group #3, device #2+ mySwitch.switchOn('b', 3, 2);++ // Wait a second+ delay(1000);++ // Switch off+ mySwitch.switchOff('b', 3, 2);++ // Wait another second+ delay(1000);++}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/TypeD_REV_cc1101/TypeD_REV_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/TypeD_REV_cc1101/TypeD_REV_cc1101.inonew file mode 100644index 00000000..316e1e88--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/Rc-Switch examples cc1101/TypeD_REV_cc1101/TypeD_REV_cc1101.ino@@ -0,0 +1,71 @@+/*+ Example for REV outlets (e.g. 8342L)++ https://github.com/sui77/rc-switch/+ https://github.com/LSatan/SmartRC-CC1101-Driver-Lib++ Need help? http://forum.ardumote.com+ ----------------------------------------------------------+ Mod by Little Satan. Have Fun!+ ----------------------------------------------------------+*/+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <RCSwitch.h>++int pin; // int for Transmit pin.++RCSwitch mySwitch = RCSwitch();++void setup() {+ Serial.begin(9600);++#ifdef ESP32+pin = 2; // for esp32! Transmit on GPIO pin 2.+#elif ESP8266+pin = 5; // for esp8266! Transmit on pin 5 = D1+#else+pin = 6; // for Arduino! Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ // Transmitter on+ mySwitch.enableTransmit(pin);++ // cc1101 set Transmit on+ ELECHOUSE_cc1101.SetTx();++ // set pulse length.+ mySwitch.setPulseLength(360);++}++void loop() {++ // Switch on:+ // The first parameter represents the channel (a, b, c, d)+ // The second parameter represents the device number+ //+ // In this example it's family 'd', device #2+ mySwitch.switchOn('d', 2);++ // Wait a second+ delay(1000);++ // Switch off+ mySwitch.switchOff('d', 2);++ // Wait another second+ delay(1000);++}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/RemoteSensor examples cc1101/Repeater_cc1101/Repeater_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/RemoteSensor examples cc1101/Repeater_cc1101/Repeater_cc1101.inonew file mode 100644index 00000000..ecdbfb25--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/RemoteSensor examples cc1101/Repeater_cc1101/Repeater_cc1101.ino@@ -0,0 +1,87 @@+/*+ * This sketch simply repeats data received from remote weather sensors made by Cresta.+ *+ * Setup:+ * - connect digital output of a 433MHz receiver to digital pin 2 of Arduino.+ * - connect transmitter input of a 433MHz transmitter to digital pin 11+ * - An LED on pin 13 will tell you if and when a signal has been received and transmitted.+ *+ * Library:+ * https://github.com/mattwire/arduino-dev/tree/master/libraries/RemoteSensor+ * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ *+ */++#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <SensorReceiver.h>+#include <SensorTransmitter.h>++int LED_PIN;+int pinRx; // int for Receive pin.+int pinTx; // int for Transmit pin.++void setup() {++#ifdef ESP32+pinRx = 4; pinTx = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2.+LED_PIN = 32; // set led on GPIO pin 32.+#elif ESP8266+pinRx = 4; pinTx = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1.+LED_PIN = 16; // set led on pin 16 = D0.+#else+pinRx = 0; pinTx = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6.+LED_PIN = 4; // set led on pin D4.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.++ pinMode(LED_PIN, OUTPUT);++ // Since we're not instantiating SensorTransmitter, but only use the static methods of SensorTransmitter,+ // the pin mode must be set manually.+ pinMode(pinTx, OUTPUT);++ // When no signal has been received, the LED is lit.+ digitalWrite(LED_PIN, HIGH);++ // Init the receiver on interrupt pin 0 (digital pin 2).+ // Set the callback to function "retransmit", which is called+ // whenever valid sensor data has been received.+ ELECHOUSE_cc1101.SetRx(); // set Receive on+ SensorReceiver::init(pinRx, retransmit);+}++void loop() {+}++void retransmit(byte *data) {+ // Data received++ // Wait a second after a receiving. There's little point for decoding and sending the same signal multiple times.+ SensorReceiver::disable();+ interrupts(); // delay() requires that interrupts are enabled+ delay(1000);++ // Flash LED when transmitting.+ digitalWrite(LED_PIN, HIGH);++ // Transmit signal. Note: this is a static method, no object required!+ ELECHOUSE_cc1101.SetTx(); // set Transmit on+ SensorTransmitter::sendPackage(pinTx, data);++ digitalWrite(LED_PIN, LOW);++ noInterrupts();+ ELECHOUSE_cc1101.SetRx(); // set Receive on+ SensorReceiver::enable();+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/RemoteSensor examples cc1101/ThermoHygroReceiver_cc1101/ThermoHygroReceiver_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/RemoteSensor examples cc1101/ThermoHygroReceiver_cc1101/ThermoHygroReceiver_cc1101.inonew file mode 100644index 00000000..7de82d9c--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/RemoteSensor examples cc1101/ThermoHygroReceiver_cc1101/ThermoHygroReceiver_cc1101.ino@@ -0,0 +1,80 @@+/*+ * This sketch receives and decodes data from a 433MHz thermo/hygro weather sensor.+ * The received data (temperature, humidity, channel) is echo+ *+ * Setup:+ * - Connect digital output of a 433MHz receiver to digital pin 2 of Arduino+ * - Enable the serial monitor at 115200 baud.+ *+ * Need library:+ * https://github.com/mattwire/arduino-dev/tree/master/libraries/RemoteSensor+ * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ *+ */+#include <ELECHOUSE_CC1101_SRC_DRV.h>+#include <SensorReceiver.h>++int pin;++void setup() {+ Serial.begin(115200);++#ifdef ESP32+pin = 4; // for esp32! Receiver on GPIO pin 4.+#elif ESP8266+pin = 4; // for esp8266! Receiver on pin 4 = D2.+#else+pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.SetRx(); // set Receive on++ // Init the receiver on interrupt pin 0 (digital pin 2).+ // Set the callback to function "showTempHumi", which is called+ // whenever valid sensor data has been received.+ SensorReceiver::init(pin, showTempHumi);+}++void loop() {+ // Empty! However, you can do other stuff here if you like.+}++void showTempHumi(byte *data) {+ // is data a ThermoHygro-device?+ if ((data[3] & 0x1f) == 0x1e) {+ // Yes!++ byte channel, randomId;+ int temp;+ byte humidity;++ // Decode the data+ SensorReceiver::decodeThermoHygro(data, channel, randomId, temp, humidity);++ // Print temperature. Note: temp is 10x the actual temperature!+ Serial.print("Temperature: ");+ Serial.print(temp / 10); // units+ Serial.print('.');+ Serial.print(temp % 10); // decimal++ // Print humidity+ Serial.print(" deg, Humidity: ");+ Serial.print(humidity);+ Serial.print("% REL");++ // Print channel+ Serial.print(", Channel: ");+ Serial.println(channel, DEC);+ }+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/examples/RemoteSensor examples cc1101/ThermoHygroTransmitter_cc1101/ThermoHygroTransmitter_cc1101.ino b/lib/SmartRC-CC1101-Driver-Lib/examples/RemoteSensor examples cc1101/ThermoHygroTransmitter_cc1101/ThermoHygroTransmitter_cc1101.inonew file mode 100644index 00000000..7948c21c--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/examples/RemoteSensor examples cc1101/ThermoHygroTransmitter_cc1101/ThermoHygroTransmitter_cc1101.ino@@ -0,0 +1,56 @@+/*+ * This sketch sends (bogus) thermo / hygro data to a remote weather sensors made by Cresta.+ *+ * Setup:+ * - connect transmitter input of a 433MHz transmitter to digital pin 11+ * - On the weather station, activate the "scan" function for channel 1.+ *+ * Library:+ * https://github.com/mattwire/arduino-dev/tree/master/libraries/RemoteSensor+ * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+ *+ */+ #include <ELECHOUSE_CC1101_SRC_DRV.h>+ #include <SensorTransmitter.h>++ int pin;++ void setup() {++#ifdef ESP32+pin = 2; // for esp32! Transmit on GPIO pin 2.+#elif ESP8266+pin = 5; // for esp8266! Transmit on pin 5 = D1+#else+pin = 6; // for Arduino! Transmit on pin 6.+#endif++ if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.+ Serial.println("Connection OK");+ }else{+ Serial.println("Connection Error");+ }++//CC1101 Settings: (Settings with "//" are optional!)+ ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!+//ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.+//ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!+ ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.+ ELECHOUSE_cc1101.SetTx(); // Transmitt on+ }++ void loop() {+ // Initializes a ThermoHygroTransmitter on pin 11, with "random" ID 0, on channel 1.+ ThermoHygroTransmitter transmitter(pin, 0, 1);++ // Displays temperatures from -10 degrees Celsius to +20,+ // and humidity from 10% REL to 40% REL, with increments of 2+ for (int i = -10; i<=20; i+=2) {+ // Temperatures are passed at 10 times the real value,+ // to avoid using floating point math.+ transmitter.sendTempHumi(i * 10, i + 20);++ // Wait two seconds before sending next.+ delay(2000);+ }+ }diff --git a/lib/SmartRC-CC1101-Driver-Lib/img/Esp32_CC1101.png b/lib/SmartRC-CC1101-Driver-Lib/img/Esp32_CC1101.pngnew file mode 100644index 00000000..c335bc81Binary files /dev/null and b/lib/SmartRC-CC1101-Driver-Lib/img/Esp32_CC1101.png differdiff --git a/lib/SmartRC-CC1101-Driver-Lib/img/Esp8266_CC1101.png b/lib/SmartRC-CC1101-Driver-Lib/img/Esp8266_CC1101.pngnew file mode 100644index 00000000..8b3076c6Binary files /dev/null and b/lib/SmartRC-CC1101-Driver-Lib/img/Esp8266_CC1101.png differdiff --git a/lib/SmartRC-CC1101-Driver-Lib/img/MEGA_CC1101.png b/lib/SmartRC-CC1101-Driver-Lib/img/MEGA_CC1101.pngnew file mode 100644index 00000000..5a799497Binary files /dev/null and b/lib/SmartRC-CC1101-Driver-Lib/img/MEGA_CC1101.png differdiff --git a/lib/SmartRC-CC1101-Driver-Lib/img/Nano_CC1101.png b/lib/SmartRC-CC1101-Driver-Lib/img/Nano_CC1101.pngnew file mode 100644index 00000000..0f31de80Binary files /dev/null and b/lib/SmartRC-CC1101-Driver-Lib/img/Nano_CC1101.png differdiff --git a/lib/SmartRC-CC1101-Driver-Lib/img/TXS0108E_CC1101.png b/lib/SmartRC-CC1101-Driver-Lib/img/TXS0108E_CC1101.pngnew file mode 100644index 00000000..46d34a6cBinary files /dev/null and b/lib/SmartRC-CC1101-Driver-Lib/img/TXS0108E_CC1101.png differdiff --git a/lib/SmartRC-CC1101-Driver-Lib/img/Wiring_CC1101.png b/lib/SmartRC-CC1101-Driver-Lib/img/Wiring_CC1101.pngnew file mode 100644index 00000000..a6dbac3aBinary files /dev/null and b/lib/SmartRC-CC1101-Driver-Lib/img/Wiring_CC1101.png differdiff --git a/lib/SmartRC-CC1101-Driver-Lib/keywords.txt b/lib/SmartRC-CC1101-Driver-Lib/keywords.txtnew file mode 100644index 00000000..3346f02d--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/keywords.txt@@ -0,0 +1,56 @@+ELECHOUSE_CC1101_SRC_DRV KEYWORD1+ELECHOUSE_cc1101 KEYWORD1+Init KEYWORD2+SpiReadStatus KEYWORD2+SpiStrobe KEYWORD2+SpiWriteReg KEYWORD2+SpiWriteBurstReg KEYWORD2+SpiReadReg KEYWORD2+SpiReadBurstReg KEYWORD2+setSpiPin KEYWORD2+addSpiPin KEYWORD2+setGDO KEYWORD2+setGDO0 KEYWORD2+addGDO KEYWORD2+addGDO0 KEYWORD2+setModul KEYWORD2+setCCMode KEYWORD2+setModulation KEYWORD2+setPA KEYWORD2+setMHZ KEYWORD2+setRxBW KEYWORD2+setChannel KEYWORD2+SetTx KEYWORD2+SetRx KEYWORD2+getRssi KEYWORD2+getLqi KEYWORD2+setSres KEYWORD2+setSidle KEYWORD2+goSleep KEYWORD2+SendData KEYWORD2+CheckReceiveFlag KEYWORD2+CheckRxFifo KEYWORD2+CheckCRC KEYWORD2+ReceiveData KEYWORD2+setClb KEYWORD2+getCC1101 KEYWORD2+getMode KEYWORD2+setSyncWord KEYWORD2+setChsp KEYWORD2+setDRate KEYWORD2+setDeviation KEYWORD2+setSyncMode KEYWORD2+setAdrChk KEYWORD2+setAddr KEYWORD2+setWhiteData KEYWORD2+setPktFormat KEYWORD2+setLengthConfig KEYWORD2+setPacketLength KEYWORD2+setCrc KEYWORD2+setCRC_AF KEYWORD2+setDcFilterOff KEYWORD2+setManchester KEYWORD2+setFEC KEYWORD2+setPRE KEYWORD2+setPQT KEYWORD2+setAppendStatus KEYWORD2\ No newline at end of filediff --git a/lib/SmartRC-CC1101-Driver-Lib/library.json b/lib/SmartRC-CC1101-Driver-Lib/library.jsonnew file mode 100644index 00000000..2705477e--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/library.json@@ -0,0 +1,19 @@+{+ "name": "SmartRC-CC1101-Driver-Lib",+ "description": "This driver library can be used for many libraries that use a simple RF ASK module, with the advantages of the cc1101 module.It offers many direct setting options as in SmartRF Studio and calculates settings such as MHz directly.",+ "keywords": "rf, radio, wireless, cc1101",+ "authors":+ {+ "name": "Little Satan"+ },+ "repository":+ {+ "type": "git",+ "url": "https://github.com/LSatan/SmartRC-CC1101-Driver-Lib"+ },+ "version": "2.5.7",+ "frameworks": [+ "arduino"+ ],+ "platforms": "*"+}diff --git a/lib/SmartRC-CC1101-Driver-Lib/library.properties b/lib/SmartRC-CC1101-Driver-Lib/library.propertiesnew file mode 100644index 00000000..4d3f0c7b--- /dev/null+++ b/lib/SmartRC-CC1101-Driver-Lib/library.properties@@ -0,0 +1,10 @@+name=SmartRC-CC1101-Driver-Lib+version=2.5.7+author=LSatan+maintainer=LSatan <[email protected]>+sentence=Driver for cc1101.+paragraph=This driver library can be used for many libraries that use a simple RF ASK module,with the advantages of the cc1101 module.It offers many direct setting options as in SmartRF Studio and calculates settings such as MHz directly.+category=Device Control+url=https://github.com/LSatan/SmartRC-CC1101-Driver-Lib+architectures=avr,esp8266,esp32+includes=ELECHOUSE_CC1101_SRC_DRV.h