Skip to content

Commit

Permalink
RP2040: BT SPP reconnect effort
Browse files Browse the repository at this point in the history
  • Loading branch information
Linar Yusupov committed Jun 5, 2023
1 parent 3f5560b commit ab957ac
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 41 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Model(s)|Platform|First appearance|       Sta
1&nbsp;[**Academy**](https://github.com/lyusupov/SoftRF/wiki/Academy-Edition)<br>2&nbsp;[USB2BT](https://github.com/lyusupov/SoftRF/wiki/USB-to-Bluetooth-adapter)&nbsp;![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg)|[Microchip&nbsp;(Atmel)<br>SAM&nbsp;D21](https://www.microchip.com/en-us/products/microcontrollers-and-microprocessors/32-bit-mcus/sam-32-bit-mcus/sam-d) <!-- and [ATmega2560](https://www.microchip.com/en-us/product/ATmega2560) -->|Q4 2021|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png) <!-- ![](https://via.placeholder.com/140x40/c5f015/000000?text=May+need)<br>![](https://via.placeholder.com/140x40/c5f015/000000?text=improvements) -->|good for teaching students of air traffic proximity awareness
[**Octave**](https://github.com/lyusupov/SoftRF/wiki/Octave-Concept)|[ASR Microelectronics<br>ASR6601](https://asriot.readthedocs.io/en/latest/ASR6601/index.html)|Q1 2022|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)| **the best 'price per radio protocol' ratio** on the market
1&nbsp;[**Lego**](https://github.com/lyusupov/SoftRF/wiki/Lego-Edition)<br>2&nbsp;[**SkyView Pico**](https://github.com/lyusupov/SoftRF/wiki/SkyView-Pico)&nbsp;![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg)|[Raspberry Pi<br>Foundation<br>**RP2040**](https://en.wikipedia.org/wiki/RP2040)|Q1 2022|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|&nbsp;holds [**FCC/CE** mark](https://github.com/lyusupov/SoftRF/wiki/Lego-Edition#certificates)
[**Balkan**](https://github.com/lyusupov/SoftRF/wiki/Balkan-Edition)|[STMicroelectronics](https://en.wikipedia.org/wiki/STMicroelectronics)<br>[STM32**WLE5**](https://www.st.com/en/microcontrollers-microprocessors/stm32wle5cc.html)|Q3 2022|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_may_need_imp.png)|&nbsp;holds [**CE** mark](https://github.com/lyusupov/SoftRF/wiki/Balkan-Edition#certificates)
[**Balkan**](https://github.com/lyusupov/SoftRF/wiki/Balkan-Edition)|[STMicroelectronics](https://en.wikipedia.org/wiki/STMicroelectronics)<br>[STM32**WLE5**](https://www.st.com/en/microcontrollers-microprocessors/stm32wle5cc.html)|Q3 2022|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|&nbsp;holds [**CE** mark](https://github.com/lyusupov/SoftRF/wiki/Balkan-Edition#certificates)
[**WebTop USB**](https://github.com/lyusupov/SoftRF/wiki/WebTop-USB)![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg)|[Espressif<br>ESP32-S2](https://en.wikipedia.org/wiki/ESP32#ESP32-S2)|Q4 2022|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_may_need_imp.png)|
[**Standalone**](https://github.com/lyusupov/SoftRF/wiki/Standalone-Edition)&nbsp;**upgrade**![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg)|[Espressif<br>ESP32-C3](https://en.wikipedia.org/wiki/ESP32#ESP32-C3)|Q1 2023|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_may_need_imp.png)|[RISC-V](https://en.wikipedia.org/wiki/RISC-V)
1&nbsp;[**Prime Mark III**](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkIII)![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg)<br>2&nbsp;[**SkyView Pico**](https://github.com/lyusupov/SoftRF/wiki/SkyView-Pico#alternative-hardware-option)&nbsp;![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/new-icon.jpg)|[Espressif<br>ESP32-S3](https://en.wikipedia.org/wiki/ESP32#ESP32-S3)|Q1 2023|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_may_need_imp.png)|
Expand All @@ -118,7 +118,7 @@ GNSS|Model(s)|First appearance|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Status&
---|:---:|:---:|:---:|---
Generic<br>NMEA|[Standalone](https://github.com/lyusupov/SoftRF/wiki/Standalone-Edition)|Q4 2016|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|&nbsp;
[U-blox](https://en.wikipedia.org/wiki/U-blox)<br>6/7/8/9/10|1&nbsp;[**Prime Mark II**](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkII)<br>2&nbsp;[Retro](https://github.com/lyusupov/SoftRF/wiki/Retro-Edition)<br>3&nbsp;[**Uni**](https://github.com/lyusupov/SoftRF/wiki/Uni-Edition)<br>4&nbsp;[**Lego**](https://github.com/lyusupov/SoftRF/wiki/Lego-Edition)<br>5&nbsp;[**Balkan**](https://github.com/lyusupov/SoftRF/wiki/Balkan-Edition)<br>6&nbsp;[**Prime Mark III**](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkIII)|Q2 2018|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|&nbsp;
[Hangzhou ZhongKe](http://www.icofchina.com/)<br>AT6558|[1&nbsp;**Prime Mark II**](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkII)<br>2&nbsp;[**Mini**](https://github.com/lyusupov/SoftRF/wiki/Mini-Edition)<br>3&nbsp;[**Badge**](https://github.com/lyusupov/SoftRF/wiki/Badge-Edition)|Q2 2019|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|&nbsp;
[Hangzhou ZhongKe](http://www.icofchina.com/)<br>AT6558|[1&nbsp;**Prime Mark II**](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkII)<br>2&nbsp;[**Mini**](https://github.com/lyusupov/SoftRF/wiki/Mini-Edition)<br>3&nbsp;[**Badge**](https://github.com/lyusupov/SoftRF/wiki/Badge-Edition)<br>4&nbsp;[**Prime Mark III**](https://github.com/lyusupov/SoftRF/wiki/Prime-Edition-MkIII)|Q2 2019|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|&nbsp;
[Sony<br>CXD5603GF](https://www.sony-semicon.co.jp/e/products/lsi/gps/product.html)|1&nbsp;[**Dongle**](https://github.com/lyusupov/SoftRF/wiki/Dongle-Edition)<!-- <br>2&nbsp;[**Bracelet**](https://github.com/lyusupov/SoftRF/wiki/Bracelet-Edition) -->|Q4 2019|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|&nbsp;
[MediaTek](https://en.wikipedia.org/wiki/MediaTek)<br>MT3339|1&nbsp;[**Raspberry**](https://github.com/lyusupov/SoftRF/wiki/Raspberry-Edition)<br>2&nbsp;[**Uni**](https://github.com/lyusupov/SoftRF/wiki/Uni-Edition)<br>3&nbsp;[**Academy**](https://github.com/lyusupov/SoftRF/wiki/Academy-Edition)<br>4&nbsp;[**Lego**](https://github.com/lyusupov/SoftRF/wiki/Lego-Edition)|Q3 2020|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|&nbsp;
[GOKE](http://www.goke.com/en/)<br>GK9501|[**Mini**](https://github.com/lyusupov/SoftRF/wiki/Mini-Edition)|Q3 2020|![](https://github.com/lyusupov/SoftRF/raw/master/documents/images/icon_good.png)|&nbsp;
Expand Down
8 changes: 4 additions & 4 deletions software/firmware/source/SkyView/BluetoothHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ static size_t _fifoSize = 512;
static uint16_t _channelID = 0;
static volatile int _writeLen = 0;
static uint8_t rfcomm_server_channel = 1;
static char *pin_code = "0000";
static char *pin_code = (char *) "0000";
static uint8_t service_index = 0;

static mutex_t _mutex;
Expand Down Expand Up @@ -929,9 +929,9 @@ static void hci_spp_event_handler(uint8_t packet_type, uint16_t channel, uint8_t
service_index = 0;
rfcomm_server_channel = 1;

// re-enable page/inquiry scan again
gap_discoverable_control(1);
gap_connectable_control(1);
hci_power_control(HCI_POWER_OFF);
hci_power_control(HCI_POWER_ON);

break;

default:
Expand Down
8 changes: 7 additions & 1 deletion software/firmware/source/SkyView/EEPROMHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,16 @@
#include <EEPROM.h>
#endif /* ARDUINO */


#define SKYVIEW_EEPROM_MAGIC 0xABBAFACE
#define SKYVIEW_EEPROM_VERSION 0x0000001D

enum
{
EEPROM_EXT_LOAD,
EEPROM_EXT_DEFAULTS,
EEPROM_EXT_STORE
};

typedef struct Settings {
uint8_t adapter;

Expand Down
6 changes: 6 additions & 0 deletions software/firmware/source/SkyView/Platform_ESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,11 @@ static bool ESP32_EEPROM_begin(size_t size)
return EEPROM.begin(size);
}

static void ESP32_EEPROM_extension(int cmd)
{
/* TBD */
}

static const int8_t ESP32_dB_to_power_level[21] = {
8, /* 2 dB, #0 */
8, /* 2 dB, #1 */
Expand Down Expand Up @@ -1882,6 +1887,7 @@ const SoC_ops_t ESP32_ops = {
ESP32_getChipId,
ESP32_getFreeHeap,
ESP32_EEPROM_begin,
ESP32_EEPROM_extension,
ESP32_WiFi_setOutputPower,
ESP32_WiFi_hostname,
ESP32_swSer_begin,
Expand Down
6 changes: 6 additions & 0 deletions software/firmware/source/SkyView/Platform_ESP8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ static bool ESP8266_EEPROM_begin(size_t size)
return true;
}

static void ESP8266_EEPROM_extension(int cmd)
{
/* TBD */
}

static void ESP8266_WiFi_setOutputPower(int dB)
{
WiFi.setOutputPower(dB);
Expand Down Expand Up @@ -240,6 +245,7 @@ const SoC_ops_t ESP8266_ops = {
ESP8266_getChipId,
ESP8266_getFreeHeap,
ESP8266_EEPROM_begin,
ESP8266_EEPROM_extension,
ESP8266_WiFi_setOutputPower,
ESP8266_WiFi_hostname,
ESP8266_swSer_begin,
Expand Down
99 changes: 66 additions & 33 deletions software/firmware/source/SkyView/Platform_RP2040.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,30 +358,56 @@ static void RP2040_post_init()

Serial.println();

Serial.print(F("Board : "));

switch (RP2040_board)
{
case RP2040_RPIPICO_W : Serial.println(F("Pico W")); break;
case RP2040_WEACT : Serial.println(F("WeAct")); break;
case RP2040_RPIPICO :
default : Serial.println(F("Pico")); break;
break;
}

Serial.print(F("Display : "));

if (hw_info.display != DISPLAY_EPD_2_7 || display == NULL) {
Serial.println(F("NONE"));
} else {
switch (display->epd2.panel)
{
case GxEPD2::GDEY027T91: Serial.println(F("GDEY027T91")); break;
case GxEPD2::GDEW027W3 : Serial.println(F("GDEW027W3")); break;
default : Serial.println(F("OTHER")); break;
}
}

Serial.println();

Serial.print(F("Input source : "));
switch (settings->connection)
{
case CON_SERIAL_MAIN : Serial.print (F("UART MAIN "));
Serial.println(SerialBaud); break;
case CON_SERIAL_AUX : Serial.print (F("UART AUX "));
Serial.println(SerialBaud); break;
case CON_USB : Serial.println(F("USB")); break;
case CON_WIFI_UDP : Serial.println(F("WIFI UDP")); break;
case CON_WIFI_TCP : Serial.println(F("WIFI TCP")); break;
case CON_BLUETOOTH_SPP : Serial.println(F("BT SPP")); break;
case CON_BLUETOOTH_LE : Serial.println(F("BT LE")); break;
case CON_SERIAL_MAIN : Serial.print (F("UART MAIN "));
Serial.println(SerialBaud); break;
case CON_SERIAL_AUX : Serial.print (F("UART AUX "));
Serial.println(SerialBaud); break;
case CON_USB : Serial.println(F("USB")); break;
case CON_WIFI_UDP : Serial.println(F("WIFI UDP")); break;
case CON_WIFI_TCP : Serial.println(F("WIFI TCP")); break;
case CON_BLUETOOTH_SPP : Serial.println(F("BT SPP")); break;
case CON_BLUETOOTH_LE : Serial.println(F("BT LE")); break;
case CON_NONE :
default : Serial.println(F("NONE")); break;
default : Serial.println(F("NONE")); break;
}

Serial.print(F("Protocol : "));
switch (settings->protocol)
{
case PROTOCOL_NMEA : Serial.println(F("NMEA")); break;
case PROTOCOL_GDL90 : Serial.println(F("GDL90")); break;
case PROTOCOL_D1090 : Serial.println(F("D1090")); break;
case PROTOCOL_NMEA : Serial.println(F("NMEA")); break;
case PROTOCOL_GDL90 : Serial.println(F("GDL90")); break;
case PROTOCOL_D1090 : Serial.println(F("D1090")); break;
case PROTOCOL_NONE :
default : Serial.println(F("NONE")); break;
default : Serial.println(F("NONE")); break;
}

Serial.println();
Expand Down Expand Up @@ -511,39 +537,45 @@ static uint32_t RP2040_getFreeHeap()
static bool RP2040_EEPROM_begin(size_t size)
{
EEPROM.begin(size);
return true;
}

static void RP2040_EEPROM_extension(int cmd)
{
if (cmd == EEPROM_EXT_LOAD) {

if ( RP2040_has_spiflash && FATFS_is_mounted ) {
File32 file = fatfs.open("/settings.json", FILE_READ);
if ( RP2040_has_spiflash && FATFS_is_mounted ) {
File32 file = fatfs.open("/settings.json", FILE_READ);

if (file) {
// StaticJsonBuffer<RP2040_JSON_BUFFER_SIZE> RP2040_jsonBuffer;
if (file) {
// StaticJsonBuffer<RP2040_JSON_BUFFER_SIZE> RP2040_jsonBuffer;

JsonObject &root = RP2040_jsonBuffer.parseObject(file);
JsonObject &root = RP2040_jsonBuffer.parseObject(file);

if (root.success()) {
JsonVariant msg_class = root["class"];
if (root.success()) {
JsonVariant msg_class = root["class"];

if (msg_class.success()) {
const char *msg_class_s = msg_class.as<char*>();
if (msg_class.success()) {
const char *msg_class_s = msg_class.as<char*>();

if (!strcmp(msg_class_s,"SKYVIEW")) {
parseSettings(root);
if (!strcmp(msg_class_s,"SKYVIEW")) {
parseSettings(root);
}
}
}
file.close();
}
file.close();
}
}

if (RP2040_board != RP2040_RPIPICO_W &&
(settings->connection == CON_BLUETOOTH_SPP ||
settings->connection == CON_BLUETOOTH_LE)) {
settings->connection = CON_USB; /* matches EEPROMHelper.cpp default value */
if (RP2040_board != RP2040_RPIPICO_W &&
(settings->connection == CON_BLUETOOTH_SPP ||
settings->connection == CON_BLUETOOTH_LE)) {
settings->connection = CON_USB; /* matches EEPROMHelper.cpp default value */
}
}

return true;
}


static void RP2040_WiFi_setOutputPower(int dB)
{
#if !defined(EXCLUDE_WIFI)
Expand Down Expand Up @@ -1698,6 +1730,7 @@ const SoC_ops_t RP2040_ops = {
RP2040_getChipId,
RP2040_getFreeHeap,
RP2040_EEPROM_begin,
RP2040_EEPROM_extension,
RP2040_WiFi_setOutputPower,
RP2040_WiFi_hostname,
RP2040_swSer_begin,
Expand Down
1 change: 1 addition & 0 deletions software/firmware/source/SkyView/Platform_RPi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ const SoC_ops_t RPi_ops = {
NULL,
NULL,
NULL,
NULL,
RPi_swSer_begin,
NULL,
NULL,
Expand Down
2 changes: 1 addition & 1 deletion software/firmware/source/SkyView/SkyView.ino
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void setup()

SoC->DB_init();

SoC->TTS("POST");
SoC->TTS((char*) "POST");

Web_setup();
Traffic_setup();
Expand Down
1 change: 1 addition & 0 deletions software/firmware/source/SkyView/SoCHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ typedef struct SoC_ops_struct {
uint32_t (*getChipId)();
uint32_t (*getFreeHeap)();
bool (*EEPROM_begin)(size_t);
void (*EEPROM_extension)(int);
void (*WiFi_setOutputPower)(int);
bool (*WiFi_hostname)(String);
void (*swSer_begin)(unsigned long);
Expand Down

0 comments on commit ab957ac

Please sign in to comment.