windows - 使用 Intel Galileo Windows 版本连接到 REST 服务

标签 windows intel intel-galileo iot windowsondevices

如何使用英特尔 Galileo 板连接到 REST 服务?

我需要独立于 PC 客户端的解决方案。

只要通过以太网或 Wi-Fi 访问互联网,代码就会执行

最佳答案

如果您还没有倾向于 Node 项目,最直接的解决方案是使用 Win32 API。

ms-iot Sample Apps page on GitHub最近更新引用了 WinSock sample on MSDN 。我对 WinSock 客户端示例代码进行了一些更改,以将数据发布到使用 REST API 的 Cosm(现在是 Xively)。

Winsock客户端代码的相关更改是:

// replace nnnnn with your Feed ID, and xxxxxxxxxxx with your API key!
char *sendbuf = "PUT /v2/feeds/nnnnn.csv HTTP/1.1\r\nHost: api.cosm.com\r\nX-ApiKey: xxxxxxxxx\r\nUser-Agent: WinGalileo\r\nContent-Length: 18\r\nContent-Type: text/csv\r\nConnection: close\r\n\r\n";
char *databuf = "GalileoTest,123.45\r\n";
. . .
iResult = getaddrinfo("www.cosm.com", 80, &hints, &result);
. . .
// Send the HTML
iResult = send(ConnectSocket, sendbuf, (int)strlen(sendbuf), 0);
. . .
// send the data
iResult = send(ConnectSocket, databuf, (int)strlen(databuf), 0);

过去几个月,Arduino 库已添加到 ms-iot Galileo SDK 中,因此我怀疑正在努力移植 WebClient 和以太网库。请密切关注 GitHub 页面。

关于windows - 使用 Intel Galileo Windows 版本连接到 REST 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25778989/

相关文章:

c++ - 如何移动到文件夹并执行 Windows 命令行调用

powershell - 使用 Powershell 解析 RSTCLI 的卷状态

c - 读取十六进制 (Intel) C 中的扩展线性地址记录

assembly - x86 汇编程序崩溃,可能忽略简单错误

python - opencv 和 intel galileo gen2 上的慢速人脸检测

linux - 如何在 Intel Galileo 上重置运行代码

c++ - COM 方法调用返回灾难性故障

java - 如果从 Windows 环境变量 PATH 启动,如何获取 Java 中可执行文件的完整路径?

windows - 在键盘上键入ALT + 251和ALT + 0251会产生不同的字符输入