@@ -82,6 +82,8 @@ STATIC mp_obj_t bluetooth_handle_errno(int err) {
8282// ----------------------------------------------------------------------------
8383
8484STATIC mp_obj_t bluetooth_uuid_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
85+ (void )type ;
86+
8587 mp_arg_check_num (n_args , n_kw , 1 , 1 , false);
8688
8789 mp_obj_bluetooth_uuid_t * self = m_new_obj (mp_obj_bluetooth_uuid_t );
@@ -106,7 +108,7 @@ STATIC mp_obj_t bluetooth_uuid_make_new(const mp_obj_type_t *type, size_t n_args
106108 // Assume UUID string (e.g. '6E400001-B5A3-F393-E0A9-E50E24DCCA9E')
107109 self -> type = MP_BLUETOOTH_UUID_TYPE_128 ;
108110 int uuid_i = 32 ;
109- for (int i = 0 ; i < uuid_bufinfo .len ; i ++ ) {
111+ for (size_t i = 0 ; i < uuid_bufinfo .len ; i ++ ) {
110112 char c = ((char * )uuid_bufinfo .buf )[i ];
111113 if (c == '-' ) {
112114 continue ;
@@ -173,6 +175,8 @@ STATIC mp_obj_t bluetooth_uuid_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_
173175}
174176
175177STATIC void bluetooth_uuid_print (const mp_print_t * print , mp_obj_t self_in , mp_print_kind_t kind ) {
178+ (void )kind ;
179+
176180 mp_obj_bluetooth_uuid_t * self = MP_OBJ_TO_PTR (self_in );
177181 mp_printf (print , "UUID%u(%s" , self -> type * 8 , self -> type <= 4 ? "0x" : "'" );
178182 for (int i = 0 ; i < self -> type ; ++ i ) {
@@ -187,7 +191,7 @@ STATIC void bluetooth_uuid_print(const mp_print_t *print, mp_obj_t self_in, mp_p
187191 mp_printf (print , ")" );
188192}
189193
190- mp_int_t bluetooth_uuid_get_buffer (mp_obj_t self_in , mp_buffer_info_t * bufinfo , mp_uint_t flags ) {
194+ STATIC mp_int_t bluetooth_uuid_get_buffer (mp_obj_t self_in , mp_buffer_info_t * bufinfo , mp_uint_t flags ) {
191195 mp_obj_bluetooth_uuid_t * self = MP_OBJ_TO_PTR (self_in );
192196
193197 if (flags != MP_BUFFER_READ ) {
@@ -203,7 +207,7 @@ mp_int_t bluetooth_uuid_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo,
203207#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
204208
205209STATIC void ringbuf_put_uuid (ringbuf_t * ringbuf , mp_obj_bluetooth_uuid_t * uuid ) {
206- assert (ringbuf_free (ringbuf ) >= uuid -> type + 1 );
210+ assert (ringbuf_free (ringbuf ) >= ( size_t ) uuid -> type + 1 );
207211 ringbuf_put (ringbuf , uuid -> type );
208212 for (int i = 0 ; i < uuid -> type ; ++ i ) {
209213 ringbuf_put (ringbuf , uuid -> data [i ]);
@@ -236,6 +240,10 @@ STATIC const mp_obj_type_t bluetooth_uuid_type = {
236240// ----------------------------------------------------------------------------
237241
238242STATIC mp_obj_t bluetooth_ble_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
243+ (void )type ;
244+ (void )n_args ;
245+ (void )n_kw ;
246+ (void )all_args ;
239247 if (MP_STATE_VM (bluetooth ) == MP_OBJ_NULL ) {
240248 mp_obj_bluetooth_ble_t * o = m_new0 (mp_obj_bluetooth_ble_t , 1 );
241249 o -> base .type = & bluetooth_ble_type ;
@@ -511,6 +519,7 @@ STATIC int bluetooth_gatts_register_service(mp_obj_t uuid_in, mp_obj_t character
511519}
512520
513521STATIC mp_obj_t bluetooth_ble_gatts_register_services (mp_obj_t self_in , mp_obj_t services_in ) {
522+ (void )self_in ;
514523 mp_obj_t len_in = mp_obj_len (services_in );
515524 size_t len = mp_obj_get_int (len_in );
516525 mp_obj_iter_buf_t iter_buf ;
@@ -529,7 +538,7 @@ STATIC mp_obj_t bluetooth_ble_gatts_register_services(mp_obj_t self_in, mp_obj_t
529538 return bluetooth_handle_errno (err );
530539 }
531540
532- int i = 0 ;
541+ size_t i = 0 ;
533542 while ((service_tuple_obj = mp_iternext (iterable )) != MP_OBJ_STOP_ITERATION ) {
534543 // (uuid, chars)
535544 mp_obj_t * service_items ;
@@ -552,7 +561,7 @@ STATIC mp_obj_t bluetooth_ble_gatts_register_services(mp_obj_t self_in, mp_obj_t
552561 // TODO: Also the Generic Access service characteristics?
553562 for (i = 0 ; i < len ; ++ i ) {
554563 mp_obj_tuple_t * service_handles = MP_OBJ_TO_PTR (mp_obj_new_tuple (num_handles [i ], NULL ));
555- for (int j = 0 ; j < num_handles [i ]; ++ j ) {
564+ for (size_t j = 0 ; j < num_handles [i ]; ++ j ) {
556565 service_handles -> items [j ] = MP_OBJ_NEW_SMALL_INT (handles [i ][j ]);
557566 }
558567 result -> items [i ] = MP_OBJ_FROM_PTR (service_handles );
@@ -603,6 +612,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bluetooth_ble_gap_scan_obj, 1, 4, blu
603612#endif // MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
604613
605614STATIC mp_obj_t bluetooth_ble_gap_disconnect (mp_obj_t self_in , mp_obj_t conn_handle_in ) {
615+ (void )self_in ;
606616 uint16_t conn_handle = mp_obj_get_int (conn_handle_in );
607617 int err = mp_bluetooth_gap_disconnect (conn_handle );
608618 if (err == 0 ) {
@@ -620,6 +630,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(bluetooth_ble_gap_disconnect_obj, bluetooth_ble
620630// ----------------------------------------------------------------------------
621631
622632STATIC mp_obj_t bluetooth_ble_gatts_read (mp_obj_t self_in , mp_obj_t value_handle_in ) {
633+ (void )self_in ;
623634 size_t len = 0 ;
624635 uint8_t * buf ;
625636 mp_bluetooth_gatts_read (mp_obj_get_int (value_handle_in ), & buf , & len );
@@ -628,6 +639,7 @@ STATIC mp_obj_t bluetooth_ble_gatts_read(mp_obj_t self_in, mp_obj_t value_handle
628639STATIC MP_DEFINE_CONST_FUN_OBJ_2 (bluetooth_ble_gatts_read_obj , bluetooth_ble_gatts_read );
629640
630641STATIC mp_obj_t bluetooth_ble_gatts_write (mp_obj_t self_in , mp_obj_t value_handle_in , mp_obj_t data ) {
642+ (void )self_in ;
631643 mp_buffer_info_t bufinfo = {0 };
632644 mp_get_buffer_raise (data , & bufinfo , MP_BUFFER_READ );
633645 int err = mp_bluetooth_gatts_write (mp_obj_get_int (value_handle_in ), bufinfo .buf , bufinfo .len );
@@ -669,12 +681,14 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bluetooth_ble_gatts_set_buffer_obj, 3
669681#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
670682
671683STATIC mp_obj_t bluetooth_ble_gattc_discover_services (mp_obj_t self_in , mp_obj_t conn_handle_in ) {
684+ (void )self_in ;
672685 mp_int_t conn_handle = mp_obj_get_int (conn_handle_in );
673686 return bluetooth_handle_errno (mp_bluetooth_gattc_discover_primary_services (conn_handle ));
674687}
675688STATIC MP_DEFINE_CONST_FUN_OBJ_2 (bluetooth_ble_gattc_discover_services_obj , bluetooth_ble_gattc_discover_services );
676689
677690STATIC mp_obj_t bluetooth_ble_gattc_discover_characteristics (size_t n_args , const mp_obj_t * args ) {
691+ (void )n_args ;
678692 mp_int_t conn_handle = mp_obj_get_int (args [1 ]);
679693 mp_int_t start_handle = mp_obj_get_int (args [2 ]);
680694 mp_int_t end_handle = mp_obj_get_int (args [3 ]);
@@ -683,6 +697,7 @@ STATIC mp_obj_t bluetooth_ble_gattc_discover_characteristics(size_t n_args, cons
683697STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (bluetooth_ble_gattc_discover_characteristics_obj , 4 , 4 , bluetooth_ble_gattc_discover_characteristics );
684698
685699STATIC mp_obj_t bluetooth_ble_gattc_discover_descriptors (size_t n_args , const mp_obj_t * args ) {
700+ (void )n_args ;
686701 mp_int_t conn_handle = mp_obj_get_int (args [1 ]);
687702 mp_int_t start_handle = mp_obj_get_int (args [2 ]);
688703 mp_int_t end_handle = mp_obj_get_int (args [3 ]);
@@ -691,6 +706,7 @@ STATIC mp_obj_t bluetooth_ble_gattc_discover_descriptors(size_t n_args, const mp
691706STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (bluetooth_ble_gattc_discover_descriptors_obj , 4 , 4 , bluetooth_ble_gattc_discover_descriptors );
692707
693708STATIC mp_obj_t bluetooth_ble_gattc_read (mp_obj_t self_in , mp_obj_t conn_handle_in , mp_obj_t value_handle_in ) {
709+ (void )self_in ;
694710 mp_int_t conn_handle = mp_obj_get_int (conn_handle_in );
695711 mp_int_t value_handle = mp_obj_get_int (value_handle_in );
696712 return bluetooth_handle_errno (mp_bluetooth_gattc_read (conn_handle , value_handle ));
@@ -777,23 +793,23 @@ const mp_obj_module_t mp_module_ubluetooth = {
777793
778794STATIC void ringbuf_extract (ringbuf_t * ringbuf , mp_obj_tuple_t * data_tuple , size_t n_u16 , size_t n_u8 , mp_obj_str_t * bytes_addr , size_t n_i8 , mp_obj_bluetooth_uuid_t * uuid , mp_obj_str_t * bytes_data ) {
779795 assert (ringbuf_avail (ringbuf ) >= n_u16 * 2 + n_u8 + (bytes_addr ? 6 : 0 ) + n_i8 + (uuid ? 1 : 0 ) + (bytes_data ? 1 : 0 ));
780- int j = 0 ;
796+ size_t j = 0 ;
781797
782- for (int i = 0 ; i < n_u16 ; ++ i ) {
798+ for (size_t i = 0 ; i < n_u16 ; ++ i ) {
783799 data_tuple -> items [j ++ ] = MP_OBJ_NEW_SMALL_INT (ringbuf_get16 (ringbuf ));
784800 }
785801 if (n_u8 ) {
786802 data_tuple -> items [j ++ ] = MP_OBJ_NEW_SMALL_INT (ringbuf_get (ringbuf ));
787803 }
788804 if (bytes_addr ) {
789805 bytes_addr -> len = 6 ;
790- for (int i = 0 ; i < bytes_addr -> len ; ++ i ) {
806+ for (size_t i = 0 ; i < bytes_addr -> len ; ++ i ) {
791807 // cast away const, this is actually bt->irq_addr_bytes.
792808 ((uint8_t * )bytes_addr -> data )[i ] = ringbuf_get (ringbuf );
793809 }
794810 data_tuple -> items [j ++ ] = MP_OBJ_FROM_PTR (bytes_addr );
795811 }
796- for (int i = 0 ; i < n_i8 ; ++ i ) {
812+ for (size_t i = 0 ; i < n_i8 ; ++ i ) {
797813 // Note the int8_t got packed into the ringbuf as a uint8_t.
798814 data_tuple -> items [j ++ ] = MP_OBJ_NEW_SMALL_INT ((int8_t )ringbuf_get (ringbuf ));
799815 }
@@ -806,7 +822,7 @@ STATIC void ringbuf_extract(ringbuf_t *ringbuf, mp_obj_tuple_t *data_tuple, size
806822 // that's what's available here in bt->irq_data_bytes.
807823 if (bytes_data ) {
808824 bytes_data -> len = ringbuf_get (ringbuf );
809- for (int i = 0 ; i < bytes_data -> len ; ++ i ) {
825+ for (size_t i = 0 ; i < bytes_data -> len ; ++ i ) {
810826 // cast away const, this is actually bt->irq_data_bytes.
811827 ((uint8_t * )bytes_data -> data )[i ] = ringbuf_get (ringbuf );
812828 }
@@ -817,6 +833,7 @@ STATIC void ringbuf_extract(ringbuf_t *ringbuf, mp_obj_tuple_t *data_tuple, size
817833}
818834
819835STATIC mp_obj_t bluetooth_ble_invoke_irq (mp_obj_t none_in ) {
836+ (void )none_in ;
820837 // This is always executing in schedule context.
821838
822839 mp_obj_bluetooth_ble_t * o = MP_OBJ_TO_PTR (MP_STATE_VM (bluetooth ));
@@ -976,7 +993,7 @@ void mp_bluetooth_gap_on_scan_result(uint8_t addr_type, const uint8_t *addr, uin
976993 // Note conversion of int8_t rssi to uint8_t. Must un-convert on the way out.
977994 ringbuf_put (& o -> ringbuf , (uint8_t )rssi );
978995 ringbuf_put (& o -> ringbuf , data_len );
979- for (int i = 0 ; i < data_len ; ++ i ) {
996+ for (size_t i = 0 ; i < data_len ; ++ i ) {
980997 ringbuf_put (& o -> ringbuf , data [i ]);
981998 }
982999 }
@@ -1036,7 +1053,7 @@ size_t mp_bluetooth_gattc_on_data_available_start(uint16_t event, uint16_t conn_
10361053
10371054void mp_bluetooth_gattc_on_data_available_chunk (const uint8_t * data , size_t data_len ) {
10381055 mp_obj_bluetooth_ble_t * o = MP_OBJ_TO_PTR (MP_STATE_VM (bluetooth ));
1039- for (int i = 0 ; i < data_len ; ++ i ) {
1056+ for (size_t i = 0 ; i < data_len ; ++ i ) {
10401057 ringbuf_put (& o -> ringbuf , data [i ]);
10411058 }
10421059}
0 commit comments