40 #if defined(ARDUINO_ARCH_AVR) 41 #include <avr/pgmspace.h> 42 #elif defined(ARDUINO_ARCH_ESP32) 74 #if !defined(EU863) && !defined(AU915) && !defined(AS920) 81 #define RFM9x_VER 0x12 84 #define MODE_SLEEP 0x00 85 #define MODE_LORA 0x80 86 #define MODE_STDBY 0x01 90 #define REG_PA_CONFIG 0x09 91 #define REG_PA_DAC 0x4D 92 #define REG_PREAMBLE_MSB 0x20 93 #define REG_PREAMBLE_LSB 0x21 94 #define REG_FRF_MSB 0x06 95 #define REG_FRF_MID 0x07 96 #define REG_FRF_LSB 0x08 97 #define REG_FEI_LSB 0x1E 98 #define REG_FEI_MSB 0x1D 99 #define REG_MODEM_CONFIG 0x26 113 void setPower(int8_t Tx_Power = 17);
114 TinyLoRa(int8_t rfm_dio0, int8_t rfm_nss, int8_t rfm_rst);
116 void sendData(
unsigned char *Data,
unsigned char Data_Length,
117 unsigned int Frame_Counter_Tx, uint8_t Frame_Port = 1);
121 int8_t _cs, _irq, _rst;
123 unsigned char _rfmMSB, _rfmMID, _rfmLSB, _sf, _bw, _modemcfg;
124 static const unsigned char LoRa_Frequency[8][3];
125 static const unsigned char S_Table[16][16];
126 void RFM_Send_Package(
unsigned char *RFM_Tx_Package,
127 unsigned char Package_Length);
128 void RFM_Write(
unsigned char RFM_Address,
unsigned char RFM_Data);
129 uint8_t RFM_Read(uint8_t RFM_Address);
130 void Encrypt_Payload(
unsigned char *Data,
unsigned char Data_Length,
131 unsigned int Frame_Counter,
unsigned char Direction);
132 void Calculate_MIC(
unsigned char *Data,
unsigned char *Final_MIC,
133 unsigned char Data_Length,
unsigned int Frame_Counter,
134 unsigned char Direction);
135 void Generate_Keys(
unsigned char *K1,
unsigned char *K2);
136 void Shift_Left(
unsigned char *Data);
137 void XOR(
unsigned char *New_Data,
unsigned char *Old_Data);
138 void AES_Encrypt(
unsigned char *Data,
unsigned char *Key);
139 void AES_Add_Round_Key(
unsigned char *Round_Key,
unsigned char (*State)[4]);
140 unsigned char AES_Sub_Byte(
unsigned char Byte);
141 void AES_Shift_Rows(
unsigned char (*State)[4]);
142 void AES_Mix_Collums(
unsigned char (*State)[4]);
143 void AES_Calculate_Round_Key(
unsigned char Round,
unsigned char *Round_Key);
void setDatarate(rfm_datarates_t datarate)
Sets the RFM datarate.
Definition: TinyLoRa.cpp:198
rfm_datarates
Definition: TinyLoRa.h:63
uint8_t txrandomNum
random number for AES
Definition: TinyLoRa.h:109
rfm_channels
Definition: TinyLoRa.h:50
void sendData(unsigned char *Data, unsigned char Data_Length, unsigned int Frame_Counter_Tx, uint8_t Frame_Port=1)
Function to assemble and send a LoRaWAN package.
Definition: TinyLoRa.cpp:609
uint16_t frameCounter
frame counter
Definition: TinyLoRa.h:110
enum rfm_datarates rfm_datarates_t
TinyLoRa(int8_t rfm_dio0, int8_t rfm_nss, int8_t rfm_rst)
Instanciates a new TinyLoRa class, including assigning irq and cs pins to the RFM breakout...
Definition: TinyLoRa.cpp:323
void setChannel(rfm_channels_t channel)
Sets the RFM channel.
Definition: TinyLoRa.cpp:249
TinyLoRa Class.
Definition: TinyLoRa.h:107
void setPower(int8_t Tx_Power=17)
Sets the TX power.
Definition: TinyLoRa.cpp:426
bool begin(void)
Initializes the RFM, including configuring SPI, configuring the frameCounter and txrandomNum.
Definition: TinyLoRa.cpp:340
enum rfm_channels rfm_channels_t