@@ -163,6 +163,8 @@ STATIC mp_obj_t peripheral_set_conn_handler(mp_obj_t self_in, mp_obj_t func) {
163163}
164164STATIC MP_DEFINE_CONST_FUN_OBJ_2 (ubluepy_peripheral_set_conn_handler_obj , peripheral_set_conn_handler );
165165
166+ #if MICROPY_PY_UBLUEPY_PERIPHERAL
167+
166168/// \method advertise(device_name, [service=[service1, service2, ...]], [data=bytearray], [connectable=True])
167169/// Start advertising. Connectable advertisment type by default.
168170///
@@ -231,6 +233,22 @@ STATIC mp_obj_t peripheral_advertise(mp_uint_t n_args, const mp_obj_t *pos_args,
231233}
232234STATIC MP_DEFINE_CONST_FUN_OBJ_KW (ubluepy_peripheral_advertise_obj , 0 , peripheral_advertise );
233235
236+ /// \method advertise_stop()
237+ /// Stop advertisment if any onging advertisment.
238+ ///
239+ STATIC mp_obj_t peripheral_advertise_stop (mp_obj_t self_in ) {
240+ ubluepy_peripheral_obj_t * self = MP_OBJ_TO_PTR (self_in );
241+
242+ (void )self ;
243+
244+ ble_drv_advertise_stop ();
245+
246+ return mp_const_none ;
247+ }
248+ STATIC MP_DEFINE_CONST_FUN_OBJ_1 (ubluepy_peripheral_advertise_stop_obj , peripheral_advertise_stop );
249+
250+ #endif // MICROPY_PY_UBLUEPY_PERIPHERAL
251+
234252/// \method disconnect()
235253/// disconnect connection.
236254///
@@ -406,6 +424,7 @@ STATIC const mp_map_elem_t ubluepy_peripheral_locals_dict_table[] = {
406424#endif // MICROPY_PY_UBLUEPY_CENTRAL
407425#if MICROPY_PY_UBLUEPY_PERIPHERAL
408426 { MP_OBJ_NEW_QSTR (MP_QSTR_advertise ), (mp_obj_t )(& ubluepy_peripheral_advertise_obj ) },
427+ { MP_OBJ_NEW_QSTR (MP_QSTR_advertise_stop ), (mp_obj_t )(& ubluepy_peripheral_advertise_stop_obj ) },
409428 { MP_OBJ_NEW_QSTR (MP_QSTR_disconnect ), (mp_obj_t )(& ubluepy_peripheral_disconnect_obj ) },
410429 { MP_OBJ_NEW_QSTR (MP_QSTR_addService ), (mp_obj_t )(& ubluepy_peripheral_add_service_obj ) },
411430#if 0
0 commit comments