mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-01 18:29:56 +00:00
if android changes radio settings - change the radio
This commit is contained in:
parent
71a0602023
commit
d2521656db
9
TODO.md
9
TODO.md
@ -1,11 +1,8 @@
|
||||
# High priority
|
||||
|
||||
* implement regen owner and radio prefs
|
||||
|
||||
* port my graphics library over from the sw102, same screen controller and resolution
|
||||
* very occasionally send our position and user packet (if for nothing else so that other nodes update last_seen)
|
||||
* switch to my gui layout manager
|
||||
* make jtag work on second board
|
||||
* make basic gui. different screens: debug, one page for each user in the user db, last received text message
|
||||
* save our node db (and any rx packets waiting for phone) to flash - see DeviceState protobuf
|
||||
|
||||
@ -13,11 +10,13 @@
|
||||
|
||||
* don't send location packets if we haven't moved
|
||||
* scrub default radio config settings for bandwidth/range/speed
|
||||
* add basic crypto - http://rweather.github.io/arduinolibs/crypto.html with speck https://www.airspayce.com/mikem/arduino/RadioHead/rf95_encrypted_client_8pde-example.html
|
||||
* override peekAtMessage so we can see any messages that pass through our node (even if not broadcast)? would that be useful?
|
||||
* sendToMesh can currently block for a long time, instead have it just queue a packet for a radio freertos thread
|
||||
* fix the logo
|
||||
* How do avalanche beacons work? Could this do that as well? possibly by using beacon mode feature of the RF95?
|
||||
* use std::map<BLECharacteristic*, std::string> in node db
|
||||
* first alpha release, article writeup
|
||||
|
||||
# Low power consumption tasks
|
||||
|
||||
@ -40,7 +39,7 @@ But fixme, think about this and look for standard solutions - it will have probl
|
||||
|
||||
# Pre-beta priority
|
||||
|
||||
* turn on basic crypto
|
||||
* swap out speck for accelerated full AES https://github.com/espressif/arduino-esp32/blob/master/tools/sdk/include/esp32/hwcrypto/aes.h
|
||||
* cope with nodes that have 0xff or 0x00 as the last byte of their mac
|
||||
* use variable length arduino Strings in protobufs (instead of current fixed buffers)
|
||||
* don't even power on bluetooth until we have some data to send to the android phone. Most of the time we should be sleeping in a lowpower "listening for lora" only mode. Once we have some packets for the phone, then power on bluetooth
|
||||
@ -96,3 +95,5 @@ until the phone pulls those packets. Ever so often power on bluetooth just so w
|
||||
* send correct hw vendor in the bluetooth info - needed so the android app can update different radio models
|
||||
* correctly map nodeids to nodenums, currently we just do a proof of concept by always doing a broadcast
|
||||
* add interrupt detach/sleep mode config to lora radio so we can enable deepsleep without panicing
|
||||
* make jtag work on second board
|
||||
* implement regen owner and radio prefs
|
@ -1,5 +1,5 @@
|
||||
#include <SPI.h>
|
||||
#include <RH_RF95.h>
|
||||
#include "RH_RF95.h"
|
||||
#include <RHMesh.h>
|
||||
#include <assert.h>
|
||||
|
||||
@ -21,6 +21,7 @@ MeshRadio::MeshRadio(MemoryPool<MeshPacket> &_pool, PointerQueue<MeshPacket> &_r
|
||||
rxDest(_rxDest),
|
||||
txQueue(MAX_TX_QUEUE)
|
||||
{
|
||||
radioConfig.modem_config = RadioConfig_ModemConfig_Bw125Cr45Sf128;
|
||||
radioConfig.tx_power = 23;
|
||||
radioConfig.center_freq = RF95_FREQ_US; // FIXME, pull this config from flash
|
||||
}
|
||||
@ -47,11 +48,29 @@ bool MeshRadio::init()
|
||||
return false;
|
||||
}
|
||||
|
||||
reloadConfig();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void MeshRadio::reloadConfig()
|
||||
{
|
||||
DEBUG_MSG("configuring radio\n");
|
||||
|
||||
rf95.setModeIdle();
|
||||
|
||||
// Set up default configuration
|
||||
// No Sync Words in LORA mode.
|
||||
rf95.setModemConfig((RH_RF95::ModemConfigChoice) radioConfig.modem_config); // Radio default
|
||||
// setModemConfig(Bw125Cr48Sf4096); // slow and reliable?
|
||||
// rf95.setPreambleLength(8); // Default is 8
|
||||
|
||||
// Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
|
||||
if (!rf95.setFrequency(radioConfig.center_freq))
|
||||
{
|
||||
DEBUG_MSG("setFrequency failed\n");
|
||||
assert(0); // fixme panic
|
||||
assert(0); // fixme panic
|
||||
}
|
||||
DEBUG_MSG("Set Freq to: %f\n", radioConfig.center_freq);
|
||||
|
||||
@ -64,8 +83,6 @@ bool MeshRadio::init()
|
||||
rf95.setTxPower(radioConfig.tx_power, false);
|
||||
|
||||
DEBUG_MSG("LoRa radio init OK!\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ErrorCode MeshRadio::send(MeshPacket *p)
|
||||
@ -93,7 +110,6 @@ void MeshRadio::handleReceive(MeshPacket *mp)
|
||||
assert(res == pdTRUE);
|
||||
}
|
||||
|
||||
|
||||
void MeshRadio::loop()
|
||||
{
|
||||
// FIXME read from radio with recvfromAckTimeout
|
||||
@ -142,7 +158,7 @@ static int16_t packetnum = 0; // packet counter, we increment per xmission
|
||||
MeshPacket *txp = txQueue.dequeuePtr(0); // nowait
|
||||
if (txp)
|
||||
{
|
||||
DEBUG_MSG("sending queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)\n", rf95.txGood(),rf95.rxGood(), rf95.rxBad());
|
||||
DEBUG_MSG("sending queued packet on mesh (txGood=%d,rxGood=%d,rxBad=%d)\n", rf95.txGood(), rf95.rxGood(), rf95.rxBad());
|
||||
assert(txp->has_payload);
|
||||
|
||||
size_t numbytes = pb_encode_to_bytes(radiobuf, sizeof(radiobuf), SubPacket_fields, &txp->payload);
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
void loop();
|
||||
|
||||
/// The radioConfig object just changed, call this to force the hw to change to the new settings
|
||||
void reloadConfig() { DEBUG_MSG("FIXME add reloadConfig\n"); }
|
||||
void reloadConfig();
|
||||
|
||||
private:
|
||||
RH_RF95 rf95; // the raw radio interface
|
||||
|
@ -47,6 +47,7 @@ PB_BIND(ToRadio, ToRadio, AUTO)
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef PB_CONVERT_DOUBLE_FLOAT
|
||||
/* On some platforms (such as AVR), double is really float.
|
||||
* To be able to encode/decode double on these platforms, you need.
|
||||
|
@ -20,6 +20,13 @@ typedef enum _Data_Type {
|
||||
Data_Type_CLEAR_READACK = 2
|
||||
} Data_Type;
|
||||
|
||||
typedef enum _RadioConfig_ModemConfig {
|
||||
RadioConfig_ModemConfig_Bw125Cr45Sf128 = 0,
|
||||
RadioConfig_ModemConfig_Bw500Cr45Sf128 = 1,
|
||||
RadioConfig_ModemConfig_Bw31_25Cr48Sf512 = 2,
|
||||
RadioConfig_ModemConfig_Bw125Cr48Sf4096 = 3
|
||||
} RadioConfig_ModemConfig;
|
||||
|
||||
/* Struct definitions */
|
||||
typedef PB_BYTES_ARRAY_T(100) Data_payload_t;
|
||||
typedef struct _Data {
|
||||
@ -43,14 +50,14 @@ typedef struct _Position {
|
||||
bool from_hardware;
|
||||
} Position;
|
||||
|
||||
typedef PB_BYTES_ARRAY_T(32) RadioConfig_psk_t;
|
||||
typedef struct _RadioConfig {
|
||||
uint32_t position_broadcast_msec;
|
||||
uint32_t min_broadcast_msec;
|
||||
int32_t tx_power;
|
||||
float center_freq;
|
||||
uint32_t bandwidth;
|
||||
int32_t spread_factor;
|
||||
int32_t coding_rate;
|
||||
RadioConfig_ModemConfig modem_config;
|
||||
RadioConfig_psk_t psk;
|
||||
bool keep_all_packets;
|
||||
bool promiscuous_mode;
|
||||
} RadioConfig;
|
||||
@ -128,6 +135,10 @@ typedef struct _ToRadio {
|
||||
#define _Data_Type_MAX Data_Type_CLEAR_READACK
|
||||
#define _Data_Type_ARRAYSIZE ((Data_Type)(Data_Type_CLEAR_READACK+1))
|
||||
|
||||
#define _RadioConfig_ModemConfig_MIN RadioConfig_ModemConfig_Bw125Cr45Sf128
|
||||
#define _RadioConfig_ModemConfig_MAX RadioConfig_ModemConfig_Bw125Cr48Sf4096
|
||||
#define _RadioConfig_ModemConfig_ARRAYSIZE ((RadioConfig_ModemConfig)(RadioConfig_ModemConfig_Bw125Cr48Sf4096+1))
|
||||
|
||||
|
||||
/* Initializer values for message structs */
|
||||
#define Position_init_default {0, 0, 0, 0, 0}
|
||||
@ -137,7 +148,7 @@ typedef struct _ToRadio {
|
||||
#define DenyNodeNum_init_default {{0}}
|
||||
#define SubPacket_init_default {0, {Position_init_default}}
|
||||
#define MeshPacket_init_default {0, 0, false, SubPacket_init_default}
|
||||
#define RadioConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define RadioConfig_init_default {0, 0, 0, 0, _RadioConfig_ModemConfig_MIN, {0, {0}}, 0, 0}
|
||||
#define NodeInfo_init_default {0, false, User_init_default, false, Position_init_default, 0, 0}
|
||||
#define MyNodeInfo_init_default {0}
|
||||
#define DeviceState_init_default {false, RadioConfig_init_default, false, MyNodeInfo_init_default, 0, {NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default, NodeInfo_init_default}, 0, {MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default, MeshPacket_init_default}}
|
||||
@ -150,7 +161,7 @@ typedef struct _ToRadio {
|
||||
#define DenyNodeNum_init_zero {{0}}
|
||||
#define SubPacket_init_zero {0, {Position_init_zero}}
|
||||
#define MeshPacket_init_zero {0, 0, false, SubPacket_init_zero}
|
||||
#define RadioConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
#define RadioConfig_init_zero {0, 0, 0, 0, _RadioConfig_ModemConfig_MIN, {0, {0}}, 0, 0}
|
||||
#define NodeInfo_init_zero {0, false, User_init_zero, false, Position_init_zero, 0, 0}
|
||||
#define MyNodeInfo_init_zero {0}
|
||||
#define DeviceState_init_zero {false, RadioConfig_init_zero, false, MyNodeInfo_init_zero, 0, {NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero, NodeInfo_init_zero}, 0, {MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero, MeshPacket_init_zero}}
|
||||
@ -171,9 +182,8 @@ typedef struct _ToRadio {
|
||||
#define RadioConfig_min_broadcast_msec_tag 2
|
||||
#define RadioConfig_tx_power_tag 3
|
||||
#define RadioConfig_center_freq_tag 4
|
||||
#define RadioConfig_bandwidth_tag 5
|
||||
#define RadioConfig_spread_factor_tag 6
|
||||
#define RadioConfig_coding_rate_tag 7
|
||||
#define RadioConfig_modem_config_tag 5
|
||||
#define RadioConfig_psk_tag 8
|
||||
#define RadioConfig_keep_all_packets_tag 100
|
||||
#define RadioConfig_promiscuous_mode_tag 101
|
||||
#define User_id_tag 1
|
||||
@ -267,9 +277,8 @@ X(a, STATIC, SINGULAR, UINT32, position_broadcast_msec, 1) \
|
||||
X(a, STATIC, SINGULAR, UINT32, min_broadcast_msec, 2) \
|
||||
X(a, STATIC, SINGULAR, INT32, tx_power, 3) \
|
||||
X(a, STATIC, SINGULAR, FLOAT, center_freq, 4) \
|
||||
X(a, STATIC, SINGULAR, UINT32, bandwidth, 5) \
|
||||
X(a, STATIC, SINGULAR, INT32, spread_factor, 6) \
|
||||
X(a, STATIC, SINGULAR, INT32, coding_rate, 7) \
|
||||
X(a, STATIC, SINGULAR, UENUM, modem_config, 5) \
|
||||
X(a, STATIC, SINGULAR, BYTES, psk, 8) \
|
||||
X(a, STATIC, SINGULAR, BOOL, keep_all_packets, 100) \
|
||||
X(a, STATIC, SINGULAR, BOOL, promiscuous_mode, 101)
|
||||
#define RadioConfig_CALLBACK NULL
|
||||
@ -353,10 +362,10 @@ extern const pb_msgdesc_t ToRadio_msg;
|
||||
#define DenyNodeNum_size 8
|
||||
#define SubPacket_size 106
|
||||
#define MeshPacket_size 130
|
||||
#define RadioConfig_size 62
|
||||
#define RadioConfig_size 70
|
||||
#define NodeInfo_size 151
|
||||
#define MyNodeInfo_size 11
|
||||
#define DeviceState_size 9261
|
||||
#define DeviceState_size 9269
|
||||
#define FromRadio_size 139
|
||||
#define ToRadio_size 133
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user