PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → BlueTooth Connects ok, but cannot read data.?
BlueTooth Connects ok, but cannot read data.?
Débuté par Adrian Wreyford, 04 aoû. 2008 09:57 - 5 réponses
Posté le 04 août 2008 - 09:57
Bonjour,

Well I have spent hours, and eventually managed to connect to a bluetooth sensor.
The sensor requires no passkey, and is attached to a loadcell(scale), and sends out packets of data 15 bytes long every 200ms. I need to capture these packets of data on the handheld.

PS(I'm using WDMobileExpress12, purchased WDMobile12 on 30/07/2008, but heard nothing to date, and payment has gone off my bank account.)

I use the following code to to load a devices HF with the available bluetooth devices.:
sListDevices is string
sADevice is string
sIDEXPRESS is string
sNameEXPRESS is string
sMACAddressEXPRESS is string

// Returns the list of the Bluetooth devices found nearby
sListDevices = BTListDevice(btDetailedList) //btSimpleList
// Browse the connected devices
FOR EACH STRING sADevice OF sListDevices SEPARATED by CR
// Stores the device information
EXPRESS_DEVICES.EXPRESS_sDEVICEID = ExtractString(sADevice, 1)
EXPRESS_DEVICES.EXPRESS_sNAME = ExtractString(sADevice, 3)
EXPRESS_DEVICES.EXPRESS_sMACADDRESS = ExtractString(sADevice, 2)
// Fills the table with the devices
HAdd(EXPRESS_DEVICES)
END


Next I connect to the device, after I select the correct one from a combo box populated with the Devices table.
Please note .. that you return MAcAddress in the following format with BTListDevices: '00:00:00:00:00:00', but when you connect using SocketConnectBlueTooth you require the MacAddress in the format:
'00-00-00-00-00-00' or '000000000000' and this took me ages to discover.
Why the '-', and not the standard ':'?
Now I connect:
bConnectedEXPRESS is boolean
sDataRead is string
nLineCom12EXPRESS is int
sMAcAddressEXPRESS is string


gsAMISCALEEXPRESS = "Sensor"
sMAcAddressEXPRESS = "00-04-3e-23-38-09"

IF SocketConnectBluetooth(gsAMISCALEEXPRESS,"SerialPortServiceClass_UUID",sMAcAddressEXPRESS) = False THEN //COMBO_EXPRESS_WIN_Attach_SENSOR..Caption) = False THEN
DelayBeforeClosing(1000)
Error("Unable to connect to Sensor socket", ErrorInfo(errFullDetails))
RETURN
END


It connects to the device, and I know it is working, as the blue light on the sensor PcBoard lights up.

The Sensor is available using the following service:
Serial Port(SPP)'KC-SPP' COM12

I tried using SocketRead, but without success.
I tried using Sopen and sRead, also no success.

So .. Can anybody out there help. Sorry I don't speak French, and I notice much more activity on the French usergroups, but hope that you guys will answer my questions here as well.

Thanks

Adrian
Posté le 06 août 2008 - 18:08
Good Morning,

I will also have to use Bluetooth soon but I have no device for the moment. It's my understanding that SocketConnectBluetooth it's for network protocol communication so I don't think it will work for your device.

I guess is that you have to use the service provided by your device. How that's the part I'll have to find it is probably by sending a STRING through the com port assigned ti the bluetooth device once activated, I really gdon't know but soon I'll !

Sorry I can't go further !

Sylvain
Posté le 07 août 2008 - 16:52
Did you test the stack used by the device and check if it's supported by Windev

Just check with BtStack(), after reading avalaible documentation from Windev 12 it 's seem that you are using the right way to talk to a Bluetooth device.

I don't have one on hand to test but I'll have it soon !

HTH,

Sylvain
Posté le 09 août 2008 - 14:10
Unfortunately the BTStack() command is not allowed in WinDevMobile.

I've got a Cipher Lab 9400CE device, that runs Win CE 5.0.

I can use API("9400CE_DLL.dll","StartBluetooth") to switch on the bluetooth of the device, but then I cannot connect using sOpen() and sRead().

What I did notice, is that if I physically enable the bluetooth on the device, then locate the Sensor, and connect to it manually .. ie end user intervention, then open com8, and read on it, I get the bluetooth packets coming from the sensor.

This however is not the way we want it to work.

We need to enable and disable bluetooth, in our mobile app, so that we can save on battery life. We also need to only call up the bluetooth when we need to connect to the sensor. Starting up Bluetooth with the API call as per above, then the SocketConnectionBluetooth()works in that the bluetooth light of the sensor turns on, but cannot read the data it is spewing out!

It looks like I'm never going to get this working?

Chow
Posté le 27 août 2008 - 15:48
Adrian,

I was not aware that BTSTACK() wasn't available under Windev mobile.

After reading "a little bit" the SDK for your device I'll suggest to try this:

1- Enable the bluetooth device with StartBluetooth API
2- sopen() com3
3- try to sread()

In your device documentation it is stated that you can acces the bluetooth service on com3 "once enable"

Keep me inform

HTH,

Sylvain
Membre enregistré
3 651 messages
Popularité : +175 (223 votes)
Posté le 03 octobre 2015 - 20:10
Hi

Look my post about MACADDRESS

http://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/708-windev-mobile-identificando-macaddress-celular-usando-codigos-nativos-710/read.awp

:merci:

--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
skype: adrianoboller
______________________________________________