Merge pull request #663 from liamcottle/feature/remove-neighbour
Add CLI command to remove neighbour
This commit is contained in:
@@ -719,6 +719,17 @@ public:
|
|||||||
*dp = 0; // null terminator
|
*dp = 0; // null terminator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeNeighbor(const uint8_t* pubkey, int key_len) override {
|
||||||
|
#if MAX_NEIGHBOURS
|
||||||
|
for (int i = 0; i < MAX_NEIGHBOURS; i++) {
|
||||||
|
NeighbourInfo* neighbour = &neighbours[i];
|
||||||
|
if(memcmp(neighbour->id.pub_key, pubkey, key_len) == 0){
|
||||||
|
neighbours[i] = NeighbourInfo(); // clear neighbour entry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
mesh::LocalIdentity& getSelfId() override { return self_id; }
|
mesh::LocalIdentity& getSelfId() override { return self_id; }
|
||||||
|
|
||||||
void clearStats() override {
|
void clearStats() override {
|
||||||
|
|||||||
@@ -165,6 +165,17 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
|
|||||||
}
|
}
|
||||||
} else if (memcmp(command, "neighbors", 9) == 0) {
|
} else if (memcmp(command, "neighbors", 9) == 0) {
|
||||||
_callbacks->formatNeighborsReply(reply);
|
_callbacks->formatNeighborsReply(reply);
|
||||||
|
} else if (memcmp(command, "neighbor.remove ", 16) == 0) {
|
||||||
|
const char* hex = &command[16];
|
||||||
|
uint8_t pubkey[PUB_KEY_SIZE];
|
||||||
|
int hex_len = min(strlen(hex), PUB_KEY_SIZE*2);
|
||||||
|
int pubkey_len = hex_len / 2;
|
||||||
|
if (mesh::Utils::fromHex(pubkey, pubkey_len, hex)) {
|
||||||
|
_callbacks->removeNeighbor(pubkey, pubkey_len);
|
||||||
|
strcpy(reply, "OK");
|
||||||
|
} else {
|
||||||
|
strcpy(reply, "ERR: bad pubkey");
|
||||||
|
}
|
||||||
} else if (memcmp(command, "tempradio ", 10) == 0) {
|
} else if (memcmp(command, "tempradio ", 10) == 0) {
|
||||||
strcpy(tmp, &command[10]);
|
strcpy(tmp, &command[10]);
|
||||||
const char *parts[5];
|
const char *parts[5];
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ public:
|
|||||||
virtual void dumpLogFile() = 0;
|
virtual void dumpLogFile() = 0;
|
||||||
virtual void setTxPower(uint8_t power_dbm) = 0;
|
virtual void setTxPower(uint8_t power_dbm) = 0;
|
||||||
virtual void formatNeighborsReply(char *reply) = 0;
|
virtual void formatNeighborsReply(char *reply) = 0;
|
||||||
|
virtual void removeNeighbor(const uint8_t* pubkey, int key_len) {
|
||||||
|
// no op by default
|
||||||
|
};
|
||||||
virtual mesh::LocalIdentity& getSelfId() = 0;
|
virtual mesh::LocalIdentity& getSelfId() = 0;
|
||||||
virtual void clearStats() = 0;
|
virtual void clearStats() = 0;
|
||||||
virtual void applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) = 0;
|
virtual void applyTempRadioParams(float freq, float bw, uint8_t sf, uint8_t cr, int timeout_mins) = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user