简体   繁体   English

如何使用蓝牙设备和 FIWARE IoT Agent

[英]How to use bluetooth devices and FIWARE IoT Agent

I would like to use my bluetooth device (for example I'm going to create an app to be installed in a tablet) to send data (set of attributes) in Orion Context Broker via IoT Agent.我想使用我的蓝牙设备(例如,我将创建一个要安装在平板电脑中的应用程序)通过 IoT 代理在 Orion Context Broker 中发送数据(属性集)。

I'm looking for the FIWARE IoT Agent and probably I've to use IoT Agent LWM2M.我正在寻找 FIWARE IoT Agent,可能我必须使用 IoT Agent LWM2M。 Is it correct?这是正确的吗? Thanks in advance and regards.提前致谢和问候。

Pasquale帕斯夸莱

Assuming you have freedom of choice, you probably don't need an IoT Agent for that, you just need a service acting as a bluetooth receiver which can receive your message and pass it on using a recognisable transport.假设你有选择的自由,你可能不需要物联网代理,你只需要一个充当蓝牙接收器的服务,它可以接收你的消息并使用可识别的传输方式传递它。

For example, you can receive data using the following Stack Overflow answer例如,您可以使用以下Stack Overflow 答案接收数据

You can then extract the necessary information to identify the device and the context to be updated.然后,您可以提取必要的信息来识别要更新的设备和上下文。

You can programmatically send NGSI requests in any language capable of HTTP - just generate a library using the NGSI Swagger file - an example is shown in the tutorials您可以使用任何支持 HTTP 的语言以编程方式发送 NGSI 请求 - 只需使用 NGSI Swagger 文件生成一个库 -教程中显示了一个示例

// Initialization - first require the NGSI v2 npm library and set
// the client instance
const NgsiV2 = require('ngsi_v2');
const defaultClient = NgsiV2.ApiClient.instance;

defaultClient.basePath = 'http://localhost:1026/v2';


// This is a promise to make an HTTP PATCH request to the /v2/entities/<entity-id>/attr end point
function updateExistingEntityAttributes(entityId, body, opts, headers = {}) {
  return new Promise((resolve, reject) => {
    defaultClient.defaultHeaders = headers;
    const apiInstance = new NgsiV2.EntitiesApi();
    apiInstance.updateExistingEntityAttributes(
      entityId,
      body,
      opts,
      (error, data, response) => {
        return error ? reject(error) : resolve(data);
      }
    );
  });
}

If you really want to do this with an IoT Agent, you can use the IoT Agent Node lib and and create your own IoT Agent如果您真的想使用 IoT 代理执行此操作,您可以使用IoT 代理节点库创建您自己的 IoT 代理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM