Estoy tratando de usar Symbol.WPAN.Bluetooth que viene con el EMDK para dispositivos Symbol.Symbol.WPAN.Bluetooth ejemplo que transfiere datos
¿Alguien tiene un ejemplo de trabajo que transfiere datos?
El ejemplo de símbolo simplemente empareja los dispositivos. (Aparentemente piensan que transferir datos no es realmente necesario en un ejemplo de red de área personal.)
De todos modos, sé que esto es una posibilidad remota, pero si alguien ha conseguido esto, me gustaría ver algún código.
Esto es lo que he intentado. Tengo un dispositivo presione el botón 1 y otro dispositivo presione el botón2. El valor de lectura es siempre una matriz de bytes de longitud cero.
using System.Text;
using System.Windows.Forms;
using Symbol.WPAN;
using Symbol.WPAN.Bluetooth;
namespace SmartDeviceProject1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Bluetooth bluetooth = new Bluetooth();
if (bluetooth.IsEnabled != true)
{
bluetooth.Enable();
bluetooth.RadioMode = BTH_RADIO_MODE.BTH_DISCOVERABLE_AND_CONNECTABLE;
}
RemoteDevice connectedDevice = null;
foreach (RemoteDevice remoteDevice in MakeEnumerable(bluetooth.RemoteDevices))
{
if ((remoteDevice.Name == "WM_Dan") && (remoteDevice.IsPaired == false))
{
remoteDevice.Pair();
connectedDevice = remoteDevice;
}
}
string test;
test = "Testing this out";
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] encTest = encoding.GetBytes(test);
if (connectedDevice != null)
{
connectedDevice.WriteTimeout = 20000;
connectedDevice.Write(encTest);
}
}
public static IEnumerable<RemoteDevice> MakeEnumerable(RemoteDevices devices)
{
for (var i = 0; i < devices.Length; i++)
{
yield return devices[i];
}
}
private void button2_Click(object sender, EventArgs e)
{
Bluetooth bluetooth = new Bluetooth();
if (bluetooth.IsEnabled != true)
{
bluetooth.Enable();
bluetooth.RadioMode = BTH_RADIO_MODE.BTH_DISCOVERABLE_AND_CONNECTABLE;
}
RemoteDevice connectedDevice = null;
foreach (RemoteDevice remoteDevice in MakeEnumerable(bluetooth.RemoteDevices))
{
if ((remoteDevice.Name == "WM_Dan2") && (remoteDevice.IsPaired == false))
{
remoteDevice.Pair();
connectedDevice = remoteDevice;
}
}
string test;
test = "Testing this out";
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] encTest = encoding.GetBytes(test);
byte[] encTest2;
string test2;
if (connectedDevice != null)
{
connectedDevice.ReadTimeout = 20000;
encTest2 = connectedDevice.Read(encTest.Length);
test2 = encoding.GetString(encTest2, 0, encTest2.Length);
MessageBox.Show(test2);
}
}
}
}
Hi Vaccano. ¿Lo probaste realmente? Ha funcionado? Lo intenté sin éxito. –
Nunca pude hacerlo funcionar. Debido a que es una pila patentada de bluetooth (StoneStreet), usted está solo. StoneStreet no le hablará a menos que los contrate, y las bibliotecas de Symbol solo parecen funcionar con impresoras y auriculares (etc.). Tuvimos que enviar nuestros datos a un servidor central y luego volver a descargarlos en el dispositivo de destino. Muy frustrante, pero Symbol/Motorola se metió en la cama con StoneStreet y no hay nada que puedas hacer si tu dispositivo tiene esa pila. (Si tienes la suerte de tener la pila de Microsoft, hay muchos frameworks que hacen que esto sea fácil. – Vaccano