Add ASHA audio status point

This commit is contained in:
Yuyang Huang
2023-03-06 17:30:31 -08:00
parent 1cd13dfc19
commit 9541cb6db0

View File

@@ -20,6 +20,7 @@ import struct
import logging import logging
from typing import List from typing import List
from ..core import AdvertisingData from ..core import AdvertisingData
from ..device import Device
from ..gatt import ( from ..gatt import (
GATT_ASHA_SERVICE, GATT_ASHA_SERVICE,
GATT_ASHA_READ_ONLY_PROPERTIES_CHARACTERISTIC, GATT_ASHA_READ_ONLY_PROPERTIES_CHARACTERISTIC,
@@ -31,7 +32,7 @@ from ..gatt import (
Characteristic, Characteristic,
CharacteristicValue, CharacteristicValue,
) )
from ..device import Device from ..utils import AsyncRunner
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Logging # Logging
@@ -81,9 +82,13 @@ class AshaService(TemplateService):
elif opcode == AshaService.OPCODE_STATUS: elif opcode == AshaService.OPCODE_STATUS:
logger.info(f'### STATUS: connected={value[1]}') logger.info(f'### STATUS: connected={value[1]}')
# TODO Respond with a status # OPCODE_STATUS does not need audio status point update
# asyncio.create_task(device.notify_subscribers(audio_status_characteristic, if opcode != AshaService.OPCODE_STATUS:
# force=True)) AsyncRunner.spawn(
device.notify_subscribers(
self.audio_status_characteristic, force=True
)
)
self.read_only_properties_characteristic = Characteristic( self.read_only_properties_characteristic = Characteristic(
GATT_ASHA_READ_ONLY_PROPERTIES_CHARACTERISTIC, GATT_ASHA_READ_ONLY_PROPERTIES_CHARACTERISTIC,