@@ -82,6 +82,8 @@ STATIC mp_obj_t bluetooth_handle_errno(int err) {
82
82
// ----------------------------------------------------------------------------
83
83
84
84
STATIC 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
+
85
87
mp_arg_check_num (n_args , n_kw , 1 , 1 , false);
86
88
87
89
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
106
108
// Assume UUID string (e.g. '6E400001-B5A3-F393-E0A9-E50E24DCCA9E')
107
109
self -> type = MP_BLUETOOTH_UUID_TYPE_128 ;
108
110
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 ++ ) {
110
112
char c = ((char * )uuid_bufinfo .buf )[i ];
111
113
if (c == '-' ) {
112
114
continue ;
@@ -173,6 +175,8 @@ STATIC mp_obj_t bluetooth_uuid_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_
173
175
}
174
176
175
177
STATIC void bluetooth_uuid_print (const mp_print_t * print , mp_obj_t self_in , mp_print_kind_t kind ) {
178
+ (void )kind ;
179
+
176
180
mp_obj_bluetooth_uuid_t * self = MP_OBJ_TO_PTR (self_in );
177
181
mp_printf (print , "UUID%u(%s" , self -> type * 8 , self -> type <= 4 ? "0x" : "'" );
178
182
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
187
191
mp_printf (print , ")" );
188
192
}
189
193
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 ) {
191
195
mp_obj_bluetooth_uuid_t * self = MP_OBJ_TO_PTR (self_in );
192
196
193
197
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,
203
207
#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
204
208
205
209
STATIC 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 );
207
211
ringbuf_put (ringbuf , uuid -> type );
208
212
for (int i = 0 ; i < uuid -> type ; ++ i ) {
209
213
ringbuf_put (ringbuf , uuid -> data [i ]);
@@ -236,6 +240,10 @@ STATIC const mp_obj_type_t bluetooth_uuid_type = {
236
240
// ----------------------------------------------------------------------------
237
241
238
242
STATIC 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 ;
239
247
if (MP_STATE_VM (bluetooth ) == MP_OBJ_NULL ) {
240
248
mp_obj_bluetooth_ble_t * o = m_new0 (mp_obj_bluetooth_ble_t , 1 );
241
249
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
511
519
}
512
520
513
521
STATIC mp_obj_t bluetooth_ble_gatts_register_services (mp_obj_t self_in , mp_obj_t services_in ) {
522
+ (void )self_in ;
514
523
mp_obj_t len_in = mp_obj_len (services_in );
515
524
size_t len = mp_obj_get_int (len_in );
516
525
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
529
538
return bluetooth_handle_errno (err );
530
539
}
531
540
532
- int i = 0 ;
541
+ size_t i = 0 ;
533
542
while ((service_tuple_obj = mp_iternext (iterable )) != MP_OBJ_STOP_ITERATION ) {
534
543
// (uuid, chars)
535
544
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
552
561
// TODO: Also the Generic Access service characteristics?
553
562
for (i = 0 ; i < len ; ++ i ) {
554
563
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 ) {
556
565
service_handles -> items [j ] = MP_OBJ_NEW_SMALL_INT (handles [i ][j ]);
557
566
}
558
567
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
603
612
#endif // MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
604
613
605
614
STATIC mp_obj_t bluetooth_ble_gap_disconnect (mp_obj_t self_in , mp_obj_t conn_handle_in ) {
615
+ (void )self_in ;
606
616
uint16_t conn_handle = mp_obj_get_int (conn_handle_in );
607
617
int err = mp_bluetooth_gap_disconnect (conn_handle );
608
618
if (err == 0 ) {
@@ -620,6 +630,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(bluetooth_ble_gap_disconnect_obj, bluetooth_ble
620
630
// ----------------------------------------------------------------------------
621
631
622
632
STATIC mp_obj_t bluetooth_ble_gatts_read (mp_obj_t self_in , mp_obj_t value_handle_in ) {
633
+ (void )self_in ;
623
634
size_t len = 0 ;
624
635
uint8_t * buf ;
625
636
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
628
639
STATIC MP_DEFINE_CONST_FUN_OBJ_2 (bluetooth_ble_gatts_read_obj , bluetooth_ble_gatts_read );
629
640
630
641
STATIC 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 ;
631
643
mp_buffer_info_t bufinfo = {0 };
632
644
mp_get_buffer_raise (data , & bufinfo , MP_BUFFER_READ );
633
645
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
669
681
#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
670
682
671
683
STATIC mp_obj_t bluetooth_ble_gattc_discover_services (mp_obj_t self_in , mp_obj_t conn_handle_in ) {
684
+ (void )self_in ;
672
685
mp_int_t conn_handle = mp_obj_get_int (conn_handle_in );
673
686
return bluetooth_handle_errno (mp_bluetooth_gattc_discover_primary_services (conn_handle ));
674
687
}
675
688
STATIC MP_DEFINE_CONST_FUN_OBJ_2 (bluetooth_ble_gattc_discover_services_obj , bluetooth_ble_gattc_discover_services );
676
689
677
690
STATIC mp_obj_t bluetooth_ble_gattc_discover_characteristics (size_t n_args , const mp_obj_t * args ) {
691
+ (void )n_args ;
678
692
mp_int_t conn_handle = mp_obj_get_int (args [1 ]);
679
693
mp_int_t start_handle = mp_obj_get_int (args [2 ]);
680
694
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
683
697
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (bluetooth_ble_gattc_discover_characteristics_obj , 4 , 4 , bluetooth_ble_gattc_discover_characteristics );
684
698
685
699
STATIC mp_obj_t bluetooth_ble_gattc_discover_descriptors (size_t n_args , const mp_obj_t * args ) {
700
+ (void )n_args ;
686
701
mp_int_t conn_handle = mp_obj_get_int (args [1 ]);
687
702
mp_int_t start_handle = mp_obj_get_int (args [2 ]);
688
703
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
691
706
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (bluetooth_ble_gattc_discover_descriptors_obj , 4 , 4 , bluetooth_ble_gattc_discover_descriptors );
692
707
693
708
STATIC 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 ;
694
710
mp_int_t conn_handle = mp_obj_get_int (conn_handle_in );
695
711
mp_int_t value_handle = mp_obj_get_int (value_handle_in );
696
712
return bluetooth_handle_errno (mp_bluetooth_gattc_read (conn_handle , value_handle ));
@@ -777,23 +793,23 @@ const mp_obj_module_t mp_module_ubluetooth = {
777
793
778
794
STATIC 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 ) {
779
795
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 ;
781
797
782
- for (int i = 0 ; i < n_u16 ; ++ i ) {
798
+ for (size_t i = 0 ; i < n_u16 ; ++ i ) {
783
799
data_tuple -> items [j ++ ] = MP_OBJ_NEW_SMALL_INT (ringbuf_get16 (ringbuf ));
784
800
}
785
801
if (n_u8 ) {
786
802
data_tuple -> items [j ++ ] = MP_OBJ_NEW_SMALL_INT (ringbuf_get (ringbuf ));
787
803
}
788
804
if (bytes_addr ) {
789
805
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 ) {
791
807
// cast away const, this is actually bt->irq_addr_bytes.
792
808
((uint8_t * )bytes_addr -> data )[i ] = ringbuf_get (ringbuf );
793
809
}
794
810
data_tuple -> items [j ++ ] = MP_OBJ_FROM_PTR (bytes_addr );
795
811
}
796
- for (int i = 0 ; i < n_i8 ; ++ i ) {
812
+ for (size_t i = 0 ; i < n_i8 ; ++ i ) {
797
813
// Note the int8_t got packed into the ringbuf as a uint8_t.
798
814
data_tuple -> items [j ++ ] = MP_OBJ_NEW_SMALL_INT ((int8_t )ringbuf_get (ringbuf ));
799
815
}
@@ -806,7 +822,7 @@ STATIC void ringbuf_extract(ringbuf_t *ringbuf, mp_obj_tuple_t *data_tuple, size
806
822
// that's what's available here in bt->irq_data_bytes.
807
823
if (bytes_data ) {
808
824
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 ) {
810
826
// cast away const, this is actually bt->irq_data_bytes.
811
827
((uint8_t * )bytes_data -> data )[i ] = ringbuf_get (ringbuf );
812
828
}
@@ -817,6 +833,7 @@ STATIC void ringbuf_extract(ringbuf_t *ringbuf, mp_obj_tuple_t *data_tuple, size
817
833
}
818
834
819
835
STATIC mp_obj_t bluetooth_ble_invoke_irq (mp_obj_t none_in ) {
836
+ (void )none_in ;
820
837
// This is always executing in schedule context.
821
838
822
839
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
976
993
// Note conversion of int8_t rssi to uint8_t. Must un-convert on the way out.
977
994
ringbuf_put (& o -> ringbuf , (uint8_t )rssi );
978
995
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 ) {
980
997
ringbuf_put (& o -> ringbuf , data [i ]);
981
998
}
982
999
}
@@ -1036,7 +1053,7 @@ size_t mp_bluetooth_gattc_on_data_available_start(uint16_t event, uint16_t conn_
1036
1053
1037
1054
void mp_bluetooth_gattc_on_data_available_chunk (const uint8_t * data , size_t data_len ) {
1038
1055
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 ) {
1040
1057
ringbuf_put (& o -> ringbuf , data [i ]);
1041
1058
}
1042
1059
}
0 commit comments