本文整理汇总了TypeScript中pc-ble-driver-js.Adapter.getCharacteristics方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Adapter.getCharacteristics方法的具体用法?TypeScript Adapter.getCharacteristics怎么用?TypeScript Adapter.getCharacteristics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pc-ble-driver-js.Adapter
的用法示例。
在下文中一共展示了Adapter.getCharacteristics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
adapterOne.getServices(device.instanceId, (err, services) => {
if (err) {
console.error('failed to discover services');
} else {
// since we are connecitng to iPhone the discovery
// will return many services
console.log(services);
// get the desired service and then discover characterisitc on it
const desiredService = services.filter((s) => s.uuid === config.peripheralOptions.serviceUUID)[0];
console.log(desiredService);
adapterOne.getCharacteristics(desiredService.instanceId, (err, chars) => {
console.log(chars);
const desiredChar = chars.filter((c) => c.uuid === config.peripheralOptions.charUUID)[0];
adapterOne.readCharacteristicValue(desiredChar.instanceId, (err, val) => {
console.log(val);
console.log('Press c to terminate the program ..');
});
});
}
});
示例2: CharacteristicDiscoveryError
return Observable.create((obs: Subscriber<Characteristic[]>) => {
adapter.getCharacteristics(service.instanceId, (err, chars) => {
if (err) {
obs.error(new CharacteristicDiscoveryError(err, service));
return;
}
obs.next(chars);
obs.complete();
});
return () => {
};
});