@@ -2139,10 +2139,10 @@ STATIC void network_bluetooth_char_descr_print(const mp_print_t *print, mp_obj_t
2139
2139
mp_printf (print , "GATTCDescr" );
2140
2140
} else if (MP_OBJ_IS_TYPE (self_in , & network_bluetooth_gatts_char_type )) {
2141
2141
type = GATTS_CHAR ;
2142
- mp_printf (print , "GATTCChar " );
2142
+ mp_printf (print , "GATTSChar " );
2143
2143
} else if (MP_OBJ_IS_TYPE (self_in , & network_bluetooth_gattc_char_type )) {
2144
2144
type = GATTC_CHAR ;
2145
- mp_printf (print , "GATTSChar " );
2145
+ mp_printf (print , "GATTCChar " );
2146
2146
} else {
2147
2147
type = GATTS_DESCR ;
2148
2148
mp_printf (print , "GATTSDescr" );
@@ -2151,24 +2151,14 @@ STATIC void network_bluetooth_char_descr_print(const mp_print_t *print, mp_obj_t
2151
2151
mp_printf (print , "(uuid = " );
2152
2152
network_bluetooth_gatt_id_print (print , & self -> id );
2153
2153
2154
- switch (type ) {
2155
- case GATTS_CHAR :
2156
- mp_printf (print , ", handle = %04X, perm = %02X, value = " , self -> handle , self -> perm );
2157
- mp_obj_print_helper (print , self -> value , PRINT_REPR );
2158
- // intentional fallthrough
2159
-
2160
- case GATTC_CHAR :
2154
+ if (type != GATTC_DESCR ) {
2155
+ mp_printf (print , ", handle = %04X, perm = %02X, value = " , self -> handle , self -> perm );
2156
+ mp_obj_print_helper (print , self -> value , PRINT_REPR );
2157
+ if (type == GATTC_CHAR ) {
2161
2158
mp_printf (print , ", prop = %02X" , self -> prop );
2162
- break ;
2163
-
2164
- case GATTC_DESCR :
2165
- // do nothing
2166
- break ;
2167
-
2168
- case GATTS_DESCR :
2169
- mp_printf (print , ", handle = %04X" , self -> handle );
2170
- break ;
2159
+ }
2171
2160
}
2161
+
2172
2162
mp_printf (print , ")" );
2173
2163
}
2174
2164
@@ -2928,21 +2918,25 @@ STATIC mp_obj_t network_bluetooth_service_make_new(const mp_obj_type_t *type, si
2928
2918
STATIC mp_obj_t network_bluetooth_char_descr_make_new (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
2929
2919
2930
2920
enum {ARG_uuid , ARG_value , ARG_perm , ARG_prop };
2931
- static const mp_arg_t allowed_args [] = {
2921
+ mp_arg_t allowed_args [] = {
2932
2922
{ MP_QSTR_uuid , MP_ARG_REQUIRED | MP_ARG_OBJ },
2933
2923
{ MP_QSTR_value , MP_ARG_OBJ , {.u_obj = mp_const_none }},
2934
2924
{ MP_QSTR_perm , MP_ARG_INT , {.u_int = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE } },
2925
+ // "prop" is disabled for descriptors, below
2926
+ // Ensure the index of "prop" is updated if this list changes
2935
2927
{ MP_QSTR_prop , MP_ARG_INT , {.u_int = ESP_GATT_CHAR_PROP_BIT_READ | ESP_GATT_CHAR_PROP_BIT_WRITE | ESP_GATT_CHAR_PROP_BIT_NOTIFY } },
2936
2928
};
2937
2929
mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
2938
2930
2939
2931
network_bluetooth_service_obj_t * service = MP_OBJ_NULL ;
2940
2932
network_bluetooth_char_descr_obj_t * chr = MP_OBJ_NULL ;
2941
2933
2942
- if (MP_OBJ_IS_TYPE (pos_args [0 ], & network_bluetooth_gatts_service_type )) { // Make new descriptor
2934
+ if (MP_OBJ_IS_TYPE (pos_args [0 ], & network_bluetooth_gatts_service_type )) { // Make new char
2943
2935
service = MP_OBJ_TO_PTR (pos_args [0 ]);
2944
- } else { // Make new char
2936
+ } else { // Make new descriptor
2945
2937
chr = MP_OBJ_TO_PTR (pos_args [0 ]);
2938
+ // Disable the "prop" argument
2939
+ allowed_args [3 ].qst = MP_QSTR_ ;
2946
2940
}
2947
2941
2948
2942
mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
0 commit comments