Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,7 @@ bool NodeDB::resetRadioConfig(bool factory_reset)
rebootAtMsec = millis() + (5 * 1000);
}

#if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3)) && HAS_TFT
// as long as PhoneAPI shares BT and TFT app switch BT off
config.bluetooth.enabled = false;
if (moduleConfig.external_notification.nag_timeout == 60)
moduleConfig.external_notification.nag_timeout = 0;
#endif

LOG_ERROR("NodeDB::resetRadioConfig done %d", didFactoryReset);
return didFactoryReset;
}

Expand Down Expand Up @@ -612,6 +606,13 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
#else
bool hasScreen = screen_found.port != ScanI2C::I2CPort::NO_I2C;
#endif
#if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3) || defined(INDICATOR)) && HAS_TFT
// as long as PhoneAPI shares BT and TFT app switch BT off
LOG_ERROR("config.bluetooth.enabled = false");
config.bluetooth.enabled = false;
if (moduleConfig.external_notification.nag_timeout == 60)
moduleConfig.external_notification.nag_timeout = 0;
#endif
#ifdef USERPREFS_FIXED_BLUETOOTH
config.bluetooth.fixed_pin = USERPREFS_FIXED_BLUETOOTH;
config.bluetooth.mode = meshtastic_Config_BluetoothConfig_PairingMode_FIXED_PIN;
Expand Down
32 changes: 26 additions & 6 deletions src/mesh/api/PacketAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@ PacketAPI *PacketAPI::create(PacketServer *_server)
return packetAPI;
}

PacketAPI::PacketAPI(PacketServer *_server) : concurrency::OSThread("PacketAPI"), isConnected(false), server(_server) {}
PacketAPI::PacketAPI(PacketServer *_server)
: concurrency::OSThread("PacketAPI"), isConnected(false), programmingMode(false), server(_server)
{
}

int32_t PacketAPI::runOnce()
{
bool success = sendPacket();
bool success = false;
if (config.bluetooth.enabled) {
if (!programmingMode) {
// in programmingMode we don't send any packets to the client except this one notify
programmingMode = true;
success = notifyProgrammingMode();
}
} else {
success = sendPacket();
}
success |= receivePacket();
return success ? 10 : 50;
}
Expand Down Expand Up @@ -79,10 +91,6 @@ bool PacketAPI::sendPacket(void)
if (len != 0) {
static uint32_t id = 0;
fromRadioScratch.id = ++id;
// TODO: think about redesign or drop class MeshPacketServer
// if (typeid(*server) == typeid(MeshPacketServer))
// return dynamic_cast<MeshPacketServer*>(server)->sendPacket(fromRadioScratch);
// else
bool result = server->sendPacket(DataPacket<meshtastic_FromRadio>(id, fromRadioScratch));
if (!result) {
LOG_ERROR("send queue full");
Expand All @@ -92,6 +100,18 @@ bool PacketAPI::sendPacket(void)
return false;
}

bool PacketAPI::notifyProgrammingMode(void)
{
// tell the client we are in programming mode by sending only the bluetooth config state
LOG_INFO("force client into programmingMode");
memset(&fromRadioScratch, 0, sizeof(fromRadioScratch));
fromRadioScratch.id = nodeDB->getNodeNum();
fromRadioScratch.which_payload_variant = meshtastic_FromRadio_config_tag;
fromRadioScratch.config.which_payload_variant = meshtastic_Config_bluetooth_tag;
fromRadioScratch.config.payload_variant.bluetooth = config.bluetooth;
return server->sendPacket(DataPacket<meshtastic_FromRadio>(0, fromRadioScratch));
}

/**
* return true if we got (once!) contact from our client and the server send queue is not full
*/
Expand Down
2 changes: 2 additions & 0 deletions src/mesh/api/PacketAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ class PacketAPI : public PhoneAPI, public concurrency::OSThread
private:
bool receivePacket(void);
bool sendPacket(void);
bool notifyProgrammingMode(void);

bool isConnected;
bool programmingMode;
PacketServer *server;
uint8_t txBuf[MAX_TO_FROM_RADIO_SIZE] = {0}; // dummy buf to obey PhoneAPI
};
Expand Down
4 changes: 1 addition & 3 deletions variants/seeed-sensecap-indicator/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ build_flags =
${env:seeed-sensecap-indicator.build_flags}
-D MESHTASTIC_EXCLUDE_CANNEDMESSAGES=1
-D MESHTASTIC_EXCLUDE_INPUTBROKER=1
-D MESHTASTIC_EXCLUDE_BLUETOOTH=1
-D MESHTASTIC_EXCLUDE_SCREEN=1
-D MESHTASTIC_EXCLUDE_ENVIRONMENTAL_SENSOR=1
-D MESHTASTIC_EXCLUDE_WEBSERVER=1
Expand All @@ -52,7 +51,7 @@ build_flags =
-D HAS_TFT=1
-D DISPLAY_SET_RESOLUTION
-D USE_I2S_BUZZER
-D RAM_SIZE=3072
-D RAM_SIZE=4096
-D LV_LVGL_H_INCLUDE_SIMPLE
-D LV_CONF_INCLUDE_SIMPLE
-D LV_COMP_CONF_INCLUDE_SIMPLE
Expand All @@ -64,7 +63,6 @@ build_flags =
-D USE_LOG_DEBUG
-D LOG_DEBUG_INC=\"DebugConfiguration.h\"
-D CUSTOM_TOUCH_DRIVER
; -D CALIBRATE_TOUCH=0
-D LGFX_DRIVER=LGFX_INDICATOR
-D GFX_DRIVER_INC=\"graphics/LGFX/LGFX_INDICATOR.h\"
-D VIEW_320x240
Expand Down
2 changes: 2 additions & 0 deletions variants/seeed-sensecap-indicator/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#define SENSOR_PORT_NUM 2
#define SENSOR_BAUD_RATE 115200

#if !HAS_TFT
#define BUTTON_PIN 38
#endif
// #define BUTTON_NEED_PULLUP

// #define BATTERY_PIN 27 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage
Expand Down
3 changes: 0 additions & 3 deletions variants/t-deck/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ build_flags =
-D CONFIG_DISABLE_HAL_LOCKS=1 ; "feels" to be a bit more stable without locks
-D MESHTASTIC_EXCLUDE_CANNEDMESSAGES=1
-D MESHTASTIC_EXCLUDE_INPUTBROKER=1
-D MESHTASTIC_EXCLUDE_BLUETOOTH=1
-D MESHTASTIC_EXCLUDE_WEBSERVER=1
-D MESHTASTIC_EXCLUDE_SERIAL=1
-D MESHTASTIC_EXCLUDE_SOCKETAPI=1
Expand Down Expand Up @@ -58,7 +57,6 @@ build_flags =
-D RADIOLIB_DEBUG_SPI=0
-D RADIOLIB_DEBUG_PROTOCOL=0
-D RADIOLIB_SPI_PARANOID=0
; -D CUSTOM_TOUCH_DRIVER
-D CALIBRATE_TOUCH=0
-D LGFX_DRIVER=LGFX_TDECK
-D GFX_DRIVER_INC=\"graphics/LGFX/LGFX_T_DECK.h\"
Expand All @@ -79,4 +77,3 @@ build_src_filter =

lib_deps =
${env:t-deck.lib_deps}
bitbank2/bb_captouch@1.2.2 ; alternative touch library supporting GT911
Loading