# BLEPeripheralServer
基础库 2.10.3 开始支持,低版本需做兼容处理。
相关文档: 蓝牙介绍
外围设备的服务端
# 方法
# BLEPeripheralServer.addService(Object object)
添加服务。
# BLEPeripheralServer.removeService(Object object)
移除服务。
# BLEPeripheralServer.startAdvertising(Object Object)
开始广播本地创建的外围设备。
# BLEPeripheralServer.stopAdvertising()
停止广播。
# BLEPeripheralServer.writeCharacteristicValue(Object Object)
往指定特征写入二进制数据值,并通知已连接的主机,从机的特征值已发生变化,该接口会处理是走回包还是走订阅。
# BLEPeripheralServer.onCharacteristicWriteRequest(function callback)
监听已连接的设备请求写当前外围设备的特征值事件。收到该消息后需要立刻调用 writeCharacteristicValue 写回数据,否则主机不会收到响应。
# BLEPeripheralServer.offCharacteristicWriteRequest(function callback)
取消监听已连接的设备请求写当前外围设备的特征值事件
# BLEPeripheralServer.onCharacteristicReadRequest(function callback)
监听已连接的设备请求读当前外围设备的特征值事件。收到该消息后需要立刻调用 writeCharacteristicValue 写回数据,否则主机不会收到响应。
# BLEPeripheralServer.offCharacteristicReadRequest(function callback)
取消监听已连接的设备请求读当前外围设备的特征值事件
# BLEPeripheralServer.onCharacteristicSubscribed(function callback)
监听特征订阅事件,仅 iOS 支持。
# BLEPeripheralServer.offCharacteristicSubscribed(function callback)
取消监听特征订阅事件
# BLEPeripheralServer.onCharacteristicUnsubscribed(function callback)
监听取消特征订阅事件,仅 iOS 支持。
# BLEPeripheralServer.offCharacteristicUnsubscribed(function callback)
取消监听取消特征订阅事件