mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-26 09:59:01 +00:00
emit FromRadio.rebooted to serial test harness can detect reboots
This commit is contained in:
parent
b53392ab73
commit
2ab34357d5
2
proto
2
proto
@ -1 +1 @@
|
|||||||
Subproject commit 8427b23016dc96fc78885f05de5172e9eec5fe6d
|
Subproject commit e570ee9836949d9f420fd19cc59a2595c8669a6e
|
@ -17,6 +17,7 @@ void SerialConsole::init()
|
|||||||
{
|
{
|
||||||
Port.begin(SERIAL_BAUD);
|
Port.begin(SERIAL_BAUD);
|
||||||
StreamAPI::init();
|
StreamAPI::init();
|
||||||
|
emitRebooted();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,9 +45,6 @@ class PhoneAPI
|
|||||||
/// We temporarily keep the nodeInfo here between the call to available and getFromRadio
|
/// We temporarily keep the nodeInfo here between the call to available and getFromRadio
|
||||||
const NodeInfo *nodeInfoForPhone = NULL;
|
const NodeInfo *nodeInfoForPhone = NULL;
|
||||||
|
|
||||||
/// Our fromradio packet while it is being assembled
|
|
||||||
FromRadio fromRadioScratch;
|
|
||||||
|
|
||||||
ToRadio toRadioScratch; // this is a static scratch object, any data must be copied elsewhere before returning
|
ToRadio toRadioScratch; // this is a static scratch object, any data must be copied elsewhere before returning
|
||||||
|
|
||||||
/// Use to ensure that clients don't get confused about old messages from the radio
|
/// Use to ensure that clients don't get confused about old messages from the radio
|
||||||
@ -85,6 +82,9 @@ class PhoneAPI
|
|||||||
void handleSetRadio(const RadioConfig &r);
|
void handleSetRadio(const RadioConfig &r);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/// Our fromradio packet while it is being assembled
|
||||||
|
FromRadio fromRadioScratch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclasses can use this as a hook to provide custom notifications for their transport (i.e. bluetooth notifies)
|
* Subclasses can use this as a hook to provide custom notifications for their transport (i.e. bluetooth notifies)
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "StreamAPI.h"
|
#include "StreamAPI.h"
|
||||||
|
#include "configuration.h"
|
||||||
|
|
||||||
#define START1 0x94
|
#define START1 0x94
|
||||||
#define START2 0xc3
|
#define START2 0xc3
|
||||||
@ -58,6 +59,16 @@ void StreamAPI::writeStream()
|
|||||||
do {
|
do {
|
||||||
// Send every packet we can
|
// Send every packet we can
|
||||||
len = getFromRadio(txBuf + HEADER_LEN);
|
len = getFromRadio(txBuf + HEADER_LEN);
|
||||||
|
emitTxBuffer(len);
|
||||||
|
} while (len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the current txBuffer over our stream
|
||||||
|
*/
|
||||||
|
void StreamAPI::emitTxBuffer(size_t len)
|
||||||
|
{
|
||||||
if (len != 0) {
|
if (len != 0) {
|
||||||
txBuf[0] = START1;
|
txBuf[0] = START1;
|
||||||
txBuf[1] = START2;
|
txBuf[1] = START2;
|
||||||
@ -66,6 +77,15 @@ void StreamAPI::writeStream()
|
|||||||
|
|
||||||
stream->write(txBuf, len + HEADER_LEN);
|
stream->write(txBuf, len + HEADER_LEN);
|
||||||
}
|
}
|
||||||
} while (len);
|
}
|
||||||
}
|
|
||||||
|
void StreamAPI::emitRebooted()
|
||||||
|
{
|
||||||
|
// In case we send a FromRadio packet
|
||||||
|
memset(&fromRadioScratch, 0, sizeof(fromRadioScratch));
|
||||||
|
fromRadioScratch.which_variant = FromRadio_rebooted_tag;
|
||||||
|
fromRadioScratch.variant.rebooted = true;
|
||||||
|
|
||||||
|
DEBUG_MSG("Emitting reboot packet for serial shell\n");
|
||||||
|
emitTxBuffer(pb_encode_to_bytes(txBuf + HEADER_LEN, FromRadio_size, FromRadio_fields, &fromRadioScratch));
|
||||||
}
|
}
|
@ -37,8 +37,6 @@ class StreamAPI : public PhoneAPI
|
|||||||
uint8_t rxBuf[MAX_STREAM_BUF_SIZE];
|
uint8_t rxBuf[MAX_STREAM_BUF_SIZE];
|
||||||
size_t rxPtr = 0;
|
size_t rxPtr = 0;
|
||||||
|
|
||||||
uint8_t txBuf[MAX_STREAM_BUF_SIZE];
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StreamAPI(Stream *_stream) : stream(_stream) {}
|
StreamAPI(Stream *_stream) : stream(_stream) {}
|
||||||
|
|
||||||
@ -61,6 +59,19 @@ class StreamAPI : public PhoneAPI
|
|||||||
void writeStream();
|
void writeStream();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/**
|
||||||
|
* Send a FromRadio.rebooted = true packet to the phone
|
||||||
|
*/
|
||||||
|
void emitRebooted();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the current txBuffer over our stream
|
||||||
|
*/
|
||||||
|
void emitTxBuffer(size_t len);
|
||||||
|
|
||||||
/// Are we allowed to write packets to our output stream (subclasses can turn this off - i.e. SerialConsole)
|
/// Are we allowed to write packets to our output stream (subclasses can turn this off - i.e. SerialConsole)
|
||||||
bool canWrite = true;
|
bool canWrite = true;
|
||||||
|
|
||||||
|
/// Subclasses can use this scratch buffer if they wish
|
||||||
|
uint8_t txBuf[MAX_STREAM_BUF_SIZE];
|
||||||
};
|
};
|
@ -159,6 +159,7 @@ typedef struct _FromRadio {
|
|||||||
RadioConfig radio;
|
RadioConfig radio;
|
||||||
DebugString debug_string;
|
DebugString debug_string;
|
||||||
uint32_t config_complete_id;
|
uint32_t config_complete_id;
|
||||||
|
bool rebooted;
|
||||||
} variant;
|
} variant;
|
||||||
} FromRadio;
|
} FromRadio;
|
||||||
|
|
||||||
@ -289,6 +290,7 @@ typedef struct _ToRadio {
|
|||||||
#define FromRadio_radio_tag 6
|
#define FromRadio_radio_tag 6
|
||||||
#define FromRadio_debug_string_tag 7
|
#define FromRadio_debug_string_tag 7
|
||||||
#define FromRadio_config_complete_id_tag 8
|
#define FromRadio_config_complete_id_tag 8
|
||||||
|
#define FromRadio_rebooted_tag 9
|
||||||
#define FromRadio_num_tag 1
|
#define FromRadio_num_tag 1
|
||||||
#define ToRadio_packet_tag 1
|
#define ToRadio_packet_tag 1
|
||||||
#define ToRadio_want_config_id_tag 100
|
#define ToRadio_want_config_id_tag 100
|
||||||
@ -432,7 +434,8 @@ X(a, STATIC, ONEOF, MESSAGE, (variant,my_info,variant.my_info), 3) \
|
|||||||
X(a, STATIC, ONEOF, MESSAGE, (variant,node_info,variant.node_info), 4) \
|
X(a, STATIC, ONEOF, MESSAGE, (variant,node_info,variant.node_info), 4) \
|
||||||
X(a, STATIC, ONEOF, MESSAGE, (variant,radio,variant.radio), 6) \
|
X(a, STATIC, ONEOF, MESSAGE, (variant,radio,variant.radio), 6) \
|
||||||
X(a, STATIC, ONEOF, MESSAGE, (variant,debug_string,variant.debug_string), 7) \
|
X(a, STATIC, ONEOF, MESSAGE, (variant,debug_string,variant.debug_string), 7) \
|
||||||
X(a, STATIC, ONEOF, UINT32, (variant,config_complete_id,variant.config_complete_id), 8)
|
X(a, STATIC, ONEOF, UINT32, (variant,config_complete_id,variant.config_complete_id), 8) \
|
||||||
|
X(a, STATIC, ONEOF, BOOL, (variant,rebooted,variant.rebooted), 9)
|
||||||
#define FromRadio_CALLBACK NULL
|
#define FromRadio_CALLBACK NULL
|
||||||
#define FromRadio_DEFAULT NULL
|
#define FromRadio_DEFAULT NULL
|
||||||
#define FromRadio_variant_packet_MSGTYPE MeshPacket
|
#define FromRadio_variant_packet_MSGTYPE MeshPacket
|
||||||
|
Loading…
Reference in New Issue
Block a user