Skip to content

Commit

Permalink
Bring back the SX1262 for TX, not yet RX
Browse files Browse the repository at this point in the history
  • Loading branch information
pjalocha committed May 26, 2023
1 parent d3dba4d commit a6ef1be
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 48 deletions.
11 changes: 6 additions & 5 deletions T-Beam_v10.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,24 @@
// #define WITH_KNOB
// #define WITH_VARIO

#define WITH_ADSL
// #define WITH_ADSL
// #define WITH_PAW
#define WITH_FANET
// #define WITH_FANET
#define WITH_LORAWAN

#define WITH_AP // WiFi Access Point: can work together with BT_SPP
#define WITH_AP_BUTTON // only starts when button pressed at sartup
// #define WITH_BT_SPP // Bluetooth serial port for smartphone/tablet link: can work together with WiFi Access point
#define WITH_BT_SPP // Bluetooth serial port for smartphone/tablet link: can work together with WiFi Access point
// #define WITH_STRATUX // beta-code: connect to Stratux WiFi and serve as GPS and OGN transmitter/receiver
// #define WITH_APRS // alpha-code: attempt to connect to the wifi router for uploading the log files to APRS

#define WITH_HTTP // HTTP server, works with AP dna should work with Stratux as well

// #define WITH_SD // use the SD card in SPI mode and FAT file system
#define WITH_SPIFFS_FAT
#define WITH_SPIFFS // use SPIFFS file system in Flash
#define WITH_SPIFFS_FAT // use FAT on the SPIFFS
#define WITH_LOG // log own positions and other received to SPIFFS and possibly to uSD
// #define WITH_SD // use the SD card in SPI mode and FAT file system
// #define WITH_SDLOG // log console and IGC to the SD card

// #define WITH_ENCRYPT // Encrypt (optionally) the position

Expand Down
57 changes: 38 additions & 19 deletions T-Beam_v10_sx1262.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,39 @@
#define DEFAULT_CONbaud 115200
#define DEFAULT_PPSdelay 100
#define DEFAULT_FreqPlan 0
#define DEFAULT_DispPage 3 // Fab501 Page to Display After Boot or Reset

#define WIFI_ADDRESS_IP1 192 // 192.168.1.1 for IP Address
#define WIFI_ADDRESS_IP2 168
#define WIFI_ADDRESS_IP3 1
#define WIFI_ADDRESS_IP4 1
#define WIFI_ADDRESS_GW1 0 // 0.0.0.0 for Gateway
#define WIFI_ADDRESS_GW2 0
#define WIFI_ADDRESS_GW3 0
#define WIFI_ADDRESS_GW4 0
#define WIFI_ADDRESS_MK1 255 // 255.255.255.0 for Mask
#define WIFI_ADDRESS_MK2 255
#define WIFI_ADDRESS_MK3 255
#define WIFI_ADDRESS_MK4 0

// #define WITH_HELTEC // HELTEC module: PCB LED on GPI025
// #define WITH_TTGO // TTGO module: PCB LED on GPIO2, GPIO25 free to use as DAC2 output
// #define WITH_TBEAM // T-Beam module
#define WITH_TBEAM_V10 // T-Beam module
// #define WITH_JACEK // JACEK ESP32 OGN-Tracker
// #define WITH_M5_JACEK // JACEK M5 ESP32 OGN-Tracker
// #define WITH_FollowMe // by Avionix

// #define WITH_ILI9341 // 320x240 M5stack
// #define WITH_ST7789 // IPS 240x240 ST7789
// #define WITH_TFT_LCD // TFT LCD
// #define WITH_TFT_LCD // TFT LCD (incomplete)
// #define WITH_OLED // OLED display on the I2C: some TTGO modules are without OLED display
// #define WITH_OLED2 // 2nd OLED display, I2C address next higher
// #define WITH_U8G2_OLED // I2C OLED through the U8g2 library
// #define WITH_U8G2_FLIP
// #define WITH_U8G2_SH1106 // the bigger OLED controller
// #define WITH_U8G2_FLIP // flip the OLED screen

