diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2020-11-24 23:04:58 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-12-02 14:37:55 +1100 |
commit | 60830bcba46dd649e396b605708274a2208c398d (patch) | |
tree | 3c12aeb7b65d029bada56078e50ead286972d8e3 /extmod/modbluetooth.c | |
parent | 89553997b8496aca96b46274c81fa6413d58f6bd (diff) |
extmod/modbluetooth: Allow user-specified reason in read request IRQ.
Instead of returning None/bool from the IRQ, return None/int (where a zero
value means success). This mirrors how the L2CAP_ACCEPT return value
works.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'extmod/modbluetooth.c')
-rw-r--r-- | extmod/modbluetooth.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/extmod/modbluetooth.c b/extmod/modbluetooth.c index 1e67c8ce3..ed983b794 100644 --- a/extmod/modbluetooth.c +++ b/extmod/modbluetooth.c @@ -1113,10 +1113,13 @@ void mp_bluetooth_gatts_on_indicate_complete(uint16_t conn_handle, uint16_t valu invoke_irq_handler(MP_BLUETOOTH_IRQ_GATTS_INDICATE_DONE, args, 2, &status, 1, NULL_ADDR, NULL_I8, 0, NULL_UUID, NULL_DATA, 0); } -bool mp_bluetooth_gatts_on_read_request(uint16_t conn_handle, uint16_t value_handle) { +mp_int_t mp_bluetooth_gatts_on_read_request(uint16_t conn_handle, uint16_t value_handle) { uint16_t args[] = {conn_handle, value_handle}; mp_obj_t result = invoke_irq_handler(MP_BLUETOOTH_IRQ_GATTS_READ_REQUEST, args, 2, NULL, 0, NULL_ADDR, NULL_I8, 0, NULL_UUID, NULL_DATA, 0); - return result == mp_const_none || mp_obj_is_true(result); + // Return non-zero from IRQ handler to fail the read. + mp_int_t ret = 0; + mp_obj_get_int_maybe(result, &ret); + return ret; } void mp_bluetooth_gatts_on_mtu_exchanged(uint16_t conn_handle, uint16_t value) { @@ -1320,11 +1323,11 @@ void mp_bluetooth_gatts_on_indicate_complete(uint16_t conn_handle, uint16_t valu schedule_ringbuf(atomic_state); } -bool mp_bluetooth_gatts_on_read_request(uint16_t conn_handle, uint16_t value_handle) { +mp_int_t mp_bluetooth_gatts_on_read_request(uint16_t conn_handle, uint16_t value_handle) { (void)conn_handle; (void)value_handle; // This must be handled synchronously and therefore cannot implemented with the ringbuffer. - return true; + return MP_BLUETOOTH_GATTS_NO_ERROR; } void mp_bluetooth_gatts_on_mtu_exchanged(uint16_t conn_handle, uint16_t value) { |