0 Replies Latest reply on May 18, 2017 9:55 AM by conte cedric

    RFD8500 Development using Xamarin with ZETI commands

    conte cedric

      Hi folks,

       

      We just recently get the RFD8500 for evaluation purpose. Actually, We need to develop a small Android application under xamarin form to acquire the RFID information and send it to our system.

      Unfortunately, there is no Xamarin SDK for this device under Xamarin, so I have decided to use the ZETI commands instead.

       

      So far, i have been able to Pair the RFD8500 with a Bluetooth device (android phone) but when i sent a ZETI command (like help) i got nothing.

      I have alse check the manifest autorisation : BLUETOOTH, BLUETOOTH_ADMIN, BLUETOOTH_PRIVILEGED

       

      For information, I have been able to send nicely those commands with my laptop (WIN10) and Putty.

       

      Below the sample to do it :

       

                try

                 {

                     BluetoothAdapter adapter = BluetoothAdapter.DefaultAdapter;

                     BluetoothSocket socket = null;

                     BluetoothDevice device = null;

       

                     if (adapter == null)

                         System.Diagnostics.Debug.WriteLine("No Bluetooth adapter found.");

                     else

                         System.Diagnostics.Debug.WriteLine("Adapter found!!");

       

                     if (!adapter.IsEnabled)

                         System.Diagnostics.Debug.WriteLine("Bluetooth adapter is not enabled.");

                     else

                         System.Diagnostics.Debug.WriteLine("Adapter enabled!");

       

                     System.Diagnostics.Debug.WriteLine("Try to connect to " + "RFD850015314523023914");

       

                     foreach (var bd in adapter.BondedDevices)

                     {

                         System.Diagnostics.Debug.WriteLine("Paired devices found: " + bd.Name.ToUpper());

                         if (bd.Name.ToUpper().IndexOf("RFD850015314523023914".ToUpper()) >= 0)

                         {

       

                             System.Diagnostics.Debug.WriteLine("Found " + bd.Name + ". Try to connect with it!");

                             device = bd;

                             break;

                         }

                     }

                     if (device == null)

                         System.Diagnostics.Debug.WriteLine("Named device not found.");

                     else

                     {

                         // Hint: If you are connecting to a Bluetooth serial board then try using the well-known SPP UUID 00001101-0000-1000-8000-00805F9B34FB.

                         // However if you are connecting to an Android peer then please generate your own unique UUID.

                         UUID uuid = UUID.FromString("00001101-0000-1000-8000-00805f9b34fb");

                         if ((int)Android.OS.Build.VERSION.SdkInt >= 10) // Gingerbread 2.3.3 2.3.4

                             socket = device.CreateInsecureRfcommSocketToServiceRecord(uuid);

                         else

                             socket = device.CreateRfcommSocketToServiceRecord(uuid);

       

                         if (socket != null)

                         {

                             await socket.ConnectAsync();

                         }

       

                         if (socket.IsConnected)

                         {

                             System.Diagnostics.Debug.WriteLine("Connected!");

       

                             var inReader = new BufferedReader(new InputStreamReader(socket.InputStream));

                             var outReader = new BufferedWriter(new OutputStreamWriter(socket.OutputStream));

       

                             System.Diagnostics.Debug.WriteLine("ZETI command : help");

                             outReader.Write("help\r\n"); // Used as a new line character in Windows

                                                          // After the write you may want to flush the stream to force the data to be sent out

                             outReader.Flush();

                             System.Threading.Thread.Sleep(3000); // wait 3s before read

       

                             if (inReader.Ready()) // Here the issue => Never Ready

                        {

                                 System.Diagnostics.Debug.WriteLine("buffer ready");

                                 inReader.Skip(0);

                                 string result = await inReader.ReadLineAsync();

                                 System.Diagnostics.Debug.WriteLine("Tags: " + result);

                             }

                         }

                     }

                 }

                 catch (Exception ex)

                 {

                     System.Diagnostics.Debug.WriteLine("Exception: " + ex.Message);

                 }

       

       

      output console :

       

      [0:] Adapter found!!

      [0:] Adapter enabled!

      [0:] Try to connect to RFD850015314523023914

      [0:] Paired devices found: RFD850015314523023914

      [0:] Found RFD850015314523023914. Try to connect with it!

      [0:] Connected!

      [0:] ZETI command : help

       

      Does anyone know in Xamarin development know how to use the ZETI command ?  If so, are there any examples available where it has been used that we could look at?

       

      Any help would be appreciated.

       

      Thanks

       

      Cedric