###前提
BLEのHealth thermometerをESP32で実装したいです。
###わからないところ
クライアントからreadを受けた時にデバイスの情報を返す方法が分かりません。
###コード
_HEALTH_THERM_UUID = bluetooth.UUID(0x1809)
_DEVICE_INFO_UUID = bluetooth.UUID(0x180A)
_TEMP_CHAR = (bluetooth.UUID(0x2A6E), bluetooth.FLAG_READ|bluetooth.FLAG_NOTIFY,)
_MAN_CHAR = (bluetooth.UUID(0x2A29), bluetooth.FLAG_READ,)
_MOD_CHAR = (bluetooth.UUID(0x2A24), bluetooth.FLAG_READ,)
_SYS_CHAR = (bluetooth.UUID(0x2A23), bluetooth.FLAG_READ,)
_HEALTH_THERM_SERVICE = (_HEALTH_THERM_UUID, (_TEMP_CHAR,),)
_DEVICE_INFO_SERVICE = (_DEVICE_INFO_UUID, (_MAN_CHAR, _MOD_CHAR, _SYS_CHAR,),)
_SERVICES = (_HEALTH_THERM_SERVICE,_DEVICE_INFO_SERVICE,)
class BLETemperature: def __init__(self, ble, name="thermometer_29"): self._ble = ble self._ble.active(True) self._ble.irq(self._irq) self._connections = set() ((self._Temp,),(self._Man, self._Mod, self._Sys,),) = self._ble.gatts_register_services(_SERVICES,) self._connections = set() self._payload = advertising_payload(name=name, services=[_HEALTH_THERM_UUID], appearance=_ADV_APPEARANCE_GENERIC_THERMOMETER) self._advertise() def _advertise(self, interval_us=500000): self._ble.gap_advertise(interval_us, adv_data=self._payload)
あなたの回答
tips
プレビュー