// #define WITH_RFM69 // Jacek design uses RFM69
// #define WITH_RFM95 // RF chip selection: both HELTEC and TTGO use sx1276 which is same as RFM95
#define WITH_SX1262
#define WITH_SX1262 // RF chip selection: both HELTEC and TTGO use sx1276 which is same as RFM95

// #define WITH_SLEEP // with software sleep mode controlled by the long-press on the button

Expand All @@ -49,34 +62,40 @@
#define WITH_BME280 // BMP280 with humidity (but still works with BMP280)
// #define WITH_MS5607 // MS5607 pressure sensor

// #define WITH_GDL90
#define WITH_PFLAA // PFLAU and PFLAA for compatibility with XCsoar and LK8000
// #define WITH_POGNT
#define WITH_LOOKOUT

#define WITH_CONFIG // interpret the console input: $POGNS to change parameters

// #define WITH_LORAWAN
#define WITH_PAW

// #define WITH_BEEPER // with digital buzzer
// #define WITH_SOUND // with analog sound produced by DAC on pin 25

// #define WITH_KNOB
// #define WITH_VARIO

// #define WITH_SD // use the SD card in SPI mode and FAT file system
#define WITH_SPIFFS // use SPIFFS file system in Flash
#define WITH_SPIFFS_FAT // use FAT instead of SPIFFS file system on the Flash
#define WITH_LOG // log own positions and other received to SPIFFS and possibly to uSD
// #define WITH_ADSL
// #define WITH_PAW
// #define WITH_FANET
// #define WITH_LORAWAN

#define WITH_BT_SPP // Bluetooth serial port for smartphone/tablet link
// #define WITH_WIFI // attempt to connect to the wifi router for uploading the log files
// #define WITH_SPIFFS_LOG // log transmitted and received packets to SPIFFS
#define WITH_AP // WiFi Access Point: can work together with BT_SPP
#define WITH_AP_BUTTON // only starts when button pressed at sartup
#define WITH_BT_SPP // Bluetooth serial port for smartphone/tablet link: can work together with WiFi Access point
// #define WITH_STRATUX // beta-code: connect to Stratux WiFi and serve as GPS and OGN transmitter/receiver
// #define WITH_APRS // alpha-code: attempt to connect to the wifi router for uploading the log files to APRS

#define WITH_AP
#define WITH_AP_BUTTON
#define WITH_HTTP
#define WITH_HTTP // HTTP server, works with AP dna should work with Stratux as well

#define WITH_SPIFFS // use SPIFFS file system in Flash
#define WITH_SPIFFS_FAT // use FAT on the SPIFFS
#define WITH_LOG // log own positions and other received to SPIFFS and possibly to uSD
// #define WITH_SD // use the SD card in SPI mode and FAT file system
// #define WITH_SDLOG // log console and IGC to the SD card

// #define WITH_ENCRYPT // Encrypt (optionally) the position

#if defined(WITH_STRATUX) || defined(WITH_APRS) || defined(WITH_AP)
#define WITH_WIFI
#endif

15 changes: 9 additions & 6 deletions main/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
// #define WITH_OLED // OLED display on the I2C: some TTGO modules are without OLED display
// #define WITH_OLED2 // 2nd OLED display, I2C address next higher
// #define WITH_U8G2_OLED // I2C OLED through the U8g2 library
// #define WITH_U8G2_SH1106 // the bigger OLED controller
// #define WITH_U8G2_FLIP // flip the OLED screen

#define WITH_RFM95 // RF chip selection: both HELTEC and TTGO use sx1276 which is same as RFM95
// #define WITH_SX1262 // RF chip selection: both HELTEC and TTGO use sx1276 which is same as RFM95
Expand Down Expand Up @@ -72,23 +74,24 @@
// #define WITH_KNOB
// #define WITH_VARIO

#define WITH_ADSL
// #define WITH_ADSL
// #define WITH_PAW
// #define WITH_FANET
#define WITH_LORAWAN
// #define WITH_LORAWAN

