Created
December 24, 2019 11:12
-
-
Save sidishere/49becaa48fa9c59fe9963db536c73af5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Disconnect() | |
{ | |
if (btSocket!=null) //If the btSocket is busy | |
{ | |
try | |
{ | |
btSocket.close(); //close connection | |
Toast.makeText(getApplicationContext(),"Connection closed successfully",Toast.LENGTH_SHORT).show(); | |
} | |
catch (IOException e) | |
{ | |
Toast.makeText(getApplicationContext(),"Error in closing connection",Toast.LENGTH_SHORT).show(); | |
} | |
} | |
finish(); //return to the first layout | |
} | |
private void turnOffLed() | |
{ | |
if (btSocket!=null) | |
{ | |
try | |
{ | |
btSocket.getOutputStream().write("TF".toString().getBytes()); | |
} | |
catch (IOException e) | |
{ | |
Toast.makeText(getApplicationContext(),"Error in sending command",Toast.LENGTH_SHORT).show(); | |
} | |
} | |
} | |
private void turnOnLed() | |
{ | |
if (btSocket!=null) | |
{ | |
try | |
{ | |
btSocket.getOutputStream().write("TO".toString().getBytes()); | |
} | |
catch (IOException e) | |
{ | |
Toast.makeText(getApplicationContext(),"Error in sending command",Toast.LENGTH_SHORT).show(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment