Add Reliable Packet Transmission with Addressing
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.vscode
|
||||||
22
LICENSE
Normal file
22
LICENSE
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021 Stuart Robinson
|
||||||
|
Copyright (c) 2024 Hasan Albinsaid
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
7
README.md
Normal file
7
README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# SX128x Arduino Library
|
||||||
|
|
||||||
|
This repository is based on the [StuartsProjects](https://github.com/StuartsProjects/SX12XX-LoRa) repository (as of the March 2024 commit) and focuses exclusively on the SX128x library, with additional features and improvements.
|
||||||
|
|
||||||
|
### Additional Features
|
||||||
|
- **Reliable Packet Transmission with Addressing**:
|
||||||
|
New functions `transmitReliableAutoACK_addr` and `receiveReliableAutoACK_addr` have been added to enhance reliable communication with built-in addressing support.
|
||||||
@ -38,9 +38,11 @@ CRCCCITTSX KEYWORD2
|
|||||||
CRCCCITT KEYWORD2
|
CRCCCITT KEYWORD2
|
||||||
printSXBufferASCII KEYWORD2
|
printSXBufferASCII KEYWORD2
|
||||||
receiveAddressed KEYWORD2
|
receiveAddressed KEYWORD2
|
||||||
|
destAddr KEYWORD2
|
||||||
getByteSXBuffer KEYWORD2
|
getByteSXBuffer KEYWORD2
|
||||||
startWriteSXBuffer KEYWORD2
|
startWriteSXBuffer KEYWORD2
|
||||||
transmitAddressed KEYWORD2
|
transmitAddressed KEYWORD2
|
||||||
|
srcAddr KEYWORD2
|
||||||
startReadSXBuffer KEYWORD2
|
startReadSXBuffer KEYWORD2
|
||||||
endReadSXBuffer KEYWORD2
|
endReadSXBuffer KEYWORD2
|
||||||
readBuffer KEYWORD2
|
readBuffer KEYWORD2
|
||||||
|
|||||||
622
src/SX128XLT.cpp
622
src/SX128XLT.cpp
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,13 @@
|
|||||||
#ifndef SX128XLT_h
|
#ifndef SX128XLT_h
|
||||||
#define SX128XLT_h
|
#define SX128XLT_h
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include <Arduino.h>
|
||||||
#include <SX128XLT_Definitions.h>
|
#include <SX128XLT_Definitions.h>
|
||||||
|
|
||||||
|
class SX128XLT
|
||||||
class SX128XLT {
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SX128XLT();
|
SX128XLT();
|
||||||
|
|
||||||
bool begin(int8_t pinNSS, int8_t pinNRESET, int8_t pinRFBUSY, int8_t pinDIO1, int8_t pinDIO2, int8_t pinDIO3, int8_t pinRXEN, int8_t pinTXEN, uint8_t device);
|
bool begin(int8_t pinNSS, int8_t pinNRESET, int8_t pinRFBUSY, int8_t pinDIO1, int8_t pinDIO2, int8_t pinDIO3, int8_t pinRXEN, int8_t pinTXEN, uint8_t device);
|
||||||
@ -20,7 +19,6 @@ class SX128XLT {
|
|||||||
void rxEnable();
|
void rxEnable();
|
||||||
void txEnable();
|
void txEnable();
|
||||||
|
|
||||||
|
|
||||||
void checkBusy();
|
void checkBusy();
|
||||||
bool config();
|
bool config();
|
||||||
void readRegisters(uint16_t address, uint8_t *buffer, uint16_t size);
|
void readRegisters(uint16_t address, uint8_t *buffer, uint16_t size);
|
||||||
@ -88,7 +86,6 @@ class SX128XLT {
|
|||||||
void setPeriodBase(uint8_t value);
|
void setPeriodBase(uint8_t value);
|
||||||
uint8_t getPeriodBase();
|
uint8_t getPeriodBase();
|
||||||
|
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Start direct access SX buffer routines
|
// Start direct access SX buffer routines
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
@ -130,7 +127,6 @@ class SX128XLT {
|
|||||||
void writeBufferChar(char *txbuffer, uint8_t size);
|
void writeBufferChar(char *txbuffer, uint8_t size);
|
||||||
uint8_t readBufferChar(char *rxbuffer);
|
uint8_t readBufferChar(char *rxbuffer);
|
||||||
|
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
// Start ranging routines
|
// Start ranging routines
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
@ -150,7 +146,6 @@ class SX128XLT {
|
|||||||
uint16_t getSetCalibrationValue();
|
uint16_t getSetCalibrationValue();
|
||||||
int16_t getRangingRSSI();
|
int16_t getRangingRSSI();
|
||||||
|
|
||||||
|
|
||||||
//*******************************************************************************
|
//*******************************************************************************
|
||||||
// Reliable RX\TX routines
|
// Reliable RX\TX routines
|
||||||
//*******************************************************************************
|
//*******************************************************************************
|
||||||
@ -160,11 +155,17 @@ class SX128XLT {
|
|||||||
uint8_t transmitReliableAutoACK(uint8_t *txbuffer, uint8_t size, uint16_t networkID, uint32_t acktimeout, uint32_t txtimeout, int8_t txpower, uint8_t wait);
|
uint8_t transmitReliableAutoACK(uint8_t *txbuffer, uint8_t size, uint16_t networkID, uint32_t acktimeout, uint32_t txtimeout, int8_t txpower, uint8_t wait);
|
||||||
uint8_t receiveReliableAutoACK(uint8_t *rxbuffer, uint8_t size, uint16_t networkID, uint32_t ackdelay, int8_t txpower, uint32_t rxtimeout, uint8_t wait);
|
uint8_t receiveReliableAutoACK(uint8_t *rxbuffer, uint8_t size, uint16_t networkID, uint32_t ackdelay, int8_t txpower, uint32_t rxtimeout, uint8_t wait);
|
||||||
|
|
||||||
|
uint8_t transmitReliableAutoACK_addr(uint8_t *txbuffer, uint8_t size, uint16_t networkID, uint16_t destAddr, uint16_t srcAddr, uint32_t acktimeout, uint32_t txtimeout, int8_t txpower, uint8_t wait);
|
||||||
|
uint8_t receiveReliableAutoACK_addr(uint8_t *rxbuffer, uint8_t size, uint16_t networkID, uint16_t destAddr, uint32_t ackdelay, int8_t txpower, uint32_t rxtimeout, uint8_t wait, uint16_t *srcAddr = nullptr);
|
||||||
|
|
||||||
uint8_t sendReliableACK(uint16_t networkID, uint16_t payloadcrc, int8_t txpower);
|
uint8_t sendReliableACK(uint16_t networkID, uint16_t payloadcrc, int8_t txpower);
|
||||||
uint8_t sendReliableACK(uint8_t *txbuffer, uint8_t size, uint16_t networkID, uint16_t payloadcrc, int8_t txpower);
|
uint8_t sendReliableACK(uint8_t *txbuffer, uint8_t size, uint16_t networkID, uint16_t payloadcrc, int8_t txpower);
|
||||||
uint8_t waitReliableACK(uint16_t networkID, uint16_t payloadcrc, uint32_t acktimeout);
|
uint8_t waitReliableACK(uint16_t networkID, uint16_t payloadcrc, uint32_t acktimeout);
|
||||||
uint8_t waitReliableACK(uint8_t *rxbuffer, uint8_t size, uint16_t networkID, uint16_t payloadcrc, uint32_t acktimeout);
|
uint8_t waitReliableACK(uint8_t *rxbuffer, uint8_t size, uint16_t networkID, uint16_t payloadcrc, uint32_t acktimeout);
|
||||||
|
|
||||||
|
uint8_t sendReliableACK_addr(uint16_t networkID, uint16_t srcAddr, uint16_t destAddr, uint16_t payloadcrc, int8_t txpower);
|
||||||
|
uint8_t waitReliableACK_addr(uint16_t networkID, uint16_t destAddr, uint16_t srcAddr, uint16_t payloadcrc, uint32_t acktimeout);
|
||||||
|
|
||||||
void printASCIIArray(uint8_t *buffer, uint8_t size);
|
void printASCIIArray(uint8_t *buffer, uint8_t size);
|
||||||
uint8_t getReliableConfig(uint8_t bitread);
|
uint8_t getReliableConfig(uint8_t bitread);
|
||||||
|
|
||||||
@ -218,9 +219,7 @@ class SX128XLT {
|
|||||||
uint8_t receiveDTIRQ(uint8_t *header, uint8_t headersize, uint8_t *dataarray, uint8_t datasize, uint16_t networkID, uint32_t rxtimeout, uint8_t wait);
|
uint8_t receiveDTIRQ(uint8_t *header, uint8_t headersize, uint8_t *dataarray, uint8_t datasize, uint16_t networkID, uint32_t rxtimeout, uint8_t wait);
|
||||||
uint8_t sendACKDTIRQ(uint8_t *header, uint8_t headersize, int8_t txpower);
|
uint8_t sendACKDTIRQ(uint8_t *header, uint8_t headersize, int8_t txpower);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int8_t _NSS, _NRESET, _RFBUSY, _DIO1, _DIO2, _DIO3;
|
int8_t _NSS, _NRESET, _RFBUSY, _DIO1, _DIO2, _DIO3;
|
||||||
int8_t _RXEN, _TXEN;
|
int8_t _RXEN, _TXEN;
|
||||||
uint8_t _RXPacketL; // length of packet received
|
uint8_t _RXPacketL; // length of packet received
|
||||||
@ -254,6 +253,5 @@ class SX128XLT {
|
|||||||
uint8_t _ReliableErrors; // Reliable status byte
|
uint8_t _ReliableErrors; // Reliable status byte
|
||||||
uint8_t _ReliableFlags; // Reliable flags byte
|
uint8_t _ReliableFlags; // Reliable flags byte
|
||||||
uint8_t _ReliableConfig; // Reliable config byte
|
uint8_t _ReliableConfig; // Reliable config byte
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -405,6 +405,7 @@ const double CH_freq[] = {0E6,
|
|||||||
#define ReliableTimeout 0x04 // bit number set in _ReliableErrors when there is a timeout error
|
#define ReliableTimeout 0x04 // bit number set in _ReliableErrors when there is a timeout error
|
||||||
#define SegmentSequenceError 0x05 // bit number set in _ReliableErrors when there is a segment sequence error
|
#define SegmentSequenceError 0x05 // bit number set in _ReliableErrors when there is a segment sequence error
|
||||||
#define FileError 0x06 // bit number set in _ReliableErrors when there ia a file (SD) error
|
#define FileError 0x06 // bit number set in _ReliableErrors when there ia a file (SD) error
|
||||||
|
#define ReliableAddrError 0x07 // bit number set in _ReliableErrors when there is intended Address is incorrect
|
||||||
|
|
||||||
// These are the bit numbers which when set indicate reliable status flags, variable _ReliableFlags
|
// These are the bit numbers which when set indicate reliable status flags, variable _ReliableFlags
|
||||||
#define ReliableACKSent 0x00 // bit number set in _ReliableFlags when there is a ACK sent
|
#define ReliableACKSent 0x00 // bit number set in _ReliableFlags when there is a ACK sent
|
||||||
|
|||||||
Reference in New Issue
Block a user