Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Android设备连接到Arduino(通过WiFi)并通过移动数据上传_Android_Cordova_Ionic Framework_Arduino - Fatal编程技术网

将Android设备连接到Arduino(通过WiFi)并通过移动数据上传

将Android设备连接到Arduino(通过WiFi)并通过移动数据上传,android,cordova,ionic-framework,arduino,Android,Cordova,Ionic Framework,Arduino,我有一个Arduino可以测量温度。一个WiFi模块连接到Arduino,我用它设置了一个热点。现在我想连接一个安卓设备到Arduino,以在一段时间内从Arduino获取读数。之后,Android应该使用移动数据上传数据 arduino代码主要取自 现在,我设置了一个Ionic/Cordova应用程序,它应该执行以下操作: 通过WiFi向Arduino(192.168.1.1)发送GET请求 通过移动数据将传感器读数上传至API 问题:我只能做两件事中的一件。向Arduino发出的请求成功,但

我有一个Arduino可以测量温度。一个WiFi模块连接到Arduino,我用它设置了一个热点。现在我想连接一个安卓设备到Arduino,以在一段时间内从Arduino获取读数。之后,Android应该使用移动数据上传数据

arduino代码主要取自

现在,我设置了一个Ionic/Cordova应用程序,它应该执行以下操作:

  • 通过WiFi向Arduino(192.168.1.1)发送GET请求
  • 通过移动数据将传感器读数上传至API
  • 问题:我只能做两件事中的一件。向Arduino发出的请求成功,但上载失败。或者上传工作正常,但我无法读出测量值

    有没有办法指定只能通过特定网络到达路由?或者你对如何解决这个问题还有其他想法吗

    在我的研究中,我偶然发现了一篇博客文章,但我不确定这是否解决了我的问题

            // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)
            // and a content-type so the client knows what's coming, then a blank line:
            client.println("HTTP/1.1 200 OK");
            client.println("Content-type:text/html");
            client.println("Access-Control-Allow-Headers:*");
            client.println("Access-Control-Allow-Origin:*");
            client.println();
    
            // the content of the HTTP response follows the header:
            client.print(hdc.getTemperature());
            // The HTTP response ends with another blank line:
            client.println();
            // break out of the while loop:
    
    public getArduino(){
        return this.http.get(`http://192.168.1.1/`)
              .pipe(timeout(5000));
            };
        
    public uploadAPI(){
          return this.http.get(`https://API/`)
                .pipe(timeout(30000));
        };