Meilleur auteur de réponses
Problème connexion Bluetooth avec le module InTheHand.Net.Personal

Question
-
bonjour,
depuis plusieurs jour, j'essaye de me connecter sur un dispositif serial bluetooth en utilisant la bibliothèque InTheHand.Net.Personal fourni par 32feet.NET.
je n'arrive pas a trouver un forum qui parle de cette dll. Je me suis inscrit il y a plusieurs jours sur leur forum mais j'attend depuis l'approbation de l'administrateur.
Donc la je suis bloqué sur ca.
j'explique mon problème correctement.
en fait j'arrive à me connecter, mais le bluetooth se déconnecte juste après. donc je ne peux pas me connecter au périphérique relié en serial avec le bluetooth.
voici mon code ci-dessous:
string adresseBluetooth = "0018b2002ea7";
BluetoothRadio radio;
BluetoothClient listeDePeripheriqueBluetooth= new BluetoothClient();
Guid service= BluetoothService.SerialPort;;
BluetoothDeviceInfo[] bdi = new BluetoothDeviceInfo[10];
BluetoothDeviceInfo peripheriqueBluetooth;radio = BluetoothRadio.PrimaryRadio; if (radio != null && radio.Mode == RadioMode.PowerOff) { BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable; } listeDePeripheriqueBluetooth = new BluetoothClient(); service = BluetoothService.SerialPort; bdi = listeDePeripheriqueBluetooth.DiscoverDevices(); foreach (BluetoothDeviceInfo bluetooth in bdi) { if (bluetooth.DeviceAddress.ToString().Equals(adresseBluetooth.ToUpper())) { peripheriqueBluetooth= bluetooth; } } try { BluetoothWin32Authentication authetification = new BluetoothWin32Authentication(Win32AuthCallbackHandler); SerialPort = new BluetoothClient(); SerialPort.Connect(new BluetoothEndPoint(peripheriqueBluetooth.DeviceAddress, service)); } catch (Exception ex) { MessageBox.Show("n'arrive pas a se connecter : " + ex.Message); }
public static void Win32AuthCallbackHandler(object sender, InTheHand.Net.Bluetooth.BluetoothWin32AuthenticationEventArgs e)
{
string address = e.Device.DeviceAddress.ToString();
MessageBox.Show("Received an authentication request from address " + address);
e.Pin = "0000";
e.Confirm = true;
}svp si quelqu'un a déjà utilisé ce module
merci d'avance :)
- Modifié ahmedmahdi lundi 4 mars 2013 12:01 petite correction du code
Réponses
-
oui c'est bon j'ai bien réglé le problème de connexion.
en fait, il suffisait de faire ça :
string adresseBluetooth = "0018b2002ea7"; BluetoothRadio radio; BluetoothClient listeDePeripheriqueBluetooth= new BluetoothClient(); Guid service= BluetoothService.SerialPort;; BluetoothDeviceInfo[] bdi = new BluetoothDeviceInfo[10]; BluetoothDeviceInfo peripheriqueBluetooth; radio = BluetoothRadio.PrimaryRadio; if (radio != null && radio.Mode == RadioMode.PowerOff) { BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable; } listeDePeripheriqueBluetooth = new BluetoothClient(); service = BluetoothService.SerialPort; bdi = listeDePeripheriqueBluetooth.DiscoverDevices(); foreach (BluetoothDeviceInfo bluetooth in bdi) { if (bluetooth.DeviceAddress.ToString().Equals(adresseBluetooth.ToUpper())) { peripheriqueBluetooth= bluetooth; } } try { BluetoothWin32Authentication authetification = new BluetoothWin32Authentication(peripheriqueBluetooth.DeviceAddress, "0000"); SerialPort = new BluetoothClient(); SerialPort.Connect(new BluetoothEndPoint(peripheriqueBluetooth.DeviceAddress, service)); } catch (Exception ex) { MessageBox.Show("n'arrive pas a se connecter : " + ex.Message); }
mais maintenant j'ai un autre problème. je vais essayer de le résoudre en effectuant des recherche bien sûr.
sinon je reviendrai pour poster une question
merci pour votre aide :)
- Marqué comme réponse ahmedmahdi lundi 4 mars 2013 15:04
Toutes les réponses
-
Bonjour
Avez-vous essaye le forum CodePlex dédiée 32feet.net?
http://32feet.codeplex.com/discussions (dans la page initiale l'URL pour le forum n'est pas bon, mais celui-ci existe bien)
Cordialement,
-
-
Essayez aussi de regarder les exemples. Peut-être c’est déjà fait ce que vous voulez faire.
Cordialement,
- Modifié Aurel Bera lundi 4 mars 2013 14:25
-
oui c'est bon j'ai bien réglé le problème de connexion.
en fait, il suffisait de faire ça :
string adresseBluetooth = "0018b2002ea7"; BluetoothRadio radio; BluetoothClient listeDePeripheriqueBluetooth= new BluetoothClient(); Guid service= BluetoothService.SerialPort;; BluetoothDeviceInfo[] bdi = new BluetoothDeviceInfo[10]; BluetoothDeviceInfo peripheriqueBluetooth; radio = BluetoothRadio.PrimaryRadio; if (radio != null && radio.Mode == RadioMode.PowerOff) { BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable; } listeDePeripheriqueBluetooth = new BluetoothClient(); service = BluetoothService.SerialPort; bdi = listeDePeripheriqueBluetooth.DiscoverDevices(); foreach (BluetoothDeviceInfo bluetooth in bdi) { if (bluetooth.DeviceAddress.ToString().Equals(adresseBluetooth.ToUpper())) { peripheriqueBluetooth= bluetooth; } } try { BluetoothWin32Authentication authetification = new BluetoothWin32Authentication(peripheriqueBluetooth.DeviceAddress, "0000"); SerialPort = new BluetoothClient(); SerialPort.Connect(new BluetoothEndPoint(peripheriqueBluetooth.DeviceAddress, service)); } catch (Exception ex) { MessageBox.Show("n'arrive pas a se connecter : " + ex.Message); }
mais maintenant j'ai un autre problème. je vais essayer de le résoudre en effectuant des recherche bien sûr.
sinon je reviendrai pour poster une question
merci pour votre aide :)
- Marqué comme réponse ahmedmahdi lundi 4 mars 2013 15:04