我想连接两台具有低能量蓝牙的Android手机,因此我在服务UUID中创建了一个特色UUID。一部手机将广告服务uuid,另一部手机将扫描服务uuid,但是,我不知道如何宣传服务uuid。请指导我如何完成任务。这是我的示例代码。
UUID serviceUUID = UUID.randomUUID();
UUID characteristicUUID = UUID.randomUUID();
UUID descriptorUUID = UUID.randomUUID();
BluetoothGattCharacteristic characteristic = new BluetoothGattCharacteristic(characteristicUUID, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ);
characteristic.setValue(77, BluetoothGattCharacteristic.FORMAT_UINT8, 0);
BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(descriptorUUID, BluetoothGattDescriptor.PERMISSION_READ);
characteristic.addDescriptor(descriptor);
BluetoothGattService service = new BluetoothGattService(serviceUUID, BluetoothGattService.SERVICE_TYPE_PRIMARY);
service.addCharacteristic(characteristic);
mGattServer.addService(service);