kopia lustrzana https://github.com/meshtastic/firmware
whatever makes trunk happy.
rodzic
6fdb93cd16
commit
cdf379616c
|
@ -910,7 +910,8 @@ static void drawNodeInfo(OLEDDisplay *display, OLEDDisplayUiState *state, int16_
|
||||||
// #else
|
// #else
|
||||||
Screen::Screen(uint8_t address, int sda, int scl)
|
Screen::Screen(uint8_t address, int sda, int scl)
|
||||||
: OSThread("Screen"), cmdQueue(32),
|
: OSThread("Screen"), cmdQueue(32),
|
||||||
dispdev(address, sda, scl, screen_model == meshtastic_Config_DisplayConfig_OledType_OLED_SH1107 ? GEOMETRY_128_128 : GEOMETRY_128_64),
|
dispdev(address, sda, scl,
|
||||||
|
screen_model == meshtastic_Config_DisplayConfig_OledType_OLED_SH1107 ? GEOMETRY_128_128 : GEOMETRY_128_64),
|
||||||
ui(&dispdev)
|
ui(&dispdev)
|
||||||
{
|
{
|
||||||
address_found = address;
|
address_found = address;
|
||||||
|
@ -1756,7 +1757,8 @@ void DebugInfo::drawFrameSettings(OLEDDisplay *display, OLEDDisplayUiState *stat
|
||||||
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), y + FONT_HEIGHT_SMALL * 1, chUtil);
|
display->drawString(x + SCREEN_WIDTH - display->getStringWidth(chUtil), y + FONT_HEIGHT_SMALL * 1, chUtil);
|
||||||
if (config.position.gps_enabled) {
|
if (config.position.gps_enabled) {
|
||||||
// Line 3
|
// Line 3
|
||||||
if (config.display.gps_format != meshtastic_Config_DisplayConfig_GpsCoordinateFormat_DMS) // if DMS then don't draw altitude
|
if (config.display.gps_format !=
|
||||||
|
meshtastic_Config_DisplayConfig_GpsCoordinateFormat_DMS) // if DMS then don't draw altitude
|
||||||
drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus);
|
drawGPSAltitude(display, x, y + FONT_HEIGHT_SMALL * 2, gpsStatus);
|
||||||
|
|
||||||
// Line 4
|
// Line 4
|
||||||
|
|
|
@ -496,7 +496,9 @@ void setup()
|
||||||
|
|
||||||
// Calculate and save the bit rate to myNodeInfo
|
// Calculate and save the bit rate to myNodeInfo
|
||||||
// TODO: This needs to be added what ever method changes the channel from the phone.
|
// TODO: This needs to be added what ever method changes the channel from the phone.
|
||||||
myNodeInfo.bitrate = (float(meshtastic_Constants_DATA_PAYLOAD_LEN) / (float(rIf->getPacketTime(meshtastic_Constants_DATA_PAYLOAD_LEN)))) * 1000;
|
myNodeInfo.bitrate =
|
||||||
|
(float(meshtastic_Constants_DATA_PAYLOAD_LEN) / (float(rIf->getPacketTime(meshtastic_Constants_DATA_PAYLOAD_LEN)))) *
|
||||||
|
1000;
|
||||||
LOG_DEBUG("myNodeInfo.bitrate = %f bytes / sec\n", myNodeInfo.bitrate);
|
LOG_DEBUG("myNodeInfo.bitrate = %f bytes / sec\n", myNodeInfo.bitrate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,8 @@ bool FloodingRouter::shouldFilterReceived(const meshtastic_MeshPacket *p)
|
||||||
|
|
||||||
void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c)
|
void FloodingRouter::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Routing *c)
|
||||||
{
|
{
|
||||||
bool isAck = ((c && c->error_reason == meshtastic_Routing_Error_NONE)); // consider only ROUTING_APP message without error as ACK
|
bool isAck =
|
||||||
|
((c && c->error_reason == meshtastic_Routing_Error_NONE)); // consider only ROUTING_APP message without error as ACK
|
||||||
if (isAck && p->to != getNodeNum()) {
|
if (isAck && p->to != getNodeNum()) {
|
||||||
// do not flood direct message that is ACKed
|
// do not flood direct message that is ACKed
|
||||||
LOG_DEBUG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n");
|
LOG_DEBUG("Receiving an ACK not for me, but don't need to rebroadcast this direct message anymore.\n");
|
||||||
|
|
|
@ -44,7 +44,8 @@ meshtastic_MeshPacket *MeshModule::allocAckNak(meshtastic_Routing_Error err, Nod
|
||||||
// auto p = allocDataProtobuf(c);
|
// auto p = allocDataProtobuf(c);
|
||||||
meshtastic_MeshPacket *p = router->allocForSending();
|
meshtastic_MeshPacket *p = router->allocForSending();
|
||||||
p->decoded.portnum = meshtastic_PortNum_ROUTING_APP;
|
p->decoded.portnum = meshtastic_PortNum_ROUTING_APP;
|
||||||
p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &meshtastic_Routing_msg, &c);
|
p->decoded.payload.size =
|
||||||
|
pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &meshtastic_Routing_msg, &c);
|
||||||
|
|
||||||
p->priority = meshtastic_MeshPacket_Priority_ACK;
|
p->priority = meshtastic_MeshPacket_Priority_ACK;
|
||||||
|
|
||||||
|
@ -248,7 +249,8 @@ void MeshModule::observeUIEvents(Observer<const UIFrameEvent *> *observer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AdminMessageHandleResult MeshModule::handleAdminMessageForAllPlugins(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
|
AdminMessageHandleResult MeshModule::handleAdminMessageForAllPlugins(const meshtastic_MeshPacket &mp,
|
||||||
|
meshtastic_AdminMessage *request,
|
||||||
meshtastic_AdminMessage *response)
|
meshtastic_AdminMessage *response)
|
||||||
{
|
{
|
||||||
AdminMessageHandleResult handled = AdminMessageHandleResult::NOT_HANDLED;
|
AdminMessageHandleResult handled = AdminMessageHandleResult::NOT_HANDLED;
|
||||||
|
|
|
@ -68,7 +68,8 @@ class MeshModule
|
||||||
|
|
||||||
static std::vector<MeshModule *> GetMeshModulesWithUIFrames();
|
static std::vector<MeshModule *> GetMeshModulesWithUIFrames();
|
||||||
static void observeUIEvents(Observer<const UIFrameEvent *> *observer);
|
static void observeUIEvents(Observer<const UIFrameEvent *> *observer);
|
||||||
static AdminMessageHandleResult handleAdminMessageForAllPlugins(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
|
static AdminMessageHandleResult handleAdminMessageForAllPlugins(const meshtastic_MeshPacket &mp,
|
||||||
|
meshtastic_AdminMessage *request,
|
||||||
meshtastic_AdminMessage *response);
|
meshtastic_AdminMessage *response);
|
||||||
#if HAS_SCREEN
|
#if HAS_SCREEN
|
||||||
virtual void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
virtual void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
|
||||||
|
@ -171,7 +172,8 @@ class MeshModule
|
||||||
* HANDLED if message was handled
|
* HANDLED if message was handled
|
||||||
* HANDLED_WITH_RESPONSE if a response is also prepared and to be sent.
|
* HANDLED_WITH_RESPONSE if a response is also prepared and to be sent.
|
||||||
*/
|
*/
|
||||||
virtual AdminMessageHandleResult handleAdminMessageForModule(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
|
virtual AdminMessageHandleResult handleAdminMessageForModule(const meshtastic_MeshPacket &mp,
|
||||||
|
meshtastic_AdminMessage *request,
|
||||||
meshtastic_AdminMessage *response)
|
meshtastic_AdminMessage *response)
|
||||||
{
|
{
|
||||||
return AdminMessageHandleResult::NOT_HANDLED;
|
return AdminMessageHandleResult::NOT_HANDLED;
|
||||||
|
|
|
@ -179,8 +179,8 @@ void NodeDB::installDefaultConfig()
|
||||||
#else
|
#else
|
||||||
bool hasScreen = screen_found;
|
bool hasScreen = screen_found;
|
||||||
#endif
|
#endif
|
||||||
config.bluetooth.mode =
|
config.bluetooth.mode = hasScreen ? meshtastic_Config_BluetoothConfig_PairingMode_RANDOM_PIN
|
||||||
hasScreen ? meshtastic_Config_BluetoothConfig_PairingMode_RANDOM_PIN : meshtastic_Config_BluetoothConfig_PairingMode_FIXED_PIN;
|
: meshtastic_Config_BluetoothConfig_PairingMode_FIXED_PIN;
|
||||||
// for backward compat, default position flags are ALT+MSL
|
// for backward compat, default position flags are ALT+MSL
|
||||||
config.position.position_flags =
|
config.position.position_flags =
|
||||||
(meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE | meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE_MSL);
|
(meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE | meshtastic_Config_PositionConfig_PositionFlags_ALTITUDE_MSL);
|
||||||
|
@ -403,7 +403,8 @@ bool NodeDB::loadProto(const char *filename, size_t protoSize, size_t objSize, c
|
||||||
void NodeDB::loadFromDisk()
|
void NodeDB::loadFromDisk()
|
||||||
{
|
{
|
||||||
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
// static DeviceState scratch; We no longer read into a tempbuf because this structure is 15KB of valuable RAM
|
||||||
if (!loadProto(prefFileName, meshtastic_DeviceState_size, sizeof(meshtastic_DeviceState), &meshtastic_DeviceState_msg, &devicestate)) {
|
if (!loadProto(prefFileName, meshtastic_DeviceState_size, sizeof(meshtastic_DeviceState), &meshtastic_DeviceState_msg,
|
||||||
|
&devicestate)) {
|
||||||
installDefaultDeviceState(); // Our in RAM copy might now be corrupt
|
installDefaultDeviceState(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (devicestate.version < DEVICESTATE_MIN_VER) {
|
if (devicestate.version < DEVICESTATE_MIN_VER) {
|
||||||
|
@ -414,7 +415,8 @@ void NodeDB::loadFromDisk()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadProto(configFileName, meshtastic_LocalConfig_size, sizeof(meshtastic_LocalConfig), &meshtastic_LocalConfig_msg, &config)) {
|
if (!loadProto(configFileName, meshtastic_LocalConfig_size, sizeof(meshtastic_LocalConfig), &meshtastic_LocalConfig_msg,
|
||||||
|
&config)) {
|
||||||
installDefaultConfig(); // Our in RAM copy might now be corrupt
|
installDefaultConfig(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (config.version < DEVICESTATE_MIN_VER) {
|
if (config.version < DEVICESTATE_MIN_VER) {
|
||||||
|
@ -425,8 +427,8 @@ void NodeDB::loadFromDisk()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadProto(moduleConfigFileName, meshtastic_LocalModuleConfig_size, sizeof(meshtastic_LocalModuleConfig), &meshtastic_LocalModuleConfig_msg,
|
if (!loadProto(moduleConfigFileName, meshtastic_LocalModuleConfig_size, sizeof(meshtastic_LocalModuleConfig),
|
||||||
&moduleConfig)) {
|
&meshtastic_LocalModuleConfig_msg, &moduleConfig)) {
|
||||||
installDefaultModuleConfig(); // Our in RAM copy might now be corrupt
|
installDefaultModuleConfig(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (moduleConfig.version < DEVICESTATE_MIN_VER) {
|
if (moduleConfig.version < DEVICESTATE_MIN_VER) {
|
||||||
|
@ -437,7 +439,8 @@ void NodeDB::loadFromDisk()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadProto(channelFileName, meshtastic_ChannelFile_size, sizeof(meshtastic_ChannelFile), &meshtastic_ChannelFile_msg, &channelFile)) {
|
if (!loadProto(channelFileName, meshtastic_ChannelFile_size, sizeof(meshtastic_ChannelFile), &meshtastic_ChannelFile_msg,
|
||||||
|
&channelFile)) {
|
||||||
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
installDefaultChannels(); // Our in RAM copy might now be corrupt
|
||||||
} else {
|
} else {
|
||||||
if (channelFile.version < DEVICESTATE_MIN_VER) {
|
if (channelFile.version < DEVICESTATE_MIN_VER) {
|
||||||
|
|
|
@ -182,7 +182,8 @@ extern NodeDB nodeDB;
|
||||||
// Our delay functions check for this for times that should never expire
|
// Our delay functions check for this for times that should never expire
|
||||||
#define NODE_DELAY_FOREVER 0xffffffff
|
#define NODE_DELAY_FOREVER 0xffffffff
|
||||||
|
|
||||||
#define IF_ROUTER(routerVal, normalVal) ((config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER) ? (routerVal) : (normalVal))
|
#define IF_ROUTER(routerVal, normalVal) \
|
||||||
|
((config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER) ? (routerVal) : (normalVal))
|
||||||
|
|
||||||
#define ONE_DAY 24 * 60 * 60
|
#define ONE_DAY 24 * 60 * 60
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,8 @@ 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 meshtastic_NodeInfo *nodeInfoForPhone = NULL;
|
const meshtastic_NodeInfo *nodeInfoForPhone = NULL;
|
||||||
|
|
||||||
meshtastic_ToRadio toRadioScratch = {0}; // this is a static scratch object, any data must be copied elsewhere before returning
|
meshtastic_ToRadio toRadioScratch = {
|
||||||
|
0}; // 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
|
||||||
uint32_t config_nonce = 0;
|
uint32_t config_nonce = 0;
|
||||||
|
|
|
@ -226,7 +226,8 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
|
||||||
uint32_t delay = 0;
|
uint32_t delay = 0;
|
||||||
uint8_t CWsize = map(snr, SNR_MIN, SNR_MAX, CWmin, CWmax);
|
uint8_t CWsize = map(snr, SNR_MIN, SNR_MAX, CWmin, CWmax);
|
||||||
// LOG_DEBUG("rx_snr of %f so setting CWsize to:%d\n", snr, CWsize);
|
// LOG_DEBUG("rx_snr of %f so setting CWsize to:%d\n", snr, CWsize);
|
||||||
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER || config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT) {
|
if (config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER ||
|
||||||
|
config.device.role == meshtastic_Config_DeviceConfig_Role_ROUTER_CLIENT) {
|
||||||
delay = random(0, 2 * CWsize) * slotTimeMsec;
|
delay = random(0, 2 * CWsize) * slotTimeMsec;
|
||||||
LOG_DEBUG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay);
|
LOG_DEBUG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -370,7 +370,8 @@ void RadioLibInterface::handleReceiveInterrupt()
|
||||||
|
|
||||||
addReceiveMetadata(mp);
|
addReceiveMetadata(mp);
|
||||||
|
|
||||||
mp->which_payload_variant = meshtastic_MeshPacket_encrypted_tag; // Mark that the payload is still encrypted at this point
|
mp->which_payload_variant =
|
||||||
|
meshtastic_MeshPacket_encrypted_tag; // Mark that the payload is still encrypted at this point
|
||||||
assert(((uint32_t)payloadLen) <= sizeof(mp->encrypted.bytes));
|
assert(((uint32_t)payloadLen) <= sizeof(mp->encrypted.bytes));
|
||||||
memcpy(mp->encrypted.bytes, payload, payloadLen);
|
memcpy(mp->encrypted.bytes, payload, payloadLen);
|
||||||
mp->encrypted.size = payloadLen;
|
mp->encrypted.size = payloadLen;
|
||||||
|
|
|
@ -171,7 +171,8 @@ bool initWifi()
|
||||||
WiFi.onEvent(WiFiEvent);
|
WiFi.onEvent(WiFiEvent);
|
||||||
WiFi.setAutoReconnect(true);
|
WiFi.setAutoReconnect(true);
|
||||||
WiFi.setSleep(false);
|
WiFi.setSleep(false);
|
||||||
if (config.network.address_mode == meshtastic_Config_NetworkConfig_AddressMode_STATIC && config.network.ipv4_config.ip != 0) {
|
if (config.network.address_mode == meshtastic_Config_NetworkConfig_AddressMode_STATIC &&
|
||||||
|
config.network.ipv4_config.ip != 0) {
|
||||||
WiFi.config(config.network.ipv4_config.ip, config.network.ipv4_config.gateway, config.network.ipv4_config.subnet,
|
WiFi.config(config.network.ipv4_config.ip, config.network.ipv4_config.gateway, config.network.ipv4_config.subnet,
|
||||||
config.network.ipv4_config.dns,
|
config.network.ipv4_config.dns,
|
||||||
config.network.ipv4_config.dns); // Wifi wants two DNS servers... set both to the same value
|
config.network.ipv4_config.dns); // Wifi wants two DNS servers... set both to the same value
|
||||||
|
|
|
@ -483,8 +483,9 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st
|
||||||
|
|
||||||
void CannedMessageModule::loadProtoForModule()
|
void CannedMessageModule::loadProtoForModule()
|
||||||
{
|
{
|
||||||
if (!nodeDB.loadProto(cannedMessagesConfigFile, meshtastic_CannedMessageModuleConfig_size, sizeof(meshtastic_CannedMessageModuleConfig),
|
if (!nodeDB.loadProto(cannedMessagesConfigFile, meshtastic_CannedMessageModuleConfig_size,
|
||||||
&meshtastic_CannedMessageModuleConfig_msg, &cannedMessageModuleConfig)) {
|
sizeof(meshtastic_CannedMessageModuleConfig), &meshtastic_CannedMessageModuleConfig_msg,
|
||||||
|
&cannedMessageModuleConfig)) {
|
||||||
installDefaultCannedMessageModuleConfig();
|
installDefaultCannedMessageModuleConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -503,8 +504,8 @@ bool CannedMessageModule::saveProtoForModule()
|
||||||
FS.mkdir("/prefs");
|
FS.mkdir("/prefs");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
okay &= nodeDB.saveProto(cannedMessagesConfigFile, meshtastic_CannedMessageModuleConfig_size, &meshtastic_CannedMessageModuleConfig_msg,
|
okay &= nodeDB.saveProto(cannedMessagesConfigFile, meshtastic_CannedMessageModuleConfig_size,
|
||||||
&cannedMessageModuleConfig);
|
&meshtastic_CannedMessageModuleConfig_msg, &cannedMessageModuleConfig);
|
||||||
|
|
||||||
return okay;
|
return okay;
|
||||||
}
|
}
|
||||||
|
@ -526,7 +527,8 @@ void CannedMessageModule::installDefaultCannedMessageModuleConfig()
|
||||||
* @return AdminMessageHandleResult HANDLED if message was handled
|
* @return AdminMessageHandleResult HANDLED if message was handled
|
||||||
* HANDLED_WITH_RESULT if a result is also prepared.
|
* HANDLED_WITH_RESULT if a result is also prepared.
|
||||||
*/
|
*/
|
||||||
AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
|
AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const meshtastic_MeshPacket &mp,
|
||||||
|
meshtastic_AdminMessage *request,
|
||||||
meshtastic_AdminMessage *response)
|
meshtastic_AdminMessage *response)
|
||||||
{
|
{
|
||||||
AdminMessageHandleResult result;
|
AdminMessageHandleResult result;
|
||||||
|
@ -551,7 +553,8 @@ AdminMessageHandleResult CannedMessageModule::handleAdminMessageForModule(const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CannedMessageModule::handleGetCannedMessageModuleMessages(const meshtastic_MeshPacket &req, meshtastic_AdminMessage *response)
|
void CannedMessageModule::handleGetCannedMessageModuleMessages(const meshtastic_MeshPacket &req,
|
||||||
|
meshtastic_AdminMessage *response)
|
||||||
{
|
{
|
||||||
LOG_DEBUG("*** handleGetCannedMessageModuleMessages\n");
|
LOG_DEBUG("*** handleGetCannedMessageModuleMessages\n");
|
||||||
if (req.decoded.want_response) {
|
if (req.decoded.want_response) {
|
||||||
|
|
|
@ -54,7 +54,8 @@ class CannedMessageModule : public SinglePortModule, public Observable<const UIF
|
||||||
virtual bool wantUIFrame() override { return this->shouldDraw(); }
|
virtual bool wantUIFrame() override { return this->shouldDraw(); }
|
||||||
virtual Observable<const UIFrameEvent *> *getUIFrameObservable() override { return this; }
|
virtual Observable<const UIFrameEvent *> *getUIFrameObservable() override { return this; }
|
||||||
virtual void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) override;
|
virtual void drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) override;
|
||||||
virtual AdminMessageHandleResult handleAdminMessageForModule(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
|
virtual AdminMessageHandleResult handleAdminMessageForModule(const meshtastic_MeshPacket &mp,
|
||||||
|
meshtastic_AdminMessage *request,
|
||||||
meshtastic_AdminMessage *response) override;
|
meshtastic_AdminMessage *response) override;
|
||||||
|
|
||||||
void loadProtoForModule();
|
void loadProtoForModule();
|
||||||
|
|
|
@ -164,7 +164,8 @@ ExternalNotificationModule::ExternalNotificationModule()
|
||||||
// moduleConfig.external_notification.nag_timeout = 300;
|
// moduleConfig.external_notification.nag_timeout = 300;
|
||||||
|
|
||||||
if (moduleConfig.external_notification.enabled) {
|
if (moduleConfig.external_notification.enabled) {
|
||||||
if (!nodeDB.loadProto(rtttlConfigFile, meshtastic_RTTTLConfig_size, sizeof(meshtastic_RTTTLConfig), &meshtastic_RTTTLConfig_msg, &rtttlConfig)) {
|
if (!nodeDB.loadProto(rtttlConfigFile, meshtastic_RTTTLConfig_size, sizeof(meshtastic_RTTTLConfig),
|
||||||
|
&meshtastic_RTTTLConfig_msg, &rtttlConfig)) {
|
||||||
memset(rtttlConfig.ringtone, 0, sizeof(rtttlConfig.ringtone));
|
memset(rtttlConfig.ringtone, 0, sizeof(rtttlConfig.ringtone));
|
||||||
strncpy(rtttlConfig.ringtone,
|
strncpy(rtttlConfig.ringtone,
|
||||||
"a:d=8,o=5,b=125:4d#6,a#,2d#6,16p,g#,4a#,4d#.,p,16g,16a#,d#6,a#,f6,2d#6,16p,c#.6,16c6,16a#,g#.,2a#",
|
"a:d=8,o=5,b=125:4d#6,a#,2d#6,16p,g#,4a#,4d#.,p,16g,16a#,d#6,a#,f6,2d#6,16p,c#.6,16c6,16a#,g#.,2a#",
|
||||||
|
@ -319,7 +320,8 @@ ProcessMessage ExternalNotificationModule::handleReceived(const meshtastic_MeshP
|
||||||
* @return AdminMessageHandleResult HANDLED if message was handled
|
* @return AdminMessageHandleResult HANDLED if message was handled
|
||||||
* HANDLED_WITH_RESULT if a result is also prepared.
|
* HANDLED_WITH_RESULT if a result is also prepared.
|
||||||
*/
|
*/
|
||||||
AdminMessageHandleResult ExternalNotificationModule::handleAdminMessageForModule(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
|
AdminMessageHandleResult ExternalNotificationModule::handleAdminMessageForModule(const meshtastic_MeshPacket &mp,
|
||||||
|
meshtastic_AdminMessage *request,
|
||||||
meshtastic_AdminMessage *response)
|
meshtastic_AdminMessage *response)
|
||||||
{
|
{
|
||||||
AdminMessageHandleResult result;
|
AdminMessageHandleResult result;
|
||||||
|
|
|
@ -54,7 +54,8 @@ class ExternalNotificationModule : public SinglePortModule, private concurrency:
|
||||||
|
|
||||||
bool isNagging = false;
|
bool isNagging = false;
|
||||||
|
|
||||||
virtual AdminMessageHandleResult handleAdminMessageForModule(const meshtastic_MeshPacket &mp, meshtastic_AdminMessage *request,
|
virtual AdminMessageHandleResult handleAdminMessageForModule(const meshtastic_MeshPacket &mp,
|
||||||
|
meshtastic_AdminMessage *request,
|
||||||
meshtastic_AdminMessage *response) override;
|
meshtastic_AdminMessage *response) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
PositionModule *positionModule;
|
PositionModule *positionModule;
|
||||||
|
|
||||||
PositionModule::PositionModule()
|
PositionModule::PositionModule()
|
||||||
: ProtobufModule("position", meshtastic_PortNum_POSITION_APP, &meshtastic_Position_msg), concurrency::OSThread("PositionModule")
|
: ProtobufModule("position", meshtastic_PortNum_POSITION_APP, &meshtastic_Position_msg), concurrency::OSThread(
|
||||||
|
"PositionModule")
|
||||||
{
|
{
|
||||||
isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others
|
isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others
|
||||||
setIntervalFromNow(60 * 1000); // Send our initial position 60 seconds after we start (to give GPS time to setup)
|
setIntervalFromNow(60 * 1000); // Send our initial position 60 seconds after we start (to give GPS time to setup)
|
||||||
|
|
|
@ -47,8 +47,8 @@ static uint64_t digitalReads(uint64_t mask)
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoteHardwareModule::RemoteHardwareModule()
|
RemoteHardwareModule::RemoteHardwareModule()
|
||||||
: ProtobufModule("remotehardware", meshtastic_PortNum_REMOTE_HARDWARE_APP, &meshtastic_HardwareMessage_msg), concurrency::OSThread(
|
: ProtobufModule("remotehardware", meshtastic_PortNum_REMOTE_HARDWARE_APP, &meshtastic_HardwareMessage_msg),
|
||||||
"RemoteHardwareModule")
|
concurrency::OSThread("RemoteHardwareModule")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,8 @@ class DeviceTelemetryModule : private concurrency::OSThread, public ProtobufModu
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DeviceTelemetryModule()
|
DeviceTelemetryModule()
|
||||||
: concurrency::OSThread("DeviceTelemetryModule"), ProtobufModule("DeviceTelemetry", meshtastic_PortNum_TELEMETRY_APP, &meshtastic_Telemetry_msg)
|
: concurrency::OSThread("DeviceTelemetryModule"),
|
||||||
|
ProtobufModule("DeviceTelemetry", meshtastic_PortNum_TELEMETRY_APP, &meshtastic_Telemetry_msg)
|
||||||
{
|
{
|
||||||
lastMeasurementPacket = nullptr;
|
lastMeasurementPacket = nullptr;
|
||||||
setIntervalFromNow(10 * 1000);
|
setIntervalFromNow(10 * 1000);
|
||||||
|
|
|
@ -29,8 +29,8 @@ void TraceRouteModule::updateRoute(meshtastic_MeshPacket *p)
|
||||||
printRoute(updated, p->from, NODENUM_BROADCAST);
|
printRoute(updated, p->from, NODENUM_BROADCAST);
|
||||||
|
|
||||||
// Set updated route to the payload of the to be flooded packet
|
// Set updated route to the payload of the to be flooded packet
|
||||||
p->decoded.payload.size =
|
p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes),
|
||||||
pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &meshtastic_RouteDiscovery_msg, updated);
|
&meshtastic_RouteDiscovery_msg, updated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,8 @@ meshtastic_MeshPacket *TraceRouteModule::allocReply()
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
TraceRouteModule::TraceRouteModule() : ProtobufModule("traceroute", meshtastic_PortNum_TRACEROUTE_APP, &meshtastic_RouteDiscovery_msg)
|
TraceRouteModule::TraceRouteModule()
|
||||||
|
: ProtobufModule("traceroute", meshtastic_PortNum_TRACEROUTE_APP, &meshtastic_RouteDiscovery_msg)
|
||||||
{
|
{
|
||||||
ourPortNum = meshtastic_PortNum_TRACEROUTE_APP;
|
ourPortNum = meshtastic_PortNum_TRACEROUTE_APP;
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,8 +361,8 @@ bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
|
||||||
if (is_client) {
|
if (is_client) {
|
||||||
LOG_DEBUG("*** StoreAndForward_RequestResponse_ROUTER_BUSY\n");
|
LOG_DEBUG("*** StoreAndForward_RequestResponse_ROUTER_BUSY\n");
|
||||||
// retry in messages_saved * packetTimeMax ms
|
// retry in messages_saved * packetTimeMax ms
|
||||||
retry_delay =
|
retry_delay = millis() + packetHistoryCurrent * packetTimeMax *
|
||||||
millis() + packetHistoryCurrent * packetTimeMax * (meshtastic_StoreAndForward_RequestResponse_ROUTER_ERROR ? 2 : 1);
|
(meshtastic_StoreAndForward_RequestResponse_ROUTER_ERROR ? 2 : 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -422,7 +422,8 @@ bool StoreForwardModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
|
||||||
}
|
}
|
||||||
|
|
||||||
StoreForwardModule::StoreForwardModule()
|
StoreForwardModule::StoreForwardModule()
|
||||||
: concurrency::OSThread("StoreForwardModule"), ProtobufModule("StoreForward", meshtastic_PortNum_STORE_FORWARD_APP, &meshtastic_StoreAndForward_msg)
|
: concurrency::OSThread("StoreForwardModule"),
|
||||||
|
ProtobufModule("StoreForward", meshtastic_PortNum_STORE_FORWARD_APP, &meshtastic_StoreAndForward_msg)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
|
|
|
@ -106,7 +106,8 @@ void MQTT::onPublish(char *topic, byte *payload, unsigned int length)
|
||||||
p->decoded.portnum = meshtastic_PortNum_POSITION_APP;
|
p->decoded.portnum = meshtastic_PortNum_POSITION_APP;
|
||||||
p->channel = sendChannel.settings.channel_num;
|
p->channel = sendChannel.settings.channel_num;
|
||||||
if (sendChannel.settings.downlink_enabled) {
|
if (sendChannel.settings.downlink_enabled) {
|
||||||
p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes),
|
p->decoded.payload.size =
|
||||||
|
pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes),
|
||||||
&meshtastic_Position_msg, &pos); // make the Data protobuf from position
|
&meshtastic_Position_msg, &pos); // make the Data protobuf from position
|
||||||
service.sendToMesh(p, RX_SRC_LOCAL);
|
service.sendToMesh(p, RX_SRC_LOCAL);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -168,7 +168,8 @@ void setupMeshService(void)
|
||||||
// any characteristic(s) within that service definition.. Calling .begin() on
|
// any characteristic(s) within that service definition.. Calling .begin() on
|
||||||
// a BLECharacteristic will cause it to be added to the last BLEService that
|
// a BLECharacteristic will cause it to be added to the last BLEService that
|
||||||
// was 'begin()'ed!
|
// was 'begin()'ed!
|
||||||
auto secMode = config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN ? SECMODE_OPEN : SECMODE_ENC_NO_MITM;
|
auto secMode =
|
||||||
|
config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN ? SECMODE_OPEN : SECMODE_ENC_NO_MITM;
|
||||||
|
|
||||||
fromNum.setProperties(CHR_PROPS_NOTIFY | CHR_PROPS_READ);
|
fromNum.setProperties(CHR_PROPS_NOTIFY | CHR_PROPS_READ);
|
||||||
fromNum.setPermission(secMode, SECMODE_NO_ACCESS); // FIXME, secure this!!!
|
fromNum.setPermission(secMode, SECMODE_NO_ACCESS); // FIXME, secure this!!!
|
||||||
|
@ -226,7 +227,8 @@ void NRF52Bluetooth::setup()
|
||||||
Bluefruit.ScanResponse.clearData();
|
Bluefruit.ScanResponse.clearData();
|
||||||
|
|
||||||
if (config.bluetooth.mode != meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN) {
|
if (config.bluetooth.mode != meshtastic_Config_BluetoothConfig_PairingMode_NO_PIN) {
|
||||||
configuredPasskey = config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_FIXED_PIN ? config.bluetooth.fixed_pin
|
configuredPasskey = config.bluetooth.mode == meshtastic_Config_BluetoothConfig_PairingMode_FIXED_PIN
|
||||||
|
? config.bluetooth.fixed_pin
|
||||||
: random(100000, 999999);
|
: random(100000, 999999);
|
||||||
auto pinString = std::to_string(configuredPasskey);
|
auto pinString = std::to_string(configuredPasskey);
|
||||||
LOG_INFO("Bluetooth pin set to '%i'\n", configuredPasskey);
|
LOG_INFO("Bluetooth pin set to '%i'\n", configuredPasskey);
|
||||||
|
|
|
@ -9,7 +9,7 @@ SimRadio::SimRadio()
|
||||||
|
|
||||||
SimRadio *SimRadio::instance;
|
SimRadio *SimRadio::instance;
|
||||||
|
|
||||||
ErrorCode SimRadio::send(MeshPacket *p)
|
ErrorCode SimRadio::send(meshtastic_MeshPacket *p)
|
||||||
{
|
{
|
||||||
printPacket("enqueuing for send", p);
|
printPacket("enqueuing for send", p);
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ ErrorCode SimRadio::send(MeshPacket *p)
|
||||||
|
|
||||||
void SimRadio::setTransmitDelay()
|
void SimRadio::setTransmitDelay()
|
||||||
{
|
{
|
||||||
MeshPacket *p = txQueue.getFront();
|
meshtastic_MeshPacket *p = txQueue.getFront();
|
||||||
// We want all sending/receiving to be done by our daemon thread.
|
// We want all sending/receiving to be done by our daemon thread.
|
||||||
// We use a delay here because this packet might have been sent in response to a packet we just received.
|
// We use a delay here because this packet might have been sent in response to a packet we just received.
|
||||||
// So we want to make sure the other side has had a chance to reconfigure its radio.
|
// So we want to make sure the other side has had a chance to reconfigure its radio.
|
||||||
|
@ -163,7 +163,7 @@ void SimRadio::onNotify(uint32_t notification)
|
||||||
setTransmitDelay(); // reset random delay
|
setTransmitDelay(); // reset random delay
|
||||||
} else {
|
} else {
|
||||||
// Send any outgoing packets we have ready
|
// Send any outgoing packets we have ready
|
||||||
MeshPacket *txp = txQueue.dequeue();
|
meshtastic_MeshPacket *txp = txQueue.dequeue();
|
||||||
assert(txp);
|
assert(txp);
|
||||||
startSend(txp);
|
startSend(txp);
|
||||||
// Packet has been sent, count it toward our TX airtime utilization.
|
// Packet has been sent, count it toward our TX airtime utilization.
|
||||||
|
@ -188,9 +188,9 @@ void SimRadio::startSend(MeshPacket *txp)
|
||||||
{
|
{
|
||||||
printPacket("Starting low level send", txp);
|
printPacket("Starting low level send", txp);
|
||||||
size_t numbytes = beginSending(txp);
|
size_t numbytes = beginSending(txp);
|
||||||
MeshPacket *p = packetPool.allocCopy(*txp);
|
meshtastic_MeshPacket *p = packetPool.allocCopy(*txp);
|
||||||
perhapsDecode(p);
|
perhapsDecode(p);
|
||||||
Compressed c = Compressed_init_default;
|
meshtastic_Compressed c = meshtastic_Compressed_init_default;
|
||||||
c.portnum = p->decoded.portnum;
|
c.portnum = p->decoded.portnum;
|
||||||
// LOG_DEBUG("Sending back to simulator with portNum %d\n", p->decoded.portnum);
|
// LOG_DEBUG("Sending back to simulator with portNum %d\n", p->decoded.portnum);
|
||||||
if (p->decoded.payload.size <= sizeof(c.data.bytes)) {
|
if (p->decoded.payload.size <= sizeof(c.data.bytes)) {
|
||||||
|
@ -199,8 +199,9 @@ void SimRadio::startSend(MeshPacket *txp)
|
||||||
} else {
|
} else {
|
||||||
LOG_WARN("Payload size is larger than compressed message allows! Sending empty payload.\n");
|
LOG_WARN("Payload size is larger than compressed message allows! Sending empty payload.\n");
|
||||||
}
|
}
|
||||||
p->decoded.payload.size = pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &Compressed_msg, &c);
|
p->decoded.payload.size =
|
||||||
p->decoded.portnum = PortNum_SIMULATOR_APP;
|
pb_encode_to_bytes(p->decoded.payload.bytes, sizeof(p->decoded.payload.bytes), &meshtastic_Compressed_msg, &c);
|
||||||
|
p->decoded.portnum = meshtastic_PortNum_SIMULATOR_APP;
|
||||||
service.sendToPhone(p); // Sending back to simulator
|
service.sendToPhone(p); // Sending back to simulator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,9 +214,9 @@ void SimRadio::startReceive(MeshPacket *p)
|
||||||
handleReceiveInterrupt(p);
|
handleReceiveInterrupt(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueStatus SimRadio::getQueueStatus()
|
meshtastic_QueueStatus SimRadio::getQueueStatus()
|
||||||
{
|
{
|
||||||
QueueStatus qs;
|
meshtastic_QueueStatus qs;
|
||||||
|
|
||||||
qs.res = qs.mesh_packet_id = 0;
|
qs.res = qs.mesh_packet_id = 0;
|
||||||
qs.free = txQueue.getFree();
|
qs.free = txQueue.getFree();
|
||||||
|
@ -224,7 +225,7 @@ QueueStatus SimRadio::getQueueStatus()
|
||||||
return qs;
|
return qs;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimRadio::handleReceiveInterrupt(MeshPacket *p)
|
void SimRadio::handleReceiveInterrupt(meshtastic_MeshPacket *p)
|
||||||
{
|
{
|
||||||
LOG_DEBUG("HANDLE RECEIVE INTERRUPT\n");
|
LOG_DEBUG("HANDLE RECEIVE INTERRUPT\n");
|
||||||
uint32_t xmitMsec;
|
uint32_t xmitMsec;
|
||||||
|
@ -241,8 +242,8 @@ void SimRadio::handleReceiveInterrupt(MeshPacket *p)
|
||||||
xmitMsec = getPacketTime(length);
|
xmitMsec = getPacketTime(length);
|
||||||
// LOG_DEBUG("Payload size %d vs length (includes header) %d\n", p->decoded.payload.size, length);
|
// LOG_DEBUG("Payload size %d vs length (includes header) %d\n", p->decoded.payload.size, length);
|
||||||
|
|
||||||
MeshPacket *mp = packetPool.allocCopy(*p); // keep a copy in packtPool
|
meshtastic_MeshPacket *mp = packetPool.allocCopy(*p); // keep a copy in packtPool
|
||||||
mp->which_payload_variant = MeshPacket_decoded_tag; // Mark that the payload is already decoded
|
mp->which_payload_variant = meshtastic_MeshPacket_decoded_tag; // Mark that the payload is already decoded
|
||||||
|
|
||||||
printPacket("Lora RX", mp);
|
printPacket("Lora RX", mp);
|
||||||
|
|
||||||
|
@ -251,7 +252,7 @@ void SimRadio::handleReceiveInterrupt(MeshPacket *p)
|
||||||
deliverToReceiver(mp);
|
deliverToReceiver(mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SimRadio::getPacketLength(MeshPacket *mp)
|
size_t SimRadio::getPacketLength(meshtastic_MeshPacket *mp)
|
||||||
{
|
{
|
||||||
auto &p = mp->decoded;
|
auto &p = mp->decoded;
|
||||||
return (size_t)p.payload.size + sizeof(PacketHeader);
|
return (size_t)p.payload.size + sizeof(PacketHeader);
|
||||||
|
|
|
@ -24,7 +24,7 @@ class SimRadio : public RadioInterface
|
||||||
*/
|
*/
|
||||||
static SimRadio *instance;
|
static SimRadio *instance;
|
||||||
|
|
||||||
virtual ErrorCode send(MeshPacket *p) override;
|
virtual ErrorCode send(meshtastic_MeshPacket *p) override;
|
||||||
|
|
||||||
/** can we detect a LoRa preamble on the current channel? */
|
/** can we detect a LoRa preamble on the current channel? */
|
||||||
virtual bool isChannelActive();
|
virtual bool isChannelActive();
|
||||||
|
@ -42,9 +42,9 @@ class SimRadio : public RadioInterface
|
||||||
*
|
*
|
||||||
* External functions can call this method to wake the device from sleep.
|
* External functions can call this method to wake the device from sleep.
|
||||||
*/
|
*/
|
||||||
virtual void startReceive(MeshPacket *p);
|
virtual void startReceive(meshtastic_MeshPacket *p);
|
||||||
|
|
||||||
QueueStatus getQueueStatus() override;
|
meshtastic_QueueStatus getQueueStatus() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// are _trying_ to receive a packet currently (note - we might just be waiting for one)
|
/// are _trying_ to receive a packet currently (note - we might just be waiting for one)
|
||||||
|
@ -60,15 +60,15 @@ class SimRadio : public RadioInterface
|
||||||
void startTransmitTimerSNR(float snr);
|
void startTransmitTimerSNR(float snr);
|
||||||
|
|
||||||
void handleTransmitInterrupt();
|
void handleTransmitInterrupt();
|
||||||
void handleReceiveInterrupt(MeshPacket *p);
|
void handleReceiveInterrupt(meshtastic_MeshPacket *p);
|
||||||
|
|
||||||
void onNotify(uint32_t notification);
|
void onNotify(uint32_t notification);
|
||||||
|
|
||||||
// start an immediate transmit
|
// start an immediate transmit
|
||||||
virtual void startSend(MeshPacket *txp);
|
virtual void startSend(meshtastic_MeshPacket *txp);
|
||||||
|
|
||||||
// derive packet length
|
// derive packet length
|
||||||
size_t getPacketLength(MeshPacket *p);
|
size_t getPacketLength(meshtastic_MeshPacket *p);
|
||||||
|
|
||||||
int16_t readData(uint8_t *str, size_t len);
|
int16_t readData(uint8_t *str, size_t len);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
// set HW_VENDOR
|
// set HW_VENDOR
|
||||||
//
|
//
|
||||||
|
|
||||||
#define HW_VENDOR HardwareModel_PORTDUINO
|
#define HW_VENDOR meshtastic_HardwareModel_PORTDUINO
|
||||||
|
|
||||||
#define HAS_RTC 1
|
#define HAS_RTC 1
|
||||||
#define HAS_WIFI 1
|
#define HAS_WIFI 1
|
||||||
|
|
Ładowanie…
Reference in New Issue