mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2024-09-27 04:22:46 +02:00
feat: Unsubscribe from BLE advertisements fully on unsub (#409)
This commit is contained in:
parent
5ebd8956ec
commit
4bb8fbbed1
@ -53,6 +53,8 @@ service APIConnection {
|
||||
rpc bluetooth_gatt_read_descriptor(BluetoothGATTReadDescriptorRequest) returns (void) {}
|
||||
rpc bluetooth_gatt_write_descriptor(BluetoothGATTWriteDescriptorRequest) returns (void) {}
|
||||
rpc bluetooth_gatt_notify(BluetoothGATTNotifyRequest) returns (void) {}
|
||||
rpc unsubscribe_bluetooth_le_advertisements(UnsubscribeBluetoothLEAdvertisementsRequest) returns (void) {}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1385,3 +1387,8 @@ message BluetoothDeviceUnpairingResponse {
|
||||
bool success = 2;
|
||||
int32 error = 3;
|
||||
}
|
||||
|
||||
message UnsubscribeBluetoothLEAdvertisementsRequest {
|
||||
option (id) = 87;
|
||||
option (source) = SOURCE_CLIENT;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -96,6 +96,7 @@ from .api_pb2 import ( # type: ignore
|
||||
SwitchCommandRequest,
|
||||
SwitchStateResponse,
|
||||
TextSensorStateResponse,
|
||||
UnsubscribeBluetoothLEAdvertisementsRequest,
|
||||
)
|
||||
from .connection import APIConnection, ConnectionParams
|
||||
from .core import (
|
||||
@ -468,6 +469,9 @@ class APIClient:
|
||||
def unsub() -> None:
|
||||
if self._connection is not None:
|
||||
self._connection.remove_message_callback(on_msg, msg_types)
|
||||
self._connection.send_message(
|
||||
UnsubscribeBluetoothLEAdvertisementsRequest()
|
||||
)
|
||||
|
||||
return unsub
|
||||
|
||||
|
@ -89,6 +89,7 @@ from .api_pb2 import ( # type: ignore
|
||||
SwitchCommandRequest,
|
||||
SwitchStateResponse,
|
||||
TextSensorStateResponse,
|
||||
UnsubscribeBluetoothLEAdvertisementsRequest,
|
||||
)
|
||||
|
||||
TWO_CHAR = re.compile(r".{2}")
|
||||
@ -306,4 +307,5 @@ MESSAGE_TYPE_TO_PROTO = {
|
||||
84: BluetoothGATTNotifyResponse,
|
||||
85: BluetoothDevicePairingResponse,
|
||||
86: BluetoothDeviceUnpairingResponse,
|
||||
87: UnsubscribeBluetoothLEAdvertisementsRequest,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user