[英]FIWARE - IoT Agent - Data for Orion
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:我已经在我的机器(Ubuntu 18.04)上安装了 FIWARE,我目前正在尝试使用 HTTPBindings.js(我的数据是通过 LoRaWAN 发送的,我已经更改了 parseData 函数以使用我自己的数据) "protocol" [id=1&temp=12&warmity=10],这让我在这里向更有经验的人提出两个问题,可以帮助我:
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();
}
}
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?更改此功能后,我无法在 orion/v2/entities 中获取要更新的数据.. 有人可以解释一下这是如何工作的吗?
How can I add a proxy to us enter code here
e in the Wirecloud?我如何添加代理给我们在 Wirecloud 中
enter code here
? I've created it using the FIWARE servers, but testing on my own, I do not have this.我已经使用 FIWARE 服务器创建了它,但是我自己进行了测试,我没有这个。
Thank you in advance.先感谢您。
The ngsi-proxy
is configured using environment variables and a port
. ngsi-proxy
是使用环境变量和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
wirecloud 小部件中的 NGSI 代理配置为
http://<host>:<port>
- 在本例中为http://ngsi-proxy:8100
Incoming HTTP measures can be controlled by the IOTA_HTTP_PORT
Environment variable:传入的 HTTP 度量可以由
IOTA_HTTP_PORT
环境变量控制:
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.如果您加速调试并公开相关端口,您应该能够直接向您的自定义 IoT 代理发送测量值并查看某种响应(可能是错误)——这有助于追踪您的编码问题。
You can always add additional debug logging to the custom IoT Agent to see how the conversion is working.您始终可以向自定义 IoT 代理添加额外的调试日志记录,以查看转换的工作方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.