简体   繁体   中英

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.

I'm looking for the FIWARE IoT Agent and probably I've to use 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

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

// 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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