added restapi
This commit is contained in:
@@ -116,6 +116,19 @@ class BlessAdvertiser:
|
||||
log.debug("stop_advertising: %s", e)
|
||||
|
||||
try:
|
||||
try:
|
||||
gatt_manager = adapter.get_interface("org.bluez.GattManager1")
|
||||
# Сначала убираем старую регистрацию, чтобы не было конфликта
|
||||
await gatt_manager.call_unregister_application(app.base_path)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
# Регистрируем GATT-сервер (сервисы и характеристики) заново
|
||||
await gatt_manager.call_register_application(app.base_path, {})
|
||||
log.debug("GATT application re-registered successfully")
|
||||
except Exception as e:
|
||||
log.debug("GATT re-register failed (already active?): %s", e)
|
||||
await app.set_name(adapter, LOCAL_NAME)
|
||||
advertisement = BlueZLEAdvertisement(
|
||||
Type.PERIPHERAL, len(app.advertisements) + 1, app
|
||||
@@ -133,6 +146,10 @@ class BlessAdvertiser:
|
||||
}
|
||||
# Avoid experimental interval props on BlueZ 5.55 if possible —
|
||||
# leave bless defaults; they are ignored without -E.
|
||||
try:
|
||||
app.bus.unexport(advertisement.path)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
app.bus.export(advertisement.path, advertisement)
|
||||
iface = adapter.get_interface("org.bluez.LEAdvertisingManager1")
|
||||
|
||||
Reference in New Issue
Block a user