无法通过教程草图将数据从arduino mega上传到Cosm

标签 c upload arduino cosm xively

我无法通过以太网屏蔽从我的 Arduino Mega 上传数据到 Cosm。我尝试了其中一个教程示例 ( DatastreamUpload.ino )。我使用了 Cosm 在注册时提供给我的 API key 和提要 ID,并将 init() 函数更改为使用静态 IP 地址,如下所示:

    byte mac[] = {0x90, 0xA2, 0xDA, 0x0D, 0xD3, 0x45 };
    IPAddress ip(192,168,0, 110);
    IPAddress gateway(192,168,0, 1);
    IPAddress subnet(255, 255, 255, 0);

然后:

    Ethernet.begin(mac, ip, gateway, subnet);

这是串行监视器的输出:

Read sensor value 452.00
Uploading it to Cosm
cosmclient.put returned -1

Read sensor value 451.00
Uploading it to Cosm
cosmclient.put returned -1

Read sensor value 378.00
Uploading it to Cosm
cosmclient.put returned -3

Read sensor value 352.00
Uploading it to Cosm
cosmclient.put returned -3

有人对此有解决方案吗?

最佳答案

目前缺少这方面的文档,需要查看源代码才能找到答案。这些错误代码在 HttpClient.h 中定义如下:

// The end of the headers has been reached.  This consumes the '\n'
static const int HTTP_SUCCESS =0;
// Could not connect to the server
static const int HTTP_ERROR_CONNECTION_FAILED =-1;
// This call was made when the HttpClient class wasn't expecting it
// to be called.  Usually indicates your code is using the class
// incorrectly
static const int HTTP_ERROR_API =-2;
// Spent too long waiting for a reply
static const int HTTP_ERROR_TIMED_OUT =-3;
// The response from the server is invalid, is it definitely an HTTP
// server?
static const int HTTP_ERROR_INVALID_RESPONSE =-4;

关于无法通过教程草图将数据从arduino mega上传到Cosm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16178873/

相关文章:

android - Android中的Volley框架适合上传图片和视频吗?

c# - 如何在新的子窗口中实现文件上传?

c++ - 如何在Arduino上使用char数组实现函数

c# - .NET MVC3 图片上传相关错误 : conversion from type 'System.Web.HttpPostedFileWrapper' to type 'Project.Domain.Entities.Image'

c++ - 一个中断函数来修改动态确定的实例?

c++ - 当条件激活时停止 arduino 循环

c - 自动换行程序 C

c++ - MATLAB 在 mex_compile Linux 中找不到支持的编译器或 SDK

c - 在 C 编程中定义和初始化此数据类型

c - 使用文件类型参数在系统 Verilog 中导入 C 函数