mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-26 18:09:04 +00:00
Better logging and cleanup (#1662)
This commit is contained in:
parent
0efa1b25c5
commit
7f586f7099
@ -1 +1 @@
|
|||||||
Subproject commit 579308947366b35f7eb6908d5eaabd0114bba244
|
Subproject commit d8213ad133c42fb59a052326659e2cbfde3db6d6
|
@ -84,10 +84,10 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
|
|||||||
case ToRadio_want_config_id_tag:
|
case ToRadio_want_config_id_tag:
|
||||||
config_nonce = toRadioScratch.want_config_id;
|
config_nonce = toRadioScratch.want_config_id;
|
||||||
DEBUG_MSG("Client wants config, nonce=%u\n", config_nonce);
|
DEBUG_MSG("Client wants config, nonce=%u\n", config_nonce);
|
||||||
|
|
||||||
handleStartConfig();
|
handleStartConfig();
|
||||||
break;
|
break;
|
||||||
case ToRadio_disconnect_tag:
|
case ToRadio_disconnect_tag:
|
||||||
|
DEBUG_MSG("Disconnecting from phone\n");
|
||||||
close();
|
close();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -116,9 +116,8 @@ bool PhoneAPI::handleToRadio(const uint8_t *buf, size_t bufLength)
|
|||||||
*/
|
*/
|
||||||
size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
||||||
{
|
{
|
||||||
DEBUG_MSG("getFromRadio, state=%d\n", state);
|
|
||||||
if (!available()) {
|
if (!available()) {
|
||||||
// DEBUG_MSG("PhoneAPI::getFromRadio, !available\n");
|
DEBUG_MSG("getFromRadio=not available\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// In case we send a FromRadio packet
|
// In case we send a FromRadio packet
|
||||||
@ -127,9 +126,11 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
|||||||
// Advance states as needed
|
// Advance states as needed
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case STATE_SEND_NOTHING:
|
case STATE_SEND_NOTHING:
|
||||||
|
DEBUG_MSG("getFromRadio=STATE_SEND_NOTHING\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_SEND_MY_INFO:
|
case STATE_SEND_MY_INFO:
|
||||||
|
DEBUG_MSG("getFromRadio=STATE_SEND_MY_INFO\n");
|
||||||
// If the user has specified they don't want our node to share its location, make sure to tell the phone
|
// If the user has specified they don't want our node to share its location, make sure to tell the phone
|
||||||
// app not to send locations on our behalf.
|
// app not to send locations on our behalf.
|
||||||
myNodeInfo.has_gps = gps && gps->isConnected(); // Update with latest GPS connect info
|
myNodeInfo.has_gps = gps && gps->isConnected(); // Update with latest GPS connect info
|
||||||
@ -141,6 +142,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_SEND_NODEINFO: {
|
case STATE_SEND_NODEINFO: {
|
||||||
|
DEBUG_MSG("getFromRadio=STATE_SEND_NODEINFO\n");
|
||||||
const NodeInfo *info = nodeInfoForPhone;
|
const NodeInfo *info = nodeInfoForPhone;
|
||||||
nodeInfoForPhone = NULL; // We just consumed a nodeinfo, will need a new one next time
|
nodeInfoForPhone = NULL; // We just consumed a nodeinfo, will need a new one next time
|
||||||
|
|
||||||
@ -160,6 +162,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case STATE_SEND_CONFIG:
|
case STATE_SEND_CONFIG:
|
||||||
|
DEBUG_MSG("getFromRadio=STATE_SEND_CONFIG\n");
|
||||||
fromRadioScratch.which_payloadVariant = FromRadio_config_tag;
|
fromRadioScratch.which_payloadVariant = FromRadio_config_tag;
|
||||||
switch (config_state) {
|
switch (config_state) {
|
||||||
case Config_device_tag:
|
case Config_device_tag:
|
||||||
@ -205,6 +208,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_SEND_MODULECONFIG:
|
case STATE_SEND_MODULECONFIG:
|
||||||
|
DEBUG_MSG("getFromRadio=STATE_SEND_MODULECONFIG\n");
|
||||||
fromRadioScratch.which_payloadVariant = FromRadio_moduleConfig_tag;
|
fromRadioScratch.which_payloadVariant = FromRadio_moduleConfig_tag;
|
||||||
switch (config_state) {
|
switch (config_state) {
|
||||||
case ModuleConfig_mqtt_tag:
|
case ModuleConfig_mqtt_tag:
|
||||||
@ -242,6 +246,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_SEND_COMPLETE_ID:
|
case STATE_SEND_COMPLETE_ID:
|
||||||
|
DEBUG_MSG("getFromRadio=STATE_SEND_COMPLETE_ID\n");
|
||||||
fromRadioScratch.which_payloadVariant = FromRadio_config_complete_id_tag;
|
fromRadioScratch.which_payloadVariant = FromRadio_config_complete_id_tag;
|
||||||
fromRadioScratch.config_complete_id = config_nonce;
|
fromRadioScratch.config_complete_id = config_nonce;
|
||||||
config_nonce = 0;
|
config_nonce = 0;
|
||||||
@ -250,6 +255,7 @@ size_t PhoneAPI::getFromRadio(uint8_t *buf)
|
|||||||
|
|
||||||
case STATE_SEND_PACKETS:
|
case STATE_SEND_PACKETS:
|
||||||
// Do we have a message from the mesh?
|
// Do we have a message from the mesh?
|
||||||
|
DEBUG_MSG("getFromRadio=STATE_SEND_PACKETS\n");
|
||||||
if (packetForPhone) {
|
if (packetForPhone) {
|
||||||
printPacket("phone downloaded packet", packetForPhone);
|
printPacket("phone downloaded packet", packetForPhone);
|
||||||
|
|
||||||
@ -310,11 +316,10 @@ bool PhoneAPI::available()
|
|||||||
case STATE_SEND_COMPLETE_ID:
|
case STATE_SEND_COMPLETE_ID:
|
||||||
return true;
|
return true;
|
||||||
case STATE_SEND_PACKETS: {
|
case STATE_SEND_PACKETS: {
|
||||||
// Try to pull a new packet from the service (if we haven't already)
|
|
||||||
if (!packetForPhone)
|
if (!packetForPhone)
|
||||||
packetForPhone = service.getForPhone();
|
packetForPhone = service.getForPhone();
|
||||||
bool hasPacket = !!packetForPhone;
|
bool hasPacket = !!packetForPhone;
|
||||||
// DEBUG_MSG("available hasPacket=%d\n", hasPacket);
|
DEBUG_MSG("available hasPacket=%d\n", hasPacket);
|
||||||
return hasPacket;
|
return hasPacket;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#ifndef PB_MODULE_CONFIG_PB_H_INCLUDED
|
#ifndef PB_MODULE_CONFIG_PB_H_INCLUDED
|
||||||
#define PB_MODULE_CONFIG_PB_H_INCLUDED
|
#define PB_MODULE_CONFIG_PB_H_INCLUDED
|
||||||
#include <pb.h>
|
#include <pb.h>
|
||||||
#include "telemetry.pb.h"
|
|
||||||
|
|
||||||
#if PB_PROTO_HEADER_VERSION != 40
|
#if PB_PROTO_HEADER_VERSION != 40
|
||||||
#error Regenerate this file with the current version of nanopb generator.
|
#error Regenerate this file with the current version of nanopb generator.
|
||||||
|
@ -22,7 +22,6 @@ static BLEDfu bledfu; // DFU software update helper service
|
|||||||
static uint8_t fromRadioBytes[FromRadio_size];
|
static uint8_t fromRadioBytes[FromRadio_size];
|
||||||
static uint8_t toRadioBytes[ToRadio_size];
|
static uint8_t toRadioBytes[ToRadio_size];
|
||||||
|
|
||||||
static bool bleConnected;
|
|
||||||
static uint16_t connectionHandle;
|
static uint16_t connectionHandle;
|
||||||
|
|
||||||
class BluetoothPhoneAPI : public PhoneAPI
|
class BluetoothPhoneAPI : public PhoneAPI
|
||||||
@ -51,12 +50,12 @@ void onConnect(uint16_t conn_handle)
|
|||||||
{
|
{
|
||||||
// Get the reference to current connection
|
// Get the reference to current connection
|
||||||
BLEConnection *connection = Bluefruit.Connection(conn_handle);
|
BLEConnection *connection = Bluefruit.Connection(conn_handle);
|
||||||
|
connectionHandle = conn_handle;
|
||||||
|
|
||||||
char central_name[32] = {0};
|
char central_name[32] = {0};
|
||||||
connection->getPeerName(central_name, sizeof(central_name));
|
connection->getPeerName(central_name, sizeof(central_name));
|
||||||
|
|
||||||
DEBUG_MSG("BLE Connected to %s\n", central_name);
|
DEBUG_MSG("BLE Connected to %s\n", central_name);
|
||||||
bleConnected = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,8 +66,6 @@ void onConnect(uint16_t conn_handle)
|
|||||||
void onDisconnect(uint16_t conn_handle, uint8_t reason)
|
void onDisconnect(uint16_t conn_handle, uint8_t reason)
|
||||||
{
|
{
|
||||||
// FIXME - we currently assume only one active connection
|
// FIXME - we currently assume only one active connection
|
||||||
bleConnected = false;
|
|
||||||
|
|
||||||
DEBUG_MSG("BLE Disconnected, reason = 0x%x\n", reason);
|
DEBUG_MSG("BLE Disconnected, reason = 0x%x\n", reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +291,6 @@ void NRF52Bluetooth::clearBonds()
|
|||||||
void NRF52Bluetooth::onConnectionSecured(uint16_t conn_handle)
|
void NRF52Bluetooth::onConnectionSecured(uint16_t conn_handle)
|
||||||
{
|
{
|
||||||
DEBUG_MSG("BLE connection secured\n");
|
DEBUG_MSG("BLE connection secured\n");
|
||||||
//bluetoothPhoneAPI->setInitialState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NRF52Bluetooth::onPairingPasskey(uint16_t conn_handle, uint8_t const passkey[6], bool match_request)
|
bool NRF52Bluetooth::onPairingPasskey(uint16_t conn_handle, uint8_t const passkey[6], bool match_request)
|
||||||
|
Loading…
Reference in New Issue
Block a user