Further imrpovements to protocol suport
This commit is contained in:
@@ -128,6 +128,22 @@ void MeshCoreCompanion::getStats(uint8_t statsType) {
|
||||
uint8_t p[2]; sendPayload(p, mc_cmd_get_stats(p, sizeof(p), statsType));
|
||||
}
|
||||
|
||||
/* ---- provisioning ---- */
|
||||
void MeshCoreCompanion::setAdvertName(const char *name) {
|
||||
uint8_t p[1 + MC_MAX_TEXT];
|
||||
sendPayload(p, mc_cmd_set_advert_name(p, sizeof(p), name));
|
||||
}
|
||||
void MeshCoreCompanion::setRadioParams(float freqMHz, float bwKHz, uint8_t sf, uint8_t cr) {
|
||||
/* wire units: freq = MHz*1000 (kHz), bw = kHz*1000 (Hz) */
|
||||
uint32_t freq = (uint32_t)(freqMHz * 1000.0f + 0.5f);
|
||||
uint32_t bw = (uint32_t)(bwKHz * 1000.0f + 0.5f);
|
||||
uint8_t p[11];
|
||||
sendPayload(p, mc_cmd_set_radio_params(p, sizeof(p), freq, bw, sf, cr));
|
||||
}
|
||||
void MeshCoreCompanion::setTxPower(uint32_t dbm) {
|
||||
uint8_t p[5]; sendPayload(p, mc_cmd_set_tx_power(p, sizeof(p), dbm));
|
||||
}
|
||||
|
||||
/* ---- contacts ---- */
|
||||
void MeshCoreCompanion::getContacts(uint32_t sinceLastmod) {
|
||||
uint8_t p[5]; sendPayload(p, mc_cmd_get_contacts(p, sizeof(p), sinceLastmod));
|
||||
|
||||
@@ -50,6 +50,10 @@ public:
|
||||
void getDeviceTime();
|
||||
void setDeviceTime(uint32_t epochSecs);
|
||||
void sendSelfAdvert(bool flood = true);
|
||||
/* Provisioning: node name, radio region, tx power. */
|
||||
void setAdvertName(const char *name);
|
||||
void setRadioParams(float freqMHz, float bwKHz, uint8_t sf, uint8_t cr);
|
||||
void setTxPower(uint32_t dbm);
|
||||
void getChannel(uint8_t idx);
|
||||
void setChannel(uint8_t idx, const char *name, const uint8_t secret[MC_SECRET_LEN]);
|
||||
/* Set a channel using a 32-hex-char PSK string (-> 16 bytes). false if malformed. */
|
||||
|
||||
@@ -252,6 +252,20 @@ size_t mc_cmd_set_radio_params(uint8_t *out, size_t cap, uint32_t freq_hz_x1000,
|
||||
return i;
|
||||
}
|
||||
|
||||
size_t mc_cmd_set_advert_name(uint8_t *out, size_t cap, const char *name) {
|
||||
size_t nlen = name ? strlen(name) : 0;
|
||||
size_t total = 1 + nlen;
|
||||
if (cap < total) return 0;
|
||||
out[0] = MC_CMD_SET_ADVERT_NAME;
|
||||
if (nlen) memcpy(out + 1, name, nlen);
|
||||
return total;
|
||||
}
|
||||
|
||||
size_t mc_cmd_set_tx_power(uint8_t *out, size_t cap, uint32_t dbm) {
|
||||
if (cap < 5) return 0;
|
||||
out[0] = MC_CMD_SET_TX_POWER; put_u32(out + 1, dbm); return 5;
|
||||
}
|
||||
|
||||
size_t mc_cmd_get_stats(uint8_t *out, size_t cap, uint8_t stats_type) {
|
||||
if (cap < 2) return 0;
|
||||
out[0] = MC_CMD_GET_STATS; out[1] = stats_type; return 2;
|
||||
|
||||
@@ -208,6 +208,10 @@ size_t mc_cmd_send_cmd (uint8_t *out, size_t cap, uint32_t sender_ts,
|
||||
const char *cmd);
|
||||
size_t mc_cmd_set_radio_params (uint8_t *out, size_t cap, uint32_t freq_hz_x1000,
|
||||
uint32_t bw, uint8_t sf, uint8_t cr);
|
||||
/* Node name shown in adverts (cmd 8). */
|
||||
size_t mc_cmd_set_advert_name (uint8_t *out, size_t cap, const char *name);
|
||||
/* Radio TX power in dBm (cmd 12). */
|
||||
size_t mc_cmd_set_tx_power (uint8_t *out, size_t cap, uint32_t dbm);
|
||||
size_t mc_cmd_get_stats (uint8_t *out, size_t cap, uint8_t stats_type);
|
||||
|
||||
/* ---- contacts (Phase 2) ---- */
|
||||
|
||||
Reference in New Issue
Block a user