B4R Library rCurieBLE - Arduino 101 BLE

With this library it is simple to connect to the Arduino 101 board with an Android or iOS device.
Arduino 101 instructions: https://www.b4x.com/android/forum/posts/448783/

It is similar to B4i peripheral implementation: BLE (Bluetooth Low Energy) Peripheral

It creates a service (0001) with a readable characteristic (1001) and a writable characteristic (1002).

The NewData event is raised when a central device, the iOS or Android device, writes to the writable character.
The DataAvailable event on the central device is raised after a call to CuriePeripheral.Write.

Note that messages are limited to 20 bytes. Don't try to send more as it will break the connection.

A B4A + B4R example is attached.
 

Attachments

  • rCurieBLE.zip
    2.3 KB · Views: 631
  • B4R_BLE_Example.zip
    828 bytes · Views: 578
  • B4A_BLE_Example.zip
    8.3 KB · Views: 625

tigleth

Member
Licensed User
Longtime User
Hello

log from b4a

LogCat connected to: B4A-Bridge: motorola MotoE2(4G-LTE)
--------- beginning of main
Connected to B4A-Bridge (Wifi)
sending message to waiting queue (CallSubDelayed - UpdateStatus)
Ignoring event (too many queued events: CallSubDelayed - UpdateStatus)
Installing file.
PackageAdded: package:b4a.example
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Installing file.
Installing file.
PackageAdded: package:b4a.example
Installing file.
PackageAdded: package:b4a.example
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Streams_terminated
sending message to waiting queue (CallSubDelayed - UpdateStatus)
Ignoring event (too many queued events: CallSubDelayed - UpdateStatus)
Connected to B4A-Bridge (Wifi)
sending message to waiting queue (CallSubDelayed - UpdateStatus)
Ignoring event (too many queued events: CallSubDelayed - UpdateStatus)




log from b4r

Error opening port
jssc.SerialPortException: Port name - COM4; Method name - openPort(); Exception type - Port not found.
AppStart

the b4r example starts when u click connect

Thank you
 

tigleth

Member
Licensed User
Longtime User
Hello, looks like I have usb debugging now and this is what I get from b4a

LogCat connected to: TA09302FUC
--------- beginning of system
--------- beginning of main
** Activity (main) Pause, UserClosed = false **
java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
** Service (notificationservice) Start **
NotificationRemoved, package = android, id = 17040344, text = USB for charging
** Service (notificationservice) Start **
NotificationPosted, package = android, id = 17040345, text = USB for file transfer
(Bundle) Bundle[{android.title=USB for file transfer, android.subText=null, android.showChronometer=false, android.icon=17303109, android.text=Touch for more options., android.progress=0, android.progressMax=0, android.showWhen=true, android.rebuild.applicationInfo=ApplicationInfo{b141b63 android}, android.infoText=null, android.originatingUserId=0, android.progressIndeterminate=false}]
Title = USB for file transfer
** Activity (main) Resume **
PackageAdded: package:b4a.example
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
Notification internal service created
** Activity (main) Resume **
PackageAdded: package:b4a.example
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
PackageAdded: package:b4a.example
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
PackageAdded: package:anywheresoftware.b4a.designer
** Activity (main) Pause, UserClosed = false **


Thank you
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
It looks like you are still using B4A-Bridge.
Make sure that B4A-Bridge is disconnected (bottom left corner):

SS-2017-01-17_08.35.44.png
 

tigleth

Member
Licensed User
Longtime User
Hello, used the ble2 library and example and now time comes thru on my motoe2; thank you for this.

Kim
 
Top