#define WITH_AP // WiFi Access Point: can work together with BT_SPP
// #define WITH_AP_BUTTON // only starts when button pressed at sartup
// #define WITH_BT_SPP // Bluetooth serial port for smartphone/tablet link: can work together with WiFi Access point
#define WITH_AP_BUTTON // only starts when button pressed at sartup
#define WITH_BT_SPP // Bluetooth serial port for smartphone/tablet link: can work together with WiFi Access point
// #define WITH_STRATUX // beta-code: connect to Stratux WiFi and serve as GPS and OGN transmitter/receiver
// #define WITH_APRS // alpha-code: attempt to connect to the wifi router for uploading the log files to APRS

#define WITH_HTTP // HTTP server, works with AP dna should work with Stratux as well

// #define WITH_SD // use the SD card in SPI mode and FAT file system
#define WITH_SPIFFS_FAT
#define WITH_SPIFFS // use SPIFFS file system in Flash
#define WITH_SPIFFS_FAT // use FAT on the SPIFFS
#define WITH_LOG // log own positions and other received to SPIFFS and possibly to uSD
// #define WITH_SD // use the SD card in SPI mode and FAT file system
// #define WITH_SDLOG // log console and IGC to the SD card

// #define WITH_ENCRYPT // Encrypt (optionally) the position

Expand Down
20 changes: 12 additions & 8 deletions main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,18 @@ void app_main(void)
#endif
#endif

#ifdef WITH_AP
#ifdef WITH_AP_BUTTON
bool StartAP = Button_isPressed() && Parameters.APname[0]; // start WiFi AP when button pressed during startup and APname non-empty
#else
bool StartAP = Parameters.APname[0]; // start WiFi AP when APname non-empty
#endif
#else // WITH_AP
const bool StartAP=0;
#endif // WITH_AP

