Port and protocol settings for Cloud Send data

Hi,
I am learning about cloud connection using Dash. So far I can send a message to the console using SerialCloud.Println OK and see the message.

I can also send text (seems I need to add CR and LF to get it to work) from a terminal program, via RX2 port and it gets to console ok.

BUT, I cannot receive any data sent from the console and wondering if the port 4010 and TCP (default) setting is correct?

Thanks

Hi @orbitcoms - If you look at the hologram_cloud example sketch, you’ll find an example of how to send data from our Dashboard or API inbound to the Dash’s inbound message handler. In the example, 4444 is set as the listening TCP socket port.

I cannot see how this works in the example link you provided. That sketch is processing SMS data received.
The code I was using is one of the examples “Hologram Dash hello world” that installed with the library. It does not use SMS. I can enter text using terminal program and the text gets to my dashboard in cloud ok but I cannot receive any data back from cloud when I send a message.

void setup() {

SerialCloud.begin(115200); /* Hologram Cloud /
SerialCloud.println(“Hello, World!”); /
one-time message */

}

void loop() {
char currChar;
while (SerialUSB.available()) {
SerialCloud.write(SerialUSB.read());
}

while (Serial2.available()) {
SerialCloud.write(Serial2.read());
}

while (SerialCloud.available()) {
currChar = (char)SerialCloud.read();
SerialUSB.write(currChar);
Serial2.write(currChar);
}

delay(5);
}

Take a look at this function: https://hologram.io/docs/reference/dash/api/#hologramcloud-attachhandlerinbound-callback-

Call the listen function with the port number once you do that: https://hologram.io/docs/reference/dash/api/#hologramcloud-listen-port-

P.S. If you’re in the Arduino IDE go to File->Examples->Dash Examples->hologram_dash_cloud and you can see more of how this is used. That file on github is supposed to have it but it’s outdated. We’ll update that soon.

I managed to get the system receiving messages using the example code. I get “Ok” back on cloud in response.

However, I am having some issue with printing the received message. When I add a line to print the received message I get “Socket error: [Errno 111] Connection refused” instead of the “OK”. If I comment out my print line it is ok again.

Here is my code for the received message handler. Thanks again.

void cloud_inbound(int length) {
buffer_inbound[length] = 0; //NULL terminate the data for printing as a String
HologramCloud.sendMessage(buffer_inbound, “inbound”);
SerialUSB.println(buffer_inbound);
}

Ah I think I see the issue. At the moment, I don’t think the firmware supports changing that response value so you’ll always get an OK in the immediate response packet. What’s going on here is when you call sendMessage in that handler it actually disconnects that TCP stream you were listening on and then sends a new stream to our cloud.

The way to do this is probably to set a flag that gets used in your main loop and causes it to send the buffer to the cloud from there. Something like this:

void loop()
{
   if(hasNewBuffer) {
     HologramCloud.sendMessage(buffer_inbound, "inbound");
     hasNewBuffer = false;
   }
}

And then in your cloud_inbound function you would set hasNewBuffer = true

This is an interesting case by the way and we’ll look into seeing if we can get that to work smoother in a future firmware version

The problem is not the response, The problem is that I want to print our the received message to the serial port but when I add the line to print it affects the response error.

Or would I be better to set another flag like “receivedCloudMessage = true”

Then in my mainline code
if(receivedCloudMessage){
//print out buffer_inbound
}

Ah ok, then yes, that example should also work. I’m not sure why printing from within that handler is causing issues. We’ll do some investigation on our end.

Huh, I hear that comment a lot about my “interesting applications” when I am familiarizing myself with new devices.

Maybe due to inexperience my approach is not conventional? Or others are not doing these sort of projects, or if they are then they figure it out themselves without needing to ask?

I am not afraid to ask silly questions, it is how I get to understand things in terms that make sense to me.

Keep them coming! We’re happy to help debug and it helps us to improve the product.