@@ -531,6 +531,10 @@ int setRfChannel(const struct device *dev, uint32_t freq) {
531
531
SX126xWaitOnBusy ();
532
532
SX126xSetStandby (STDBY_RC );
533
533
SX126xSetPacketType (PACKET_TYPE_LORA );
534
+ //SX126xSetRfFrequency(freq);
535
+
536
+ //SX126xSetFs();
537
+ SX126xWaitOnBusy ();
534
538
SX126xSetRfFrequency (freq );
535
539
SX126xWaitOnBusy ();
536
540
return 0 ;
@@ -547,7 +551,7 @@ int setSleep(const struct device *dev) {
547
551
SX126xWaitOnBusy ();
548
552
SX126xSetStandby (STDBY_XOSC );
549
553
SleepParams_t sleep = {
550
- .Fields .WarmStart = 0 ,
554
+ .Fields .WarmStart = 1 ,
551
555
.Fields .Reset = 0 ,
552
556
.Fields .WakeUpRTC = 0 ,
553
557
.Fields .Reserved = 0 ,
@@ -622,7 +626,15 @@ int setRxContinuous(const struct device *dev) {
622
626
SX126xSetDioIrqParams (0xff , 0xff , 0x00 , 0x00 );
623
627
SX126xWriteRegister (0x08 , 0x04 ); //syncword
624
628
SX126xSetOperatingMode (MODE_RX );
625
- SX126xSetRx (0 );
629
+ //SX126xSetRx(0);
630
+
631
+ SX126xSetDioIrqParams ( IRQ_RADIO_ALL , //IRQ_RX_DONE | IRQ_RX_TX_TIMEOUT,
632
+ IRQ_RADIO_ALL , //IRQ_RX_DONE | IRQ_RX_TX_TIMEOUT,
633
+ IRQ_RADIO_NONE ,
634
+ IRQ_RADIO_NONE );
635
+
636
+ SX126xSetRxBoosted (0 );
637
+
626
638
//Wait for IRQ RxDone2 or Timeout: the chip will stay in Rx and look for a new packet if the continuous mode is selected
627
639
//otherwise it will goes to STDBY_RC mode.
628
640
@@ -640,11 +652,12 @@ void setModParams(const struct lora_modem_config *config) {
640
652
int n = 4 ;
641
653
uint8_t buf [n ];
642
654
//buf[0] = modulationParams->Params.LoRa.SpreadingFactor;
643
- buf [0 ] = config -> datarate ;
655
+ //buf[0] = config->datarate;
656
+ buf [0 ] = SF_11 ;
644
657
//buf[1] = modulationParams->Params.LoRa.Bandwidth;
645
- buf [1 ] = config -> bandwidth ;
658
+ buf [1 ] = BW_125_KHZ ;
646
659
//buf[2] = modulationParams->Params.LoRa.CodingRate;
647
- buf [2 ] = config -> coding_rate ;
660
+ buf [2 ] = CR_4_5 ;
648
661
//buf[3] = modulationParams->Params.LoRa.LowDatarateOptimize;
649
662
buf [3 ] = 0x01 ;
650
663
SX126xWriteCommand ( RADIO_SET_MODULATIONPARAMS , buf , n );
@@ -653,12 +666,12 @@ void setModParams(const struct lora_modem_config *config) {
653
666
void setPacketParams (const struct lora_modem_config * config , uint8_t size ) {
654
667
int n = 6 ;
655
668
uint8_t buf [n ];
656
- buf [0 ] = ( config -> preamble_len >> 8 ) & 0xFF ;
657
- buf [1 ] = config -> preamble_len ;
669
+ buf [0 ] = ( 0x00 >> 8 ) & 0xFF ; //Preamble length
670
+ buf [1 ] = 0x06 ; //Preamble length
658
671
buf [2 ] = 0x01 ; //Implicit header
659
- buf [3 ] = size ;
660
- buf [4 ] = LORA_CRC_ON ;
661
- buf [5 ] = config -> iq_inverted ;
672
+ buf [3 ] = 0x06 ; //Payload length
673
+ buf [4 ] = LORA_CRC_ON ; //CRC on
674
+ buf [5 ] = false; //Invert IQ
662
675
SX126xWriteCommand ( RADIO_SET_PACKETPARAMS , buf , n );
663
676
}
664
677
0 commit comments