因此,我一直在努力实现从速卖通获得的蓝牙指纹读取器。我已经花了两天的时间进行操作,目前处于可以连接和发送内容的阶段。但是我不知道如果没有适当的UUID和服务怎么办。这是外围设备信息
{
"characteristics":[
{
"properties":{
"Read":"Read"
},"characteristic":"2a00","service":"1800"
},{
"properties":{
"Read":"Read"
},"characteristic":"2a01","characteristic":"2a04","characteristic":"2a29","service":"180a"
},"characteristic":"2a24","characteristic":"2a25","characteristic":"2a27","characteristic":"2a26","characteristic":"2a28","characteristic":"2a23","characteristic":"2a2a",{
"properties":{
"Write":"Write","Read":"Read"
},"characteristic":"49535343-6daa-4d02-abf6-19569aca69fe","service":"49535343-fe7d-4ae5-8fa9-9fafd205e455"
},{
"descriptors":[
{
"value":null,"uuid":"2902"
}
],"properties":{
"Notify":"Notify","Write":"Write"
},"characteristic":"49535343-aca3-481c-91ec-d85e28a60318","properties":{
"Indicate":"Indicate","Notify":"Notify"
},"characteristic":"fff1","service":"fff0"
},"WriteWithoutResponse":"WriteWithoutResponse"
},"characteristic":"fff2","service":"fff0"
}
],"services":[
{
"uuid":"1800"
},{
"uuid":"180a"
},{
"uuid":"49535343-fe7d-4ae5-8fa9-9fafd205e455"
},{
"uuid":"fff0"
}
],"advertising":{
"txPowerLevel":2,"serviceData":{
},"serviceUUIDs":[
"fff0"
],"localName":"FGT19100003","isConnectable":true,"manufacturerData":{
"bytes":[
2,1,2,12,9,70,71,84,49,57,48,51,3,240,255,10,0
],"data":"AgECDAlGR1QxOTEwMDAwMwMD8P8CCgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=","CDVType":"ArrayBuffer"
}
},"rssi":-48,"id":"88:1B:99:25:AD:54","name":"FGT19100003"
但是我看到只有4个字符的特征。据我所知,它们的格式为XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX。我已经在JAVA中获得了一些源代码,如果有人想看一下,我可以上载(我安装了它,它可以扫描指纹并将其BitMatrix返回给我。)(src java项目:{{ 3}})
这是我在RN中使用的功能的代码。
test(peripheral: { connected: any; id: string; }) {
if (peripheral) {
if (peripheral.connected) {
BleManager.disconnect(peripheral.id);
} else {
BleManager.connect(peripheral.id).then(() => {
let peripherals = this.state.peripherals;
let p = peripherals.get(peripheral.id);
if (p) {
p.connected = true;
peripherals.set(peripheral.id,p);
this.setState({ peripherals });
}
console.log('Connected to ' + peripheral.id);
setTimeout(() => {
BleManager.retrieveServices(peripheral.id).then((peripheralInfo) => {
console.log(JSON.stringify(peripheralInfo))
var service = '49535343-6daa-4d02-abf6-19569aca69fe';
var crustCharacteristic = '49535343-fe7d-4ae5-8fa9-9fafd205e455';
setTimeout(() => {
BleManager.startNotification(peripheral.id,service,crustCharacteristic).then(() => {
console.log('Started notification on ' + peripheral.id);
setTimeout(() => {
BleManager.write(peripheral.id,crustCharacteristic,[0]).then(() => {
console.log('write succes');
});
},500);
}).catch((error) => {
console.log('Notification error',error);
});
},200);
});
},900);
}).catch((error) => {
console.log('Connection error',error);
});
}
}
}
有人有经验吗?我还得到一张表,该表指出我认为其中包含所有可能的命令(https://filebin.net/7jeo1o0lkgd8x2oy)。