我对node.js相当新,并且有一个程序,我必须设置一个环境变量才能运行(使用高级库,我的bash命令是:sudo NOBLE_HCI_DEVICE_ID=x node program.js,告诉我的代码哪个蓝牙适配器 - HCI设备 - 使用).
这背后的原因是我有许多模块,每个模块都需要自己的蓝牙适配器,我希望在我的代码中指定每个模块应该使用哪个适配器.
我发现很多文章告诉我如何在我的代码中使用环境变量并通过命令行(process.env.VARIABLE_NAME)设置它们,但没有告诉我如何在node.js中设置它们.
是否可以在我的node.js代码中设置环境变量?
我正在尝试在我的Linux机器上使用GATT来设置具有大量特征的自定义服务.
使用这个问题及其链接的问题,我能够识别出我需要编写的代码(利用该gatt_service_add()函数).
我创建了一个名为gatt_service.c的独立文件,并编写了我认为我需要的代码.但是,我无法弄清楚如何将我的代码链接到Bluez库以编译和运行我的解决方案.例如,这个站点(虽然不是用于BLE开发)使用-lbluetoothgcc参数链接libbluetooth ,我无法找出链接的内容以使我的代码工作.
我没有发布任何样品,因为我不确定要发布什么 - 如果有任何要求,或者我没有提及,请告诉我.
提前致谢.
编辑 - 更多信息:
在评论之后,我使用插件/时间作为基础为我自己的"Broadcaster服务"编写我自己的文件.完整代码位于:这里(我不知道在答案中放置哪些代码!).
我的编译命令是:( gcc gatt_broadcaster_service.c -Wall -o gatt_broadcaster_service -lbluetooth 'pkg-config --cflags --libs glib-2.0' -I/home/alexander/Documents/bluez-5.29/lib包括修复此处报告的问题的glib位).
我得到的错误是:gatt_broadcaster_service.c:11:27:致命错误:lib/bluetooth.h:没有这样的文件或目录#include"lib/bluetooth.h"
我的C文件存储在Documents中,我的研究告诉我它找不到lib/bluetooth.h,因为它没有找到正确的位置(这和这个谈论在文件不是时使用包含标志的编译器在一般的位置,但我无法做到这一点.
再次感谢!
我有一个Angular2组件,其中包含一个选项卡控件@angular/material.
我正在尝试测试我的组件(请参阅下面的简化代码 - 我知道测试一个这么简单的组件没有意义),并且收到以下错误:
Error: Error in ./MdTabHeader class MdTabHeader - inline template:0:0 caused by: No provider for ViewportRuler!
Error: No provider for ViewportRuler!
Run Code Online (Sandbox Code Playgroud)
我的假设是尝试将ViewportRuler(https://github.com/angular/material2/blob/master/src/lib/core/overlay/position/viewport-ruler.ts)作为提供者包含在内.当我这样做时(见下面注释掉的行),业力回报:
Uncaught SyntaxError: Unexpected token import
at http://localhost:9876/context.html:10
Run Code Online (Sandbox Code Playgroud)
从Googling的一点来看,它表明它将.ts文件提供给浏览器,而不是编译的.js.我可能是从错误的地方引用它.
我的问题是:如何编译我的测试?
我的代码是:
my.component.ts:
@Component({
selector: 'test',
template: require('./test.component.html')
})
export class TestComponent {
items: any[];
constructor() {
this.items = [{ title: 'test 1', description: 'description 1' }, { title: 'test 2', description: 'description 2' }];
}
}
Run Code Online (Sandbox Code Playgroud)
my.component.html:
<md-tab-group>
<md-tab *ngFor="let link …Run Code Online (Sandbox Code Playgroud) 我创建了一个streamReader,但第一个'ReadLine()'读取文件中的第14行,而不是第一行,我不知道为什么会这样.
我的代码是:
StreamReader reader = new StreamReader("argus-BIG.txt");
//create array to hold data values
string[] branchData = new string[11];
//get 11 lines of branch data file and store in an array
for (int i = 0; i < 11; i++)
{
branchData[i] = reader.ReadLine();
}
//new instance of Branch Class
Branch tempBranch = new Branch();
//set branch values from branchData array
tempBranch.setBranchID(branchData[0]);
tempBranch.setBranchNickname(branchData[1]);
tempBranch.setBranchAddressNo(branchData[2]);
tempBranch.setBranchAddressStreet(branchData[3]);
tempBranch.setBranchAddressCity(branchData[4]);
tempBranch.setBranchAddressCountry(branchData[5]);
tempBranch.setBranchAddressPostCode(branchData[6]);
tempBranch.setNearestBranch1(branchData[7]);
tempBranch.setNearestBranch2(branchData[8]);
tempBranch.setNearestBranch3(branchData[9]);
tempBranch.setNoCategories(Convert.ToInt32(branchData[10]));
Run Code Online (Sandbox Code Playgroud)
我写了一个测试应用程序,它工作,然后复制并粘贴代码(看起来与我相同)回到我的主程序,它工作.谢谢你的帮助
javascript ×2
linux ×2
angular ×1
bluez ×1
c# ×1
gatt ×1
node.js ×1
streamreader ×1
typescript ×1