@@ -49,7 +49,19 @@ STATIC int characteristic_buffer_on_ble_evt(struct ble_gap_event *event, void *p
4949 event -> notify_rx .attr_handle == self -> characteristic -> handle ) {
5050 const struct os_mbuf * m = event -> notify_rx .om ;
5151 while (m != NULL ) {
52- ringbuf_put_n (& self -> ringbuf , m -> om_data , m -> om_len );
52+ const uint8_t * data = m -> om_data ;
53+ uint16_t len = m -> om_len ;
54+ if (self -> watch_for_interrupt_char ) {
55+ for (uint16_t i = 0 ; i < len ; i ++ ) {
56+ if (data [i ] == mp_interrupt_char ) {
57+ mp_sched_keyboard_interrupt ();
58+ } else {
59+ ringbuf_put (& self -> ringbuf , data [i ]);
60+ }
61+ }
62+ } else {
63+ ringbuf_put_n (& self -> ringbuf , data , len );
64+ }
5365 m = SLIST_NEXT (m , om_next );
5466 }
5567 }
@@ -69,9 +81,11 @@ void _common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buff
6981 bleio_characteristic_obj_t * characteristic ,
7082 mp_float_t timeout ,
7183 uint8_t * buffer , size_t buffer_size ,
72- void * static_handler_entry ) {
84+ void * static_handler_entry ,
85+ bool watch_for_interrupt_char ) {
7386 self -> characteristic = characteristic ;
7487 self -> timeout_ms = timeout * 1000 ;
88+ self -> watch_for_interrupt_char = watch_for_interrupt_char ;
7589 ringbuf_init (& self -> ringbuf , buffer , buffer_size );
7690
7791 if (static_handler_entry != NULL ) {
@@ -87,7 +101,7 @@ void common_hal_bleio_characteristic_buffer_construct(bleio_characteristic_buffe
87101 mp_float_t timeout ,
88102 size_t buffer_size ) {
89103 uint8_t * buffer = m_malloc (buffer_size , true);
90- _common_hal_bleio_characteristic_buffer_construct (self , characteristic , timeout , buffer , buffer_size , NULL );
104+ _common_hal_bleio_characteristic_buffer_construct (self , characteristic , timeout , buffer , buffer_size , NULL , false );
91105}
92106
93107uint32_t common_hal_bleio_characteristic_buffer_read (bleio_characteristic_buffer_obj_t * self , uint8_t * data , size_t len , int * errcode ) {
0 commit comments