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!")
Asked
— Edited
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.
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
Can you help?
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