if android updates owner or radio, tell the network

pull/1/head
geeksville 2020-02-03 21:17:35 -08:00
rodzic 634a547030
commit 31ee795e9b
3 zmienionych plików z 46 dodań i 3 usunięć

Wyświetl plik

@ -79,6 +79,38 @@ public:
}
};
// wrap our protobuf version with something that forces the service to reload the config
class RadioCharacteristic : public ProtobufCharacteristic
{
public:
RadioCharacteristic()
: ProtobufCharacteristic("b56786c8-839a-44a1-b98e-a1724c4a0262", BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_READ, RadioConfig_fields, &radioConfig)
{
}
void onWrite(BLECharacteristic *c)
{
ProtobufCharacteristic::onWrite(c);
service.reloadConfig();
}
};
// wrap our protobuf version with something that forces the service to reload the owner
class OwnerCharacteristic : public ProtobufCharacteristic
{
public:
OwnerCharacteristic()
: ProtobufCharacteristic("6ff1d8b6-e2de-41e3-8c0b-8fa384f64eb6", BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_READ, User_fields, &owner)
{
}
void onWrite(BLECharacteristic *c)
{
ProtobufCharacteristic::onWrite(c);
service.reloadOwner();
}
};
static BLECharacteristic
meshFromRadioCharacteristic("8ba2bcc2-ee02-4a55-a531-c525c5e454d5", BLECharacteristic::PROPERTY_READ),
meshToRadioCharacteristic("f75c76d2-129e-4dad-a1dd-7866124401e7", BLECharacteristic::PROPERTY_WRITE),
@ -87,9 +119,11 @@ static BLECharacteristic
static NodeInfoCharacteristic meshNodeInfoCharacteristic;
static ProtobufCharacteristic
meshMyNodeCharacteristic("ea9f3f82-8dc4-4733-9452-1f6da28892a2", BLECharacteristic::PROPERTY_READ, MyNodeInfo_fields, &myNodeInfo),
meshRadioCharacteristic("b56786c8-839a-44a1-b98e-a1724c4a0262", BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_READ, RadioConfig_fields, &radioConfig),
meshOwnerCharacteristic("6ff1d8b6-e2de-41e3-8c0b-8fa384f64eb6", BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_READ, User_fields, &owner);
meshMyNodeCharacteristic("ea9f3f82-8dc4-4733-9452-1f6da28892a2", BLECharacteristic::PROPERTY_READ, MyNodeInfo_fields, &myNodeInfo);
static OwnerCharacteristic meshOwnerCharacteristic;
static RadioCharacteristic meshRadioCharacteristic;
/**
* Tell any bluetooth clients that the number of rx packets has changed

Wyświetl plik

@ -36,6 +36,9 @@ public:
/// for received packets it will call the rx handler
void loop();
/// The radioConfig object just changed, call this to force the hw to change to the new settings
void reloadConfig() { Serial.println("FIXME add reloadConfig"); }
private:
RH_RF95 rf95; // the raw radio interface
RHMesh manager;

Wyświetl plik

@ -50,6 +50,12 @@ public:
/// Given a ToRadio buffer (from bluetooth) parse it and properly handle it (setup radio, owner or send packet into the mesh)
void handleToRadio(std::string s);
/// The radioConfig object just changed, call this to force the hw to change to the new settings
void reloadConfig() { radio.reloadConfig(); }
/// The owner User record just got updated, update our node DB and broadcast the info into the mesh
void reloadOwner() { Serial.println("FIXME implement reloadOwner"); }
private:
/// Send a packet into the mesh - note p is read only and should be copied into a pool based MeshPacket before