add check for characteristic max_len
This commit is contained in:
1 parent
36cfbe0106
commit
4bffc65b9e
2 files changed
+10
-6
No files matched your search
@@ -355,9 +355,12 @@ err_t BLECharacteristic::write(const char * str)
|
||||
|
||||
err_t BLECharacteristic::write(const uint8_t* data, int len, uint16_t offset)
|
||||
{
|
||||
// could not exceed max len
|
||||
uint16_t actual_len = min16(len, _max_len);
|
||||
|
||||
ble_gatts_value_t value =
|
||||
{
|
||||
.len = (uint16_t) len,
|
||||
.len = (uint16_t) actual_len,
|
||||
.offset = offset,
|
||||
.p_value = (uint8_t*) data
|
||||
};
|
||||
@@ -388,7 +391,7 @@ err_t BLECharacteristic::write(uint8_t num)
|
||||
|
||||
bool BLECharacteristic::notifyEnabled(void)
|
||||
{
|
||||
VERIFY( _properties.notify );
|
||||
VERIFY( _properties.notify && Bluefruit.connected() );
|
||||
uint16_t cccd;
|
||||
ble_gatts_value_t value =
|
||||
{
|
||||
@@ -409,14 +412,15 @@ err_t BLECharacteristic::notify(const uint8_t* data, int len, uint16_t offset)
|
||||
// Whether Txbuf available or not we still update the chars'value
|
||||
(void) Bluefruit.txbuf_get(100);
|
||||
|
||||
uint16_t len16 = (uint16_t) len;
|
||||
// could not exceed max len
|
||||
uint16_t actual_len = min16(len, _max_len);
|
||||
|
||||
ble_gatts_hvx_params_t hvx_params =
|
||||
{
|
||||
.handle = _handles.value_handle,
|
||||
.type = BLE_GATT_HVX_NOTIFICATION,
|
||||
.offset = offset,
|
||||
.p_len = &len16,
|
||||
.p_len = &actual_len,
|
||||
.p_data = (uint8_t*) data,
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user