@@ -851,6 +851,7 @@ static int characteristic_access_cb(uint16_t conn_handle, uint16_t value_handle,
851
851
switch (ctxt -> op ) {
852
852
case BLE_GATT_ACCESS_OP_READ_CHR :
853
853
case BLE_GATT_ACCESS_OP_READ_DSC : {
854
+ DEBUG_printf ("write for %d %d (op=%d)\n" , conn_handle , value_handle , ctxt -> op );
854
855
// Allow Python code to override (by using gatts_write), or deny (by returning false) the read.
855
856
// Note this will be a no-op if the ringbuffer implementation is being used (i.e. the stack isn't
856
857
// run in the scheduler). The ringbuffer is not used on STM32 and Unix-H4 only.
@@ -872,6 +873,7 @@ static int characteristic_access_cb(uint16_t conn_handle, uint16_t value_handle,
872
873
}
873
874
case BLE_GATT_ACCESS_OP_WRITE_CHR :
874
875
case BLE_GATT_ACCESS_OP_WRITE_DSC :
876
+ DEBUG_printf ("write for %d %d (op=%d)\n" , conn_handle , value_handle , ctxt -> op );
875
877
entry = mp_bluetooth_gatts_db_lookup (MP_STATE_PORT (bluetooth_nimble_root_pointers )-> gatts_db , value_handle );
876
878
if (!entry ) {
877
879
return BLE_ATT_ERR_ATTR_NOT_FOUND ;
@@ -963,7 +965,14 @@ int mp_bluetooth_gatts_register_service(mp_obj_bluetooth_uuid_t *service_uuid, m
963
965
descriptors [j ].uuid = create_nimble_uuid (descriptor_uuids [descriptor_index ], NULL );
964
966
descriptors [j ].access_cb = characteristic_access_cb ;
965
967
// NimBLE doesn't support security/privacy options on descriptors.
966
- descriptors [j ].att_flags = (uint8_t )descriptor_flags [descriptor_index ];
968
+ uint8_t desc_att_flags = 0 ;
969
+ if (descriptor_flags [descriptor_index ] & MP_BLUETOOTH_CHARACTERISTIC_FLAG_READ ) {
970
+ desc_att_flags |= BLE_ATT_F_READ ;
971
+ }
972
+ if (descriptor_flags [descriptor_index ] & (MP_BLUETOOTH_CHARACTERISTIC_FLAG_WRITE | MP_BLUETOOTH_CHARACTERISTIC_FLAG_WRITE_NO_RESPONSE )) {
973
+ desc_att_flags |= BLE_ATT_F_WRITE ;
974
+ }
975
+ descriptors [j ].att_flags = desc_att_flags ;
967
976
descriptors [j ].min_key_size = 0 ;
968
977
// Unlike characteristic, Nimble doesn't provide an automatic way to remember the handle, so use the arg.
969
978
descriptors [j ].arg = & handles [handle_index ];
0 commit comments