5

I currently have a working REST client on my Arduino, but the requests always go to port 80. How do I make it send the request to a specific port?

This is my current code:

/*
File: RestClient.ino
This example makes an HTTP request after 10 seconds and shows the result both in
serial monitor and in the wifi console of the Arduino Uno WiFi.
Note: works only with Arduino Uno WiFi Developer Edition.
http://www.arduino.org/learning/tutorials/boards-tutorials/restserver-and-restclient
*/
#include <Wire.h>
#include <UnoWiFiDevEd.h>
 
void setup() {
 const char* connector = "rest";
 const char* server = "download.arduino.org";
 const char* method = "GET";
 const char* resource = "/latest.txt";
 Serial.begin(9600);
 Ciao.begin();
 pinMode(2, INPUT);
 delay(10000);
 doRequest(connector, server, resource, method);
}
 
void loop() {
}
 
void doRequest(const char* conn, const char* server, const char* command, const char* method) {
 CiaoData data = Ciao.write(conn, server, command, method);
 if (!data.isEmpty()) {
 Ciao.println( "State: " + String (data.get(1)) );
 Ciao.println( "Response: " + String (data.get(2)) );
 Serial.println( "State: " + String (data.get(1)) );
 Serial.println( "Response: " + String (data.get(2)) );
 } else {
 Ciao.println ("Write Error");
 Serial.println ("Write Error");
 }
}

If I add for example :8080 to the end of the server variable, it does not work.

How do I make that request go to a specific port?

ocrdu
1,7953 gold badges12 silver badges24 bronze badges
asked Mar 22, 2017 at 16:23
3
  • 1
    Chances are you can't unless 'Ciao' allows you to. Have a look a PAT, port forwarding or proxy servers. Depending on you topology one of those may be able to help. Commented Mar 23, 2017 at 13:05
  • change the firmware to WiFi Link github.com/jandrassy/… Commented Feb 18, 2018 at 16:25
  • 1
    update 2022. put AT firmware 1.7.5 into the esp8266 and use my WiFiEspAT library Commented May 5, 2023 at 12:27

1 Answer 1

0

You can find a port definition for your Arduino in this path:

/usr/lib/python2.7/ciao/connectors/restserver/restserver.json.conf

{
 "name" : "restserver",
 "description" : "REST server connector for the Ciao Core",
 "authors": ["Arduino Team <[email protected]>;"],
 "repository" : "https://github.com/arduino-org/Ciao",
 "version" : "0.0.2",
 "params" : {
 "port" : 80
 },
 "log" : {
 "level" : "info"
 }
}

The confusing part is that your Arduino has a server-client connection to itself from the CPU/Linino server to the MCU/Arduino client.

https://www.arduino.cc/en/Reference/CiaoRestServer

ocrdu
1,7953 gold badges12 silver badges24 bronze badges
answered Feb 18, 2018 at 8:44
1
  • 1
    OP has Uno WiFi, not Yun. The library UnoWiFiDevEd has a ciao-like object but the WiFi is served by esp8266 Commented Feb 18, 2018 at 16:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.