mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-22 13:04:53 +00:00
return ble errors for invalid values
This commit is contained in:
parent
71d1d4d8fa
commit
d045139945
@ -392,6 +392,7 @@ void gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper function that implements simple read and write handling for a uint32_t
|
* A helper function that implements simple read and write handling for a uint32_t
|
||||||
*
|
*
|
||||||
@ -415,6 +416,7 @@ int chr_readwrite32le(uint32_t *v, struct ble_gatt_access_ctxt *ctxt)
|
|||||||
if (len < sizeof(le)) {
|
if (len < sizeof(le)) {
|
||||||
DEBUG_MSG("Error: wrongsized write32\n");
|
DEBUG_MSG("Error: wrongsized write32\n");
|
||||||
*v = 0;
|
*v = 0;
|
||||||
|
return BLE_ATT_ERR_UNLIKELY;
|
||||||
} else {
|
} else {
|
||||||
*v = get_le32(le);
|
*v = get_le32(le);
|
||||||
DEBUG_MSG("BLE writing a uint32\n");
|
DEBUG_MSG("BLE writing a uint32\n");
|
||||||
@ -441,8 +443,10 @@ int chr_readwrite8(uint8_t *v, size_t vlen, struct ble_gatt_access_ctxt *ctxt)
|
|||||||
|
|
||||||
auto rc = ble_hs_mbuf_to_flat(ctxt->om, v, vlen, &len);
|
auto rc = ble_hs_mbuf_to_flat(ctxt->om, v, vlen, &len);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
if (len < vlen)
|
if (len < vlen) {
|
||||||
DEBUG_MSG("Error: wrongsized write\n");
|
DEBUG_MSG("Error: wrongsized write\n");
|
||||||
|
return BLE_ATT_ERR_UNLIKELY;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG_MSG("BLE writing bytes\n");
|
DEBUG_MSG("BLE writing bytes\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user