#if defined(WITH_BT_SPP) || defined(WITH_BLE_SPP)
if(!StartAP)
{ int32_t Err=BT_SPP_Init(); // start BT SPP
// #ifdef DEBUG_PRINT
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
Expand Down Expand Up @@ -166,16 +177,9 @@ void app_main(void)
#endif

#ifdef WITH_AP
#ifdef WITH_AP_BUTTON
bool StartAP = Button_isPressed() && Parameters.APname[0]; // start WiFi AP when button pressed during startup and APname non-empty
#else
bool StartAP = Parameters.APname[0]; // start WiFi AP when APname non-empty
#endif
if(StartAP)
xTaskCreate(vTaskAP, "AP", 3000, 0, tskIDLE_PRIORITY+3, 0);
#else // WITH_AP
const bool StartAP=0;
#endif // WITH_AP
#endif
#ifdef WITH_APRS
if(!StartAP)
xTaskCreate(vTaskAPRS, "APRS", 4000, 0, tskIDLE_PRIORITY+2, 0);
Expand Down
12 changes: 6 additions & 6 deletions main/rf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static uint8_t RX_Channel=0; // (hopping) channel currently being
static void SetTxChannel(uint8_t TxChan=RX_Channel, const uint8_t *SYNC=OGN_SYNC) // default channel to transmit is same as the receive channel
{
#ifdef WITH_SX1262
TRX.OGN_Configure(TxChan&0x7F, SYNC);
TRX.FSK_Configure(TxChan&0x7F, SYNC, OGN_TxPacket<OGN_Packet>::Bytes);
TRX.WaitWhileBusy_ms(2);
TRX.WriteTxPower(Parameters.TxPower);
TRX.WaitWhileBusy_ms(2);
Expand All @@ -83,7 +83,7 @@ static void SetTxChannel(uint8_t TxChan=RX_Channel, const uint8_t *SYNC=OGN_SYNC
static void SetRxChannel(uint8_t RxChan=RX_Channel, const uint8_t *SYNC=OGN_SYNC)
{
#ifdef WITH_SX1262
// TRX.OGN_Configure(RxChan&0x7F, SYNC);
// TRX.FSK_Configure(RxChan&0x7F, SYNC);
TRX.setChannel(RxChan&0x7F);
TRX.FSK_WriteSYNC(7, 7, SYNC); // Shorter SYNC for RX
#else
Expand Down Expand Up @@ -221,7 +221,7 @@ static uint8_t Transmit(uint8_t TxChan, const uint8_t *PacketByte, uint8_t Thres
SetTxChannel(TxChan);

#ifdef WITH_SX1262
TRX.OGN_WritePacket(PacketByte);
TRX.FSK_WritePacket(PacketByte, OGN_TxPacket<OGN_Packet>::Bytes);
uint16_t PreFlags=TRX.ReadIrqFlags();
TRX.ClearIrqFlags();
TRX.WaitWhileBusy_ms(10);
Expand Down Expand Up @@ -376,11 +376,11 @@ static uint8_t StartRFchip(void)
{ Format_Hex(CONS_UART_Write, SYNC[Idx]); } // SYNC after chip reset can serve as a detection method for sx1262
Format_String(CONS_UART_Write, "\n"); // it should be: 0x9723522556536564
xSemaphoreGive(CONS_Mutex); }
#endif
#endif // DEBUG_PRINT
TRX.StopOnPreamble(0);
#else // WITH_SX1262 // not WITH_SX1262
vTaskDelay(5); // wait 10ms
#endif
#endif // WITH_SX1262
SetFreqPlanOGN(); // set TRX base frequency and channel separation after the frequency hopping plan
#ifdef DEBUG_PRINT
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
Expand All @@ -406,7 +406,7 @@ static uint8_t StartRFchip(void)
#endif
TRX.CalibrateImage();
TRX.WaitWhileBusy_ms(20);
if(TRX.readBusy()) Format_String(CONS_UART_Write, "StartRFchip() sx1262 BUSY after OGN_Configure() and Calibrate()\n");
if(TRX.readBusy()) Format_String(CONS_UART_Write, "StartRFchip() sx1262 BUSY after FSK_Configure() and Calibrate()\n");
#endif
TRX.setModeStandby(); // set RF chip mode to STANDBY
uint8_t Version = TRX.ReadVersion();
Expand Down
8 changes: 4 additions & 4 deletions main/rfm.h
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ class RFM_TRX
Cmd_Write(CMD_SETPACKETPARAMS, Param, 9); // 0x8C, PacketParam
Regs_Write(REG_SYNCWORD0, SyncData+(8-WriteSize), WriteSize); } // Write the SYNC word

void OGN_Configure(int16_t Channel, const uint8_t *SyncData)
void FSK_Configure(int16_t Channel, const uint8_t *SyncData, uint8_t PktSize)
{ setChannel(Channel);
uint8_t Param[12];
Pack3bytes(Param, 10240); // data bitrate = 32*Xtal/100e3 for OGN 100kbps
Expand All @@ -781,7 +781,7 @@ class RFM_TRX
Param[3] = 8*8; // [bits] SYNC word length, write word at 0x06C0
Param[4] = 0x00; // address filtering: OFF
Param[5] = 0x00; // fixed packet size
Param[6] = 2*26; // 26 bytes, software Manchester
Param[6] = PktSize*2; // 26 bytes, software Manchester
Param[7] = 0x01; // no CRC
Param[8] = 0x00; // no whitening
Cmd_Write(CMD_SETPACKETPARAMS, Param, 9); // 0x8C, PacketParam
Expand Down Expand Up @@ -887,7 +887,7 @@ class RFM_TRX

void WriteTxPowerMin(void) { WriteTxPower_W(-18); } // set minimal Tx power and setup for reception

void OGN_Configure(int16_t Channel, const uint8_t *Sync)
void FSK_Configure(int16_t Channel, const uint8_t *Sync)
{ WriteMode(RF_OPMODE_STANDBY); // mode = STDBY
ClearIrqFlags();
WriteByte( 0x02, REG_DATAMODUL); // [0x00] Packet mode, FSK, 0x02: BT=0.5, 0x01: BT=1.0, 0x03: BT=0.3
Expand Down Expand Up @@ -1086,7 +1086,7 @@ class RFM_TRX

return 0; }

// void OGN_Configure(int16_t Channel, const uint8_t *Sync)
// void FSK_Configure(int16_t Channel, const uint8_t *Sync)
// { FSK_Configure(Channel, Sync, 2*26); }

// void ADSL_Configure(int16_t Channel, const uint8_t *Sync)
Expand Down

0 comments on commit a6ef1be

Please sign in to comment.