New Zealand
Asked — Edited

Managing Connection Failures

Hi team....

A question for the masses.... is there any way for me to find out if a bluetooth connection to a particular EZ-B board has been dropped?

I would like to script a reconnection attempt when a connection is dropped just in case the board has had a momentary brownout.... due to a power fluctuation.

Or, here's a thought, installing a return to GPS location (base) routine when a drone gets out of range, then computer attempts a reconnect when the EZ-B in back in range.

  • Wayne ("Rage with the machine and not against it!")


ARC Pro

Upgrade to ARC Pro

Join the ARC Pro community and gain access to a wealth of resources and support, ensuring your robot's success.

New Zealand
#1  

No one got any bright ideas for this one? stress

#2  

You could have a reconnect sequence, use the c# scripting. Problem here is if it is a brownout you might have to reset the ez-board. The big problem with having it return to home if it does lose connection is the inability to bootload, without connection you can't send commands thus the board can't execute any code since it is not localized into the PIC.

New Zealand
#3  

Yes I see what you mean ... realised this was a weak argument once I pressed the post button.... lol.

So how does one determine if a connection has been successful?

If LightDependentResister.ADR1=0 there ConnectionFailure=True?

Or does anyone have a better suggection.

#4  

EZ_B.EZB_Connect.OnDisconnect or EZ_B.EZB_Connect.OnConnection

I have an event handler in my coding for taking care of onConnection to automaticly turn on my robots eyes and send a speech command to my voice module.

You might have a loop for:

EZ_B.EZB_Connect

New Zealand
#5  

Though I am quickly assimilating your knowledge ... I lack the currently lack the knowledge base to convert this into working ez-script...

Can you help?

#6  

You can create a loop that will specificly wait for the connection to be made

use ezB_Connec1.EZB.IsConnected() which will return a bool value based on whether or not the connection is made thus false if no connection true if connected.

Sample code:

while(true) { if(ezb0.IsConnected == true) { MessageBox.Show("Connected"); } else { MessageBox.Show("Is not Connected"); } }

this is a simple code example that will continuously display a Message box stating "Is not Connected" unless a connection to the ez-b on channel 0 is made then the message box will continuously dispaly "Connected"

this is just a brief example you will most likely want to create a function definition for use in later applications

so something like so:

private void ConnectionCheck() { if(ezb0.IsConnected == true) { MessageBox.Show("Connected"); } else { MessageBox.Show("Is not Connected"); } }

anytime you wish in your code to check the connection you can just call ConnectionCheck(); if you wish to make it auto reconnect you may be able to have instead of MessageBox.Show("Is not Connected"); use ezb0.Open();

this should reconnect ou to your specified connection