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
Raised when the device is connected to another Bluetooth device
Raised when found list of available devices
names: List of available device's name
addresses: List of available device's addresses
Raised when message/document arrived.
isMessage: If the data received is message or document
data: Message/Document path
length: Length of bytes received
Raised when sending of message/document is in progress
sentBytes: Number of sent bytes
totalBytes: Totall number of bytes
Raised when sent message/document
isMessage: Number of sent bytes
Accept the any incoming connection
Search for all the available Bluetooth devices
raises: Connected event
Connect using the device index
device: Index of device to connect
Start the message/document listener
Send document to the connected device
Send message to the connected device
Set the UUID needed for Bluetooth connection
"8ce255c0-223a-11e0-ac64-0803450c9a66" is the default value
Get the UUID set previously
Set the path where icoming files will be saved
"/storage/emulated/0/BluetoothTransfer/" is the defualt value
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
Get the list of available Bluetooth devices. Asks to turn on Bluetooth if not on.
Returns: List of device names and address
Start the server-side connection (Waits for client connection). Auto pairs device if not paired
Connect using the index from the client-side using from the index of Bluetooth devices.
Start listening to the messages.
Triggers: FoundMessage Event
Send a message to the connected device/phone
Raised when the opposite device sends the message.
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 - #13 by Kumaraswamy
Demo Chat
Thanks!
11 Likes
Nice and useful extension @Kumaraswamy
2 Likes
TIMAI2
December 27, 2020, 10:45am
3
Perhaps a more descriptive name for your extension ?
e.g. BluetoothTextTransfer
1 Like
Wow, Very Useful Extension @Kumaraswamy
Thank you very much
1 Like
Taifun
December 27, 2020, 5:17pm
5
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 Taifun.
1 Like
I think this block is the difference :
Very amazing.
Taifun
December 28, 2020, 1:18am
7
Salman_Dev:
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.
Salman_Dev:
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
Kumaraswamy:
Get the list of available Bluetooth devices . Asks to turn on Bluetooth if not on.
Returns: List of device names and address
Start the server-side connection (Waits for client connection). Auto pairs device if not paired
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 keep updates.
1 Like
Update Version 2
• Remade the extension
• Added useful blocks
2.0 Extension version
Documentations
Explanation of all the available blocks
Start / Waits for the client connection
Returns: List of the available devices
Pick an item from the list of devices and connect through the index
Returns: Device name
Disconnect from the connected device
Returns: If the device is searching for connection
Returns: If Bluetooth is enabled
Send the message to the connected device
Send bytes by their values separated by spaces, for example :
"65 66"
Enables message listener
Stop searching for client connection
Returns: Current UUID. To set custom one then you need to set it from the designer tab.
Raised when the device is connected
device: Connected device
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.
5 Likes
Awesome extension @Kumaraswamy
1 Like
Ronald
May 21, 2022, 5:36am
18
Hi... I'm testing your extension.. But I dont know where is the problem....
I'm trying to connect and receive text from other device....
Thank you so much...
Here's my block