将Android设备连接到Arduino(通过WiFi)并通过移动数据上传
我有一个Arduino可以测量温度。一个WiFi模块连接到Arduino,我用它设置了一个热点。现在我想连接一个安卓设备到Arduino,以在一段时间内从Arduino获取读数。之后,Android应该使用移动数据上传数据 arduino代码主要取自 现在,我设置了一个Ionic/Cordova应用程序,它应该执行以下操作:将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发出的请求成功,但
// 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));
};