nrf5/modules: Updating service object to clear pointer to parent peripheral instance. Also assinging pointer to the service when adding a new characteristic.
This commit is contained in:
parent
f3d8fc830e
commit
f956947c23
|
@ -78,6 +78,9 @@ STATIC mp_obj_t ubluepy_service_make_new(const mp_obj_type_t *type, size_t n_arg
|
||||||
"Invalid UUID parameter"));
|
"Invalid UUID parameter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear reference to peripheral
|
||||||
|
s->p_periph = NULL;
|
||||||
|
|
||||||
return MP_OBJ_FROM_PTR(s);
|
return MP_OBJ_FROM_PTR(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +95,10 @@ STATIC mp_obj_t service_add_characteristic(mp_obj_t self_in, mp_obj_t characteri
|
||||||
|
|
||||||
bool retval = ble_drv_characteristic_add(p_char);
|
bool retval = ble_drv_characteristic_add(p_char);
|
||||||
|
|
||||||
|
if (retval) {
|
||||||
|
p_char->p_service = self;
|
||||||
|
}
|
||||||
|
|
||||||
return mp_obj_new_bool(retval);
|
return mp_obj_new_bool(retval);
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(ubluepy_service_add_char_obj, service_add_characteristic);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(ubluepy_service_add_char_obj, service_add_characteristic);
|
||||||
|
|
Loading…
Reference in New Issue