HI,
I add a readable and writeable characteristic with :
attr_md.vloc = BLE_GATTS_VLOC_USER;
attr_md.vlen = 1;
attr_md.wr_auth = 1;
and
attr_char_value.p_attr_md = &attr_md;
attr_char_value.init_len = sizeof(my_value);
attr_char_value.init_offs = 0;
attr_char_value.max_len = sizeof(m_value);;
attr_char_value.p_value = (uint8_t *)&my_value;
I want to correct the value that write from App, when value out of the spec. range, for example, If value > 100, the value will be corrected to 100.
In RW_AUTH_REQUEST Event:
if ( p_evt_write->handle==m_beacon_period_char_handles.value_handle ) {
if ( p_evt_write->len==1 ) {
if ( p_evt_write->data[0]>100 ) {
// TODO: correct the value to 100
my_value = 100;
}
bUpdate = true;
} else {
write_authorize_reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_INVALID_ATT_VAL_LENGTH;
}
}
But, when I set the value to 200 by MCP of Android, the MCP still show the incorrect value (200). How to update the value to 100 for "read" ?
Thanks