Added new roles

pull/1337/head
Jm Casler 2022-03-29 22:02:21 -07:00
rodzic 3d42da7968
commit e905f15a0f
3 zmienionych plików z 40 dodań i 16 usunięć

Wyświetl plik

@ -32,14 +32,19 @@ void FloodingRouter::sniffReceived(const MeshPacket *p, const Routing *c)
if ((p->to == NODENUM_BROADCAST) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) { if ((p->to == NODENUM_BROADCAST) && (p->hop_limit > 0) && (getFrom(p) != getNodeNum())) {
if (p->id != 0) { if (p->id != 0) {
MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it if (radioConfig.preferences.role != Role_ClientMute) {
MeshPacket *tosend = packetPool.allocCopy(*p); // keep a copy because we will be sending it
tosend->hop_limit--; // bump down the hop count tosend->hop_limit--; // bump down the hop count
printPacket("Rebroadcasting received floodmsg to neighbors", p); printPacket("Rebroadcasting received floodmsg to neighbors", p);
// Note: we are careful to resend using the original senders node id // Note: we are careful to resend using the original senders node id
// We are careful not to call our hooked version of send() - because we don't want to check this again // We are careful not to call our hooked version of send() - because we don't want to check this again
Router::send(tosend); Router::send(tosend);
} else {
DEBUG_MSG("Not rebroadcasting. Role = Role_ClientMute\n");
}
} else { } else {
DEBUG_MSG("Ignoring a simple (0 id) broadcast\n"); DEBUG_MSG("Ignoring a simple (0 id) broadcast\n");

Wyświetl plik

@ -202,7 +202,7 @@ uint32_t RadioInterface::getTxDelayMsecWeighted(float snr)
// low SNR = Short Delay // low SNR = Short Delay
uint32_t delay = 0; uint32_t delay = 0;
if (radioConfig.preferences.role == Role_Router) { if (radioConfig.preferences.role == Role_Router || radioConfig.preferences.role == Role_RouterClient) {
delay = map(snr, SNR_MIN, SNR_MAX, MIN_TX_WAIT_MSEC, (MIN_TX_WAIT_MSEC + (shortPacketMsec / 2))); delay = map(snr, SNR_MIN, SNR_MAX, MIN_TX_WAIT_MSEC, (MIN_TX_WAIT_MSEC + (shortPacketMsec / 2)));
DEBUG_MSG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay); DEBUG_MSG("rx_snr found in packet. As a router, setting tx delay:%d\n", delay);
} else { } else {

Wyświetl plik

@ -51,10 +51,23 @@ typedef enum _RegionCode {
Router Router
Functions as a router */ Functions as a router */
typedef enum _Role { typedef enum _Role {
/* Default device role */ /* Client device role */
Role_Default = 0, Role_Client = 0,
/* Router device role */ /* ClientMute device role
Role_Router = 1 This is like the client but packets will not hop over this node. Would be
useful if you want to save power by not contributing to the mesh. */
Role_ClientMute = 1,
/* Router device role.
Uses an agressive algirithem for the flood networking so packets will
prefer to be routed over this node. Also assume that this will be generally
unattended and so will turn off the wifi/ble radio as well as the oled screen. */
Role_Router = 2,
/* RouterClient device role
Uses an agressive algirithem for the flood networking so packets will
prefer to be routed over this node. Similiar power management as a regular
client, so the RouterClient can be used as both a Router and a Client. Useful
as a well placed base station that you could also use to send messages. */
Role_RouterClient = 3
} Role; } Role;
/* Sets the charge control current of devices with a battery charger that can be /* Sets the charge control current of devices with a battery charger that can be
@ -206,10 +219,16 @@ typedef enum _RadioConfig_UserPreferences_Serial_Baud {
Router Router
Functions as a router */ Functions as a router */
typedef enum _RadioConfig_UserPreferences_Serial_Mode { typedef enum _RadioConfig_UserPreferences_Serial_Mode {
/* Default device role */ /* Client device role */
RadioConfig_UserPreferences_Serial_Mode_MODE_Default = 0, RadioConfig_UserPreferences_Serial_Mode_MODE_Default = 0,
/* Router device role */ /* ClientMute device role
This is like the client but packets will not hop over this node. Would be
useful if you want to save power by not contributing to the mesh. */
RadioConfig_UserPreferences_Serial_Mode_MODE_SIMPLE = 1, RadioConfig_UserPreferences_Serial_Mode_MODE_SIMPLE = 1,
/* Router device role.
Uses an agressive algirithem for the flood networking so packets will
prefer to be routed over this node. Also assume that this will be generally
unattended and so will turn off the wifi/ble radio as well as the oled screen. */
RadioConfig_UserPreferences_Serial_Mode_MODE_PROTO = 2 RadioConfig_UserPreferences_Serial_Mode_MODE_PROTO = 2
} RadioConfig_UserPreferences_Serial_Mode; } RadioConfig_UserPreferences_Serial_Mode;
@ -343,9 +362,9 @@ typedef struct _RadioConfig {
#define _RegionCode_MAX RegionCode_TH #define _RegionCode_MAX RegionCode_TH
#define _RegionCode_ARRAYSIZE ((RegionCode)(RegionCode_TH+1)) #define _RegionCode_ARRAYSIZE ((RegionCode)(RegionCode_TH+1))
#define _Role_MIN Role_Default #define _Role_MIN Role_Client
#define _Role_MAX Role_Router #define _Role_MAX Role_RouterClient
#define _Role_ARRAYSIZE ((Role)(Role_Router+1)) #define _Role_ARRAYSIZE ((Role)(Role_RouterClient+1))
#define _ChargeCurrent_MIN ChargeCurrent_MAUnset #define _ChargeCurrent_MIN ChargeCurrent_MAUnset
#define _ChargeCurrent_MAX ChargeCurrent_MA1320 #define _ChargeCurrent_MAX ChargeCurrent_MA1320