B4A Library BLE 2 - Bluetooth Low Energy

Status
Not open for further replies.

Turbo3

Active Member
Licensed User
Can you add the features from iBLE into BLE2? (read Characteristic properties, report more than one characteristic)

Ok, That's embarrassing. I did not read the above post.

(I am going to claim I was looking at a cached copy of the page that did not show the above post when I made mine.)
 
Last edited:

Turbo3

Active Member
Licensed User
I don't see a WriteData with Response like we have in iBLE.

I have one adapter working but the other fails do to not getting any data back from the first write so seems to be a similar problem to the one you fixed in iBLE.
 
Last edited:

Turbo3

Active Member
Licensed User
The device that works report 0x1A for the property. The one that hangs waiting for a response reports 0x3A for the property. Could that make a difference?

Both these devices work fine with iBLE 1.31.
 

Turbo3

Active Member
Licensed User
Basically the same line of code for both B4i and B4A.
B4X:
B4i: manager.WriteDataWithResponse(CurService,CurCharWrite,ATCmdOut.GetBytes("UTF8"))
B4A: Starter.manager.WriteData(Starter.CurService,Starter.CurCharWrite,ATCmdOut.GetBytes("UTF8"))
Could you add the WriteDataWithResponse to B4A just to see if forcing it makes a difference?
 

Turbo3

Active Member
Licensed User
Erel, Can you please add two additional WriteData commands, one WithResponse and another WithoutResponse. That way I can test and see if either of those writes work. If not then the problem is somewhere else.
 

KY Leng

Member
Licensed User
Good evening Erel,

In the previous version of BleExtEx (version: 1.10), we can read/write data (serial data from/to BLE device) by using

'Read:
Sub Manager_CharacteristicChanged (Characteristic As BleCharacteristic)
Dim StrIn As String
StrIn = Characteristic.GetStringValue(0)
Log(" RxD <" & StrIn & ">")
End Sub

'Wite:
cwrite.SetStringValue(StrOutBT)
Manager.WriteCharacteristic(cwrite)

With this new BLE2 (version: 1.10), could you please tell us how to do it?
Note: The reason I move from BleExtEx to BLE2 is that BleExtEx could not allow Nexus Android Version 6.0.1 to find BLE device.
And it seem that all Android Version 6.0.1 could not find BLE device with EleExtEx library.

Looking forward to hearing from you soon...
 

Erel

Administrator
Staff member
Licensed User
@KY Leng see this tutorial: http://www.b4x.com/android/forum/threads/ble-bluetooth-low-energy-library.46099/#content
For further help please start a new thread.


@Turbo3 Replace the existing jar with the one attached (copy it to the internal libraries folder).
It allows getting the characteristics with JavaObject:
B4X:
Dim jo As JavaObject = BleManager1
Dim ser As JavaObject = jo.RunMethod("getService", Array(ServiceId))
Dim chrc As JavaObject = jo.RunMethod("getChar", Array (ser, CharacteristicId))
chrc.RunMethod("setWriteType", Array (2)) '2 = with response, 1 = no response
'... now  call the regular Write method.
 

Attachments

Turbo3

Active Member
Licensed User
By "internal libraries folder" I assume you mean the Libraries folder under Basic4android where the current BLE2.jar was located.

With the new BLE2.jar JavaObject is an unknown type.

==================

Never mind. I needed to enable the JavaObject library.

I will test in the morning.
 
Last edited:

DonManfred

Expert
Licensed User
By "internal libraries folder" I assume you mean the Libraries folder under Basic4android where the current BLE2.jar was located.
and where the core.jar are located, yes.

The INTERNAL is the Libraries folder in b4a program path
The Additional Libraries folder is the one you setup in b4a Paths.
 

Turbo3

Active Member
Licensed User
No luck. I can see the adapter light flash indicating it has received the command from the WriteData but I never get a response back.

If I switch back to the adapter that works it continues to work for both the 1 and 2 settings for SetWriteType. I expected it to fail with the 1 settings of no response. So that makes me think the 1 settings is not actually working.

Can you add a debug message when you execute the WriteData that says which type it is actually using?
 
Last edited:

Turbo3

Active Member
Licensed User
Then just a log message that the WriteType has been changed by this new "SetWriteType".

What else could be stopping the response from one adapter and not the other? Both adapters work fine in B4i.
 

Erel

Administrator
Staff member
Licensed User
Then just a log message that the WriteType has been changed by this new "SetWriteType".
B4X:
log(chrc.RunMethod("getWriteType", Null))

What else could be stopping the response from one adapter and not the other? Both adapters work fine in B4i.
Hard to say. The first step is to try to check it with a different Android device.
 

Turbo3

Active Member
Licensed User
Just checked with two different Android devices. Same problem. One running 4.4.2 the other Fire OS 4.5.5

One adapter (LELink) works for both Type 1 or Type 2.

The other (Vgate iCar 3) flashes when sent a command but I never get any data back. Both a Type 1 or 2 setting fails.

So the SetType makes no difference on Android but it does on iOS.
 
Last edited:

KY Leng

Member
Licensed User
Good evening Erel,

In the previous version of BleExtEx (version: 1.10), we can read/write data (serial data from/to BLE device) by using

'Read:
Sub Manager_CharacteristicChanged (Characteristic As BleCharacteristic)
Dim StrIn As String
StrIn = Characteristic.GetStringValue(0)
Log(" RxD <" & StrIn & ">")
End Sub

'Wite:
cwrite.SetStringValue(StrOutBT)
Manager.WriteCharacteristic(cwrite)

With this new BLE2 (version: 1.10), could you please tell us how to do it?
Note: The reason I move from BleExtEx to BLE2 is that BleExtEx could not allow Nexus Android Version 6.0.1 to find BLE device.
And it seem that all Android Version 6.0.1 could not find BLE device with EleExtEx library.

Looking forward to hearing from you soon...
Now I can solve my problem by using BLE2 instead of BluetoothAdmin to scan BLE device. And use BleExtEx to send/read data to/from BLE device (HM-10). Data that I mentioned here is the same serial data that we send using Serial library with Bluetooth 2 device (HC-05).

However, I want to know if BLE2 can do the same (send/read data to/from HM-10 with TxD/RxD pin) with BLE device as Serial do with BT2 device or not ? With BleExtEx, we can do but with limited byte per frame (maybe 20 byte max).
 
Last edited:
Status
Not open for further replies.
Top