Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
cschorn01 authored Apr 23, 2024
1 parent 73271ab commit 660fd90
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
25 changes: 14 additions & 11 deletions examples/arduinoSendAndReceive/arduinoSendAndReceive.ino
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,29 @@ void loop() {
0x00, /* uint8_t headerType */
0x20, /* uint8_t cyclicalRedundancyCheck */
0x40, /* uint8_t chirpInvert */
sx1280Data ); /* uint8_t outboundMessage[ ] */
sx1280Data ); /* uint8_t outboundMessage[ ] */

sx1280_1.sx1280Rx( 0x40, /* uint8_t rxIrq158 */
0x7E, /* uint8_t rxIrq70 */
0x02, /* uint8_t rxPeriodBase */
0xFF, /* uint8_t rxPeriodBaseCount[15:8] */
0xFF, /* uint8_t rxPeriodBaseCount[7:0] */
sx1280Data ); /* uint8_t inboundMessage[ ] */
sx1280Data ); /* uint8_t inboundMessage[ ] */

/* Checking message for "hi", "h"=0x68 & "i"=0x69, in hexadecimal ascii in the first three bytes */
if( sx1280Data[ 0 ] == 0x68 && sx1280Data[ 1 ] == 0x69 ){

for( uint32_t i = 0; i <= 2; i++ ){
if( sx1280Data[ 0 ] == 0xFF && sx1280Data[ 1 ] == 0xFF &&sx1280Data[ 253 ] == 0xFF ){
Serial.println("No Inbound Message");
}
else{
for( i = 0; i < 255; i++ ){
Serial.print( "Inbound Message: 0x");
Serial.println( sx1280Data[ i ], HEX );
}
Serial.print( sx1280Data[ i ], HEX );

}
else if( sx1280Data[ 0 ] == 0xFF ){
Serial.println("No Inbound Message");
/* Uncomment to shorten printed message */
/* if( (sx1280Data[ i ] == 0xFF && sx1280Data[ i - 1 ] == 0xFF && sx1280Data[ i + 1 ] == 0xFF ) || sx1280Data[ i ] == 0x00 ){
break;
} */
}
}

sx1280Data[ 0 ] = 0x68; /* "h" */
Expand All @@ -102,7 +105,7 @@ void loop() {
0x00, /* uint8_t headerType */
0x20, /* uint8_t cyclicalRedundancyCheck */
0x40, /* uint8_t chirpInvert */
sx1280Data ); /* uint8_t outboundMessage[ ] */
sx1280Data ); /* uint8_t outboundMessage[ ] */

sx1280_1.sx1280Tx( 0x1F, /* uint8_t power */
0xE0, /* uint8_t rampTime */
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=sx1280OverSpi
version=1.1.5
version=1.1.6
author=Chris Schorn
maintainer=Chris Schorn <[email protected]>
sentence=Arduino library interacting and sending messages with a 2.4Ghz Lora modem.
Expand Down
25 changes: 14 additions & 11 deletions src/sx1280OverSpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Library Spec Link: https://arduino.github.io/arduino-cli/0.34/library-specification/
*/

#include "Arduino.h"
#include "SPI.h"
#include "sx1280OverSpi.h"

sx1280OverSpi::sx1280OverSpi( uint8_t cssPin,
Expand Down Expand Up @@ -170,7 +172,6 @@ void sx1280OverSpi::sx1280Setup( uint8_t standbyMode,
sx1280Deselect();
zeroingAnArray( setupWriteData, /* Reassigning all array values to 0 */
10 );

}
/* 0x37 Must be written to register 0x0925 for SF7 or SF8 */
else if( spreadingFactor == 0x70 || spreadingFactor == 0x80 ){
Expand Down Expand Up @@ -292,7 +293,7 @@ void sx1280OverSpi::sx1280Tx( uint8_t power,
uint8_t txPeriodBaseCount158,
uint8_t txPeriodBaseCount70 ){

uint8_t txWriteData[ 258 ] = { 0 }; /* Size is 258 cause message buffer + opcode + offset */
uint8_t txWriteData[ 259 ] = { 0 }; /* Size is 258 cause message buffer + opcode + offset */
uint16_t txPayloadLength = 0;

/* Iterators */
Expand All @@ -318,10 +319,13 @@ void sx1280OverSpi::sx1280Tx( uint8_t power,
while( *( outboundMessage + txPayloadLength ) != 0x00 ){

/* Getting size of a single outbound message, storing it in a holder variable */
txPayloadLength = txPayloadLength + 1;

if( txPayloadLength > 255 ){
txPayloadLength = 255;
*( outboundMessage + txPayloadLength ) = 0x00;

}
txPayloadLength = txPayloadLength + 1;
}
/* Allocating txPayloadLength+3 bytes to writeData, payloadLength is indexed from zero
and space is needed for the WRITEBUFFER command and nop
Expand Down Expand Up @@ -512,7 +516,7 @@ void sx1280OverSpi::sx1280Rx( uint8_t rxIrq158,
Serial.println(F("Busy after SETRX"));
}

/* Loop pollingi 25 times over rx mode
/* Loop polling 25 times over rx mode
Each loop has a 50 millisecond delay allowing other tasks to run */
for( i = 0; i <= 25; i++ ){

Expand Down Expand Up @@ -540,8 +544,6 @@ void sx1280OverSpi::sx1280Rx( uint8_t rxIrq158,
Serial.println(F("Busy after rx GETIRQSTATUS"));
}

/* see what the message is and decide what to do with it */

/* using GETPACKETSTATUS which returns rssiSync, and Signal to Noise Ratio ( SNR )
Not currently using but it's in sx1280 Documentation for Rx operation
pretty sure it's used to see if the received message is useable or not */
Expand Down Expand Up @@ -610,16 +612,17 @@ void sx1280OverSpi::sx1280Rx( uint8_t rxIrq158,
/* Looping through rxWriteData to add nops, i begins at *( rxWriteData + 3 ) */
/* Serial.print("Final Address = 0x");
Serial.println( *( rxWriteData + sizeOfMessageInBuffer + 3 ), HEX ); */
for( j = 0; j <= sizeOfMessageInBuffer; j++){
*( rxWriteData + j + 3 ) = 0x00;
/* Serial.print("rxWriteData + j = 0x j = ", ( rxWriteData + j + 3 ), j ); */
for( j = 3; j <= sizeOfMessageInBuffer; j++){
*( rxWriteData + j ) = 0x00;
/* Serial.print("rxWriteData + j = 0x j = ", ( rxWriteData + j ), j ); */
}
sx1280Select();
SPI.transfer( rxWriteData, ( sizeOfMessageInBuffer + 3 )*sizeof( uint8_t));
SPI.transfer( rxWriteData, ( sizeOfMessageInBuffer + 3 )*sizeof( uint8_t ) );
sx1280Deselect();

/* Passing newly received message pointer to vSx1280Task */
for( j = 0; j <= sizeOfMessageInBuffer; j++ ){
inboundMessage[ j ] = *( rxWriteData + j );
inboundMessage[ j ] = *( rxWriteData + j + 3 );
}
zeroingAnArray( rxWriteData, /* Reassigning all array values to 0 */
258 );
Expand Down
1 change: 0 additions & 1 deletion src/sx1280OverSpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define SX1280OVERSPI_H

#include "Arduino.h"
#include <SPI.h>


/* -------------- Defining SX1280 Opcodes with Hexadecimel Commands ------------------ */
Expand Down

0 comments on commit 660fd90

Please sign in to comment.