Extension : Send message/documents via Bluetooth (FAST) || OPEN SOURCE

Transfer data from one device to another via Bluetooth!

• Send documents/text
• Fast data transfer (450KB/s) (android 9 --> android 10)
• No data loss

Documentation

Of blocks available and their purpose

component_event

Raised when the device is connected to another Bluetooth device

component_event

Raised when found list of available devices

names: List of available device's name
addresses: List of available device's addresses

component_event (1)

Raised when message/document arrived.

isMessage: If the data received is message or document
data: Message/Document path
length: Length of bytes received

component_event (2)

Raised when sending of message/document is in progress

sentBytes: Number of sent bytes
totalBytes: Totall number of bytes

component_event (4)

Raised when sent message/document

isMessage: Number of sent bytes

component_method

Accept the any incoming connection

component_method (1)

Search for all the available Bluetooth devices

raises: Connected event

component_method (2)

Connect using the device index

device: Index of device to connect

component_method (3)

Start the message/document listener

component_method (4)

Send document to the connected device

component_method (5)

Send message to the connected device

Set the UUID needed for Bluetooth connection
"8ce255c0-223a-11e0-ac64-0803450c9a66" is the default value

component_set_get (1)

Get the UUID set previously

Set the path where icoming files will be saved
"/storage/emulated/0/BluetoothTransfer/" is the defualt value

component_set_get (2)

Get the folder path set previously

Open Source

Check out the source

Download

Download extension (.aix)

com.kumaraswamy.bluetooth.aix (26.6 KB)

Have a good day!



Other version (only text transfer)

An extension to transfer text from one Bluetooth device (Phone) to another!

•  1.0 Extension version
•  27 / 12 / 2020

Permissions used

android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN
android.permission.ACCESS_COARSE_LOCATION
android.permission.ACCESS_FINE_LOCATION


Documentation

component_method

Get the list of available Bluetooth devices. Asks to turn on Bluetooth if not on.

Returns: List of device names and address


component_method (1)

Start the server-side connection (Waits for client connection). Auto pairs device if not paired


component_method (2)

Connect using the index from the client-side using from the index of Bluetooth devices.


component_method (3)

Start listening to the messages.

Triggers: FoundMessage Event


component_method (4)

Send a message to the connected device/phone


component_event

Raised when the opposite device sends the message.


component_method (5)

Disconnects from the connected device.



Thanks to @Vknow360 for helping me


Download

com.xoma.blue.aix (14.2 KB)
BluethoothChat.aia (15.3 KB)

Version 2

Extension : Send message/documents via Bluetooth (FAST) || OPEN SOURCE


Demo Chat

Thanks!

9 Likes

Nice and useful extension @KUMARASWAMY_B.G :grinning:

2 Likes

Perhaps a more descriptive name for your extension ?

e.g. BluetoothTextTransfer

1 Like

Wow, Very Useful Extension @KUMARASWAMY_B.G :star_struck:
Thank you very much :kissing_heart:

1 Like

thank you for your contribution...
but what is the difference between your extension and the already available bluetooth server and client components?
see my chat example, which uses the built in components here
A simple Bluetooth Chat with App Inventor 2

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

1 Like

I think this block is the difference :

image

image

Very amazing. :star_struck:

http://ai2.appinventor.mit.edu/reference/components/connectivity.html#BluetoothClient

AddressesAndNames
Returns the list of paired Bluetooth devices. Each element of the returned list is a String consisting of the device’s address, a space, and the device’s name.

http://ai2.appinventor.mit.edu/reference/components/connectivity.html#BluetoothServer

AcceptConnection( serviceName )

Accept an incoming connection with the Serial Port Profile (SPP).

Taifun

Okay I will check the extension

see which writing I bold, that's the difference

Scanning nearby Bluetooth devices is not an one block thing, as far as I know.
You need a broadcast receiver and an intent filter to list devices.

1 Like

This extension is simple and very easy to use, I'll be adding more features.
That's the only thing.

Great extension @KUMARASWAMY_B.G keep updates.

1 Like

Update Version 2

• Remade the extension
• Added useful blocks

2.0 Extension version


Documentations

Explanation of all the available blocks

component_method (15)

Start / Waits for the client connection

component_method (6)

Returns: List of the available devices

component_method (7)

Pick an item from the list of devices and connect through the index

component_method (8)

Returns: Device name

component_method (9)

Disconnect from the connected device

component_method (10)

Returns: If the device is searching for connection

component_method (11)

Returns: If Bluetooth is enabled

component_method (12)

Send the message to the connected device

component_method (13)

Send bytes by their values separated by spaces, for example :

"65 66"

component_method (14)

Enables message listener

component_method (16)

Stop searching for client connection

component_method (17)

Returns: Current UUID. To set custom one then you need to set it from the designer tab.

component_event (1)

Raised when the device is connected
device: Connected device

component_event (2)

Raised when received a message
message: text
totalBytes: No of bytes received


Download

com.xoma.blue.aix (19.8 KB)

Next

Working on the implementation of sharing documents. :grinning:

4 Likes

Nice extension.

1 Like

New version is released!

3 Likes

Awesome extension @KUMARASWAMY_B.G

1 Like