From a6ef1beedff33972be9e1f7a9d5e4b3a04282e83 Mon Sep 17 00:00:00 2001 From: Pawel Jalocha Date: Fri, 26 May 2023 01:23:38 +0100 Subject: [PATCH] Bring back the SX1262 for TX, not yet RX --- T-Beam_v10.cfg | 11 +++++---- T-Beam_v10_sx1262.cfg | 57 ++++++++++++++++++++++++++++--------------- main/config.h | 15 +++++++----- main/main.cpp | 20 +++++++++------ main/rf.cpp | 12 ++++----- main/rfm.h | 8 +++--- 6 files changed, 75 insertions(+), 48 deletions(-) diff --git a/T-Beam_v10.cfg b/T-Beam_v10.cfg index 1210d01..12512b9 100644 --- a/T-Beam_v10.cfg +++ b/T-Beam_v10.cfg @@ -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 diff --git a/T-Beam_v10_sx1262.cfg b/T-Beam_v10_sx1262.cfg index dabe495..13bb4d9 100644 --- a/T-Beam_v10_sx1262.cfg +++ b/T-Beam_v10_sx1262.cfg @@ -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 @@ -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_ADSL +// #define WITH_PAW +// #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_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_SPIFFS // use SPIFFS file system in Flash -#define WITH_SPIFFS_FAT // use FAT instead of SPIFFS file system on the 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_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 -#define WITH_AP_BUTTON -#define WITH_HTTP +// #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 + diff --git a/main/config.h b/main/config.h index 43c2ad5..1aa5124 100644 --- a/main/config.h +++ b/main/config.h @@ -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 @@ -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 diff --git a/main/main.cpp b/main/main.cpp index ffbf1d4..7256569 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -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); @@ -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); diff --git a/main/rf.cpp b/main/rf.cpp index bf13700..93b2335 100644 --- a/main/rf.cpp +++ b/main/rf.cpp @@ -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::Bytes); TRX.WaitWhileBusy_ms(2); TRX.WriteTxPower(Parameters.TxPower); TRX.WaitWhileBusy_ms(2); @@ -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 @@ -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::Bytes); uint16_t PreFlags=TRX.ReadIrqFlags(); TRX.ClearIrqFlags(); TRX.WaitWhileBusy_ms(10); @@ -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); @@ -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(); diff --git a/main/rfm.h b/main/rfm.h index 6b37f28..d5e0168 100644 --- a/main/rfm.h +++ b/main/rfm.h @@ -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 @@ -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 @@ -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 @@ -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)