[#VS2013] HowTo: Validar si un device BlueTooth esta dentro del rango de conexion

Hola!

Sigo con los posts de BlueTooth con 32Feet, la verdad es que me está dando bastantes sorpresas y muy agradables algunas. El siguiente código es de una app de consola que una vez encontrado un device bluetooh que corresponde a un Windows Phone 8.1, se encarga de ver si el mismo está en un rango de conexión aceptable.

   1: class Program

   2: {

   3:     static void Main()

   4:     {

   5:         var wp = GetWindowsPhoneBtDevice();

   6:         Console.WriteLine("{0}Press any key to validate if device is in range, or ESC to close the app", Environment.NewLine);

   7:         bool exit;

   8:         var i = 0;

   9:         do

  10:         {

  11:             i++;

  12:             ValidateIfDeviceIsOnRange(i, wp);

  13:             var cki = Console.ReadKey(true);

  14:             exit = cki.Key == ConsoleKey.Escape;

  15:         } while (!exit);

  16:     }

  17:

  18:     private static void ValidateIfDeviceIsOnRange(int i, BluetoothDeviceInfo wp)

  19:     {

  20:         Console.WriteLine("   " + i + " validating device in range");

  21:         var inRange = true;

  22:         var fakeUuid = new Guid("{F13F471D-47CB-41d6-9609-BAD0690BF891}"); // A specially created value, so no matches.

  23:         try

  24:         {

  25:             wp.GetServiceRecords(fakeUuid);

  26:         }

  27:         catch (SocketException)

  28:         {

  29:             inRange = false;

  30:         }

  31:         Console.WriteLine("     In range: " + inRange);

  32:     }

  33:

  34:     private static BluetoothDeviceInfo GetWindowsPhoneBtDevice()

  35:     {

  36:       // You can get this from my previous post ...

  37:     }

  38: }

El código es bastante simple y la verdad es que el resultado es 100% aceptable. El siguiente video muestra mi Lumia 1520 donde cambio el estado de BlueTooth en ON / OFF y como luego la app de consola verifica el estado y muestra el true / false.

BtInRange

Nota: cada operación de discovery tarda unos 5 segundos, con lo que no es lo fluido que me gustaría este proceso.

 

Siguiente paso, madurar esto para que esté orientado a eventos!

Saludos @ La Finca

El Bruno

image image image Google

[#PEBBLE] HowTo: Connect the Pebble Watch to #Windows8.1

Hello!

Do you know Pebble Watch? Pebble Is as very cool watch pretty smart who was quite famous some time ago in KickStarter for being fairly cheap and very extensible. Now that the wearable devices are trending topic, is time to continue playing around with them and see how we can use the technologies we know to create apps and to interact with them.

In the case of Pebble,  there is no SDK available for Windows, the SDK is only available for MAC and Linux, these are only official apps for iOS and Android. But that doesn’t mean that we can not connect the smart watch to our Windows 8.1 and then begin to interact with it.

So first things first, we access the list of Bluetooth devices, look for the Pebble and add it.

image

As all Bluetooth devices, we must validate the pairing code.

image

And ready! We already have the Pebble matched with Windows. In the list of devices, we can also see the COM port you’re using (this is important for the creation of a channel of communication then).

image

And for now is everything, here my Pebble with a Hello world rather than simple yet customized Open-mouthed smile

image

[#PEBBLE] HowTo: Connect the Pebble Watch to #Windows8.1

Hola!

¿Conoces a Pebble Watch? pues es un smart watch bastante smart que fue bastante famoso en KickStarter hace un año, por ser bastante barato y muy extensible. Ahora que los wearable devices están marcando tendencia, es momento de comenzar a abrir camino y ver como podemos usar las tecnologías que conocemos para crear apps.

En el caso de Pebble el SDK no está disponible para Windows, solo para MAC y Linux, ya que las apps oficiales son para iOS y Android. Pero eso no quita que no podamos conectar el smart watch a nuestro Windows 8.1 y luego comenzar a interactuar con el mismo.

Asi que primero lo primero, accedemos a la lista de devices bluetooth, buscamos el Pebble y lo agregamos.

image

Como todo device bluetoothm, tendremos que validar el código de emparejamiento.

image

Y listo! Ya tenemos el Pebble emparejado con Windows. En la lista de devices, podemos además ver el puerto COM que está utilizando (esto es importante para la creación de un canal de comunicación luego).

image

Y por ahora es todo, aquí mi Pebble con un hola mundo más que simple pero customizado Open-mouthed smile

image

Saludos @ Home

El Bruno

image image image Google

[#VS2013] HowTo: List the registered #bluetooth devices using #32feet.net

Hello!

Sometime ago I explained how to list the registered Bluetooth devices in a windows SO. Now that there are so many devices that use BLE, it was time to recheck these routines and see if it is possible to improve them.

Before I rewrite code I did a search on Bing and I found a great library for work with Bluetooth, IR, etc. 32feet.net.

The truth is that it completes most of the scenarios for me and also allows me to focus only on the data transmission (Caution:WP8.1 has improved a lot but remains a chestnuts for bluetooth devices).

An example of this is the following lines that list the Bluetooth devices in Windows

   1: using System;

   2: using InTheHand.Net.Sockets;

   3:  

   4: namespace ConsoleApplication1

   5: {

   6:     class Program

   7:     {

   8:         static void Main()

   9:         {

  10:             var bluetoothClient = new BluetoothClient();

  11:             var devices = bluetoothClient.DiscoverDevices();

  12:             Console.WriteLine("Bluetooth devices");

  13:             foreach (var device in devices)

  14:             {

  15:                 var blueToothInfo =

  16:                     string.Format(

  17:                         "- DeviceName: {0}{1}  Connected: {2}{1}  Address: {3}{1}  Last seen: {4}{1}  Last used: {5}{1}",

  18:                         device.DeviceName, Environment.NewLine, device.Connected, device.DeviceAddress, device.LastSeen,

  19:                         device.LastUsed);

  20:                 

  21:                 blueToothInfo += string.Format("  Class of device{0}   Device: {1}{0}   Major Device: {2}{0}   Service: {3}", 

  22:                     Environment.NewLine, device.ClassOfDevice.Device, device.ClassOfDevice.MajorDevice, 

  23:                     device.ClassOfDevice.Service) ;

  24:                 Console.WriteLine(blueToothInfo);

  25:                 Console.WriteLine();

  26:             }

  27:             Console.ReadLine();

  28:         }

  29:     }

  30: }

The app running gives us information like that you show in the following image.

image

Bluetooth devices
-DeviceName: EV3
Connected: False
Address: 0016534394A7
Last seen: 4/21/2014 3:23:57 PM
Last used: 4/20/2014 8:56:03 PM
Class of device
Device: ToyRobot
Major Device: Toy
Service: None
-DeviceName: Pebble C93D
Connected: False
Address: 0017E963C93D
Last seen: 4/21/2014 3:23:57 PM
Last used: 4/21/2014 2:05:34 PM
Class of device
Device: WearableWristWatch
Major Device: Wearable
Service: ObjectTransfer, Audio, Telephony, Information

In addition to being an excellent collection of functionality is possible to install it using NuGet and with support for Windows Phone also.

image

Now I have to refactor some code so that it adapts to 32feet.net and see if everything is still working.

HomePage: http://32feet.codeplex.com/

Note: The people of pebble does not support Windows as a development platform, is certainly a fact that scares Open-mouthed smile

Saludos @ La Finca

El Bruno

image image image Google

[#VS2013] HowTo: Listar los devices #bluetooth registrados usando #32feet.net

Hola!

Alguna que otra vez expliqué como listar y conectarnos con un dispositivo Bluetooth. Ahora que hay tantos devices que usan BLE, era hora de que vuelva a revisar estas rutinas y vea si es posible mejorar las mismas.

Antes de ponerme a reescribir código hice una búsqueda en Bing y me encontré con una biblioteca genial para trabajar con Bluetooth, IR, etc. 32feet.net.

La verdad es que resuelve asi todos los problemas que estaba teniendo y me permite centrarme únicamente en la transimisión de datos (ojo, WP8.1 ha mejorado pero sigue siendo una castaña para devices bluetooth).

Un ejemplo de esto es las siguiente líneas que listan los bluettoth devices registrados en Windows

   1: using System;

   2: using InTheHand.Net.Sockets;

   3:  

   4: namespace ConsoleApplication1

   5: {

   6:     class Program

   7:     {

   8:         static void Main()

   9:         {

  10:             var bluetoothClient = new BluetoothClient();

  11:             var devices = bluetoothClient.DiscoverDevices();

  12:             Console.WriteLine("Bluetooth devices");

  13:             foreach (var device in devices)

  14:             {

  15:                 var blueToothInfo =

  16:                     string.Format(

  17:                         "- DeviceName: {0}{1}  Connected: {2}{1}  Address: {3}{1}  Last seen: {4}{1}  Last used: {5}{1}",

  18:                         device.DeviceName, Environment.NewLine, device.Connected, device.DeviceAddress, device.LastSeen,

  19:                         device.LastUsed);

  20:                 

  21:                 blueToothInfo += string.Format("  Class of device{0}   Device: {1}{0}   Major Device: {2}{0}   Service: {3}", 

  22:                     Environment.NewLine, device.ClassOfDevice.Device, device.ClassOfDevice.MajorDevice, 

  23:                     device.ClassOfDevice.Service) ;

  24:                 Console.WriteLine(blueToothInfo);

  25:                 Console.WriteLine();

  26:             }

  27:             Console.ReadLine();

  28:         }

  29:     }

  30: }

 

La app en ejecucion nos da información como la que muestro en la siguiente imagen.

image

Bluetooth devices
- DeviceName: EV3
  Connected: False
  Address: 0016534394A7
  Last seen: 4/21/2014 3:23:57 PM
  Last used: 4/20/2014 8:56:03 PM
  Class of device
   Device: ToyRobot
   Major Device: Toy
   Service: None
- DeviceName: Pebble C93D
  Connected: False
  Address: 0017E963C93D
  Last seen: 4/21/2014 3:23:57 PM
  Last used: 4/21/2014 2:05:34 PM
  Class of device
   Device: WearableWristWatch
   Major Device: Wearable
   Service: ObjectTransfer, Audio, Telephony, Information

 

Además de ser una excelente coleccion de funcionalidades es posible instalar la misma utilizando NuGet y con soporte para Windows Phone tambien.

image

Ahora me toca refactorizar un poco de código para que el mismo se adapte a 32feet.net y ver si todo sigue funcionando.

HomePage: http://32feet.codeplex.com/

Por cierto, que la gente de pebble no soporte Windows como plataforma de desarrollo, es un dato que asusta Open-mouthed smile

Saludos @ Home

El Bruno

image image image Google

[#HUMOR] The creative process

Hello!

Create apps is an art, is based on the ability to transform an idea into reality. So is always nice to describe the daily life of a programmer, what is most beautiful is the reality is the ugly truth

image

“The Creative Process” as seen by Ben Pieratt

Source: http://betaknowledge.nearfuturelaboratory.com/post/35839729409/the-creative-process-as-seen-by-ben-pieratt

Saludos @ Home

El Bruno

image image image Google

[#HUMOR] Proceso creativo

Hola!

Crear apps es todo un arte, y como tal, se basa en la capacidad de transformar en realidad una idea. Asi queda bonito describir el día a día de un programador, lo que queda más bonito es la realidad

image

“The Creative Process” as seen by Ben Pieratt

Fuente: http://betaknowledge.nearfuturelaboratory.com/post/35839729409/the-creative-process-as-seen-by-ben-pieratt

Saludos @ Home

El Bruno

image image image Google