public static string readControlData() { switch (BtConnection.controlData()) { case 1: return("Connected"); case 2: return("Disconnected"); case -1: return("found your Bluetooth Module but unable to connect to it"); case -2: return("Bluetooth module with the name or the MAC you provided can't be found"); case -3: return("Connection Failed, usually because your Bluetooth module is off "); case -4: return("error while closing"); case -5: return("error while writing"); case -6: return("error while reading"); case -7: return("Plugin is not initialized"); default: return("Processing..."); } }
public static string readControlData() { switch (BtConnection.controlData()) { case 1: return(CONNECTED); case 2: return(DISCONNECTED); case -1: return(UNABLE_TO_CONNECT); case -2: return(NOT_FOUND); case -3: return(MODULE_OFF); case -4: return(CLOSING_ERROR); case -5: return(WRITING_ERROR); case -6: return(READING_ERROR); case -7: return(NOT_INITIALIZED); default: return(DEFAULT); } }
public static byte [] readBuffer(int length, byte stopByte) { if (BtConnection.mode() != 2) { BtConnection.listen(true, length, stopByte); } return(BtConnection.readBuffer(length, stopByte)); }
public static byte [] readBuffer(int length) { if (BtConnection.mode() != 1) { BtConnection.listen(true, length, false); } return(BtConnector.readBuffer()); }
static public string getPickedDeviceName() { if (!BtConnector.isDevicePicked) { return("no device"); } else { return(BtConnection.BluetoothDeviceName(BtConnection.getPickedDevice())); } }
//it will read as specified in the inspector public static byte [] readBuffer() { if (dataAvailable) { dataAvailable = false; string tempMessage = message; BtConnection.doneReading(); return(getBytes(tempMessage)); } else { return new byte[] {} }; }
void Start() { if (mode2 && !stopReading && !mode0) { BtConnection.listen(true, length, terminalByte); } else if (!mode2 && !mode0 && !stopReading) { BtConnection.listen(true, length); } else if (stopReading && !mode2 && !mode0) { BtConnection.stopListen(); } }
//it will read as specified in the inspector public static string readLine() { if (BtConnection.mode() != 0) { BtConnection.listen(true); } if (dataAvailable) { dataAvailable = false; string tempMessage = message; BtConnection.doneReading(); return(tempMessage); } else { return(""); } }
public static void listen(bool start, int length) { BtConnection.listen(start, length, false); }
public static void listen(bool start, int length, bool byteLimit) { BtConnection.listen(start, length, byteLimit); }
/////////////////// all the next methods are just calling the same BtConnection methods //private static AndroidJavaClass ajc = new AndroidJavaClass ("com.badran.bluetoothcontroller.Bridge") ; //public GameObject = GameObject. public static void askEnableBluetooth() { BtConnection.askEnableBluetooth(); }
public static void moduleMAC(string name) { BtConnection.moduleMAC(name); }
//read Control data, for testing public static int controlData() { return(BtConnection.controlData()); }
//returns true if data there's a data to read //read from Microcontroller public static string read() { return(BtConnection.read()); }
//close connection public static void close() { BtConnection.close(); }
public static bool test() { return(BtConnection.test()); }
public static int connect() { return(BtConnection.connect()); }
public static void listen(bool start, int length, byte terminalByte) { BtConnection.listen(start, length, terminalByte); }
public static void stopListen() { BtConnection.stopListen(); }
public static bool enableBluetooth() { return(BtConnection.enableBluetooth()); }
public static bool isSending() { return(BtConnection.isSending()); }
public static string readControlData() { return(BtConnection.readControlData()); }
public static bool isBluetoothEnabled() { return(BtConnection.isBluetoothEnabled()); }
public static void sendBytes(byte [] message) { BtConnection.sendBytes(message); }
//plugin methods void startReading(string s) { byteMessage = BtConnection.readBuffer(); dataAvailable = true; }
//send string public static void sendString(string message) { BtConnection.sendString(message); }
static public void showDevices() { BtConnection.showDevices(); }
//send 1 char public static void sendChar(char message) { BtConnection.sendChar(message); }
public static void listen(bool start) { BtConnection.listen(start); }
public static bool disableBluetooth() { return(BtConnection.disableBluetooth()); }