When i do this, that "call" player will automatically play even though i haven't connected my bluetooth connection. So it will automatically play when the application open.
if i do this instead, that call player is useless. Even though i turned off my bluetooth hc-05 manually (i'm not disconnecting it first at application) that "call" player never get turned on.
The DisconnectOnError block does not return whether there was an error or not...this block returns how you have the DisconnectOnError property set. If True, bluetooth will disconnect automatically, if False it will not disconnect... read the documentation of the Bluetooth component.
I wrote above in which event you will receive information about errors with bluetooth.
i already did your advice and already read the documentation to understand better.
as you can see on that picture, am i doin it well? my codeblock for ErrorOccured event.
and i already search a tutorial or explanation about error occured event but no result about it.
when i run the program not working as i expected. The player start to play when I want connect to bluetooth while outside the range of the bluetooth network, not when the bluetooth connection is lost because of out of range of the bluetooth connection.
it looks like you forgot to read my previous answer...
from the link I provided earlier
as the bluetooth protocol was designed, there is no way to detect, if a connection still is alive, therefore you have to send regularly (i.e. poll) some data to the device. And if you get an error, then you know, that the connection was lost…
your statement if BluetoothClient.DisconnectOnError does not make sense... as it already has been said
there is no possibility for the chat partner to see, that the connection is gone. Therefore currently an "Error 516: Unable to write: Connection reset by peer" will be diplayed after trying to send a text without connection.
try to send something regularly (poll) and try to catch error 516 in the ErrorOccurred event... in this error case then play your sound
When you tried these blocks, bluetooth was connected and received data from Arduino with a clock?
Your block of receiving data is badly built. Instead of "= 0" should be "> 0".
But in fact it may not work because when the buffer is empty then the data will not be received and so the error will not be detected. In that case, add a second clock and send in him, for example, "0" to Arduino. You don't have to send it back from Arduino. Change the error number from 517 to 516.
Data from Arduino send with a sign of a new line: Serial.println("data")";
If Arduino is also to receive any data from your APP, you will have to add skipping this zero in the Arduino code. If Arduino does not receive any data from APP, you can add "Serial.flush ()" in the Arduino loop in the arduino loop, so as not to overflow the buffer.