1 Reply Latest reply on Apr 6, 2018 2:46 PM by Anton Beza

    Able to print with insecure bluetooth, but not get status

    Anton Beza

      Hello,

       

      I have a ZT410 label printer and I'm using the Android SDK. Using the code examples and the printer's bluetooth mac address, I was able to print successfully from my Android app using the BluetoothConnectionInsecure class.

       

      However, using the same mac address and the code example to get status information using BluetoothStatusConnectionInsecure, I'm getting an error.

       

      Here's a sample of the code I'm using to get the printer's status info:

       

      new Thread(new Runnable() {

         public void run() {

         try {

         // Instantiate insecure connection for given Bluetooth® MAC Address.
         Connection connection = new BluetoothStatusConnectionInsecure(macAddress);

       

         // Initialize
         Looper.prepare();

       

         // Open the connection - physical connection is established here.
         connection.open();

       

         // This sends down JSON to the status channel to retrieve the 'appl.name' setting
         String firmwareVersion = SGD.GET("appl.name", connection);

       

        toast("The firmware version is : " + firmwareVersion);

       

         // Close the insecure connection to release resources.
         connection.close();

       

        Looper.myLooper().quit();

        } catch (Exception e) {

         // Handle communications error here.
         e.printStackTrace();

        }

        }

      }).start();

       

       

      And here's the error message I'm getting:

       

      com.zebra.sdk.comm.ConnectionException: Could not connect to device: read failed, socket might closed or timeout, read ret: -1