0
votes

I have installed FIWARE on my machine (Ubuntu 18.04) and I am currently trying to work with the IoT Agent, using the HTTPBindings.js (my data is sent via LoRaWAN and I've changed the parseData function in order to use my own data "protocol" [id=1&temp=12&humidity=10], which brings me here to ask 2 questions for someone who is more experienced and can help me with:

 function parseData(req, res, next) {
    let data;
    let error;
    let payload;
    let obj; 
      try {
        let newPayload = new Buffer.from(payload, "base64").toString("ascii");
      var ps = newPayload.split("&").reduce((accum, x) => {
        const kv = x.split("=");
        return { ...accum, ...{ [kv[0]]: kv[1] } };
      }, {});
        data = ulParser.parse(newPayload.replace(/&/g, "|").replace(/=/g, "|"));
       
      } catch (e) {
          error = e;
      }
    
      if (error) {
          next(error);
      } else {
          req.ulPayload = data;
          config.getLogger().debug(context, 'Parsed data: [%j]', data);
          next();
      }
    }
  1. After changing this function, I can't get the data to be updated in the orion/v2/entities.. Would someone explain me how does this work?

  2. How can I add a proxy to usenter code heree in the Wirecloud? I've created it using the FIWARE servers, but testing on my own, I do not have this.

Thank you in advance.

1
You can find a working docker-compose.yml for Wirecloud in the following tutorialJason Fox
Which IoT Agent are you using - the IoT Agent for LoRaWAN or the IoT Agent for Ultralight? The HTTPBindings.js file from the Ultralight IoT Agent is assuming comms is over HTTP, not LoRa. As your regex conversion suggests, the ulParser.js will read data in assuming Ultralight syntax, but if the binding is listening for the wrong protocol any measures will not be successfully received.Jason Fox
I'm following the docker-compose.yml that you said, just having some problemas with the NGSI Proxy. What should I put here?Pedro Martins
As for the HTTPBindings, I'm getting the comms via HTTP (not LoRa integrated). I'm using the said function to convert to the Ultralight syntax. So my problem should be related with the Binding? Somewhere around the "function handleIncomingMeasure"? Thank you JasonPedro Martins

1 Answers

0
votes

Configuring NGSI Proxy

The ngsi-proxy is configured using environment variables and a port.

  ngsi-proxy:
    image: fiware/ngsiproxy:1.2.0
    hostname: ngsi-proxy
    container_name: wc-ngsi-proxy
    networks:
      default:
        ipv4_address: 172.18.1.14
    expose:
      - "8100"
    ports:
      - "8100:8100"
    environment:
      - PORT=8100
      - TRUST_PROXY_HEADERS=0

The NGSI proxy config in the wirecloud widget is then http://<host>:<port> - in this case http://ngsi-proxy:8100

Testing HTTP Binding connectivity

Incoming HTTP measures can be controlled by the IOTA_HTTP_PORT Environment variable:

iot-agent:
    image: fiware/iotagent-ul:${ULTRALIGHT_VERSION}
    hostname: iot-agent
    container_name: fiware-iot-agent
    depends_on:
      - mongo-db
      - orion
    networks:
      - default
    ports:
      - "4041:4041" 
      - "7896:7896"
    expose:
      - "7896"
    environment:
..etc
      - IOTA_NORTH_PORT=4041
      - IOTA_LOG_LEVEL=DEBUG 
      - IOTA_HTTP_PORT=7896
      - IOTA_PROVIDER_URL=http://iot-agent:4041

If you ramp up the debug and expose the relevant port, you should be able to send measures directly to your custom IoT Agent and see some sort of response (probably an error) - this can help track down your coding issue.

You can always add additional debug logging to the custom IoT Agent to see how the conversion is working.