Пример #1
0
    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);
        }
    }
Пример #3
0
    public static byte [] readBuffer(int length, byte stopByte)
    {
        if (BtConnection.mode() != 2)
        {
            BtConnection.listen(true, length, stopByte);
        }

        return(BtConnection.readBuffer(length, stopByte));
    }
Пример #4
0
    public static byte [] readBuffer(int length)
    {
        if (BtConnection.mode() != 1)
        {
            BtConnection.listen(true, length, false);
        }

        return(BtConnector.readBuffer());
    }
Пример #5
0
 static public string getPickedDeviceName()
 {
     if (!BtConnector.isDevicePicked)
     {
         return("no device");
     }
     else
     {
         return(BtConnection.BluetoothDeviceName(BtConnection.getPickedDevice()));
     }
 }
Пример #6
0
 //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[] {}
     };
 }
Пример #7
0
 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();
     }
 }
Пример #8
0
 //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("");
     }
 }
Пример #9
0
 public static void listen(bool start, int length)
 {
     BtConnection.listen(start, length, false);
 }
Пример #10
0
 public static void listen(bool start, int length, bool byteLimit)
 {
     BtConnection.listen(start, length, byteLimit);
 }
Пример #11
0
    /////////////////// 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();
    }
Пример #12
0
 public static void moduleMAC(string name)
 {
     BtConnection.moduleMAC(name);
 }
Пример #13
0
 //read Control data, for testing
 public static int controlData()
 {
     return(BtConnection.controlData());
 }
Пример #14
0
    //returns true if data there's a data to read



    //read from Microcontroller
    public static string read()
    {
        return(BtConnection.read());
    }
Пример #15
0
 //close connection
 public static void close()
 {
     BtConnection.close();
 }
Пример #16
0
 public static bool test()
 {
     return(BtConnection.test());
 }
Пример #17
0
 public static int connect()
 {
     return(BtConnection.connect());
 }
Пример #18
0
 public static void listen(bool start, int length, byte terminalByte)
 {
     BtConnection.listen(start, length, terminalByte);
 }
Пример #19
0
 public static void stopListen()
 {
     BtConnection.stopListen();
 }
Пример #20
0
 public static bool enableBluetooth()
 {
     return(BtConnection.enableBluetooth());
 }
Пример #21
0
 public static bool isSending()
 {
     return(BtConnection.isSending());
 }
Пример #22
0
 public static string readControlData()
 {
     return(BtConnection.readControlData());
 }
Пример #23
0
 public static bool isBluetoothEnabled()
 {
     return(BtConnection.isBluetoothEnabled());
 }
Пример #24
0
 public static void sendBytes(byte [] message)
 {
     BtConnection.sendBytes(message);
 }
Пример #25
0
    //plugin methods
    void startReading(string s)
    {
        byteMessage = BtConnection.readBuffer();

        dataAvailable = true;
    }
Пример #26
0
 //send string
 public static void sendString(string message)
 {
     BtConnection.sendString(message);
 }
Пример #27
0
 static public void showDevices()
 {
     BtConnection.showDevices();
 }
Пример #28
0
 //send 1 char
 public static void sendChar(char message)
 {
     BtConnection.sendChar(message);
 }
Пример #29
0
 public static void listen(bool start)
 {
     BtConnection.listen(start);
 }
Пример #30
0
 public static bool disableBluetooth()
 {
     return(BtConnection.disableBluetooth());
 }