RoboRemo Users' Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Ping to arduino

2 posters

Go down

Ping to arduino Empty Ping to arduino

Post by jan99 Mon May 25, 2020 9:37 pm

hi!

in my project i need a function to start when bluetooth (BT) is connected.

till this time i did not found a function to detect the correct status.

in the examples there was the function bluetooth.available will be used. but it did only is successfully, when roboremo sends a command.

i think it would be great to send a "ping" message to arduino when the BT-connection works.

otherwise there is a possibility to show a red LED when connection is cancel. is the connection reactive the status led is green again. option there are commands will be autostart when status change (like events).

is this possible in current release or in feature???

regards Jan

Addtional: Even if there is a Bluetooth connection, but no command has been issued, bluetooth.available still returns false.


jan99

Posts : 20
Join date : 2019-10-27

Back to top Go down

Ping to arduino Empty Re: Ping to arduino

Post by Admin Tue May 26, 2020 7:40 pm

The bluetooth.available returns true if there is something available to read, meaning received but not read yet.

You can set the "connect action" in menu -> interface.
What you enter for the "connect action" will be sent only once, immediately after the connection.

Or you can use the "heartbeat" principle:
- add heartbeat sender to the interface
- set id to "hb" and period as desired
- it will periodically send "hb\n"
- from the Arduino, check that you receive "hb\n" and you know you are still connected

For the other direction, Arduino to app:
- add led item
- set id to "alive"
- set ON timeout to 500 ms
- the ON state will be cleared (LED will turn OFF) if 500ms passed and not received "alive 1\n".
- from Arduino, periodically send "alive 1\n" with interval less than 500ms and it will keep the LED ON.
- if you disconnect or connection drops, the LED will turn OFF.

Regards,
Victor

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

Ping to arduino Empty Re: Ping to arduino

Post by jan99 Tue May 26, 2020 7:57 pm

great - i will try and so i can make my programm perfect!

regards Jan

jan99

Posts : 20
Join date : 2019-10-27

Back to top Go down

Ping to arduino Empty Re: Ping to arduino

Post by jan99 Tue May 26, 2020 10:43 pm

hi !

i integrate the led into following:

Code:

void loop() {
  // hier sollte nichts mehr stehen vor dem Auslesen des Bluetooth
  if(bluetooth.available()) {
    char c = (char)bluetooth.read();
   
    if(c=='\n') {
      cmd[cmdIndex] = 0;
      exeCmd();  // execute the command
      cmdIndex = 0; // reset the cmdIndex
    } else {     
      cmd[cmdIndex] = c;
      if(cmdIndex<99) cmdIndex++;
    }
 
  }
  bluetooth.println("led_status active\n");
}//end-loop


but now debug by textlog is difficult because the main command in textlog is led_status active.

did you have a better idea to code?

regards Jan

jan99

Posts : 20
Join date : 2019-10-27

Back to top Go down

Ping to arduino Empty Re: Ping to arduino

Post by jan99 Wed May 27, 2020 10:53 am

Hi !

is it possible to hide the heartbeat-Control.

regards Jan

jan99

Posts : 20
Join date : 2019-10-27

Back to top Go down

Ping to arduino Empty Re: Ping to arduino

Post by Admin Wed May 27, 2020 6:24 pm

For the text log, set its id and it will display only messages starting with that id + space.
Example:
text log ID: debug
send something: bluetooth.println("debug sometexthere\n");

For the heartbeat item - just move it under some other item.
If it stays on top - copy the other item, remove and paste. Now it will be the one that stays on top.

Admin
Admin

Posts : 150
Join date : 2016-03-08

https://roboremo.forumotion.com

Back to top Go down

Ping to arduino Empty Re: Ping to arduino

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum