Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 无法使用节点js上的BLENO获取主服务的可恢复特征_Node.js_Bluetooth Lowenergy_Bleno - Fatal编程技术网

Node.js 无法使用节点js上的BLENO获取主服务的可恢复特征

Node.js 无法使用节点js上的BLENO获取主服务的可恢复特征,node.js,bluetooth-lowenergy,bleno,Node.js,Bluetooth Lowenergy,Bleno,我有一个简单的应用程序如下所示。我已经在Rpi3上的节点js上使用BLENO创建了一个主服务,并为我的服务添加了一些特性 我的应用程序似乎启动并运行正常。我使用了两个工具来查看我的BLE服务,即Nordic nRF应用程序和我用Android编写的一个简单应用程序 使用这些应用程序,我可以看到我的BLE应用程序广告,也可以连接到它。连接后,我可以看到三个服务,两个是通用的,一个是我的“未知服务”,它具有匹配的UUID,正如我在BLE服务器应用程序中设置的那样 我遇到的问题是,当我花费我的服务时,

我有一个简单的应用程序如下所示。我已经在Rpi3上的节点js上使用BLENO创建了一个主服务,并为我的服务添加了一些特性

我的应用程序似乎启动并运行正常。我使用了两个工具来查看我的BLE服务,即Nordic nRF应用程序和我用Android编写的一个简单应用程序

使用这些应用程序,我可以看到我的BLE应用程序广告,也可以连接到它。连接后,我可以看到三个服务,两个是通用的,一个是我的“未知服务”,它具有匹配的UUID,正如我在BLE服务器应用程序中设置的那样

我遇到的问题是,当我花费我的服务时,它告诉我没有为我的服务设置任何特征

`var bleno = require("bleno");
var BlenoPrimaryService = bleno.PrimaryService;
var Characteristic = bleno.Characteristic;
var Descriptor = bleno.Descriptor;
//var UserConfigCharecteristic = require('./user-config-characteristic');

bleno.on('stateChange', function (state) {
    console.log('on -> stateChagne: ' + state);
    if (state === 'poweredOn') {
        console.log('ble has been powered on');
        bleno.startAdvertising('rpi-ble-app', ['fffffffffffffffffffffffffffffff0']);
    } else {
        bleno.stopAdvertising();
    }
});

bleno.on('advertisingStart', function () {
console.log('-> advertising start');
bleno.setServices([
    new BlenoPrimaryService(
            {
                uuid: 'fffffffffffffffffffffffffffffff0',
                charecteristics: [
                    new Characteristic({
                        uuid: 'fffffffffffffffffffffffffffffff1', // or 'fff1' for 16-bit
                        properties: ['read', 'write'], // can be a combination of 'read', 'write', 'writeWithoutResponse', 'notify', 'indicate'
                        secure: [], // enable security for properties, can be a combination of 'read', 'write', 'writeWithoutResponse', 'notify', 'indicate'
                        value: null, // optional static value, must be of type Buffer - for read only characteristics
                        descriptors: [],
                        onReadRequest: null, // optional read request handler, function(offset, callback) { ... }
                        onWriteRequest: null, // optional write request handler, function(data, offset, withoutResponse, callback) { ...}
                        onSubscribe: null, // optional notify/indicate subscribe handler, function(maxValueSize, updateValueCallback) { ...}
                        onUnsubscribe: null, // optional notify/indicate unsubscribe handler, function() { ...}
                        onNotify: null, // optional notify sent handler, function() { ...}
                        onIndicate: null // optional indicate confirmation received handler, function() { ...}
                    })
                ]
            }
    )], function (error) {
    console.log('setServices: ' + (error ? 'error ' + error : 'success'));
});

});

bleno.on('servicesSet', function () {
    console.log('services set.');
});`
如果有人能查看下面的代码并检查我的服务中没有出现特征的可能原因,我将不胜感激

`var bleno = require("bleno");
var BlenoPrimaryService = bleno.PrimaryService;
var Characteristic = bleno.Characteristic;
var Descriptor = bleno.Descriptor;
//var UserConfigCharecteristic = require('./user-config-characteristic');

bleno.on('stateChange', function (state) {
    console.log('on -> stateChagne: ' + state);
    if (state === 'poweredOn') {
        console.log('ble has been powered on');
        bleno.startAdvertising('rpi-ble-app', ['fffffffffffffffffffffffffffffff0']);
    } else {
        bleno.stopAdvertising();
    }
});

bleno.on('advertisingStart', function () {
console.log('-> advertising start');
bleno.setServices([
    new BlenoPrimaryService(
            {
                uuid: 'fffffffffffffffffffffffffffffff0',
                charecteristics: [
                    new Characteristic({
                        uuid: 'fffffffffffffffffffffffffffffff1', // or 'fff1' for 16-bit
                        properties: ['read', 'write'], // can be a combination of 'read', 'write', 'writeWithoutResponse', 'notify', 'indicate'
                        secure: [], // enable security for properties, can be a combination of 'read', 'write', 'writeWithoutResponse', 'notify', 'indicate'
                        value: null, // optional static value, must be of type Buffer - for read only characteristics
                        descriptors: [],
                        onReadRequest: null, // optional read request handler, function(offset, callback) { ... }
                        onWriteRequest: null, // optional write request handler, function(data, offset, withoutResponse, callback) { ...}
                        onSubscribe: null, // optional notify/indicate subscribe handler, function(maxValueSize, updateValueCallback) { ...}
                        onUnsubscribe: null, // optional notify/indicate unsubscribe handler, function() { ...}
                        onNotify: null, // optional notify sent handler, function() { ...}
                        onIndicate: null // optional indicate confirmation received handler, function() { ...}
                    })
                ]
            }
    )], function (error) {
    console.log('setServices: ' + (error ? 'error ' + error : 'success'));
});

});

bleno.on('servicesSet', function () {
    console.log('services set.');
});`
my node.js应用程序的输出为

on -> stateChagne: poweredOn
ble has been powered on
-> advertising start
services set.
setServices: success
检查一下这个。
但是,我的问题是服务不可见。

似乎我发现了问题,我的特征拼写错误

我是nodejs新手,意识到拼写错误可能是一个问题,因为如果拼写错误,您将不会覆盖,而是会添加一个新属性