我正在两个不同的Android手机上设计中央和外围应用程序。我做了以下操作以添加设备信息服务及其特征
override fun onServicesDiscovered(gatt: BluetoothGatt, status: Int) {
super.onServicesDiscovered(gatt, status)
if (status == BluetoothGatt.GATT_SUCCESS) {
val leServiceList: List<BluetoothGattService> = gatt.services
for (mBluetoothGattService in leServiceList) {
if (mBluetoothGattService.uuid.toString().equals(DEVICE_INFO_SERVICE_UUID, ignoreCase = true)) {
for (mBluetoothGattCharacteristic in mBluetoothGattService.characteristics) {
when {
mBluetoothGattCharacteristic.uuid.toString().equals(HARDWARE_UUID, ignoreCase = true) ->
Log.d(TAG, "Hardware Version : ${mBluetoothGattCharacteristic.value}")
mBluetoothGattCharacteristic.uuid.toString().equals(FIRMWARE_UUID, ignoreCase = true) ->
Log.d(TAG, "Firmware Version : ${mBluetoothGattCharacteristic.value}")
mBluetoothGattCharacteristic.uuid.toString().equals(MANUFACTURER_UUID, ignoreCase = true) ->
Log.d(TAG, "Manufacturer Name : ${mBluetoothGattCharacteristic.value}")
}
}
}
}
}
}
我正在从外围设备上阅读它。
<TextMask
mask={[/[12]/, /\d/, /\d/, /\d/, "-", /[01]/, /\d/, "-", /[0-3]/, /\d/]}
placeholderChar="_"
showMask
render={(ref, props) => (
<Input
name="phone"
className="form-control"
placeholder="Hey I am Ant design Input"
required
ref={ref}
{...props}
/>
)}
/>
但是在这里,在外围设备上发现服务后,我得到的是空值。