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 Feb 4, 2024
1 parent 3d3f9f7 commit 9477916
Show file tree
Hide file tree
Showing 6 changed files with 202 additions and 202 deletions.
54 changes: 24 additions & 30 deletions examples/arduinoSendAndReceive/arduinoSendAndReceive.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ uint32_t i = 0; // iterator

// Arrays for passing data to and receiving data from sx1280 setup, rx, and tx functions
// Sized to 255 because an sx1280 Message Buffer is 255 bytes
uint8_t writeData[ 255 ];
uint8_t readData[ 255 ];
uint8_t sx1280Data[ 255 ];

uint8_t antselPin = 9; // Setting variable for DLP-RFS1280 antenna select pin

Expand Down Expand Up @@ -46,75 +45,70 @@ void loop() {
/* Giving writeData an arbitrary size of 255 for payloadLength in sx1280Setup
Payload length does not matter for messages with headers */
for( i = 0; i < 255; i++){
writeData[ i ] = 0xFF;
sx1280Data[ i ] = 0xFF;
}
writeData[ 254 ] = 0x00; // Null Terminating the ascii array

for( i = 0; i < 255; i++){
readData[ i ] = 0xFF;
}
readData[ 254 ] = 0x00; // Null Terminating the ascii array
sx1280Data[ 254 ] = 0x00; // Null Terminating the ascii array

sx1280_1.sx1280Setup( 0x00, /* uint8_t standbyMode */
0x01, /* uint8_t packetType */
0xB8, /* uint8_t rfFrequency2316 */
0x9D, /* uint8_t rfFrequency158 */
0x89, /* uint8_t rfFrequency70 */
0xB8, /* uint8_t rfFrequency[23:16] */
0x9D, /* uint8_t rfFrequency[15:8] */
0x89, /* uint8_t rfFrequency[7:0] */
0x70, /* uint8_t spreadingFactor */
0x0A, /* uint8_t bandwidth */
0x01, /* uint8_t codingRate */
0x0C, /* uint8_t preambleLength */
0x00, /* uint8_t headerType */
0x20, /* uint8_t cyclicalRedundancyCheck */
0x40, /* uint8_t chirpInvert */
writeData ); /* 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 rxPeriodBaseCount158 */
0xFF, /* uint8_t rxPeriodBaseCount70 */
readData ); /* uint8_t inboundMessage[ ] */
0xFF, /* uint8_t rxPeriodBaseCount[15:8] */
0xFF, /* uint8_t rxPeriodBaseCount[7:0] */
sx1280Data ); /* uint8_t inboundMessage[ ] */

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

for( uint32_t i = 0; i <= 2; i++ ){
Serial.print( "Inbound Message: 0x");
Serial.println( readData[ i ], HEX );
Serial.println( sx1280Data[ i ], HEX );
}

}
else if( readData[ 0 ] == 0xFF ){
else if( sx1280Data[ 0 ] == 0xFF ){
Serial.println("No Inbound Message");
}

writeData[ 0 ] = 0x68; /* "h" */
writeData[ 1 ] = 0x69; /* "i" */
writeData[ 2 ] = 0x00; /* "\0" or NULL */
sx1280Data[ 0 ] = 0x68; /* "h" */
sx1280Data[ 1 ] = 0x69; /* "i" */
sx1280Data[ 2 ] = 0x00; /* "\0" or NULL */
for( i = 3; i < 255; i++ ){
writeData[ i ] = 0x00;
sx1280Data[ i ] = 0x00;
}

sx1280_1.sx1280Setup( 0x00, /* uint8_t standbyMode */
0x01, /* uint8_t packetType */
0xB8, /* uint8_t rfFrequency2316 */
0x9D, /* uint8_t rfFrequency158 */
0x89, /* uint8_t rfFrequency70 */
0xB8, /* uint8_t rfFrequency[23:16] */
0x9D, /* uint8_t rfFrequency[15:8] */
0x89, /* uint8_t rfFrequency[7:0] */
0x70, /* uint8_t spreadingFactor */
0x0A, /* uint8_t bandwidth */
0x01, /* uint8_t codingRate */
0x0C, /* uint8_t preambleLength */
0x00, /* uint8_t headerType */
0x20, /* uint8_t cyclicalRedundancyCheck */
0x40, /* uint8_t chirpInvert */
writeData ); /* uint8_t outboundMessage[ ] */
sx1280Data ); /* uint8_t outboundMessage[ ] */

sx1280_1.sx1280Tx( 0x1F, /* uint8_t power */
0xE0, /* uint8_t rampTime */
writeData, /* uint8_t outboundMessage[ ] */
0x40, /* uint8_t txIrq158 */
0x01, /* uint8_t txIrq70 */
sx1280Data, /* uint8_t outboundMessage[ ] */
0x40, /* uint8_t txIrq[15:8] */
0x01, /* uint8_t txIrq[7:0] */
0x02, /* uint8_t txPeriodBase */
0x01, /* uint8_t txPeriodBaseCount158 */
0xF4 ); /* uint8_t txPeriodBaseCount70 */
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ sx1280OverSpi KEYWORD1
begin KEYWORD2
sx1280Select KEYWORD2
sx1280Deselect KEYWORD2
zeroingAnArray KEYWORD2
sx1280Reset KEYWORD2
sx1280Setup KEYWORD2
sx1280Tx KEYWORD2
Expand Down
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.0.0
version=1.1.0
author=Chris Schorn
maintainer=Chris Schorn <[email protected]>
sentence=Arduino library interacting and sending messages with a 2.4Ghz Lora modem.
Expand Down
Loading

0 comments on commit 9477916

Please sign in to comment.