Skip to content

Commit e51467b

Browse files
committed
esp32/network_bluetooth.c: Fixed print output for descriptors, removed "prop" from ctor
1 parent e4817d0 commit e51467b

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

esp32/network_bluetooth.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,10 +2139,10 @@ STATIC void network_bluetooth_char_descr_print(const mp_print_t *print, mp_obj_t
21392139
mp_printf(print, "GATTCDescr");
21402140
} else if (MP_OBJ_IS_TYPE(self_in, &network_bluetooth_gatts_char_type)) {
21412141
type = GATTS_CHAR;
2142-
mp_printf(print, "GATTCChar");
2142+
mp_printf(print, "GATTSChar");
21432143
} else if (MP_OBJ_IS_TYPE(self_in, &network_bluetooth_gattc_char_type)) {
21442144
type = GATTC_CHAR;
2145-
mp_printf(print, "GATTSChar");
2145+
mp_printf(print, "GATTCChar");
21462146
} else {
21472147
type = GATTS_DESCR;
21482148
mp_printf(print, "GATTSDescr");
@@ -2151,24 +2151,14 @@ STATIC void network_bluetooth_char_descr_print(const mp_print_t *print, mp_obj_t
21512151
mp_printf(print, "(uuid = ");
21522152
network_bluetooth_gatt_id_print(print, &self->id);
21532153

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) {
21612158
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+
}
21712160
}
2161+
21722162
mp_printf(print, ")");
21732163
}
21742164

@@ -2928,21 +2918,25 @@ STATIC mp_obj_t network_bluetooth_service_make_new(const mp_obj_type_t *type, si
29282918
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) {
29292919

29302920
enum {ARG_uuid, ARG_value, ARG_perm, ARG_prop};
2931-
static const mp_arg_t allowed_args[] = {
2921+
mp_arg_t allowed_args[] = {
29322922
{ MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ },
29332923
{ MP_QSTR_value, MP_ARG_OBJ, {.u_obj = mp_const_none }},
29342924
{ 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
29352927
{ 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} },
29362928
};
29372929
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
29382930

29392931
network_bluetooth_service_obj_t* service = MP_OBJ_NULL;
29402932
network_bluetooth_char_descr_obj_t* chr = MP_OBJ_NULL;
29412933

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
29432935
service = MP_OBJ_TO_PTR(pos_args[0]);
2944-
} else { // Make new char
2936+
} else { // Make new descriptor
29452937
chr = MP_OBJ_TO_PTR(pos_args[0]);
2938+
// Disable the "prop" argument
2939+
allowed_args[3].qst = MP_QSTR_;
29462940
}
29472941

29482942
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy