Hello!
I am using mergBLE in a new project but honestly do not know where to go from here. I am trying to connect/pair with a beacon and have gotten this far:
I have initialized mergBLE and am able to ScanForPeripheralsWithServices. I do get a device UUID.
I need to connect to this device and enter a password to complete the process. I need to be able to change its name and read certain characteristics from the device.
Where do I go from mergBLEDidConnectPeripheral?
Can anyone help?
A point in the right direction would be most appreciated
Thanks!
Todd
Help with mergBLE
Moderators: FourthWorld, heatherlaine, Klaus, robinmiller, monte
Re: Help with mergBLE
Hi @ctflatt
You really need the documentation of the hardware you are connecting to to get much further.
Cheers
Monte
You really need the documentation of the hardware you are connecting to to get much further.
Cheers
Monte
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/
-
- VIP Livecode Opensource Backer
- Posts: 243
- Joined: Sun Dec 06, 2009 12:24 am
- Location: Fredericktown, MO
- Contact:
Re: Help with mergBLE
Monte,
Thank God!
I have it... would you help? My client is chomping at the bit...
Thank God!
I have it... would you help? My client is chomping at the bit...
-
- VIP Livecode Opensource Backer
- Posts: 243
- Joined: Sun Dec 06, 2009 12:24 am
- Location: Fredericktown, MO
- Contact:
Re: Help with mergBLE
Monte,
Here is the documentation/manual... I believe everything is there, I just don't know what to do with it...
https://christopherflatt.com/monte/ibeacon_manual.pdf
Many thanks!
Christopher (Todd)
Here is the documentation/manual... I believe everything is there, I just don't know what to do with it...
https://christopherflatt.com/monte/ibeacon_manual.pdf
Many thanks!
Christopher (Todd)
Re: Help with mergBLE
OK so once you get your device UUID you need to:
Note that the docs are a bit funny for the password. It says 2 bytes but then 0x666666 which is 3 bytes converts to "fff". Anyway the above should show you how to write to a characteristic. If there's a problem with it I'd recommend logging all the services and characteristics found so you can see what's going on.
Code: Select all
on mergBLEDidDiscoverPeripheral pPeripheral, pName, pRSSI
mergBLEConnectPeripheral pPeripheral
end mergBLEDidDiscoverPeripheral
on mergBLEDidConnectPeripheral pPeripheral
mergBLEPeripheralDiscoverServices pPeripheral
end mergBLEDidConnectPeripheral
on mergBLEPeripheralDidDiscoverServices pPeripheral, pServices, pError
if pError is not empty then
answer "Error discovering services:" & cr & pError
else
repeat for each line tService in pServices
mergBLEPeripheralDiscoverCharacteristicsForService pPeripheral, tService
end repeat
end if
end mergBLEPeripheralDidDiscoverServices
on mergBLEPeripheralDidDiscoverCharacteristicsForService pPeripheral, pService, pCharacteristics, pError
if pError is not empty then
answer "Error discovering characteristics for "&sPeripheralA[pPeripheral]["name"] & cr & pError
else
repeat for each line tCharacteristic in pCharacteristics
switch
case pService begins with "FFF0" and tCharacteristic begins with "FFF1"
-- password
mergBLEPeripheralWriteValueForCharacteristic pPeripheral, pService, tCharacteristic, "fff"
break
-- other characteristics from docs
end switch
end repeat
end if
end mergBLEPeripheralDidDiscoverCharacteristicsForService
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/