我有一个蓝牙服务器,它使用 bleno 并向客户端返回可用 Wifi 网络的列表。的代码readCharacteristic看起来基本上是这样的:
class ReadCharacteristic extends bleno.Characteristic {
constructor(uuid, name, action) {
super({
uuid: uuid,
properties: ["read"],
value: null,
descriptors: [
new bleno.Descriptor({
uuid: "2901",
value: name
})
]
});
this.actionFunction = action;
}
onReadRequest(offset, callback) {
console.log("Offset: " + offset);
if(offset === 0) {
const result = this.actionFunction();
result.then(value => {
this.actionFunctionResult = value;
const data = new Buffer.from(value).slice(0,bleno.mtu);
console.log("onReadRequest: " + data.toString('utf-8'));
callback(this.RESULT_SUCCESS, data);
}, err => {
console.log("onReadRequest error: " + err);
callback(this.RESULT_UNLIKELY_ERROR); …Run Code Online (Sandbox Code Playgroud) javascript android bluetooth-lowenergy android-bluetooth bleno
我将如何为如下所示的 javascript 代码编写类型定义文件 (d.ts)
库.js:
Object.defineProperty( SceneNode.prototype, 'name', {
set: function(name)
{
this.setName( name );
},
get: function(){
return this._name;
},
enumerable: true
});
Run Code Online (Sandbox Code Playgroud)
我到目前为止:
图书馆.d.ts
class SceneNode{
private _name: string;
}
Run Code Online (Sandbox Code Playgroud)
但是我如何将 getter/setter 包含到类型定义中?
编辑1:
添加了文件名以进行说明
我正在尝试使用 CMake GUI 创建 Ninja 构建文件。
我尝试使用 Brew 手动在 macOS 上安装 Ninja。两次我都确保 ninja 在 PATH 上可用,但 CMake GUI 始终无法找到 ninja。
CMake 错误:CMake 无法找到与“Ninja”对应的构建程序。CMAKE_MAKE_PROGRAM 未设置。您可能需要选择不同的构建工具。
命令行上的 CMake 能够找到 ninja。只是 cmake-GUI 不是。
任何提示都高度赞赏。