BT: An extension to work with Bluetooth

1.Introduction

BT extension provides some features to work with bluetooth.

Latest Version: 1.2
Released: 2020-08-28T18:30:00Z
Last Updated: 2021-03-18T18:30:00Z
Required Api: 17
Permissions: android.permission.BLUETOOTH,android.permission.BLUETOOTH_ADMIN,android.permission.ACCESS_FINE_LOCATION,android.permission.ACCESS_COARSE_LOCATION

2.Blocks

image
image
image

3.Documentation

  • After Set Duration
    Event indicating whether duration was set successfuly or not.
    image
    success ~ boolean
    seconds ~ int
  • On Discovery Finished
    Event indicating that discovery has been finished and returns addresses paired and new devices.
    image
    pairedDevices ~ List
    newDevices ~ List
  • OnDiscoveryStarted
    Event indicating that discovery has been started.
    image
  • On Error
    Even indicating that a error has been occurred and returns error message.
    image
    errorMessage ~ text
  • On Pairing State Changed
    Event indicating that a device's state has changed.Either it has paired or unpaired with this device.
    image
    address ~ text
    isPaired ~ boolean
  • Address
    Returns device's bluetooth address.
    image
    Returns : text
  • Cancel Discovery
    Tries to stop discovery for nearby devices.
    image
  • Get Name
    Returns bt device name from address.
    image
    Returns : text
  • Get Paired Devices
    Returns a list of paired devices.
    image
    Returns : list
  • Is Discovering
    Returns true if device is searching for nearby bluetooth devices.
    image
    Returns : boolean
  • Is Enabled
    Returns true if bluetooth is enabled.
    image
    Returns : boolean
  • Is Paired Device
    Returns true if given address points to a paired device.
    image
    Returns : boolean
  • Is Valid Address
    Returns true if given address is valid.
    image
    Returns : boolean
  • Name
    Returns device's bluetooth name.
    image
    Returns : text
  • Pair
    Tries to pair with given device.
    image
  • Rename
    Tries to rename the device's bt name and returns result.
    image
    Returns : boolean
  • Set Visibility
    Sets visibility of device in seconds.
    image
  • Start Discovery
    Tries to start discovery for nearby devices.
    image
  • Toggle
    Enables/Disables bluetooth.
    image
  • Unpair
    Tries to unpair with given device.
    image

4.Downloads

5.Credits

Thanks to @Salman_Dev for beta testing the extension :heart_eyes:
Thanks a lot to MIT :heart:

Thank you. :slightly_smiling_face:

11 Likes

Nice Extension @vknow360 :heart_eyes: :heart_eyes:

hope your problem will solve asap

2 Likes

Great extension as always @vknow360 :grinning: :+1:

2 Likes

:ok_hand: :grin: :+1: Cool

1 Like

(added to FAQ)

3 Likes

Now this extension is free to everyone.
Here is the aix:
com.sunny.BT.aix (13.6 KB)

And aia:
Bluetooth_Extension_Research.aia (21.6 KB) [Thanks to @Salman_Dev ]

4 Likes

Thank you for making it free my Best Friend :kissing_heart:

:partying_face: :+1:

1 Like

Hi Sunny

The More Information link in the installed BT extension takes the User to:

1 Like

Thank you.
I will update it as soon as possible.

Here is v1.1:
Aix
com.sunny.BT.aix (15.3 KB)

Changes

1 Like

Hello,
First of all thank you for the work done on this extension. I was able to find a solution for my application with which I wanted to have an automatic connection to my robot.

On the other hand, I noticed a small problem that I wanted to bring up to you. Sometimes after a scan, the application gives an error message. So I tried with your application as an example, same observation.


I sometimes also "cannot accept the arguments:[any address ],[ ],[nothing]"

I wondered if it was not from a bluetooth module that does not display their mac address. So I tried adding conditions to list creations to exclude wrong addresses, but nothing helped. I'm starting to wonder if this might not come from the extension code. Little will you have an idea of the problem.

Cordially.

Hi @Pedro-51 Welcome to Community
Can you show your blocks?
Are they similar to below given blocks?

Hello,

absolutely. The problem arises even with your example program. But it's pretty random and I don't know if it happens when a particular bluetooth module is nearby or not. Because I am in university residence and I therefore do not have control over the work environment. Like you, I think the error returned on this block in question but I have not found a solution for the moment. Maybe you would have better luck.

By removing this block from the program

component_method

and doing an infinite loop of scanning to try to debug. My modified blocks for debugging:

the problem does not arise

If that's the case then version v1.2 should work fine.
com.sunny.BT.aix (15.3 KB)

Hello,

it still does not work with the new version. I was able to test on the move today and the error messages keep coming back. With hindsight, given that for my personal app, I'm trying to connect to a device that bears a particular name (Hexapod) without worrying about its Mac address (so that my app is compatible with several robots), I I created a method different from the one proposed in the example which does not need to manage a list.


It works perfectly, and I therefore see that the only element which can pose a problem and this one which seems to receive something other than text and which therefore returns an error message.


Moreover, this is specified in the help of AI2. "List of text elements to show in the ListView. This will signal an error if the elements are not text strings".

I do not see how to solve this problem, but maybe some will have more experience and will have found themselves.

1 Like

Extension is open source now:

3 Likes

Useful extension :+1: :+1:

2 Likes

2 Likes

Hello, i can not enable/disable bluetooth via BT1.Toogle call method.
How can i enable or disable Bluetooth using this call method?