Bluetooth SPP server using Flutter - android

I want to communicate with a Sepura STP8000 radio from a Flutter app via Bluetooth (specifically SPP, Serial Port Protocol).
I first tried the flutter_bluetooth_serial and was able to connect and communicate successfully with another Android device running a Bluetooth Terminal app, sending text back and forth. But when I tried connecting to the Sepura radio I was out of luck. With my basic understanding of Bluetooth, I'm under the impression that the Sepura can only act as a client, so I would need my Flutter app to start a server and listen for an incoming connection (but I might be wrong).
So instead I tried the bluetoothadapter plugin, which seems to be able to act as a server (at least it has a startServer() method). That didn't work either. I was unable to connect from the Sepura, and also unable to connect from another Android device, so I'm not sure if startServer() actually starts a SPP server or not.
Any ideas for how I can listen for incoming Bluetooth SPP connections in my Flutter app? It's fine if it only works on either Android or iOS, as long as it works on one of them.

Related

Problem with the network interface in Android

I'm trying connect a GoPro to an Android device with the USB port.
In theory, the GoPro creates a local network and I can send commands to send it orders. The problems seem like in Android 13 always send the commands by the Wifi network interface and I always get an error saying that do not exists that URL. I guess it is because the device is trying to send the command by the Wifi interface. When I disable the wifi, in some devices with Android 13 works and I can send commands to the GoPro
In Android <13 I can't send commands, even with the Wifi disabled.
For example, in iOS automatically create the network and I can access to the network and send commands.
Any idea about this?
I've tried to connect the GoPro by wire to an Android device and with an app like Postman send commands to control the GoPro, the commands are correct, tested in iOS.

Connecting an Android Device with a BLE Peripheral without using an App

I am new to Android programming and was wondering if it was possible to connect an Android device with a BLE Peripheral, without needing an App.
I am experimenting with the Node.js package "bleno" for the peripheral and connecting using an app and even a webapp are working just fine, but connecting using the standard android settings functions dont work. The device does find my peripheral after scanning but when I try to connect with it it always returns that I need an app.
Is this a problem of bleno or does this not work that way in generell?
If the peripheral has for example a HID GATT service exposed, then you can pair and connect to it through the system settings. This means BLE keyboards and mice can be used without any app.
If your peripheral only has custom services or only services the OS knows nothing about, then you will need some app to connect to it.

Best and safe way to conect Arduino and Android

I'm developing an application that communicates with Arduino (Arduino Uno), I used two ways to communicate so far, via :
1. USB (I used the usb-serial-for-android and Physicaloid libraries) and
2. Bluetooth, sending and receiving data.
Via Bluetooth was a little slow and sometimes the information was simply not sent or received, the USB communication sending data was pretty fast, but still, sometimes the connection does not open, and it's very random, run the application and USB connection does not open, close the application, run again and the connection open, have not tried connecting via Wifi.
My question is this, what is the ideal and safest way to perform connection with Arduino?
Bluetooth connection is best, because HC05 adapters are dirt cheap and those use UART for communication (the same as com- port )

How to build this android app (Bluetooth technology)

I am a little confused on how to build this android app. Here's how it should work. I have a list of paired bluetooth devices. Lets say paired devices are:
1. A bluetooth head set.
2. A mobile phone.
And my app should automatically connect only to my headset when ever it comes in range.
Thats the basic functionality. I have been doing some research on bluetooth technology and its implementation. I came across the bluetooth chat application, when I started using the application I realized that both phones should have the app on it in order to connect and exchange messages. I tried connecting to my headset but it doesnt connect. And also when I removed the bluetooth chat app from one of my device and tried to connect it from a device which had bluetooth chat app, the devices couldnt connect.
If you have already worked on bluetooth this might look very simple. But how can I connect to a bluetooth device from my app when ever its in range even if the other device doesnt have my app.
Thanks.
This will be a 2 sections answer:
-To connect to a Bluetooth Headset, check my answer on here
-To Always connect to that device, you can save device address to memory then create a service with BroadCastReciever that listens for Bluetooth Connectivity. and check which device gets connected and compare it address to the one save in memory once its finds it connected call ibth.connect(device). ibth is inside the above link.

Connect Android to another device on bluetooth and send data

I want to create a connection between my Android and a PC (or another device) just like in the Bluetooth menu from settings.
I have manage to get the list of all bt devices in my range and get their MAC addresses.
So, I have the BluetoothDevice, how can i connect to it or pair with it? I saw a lot of stuff about creating a server on PC, but I don't want that, i just wanna connect with the device.
My attempt were to get the UUID of the device and use createRfcommSocketToServiceRecord...but when i try socket.connect() it cannot connect (because I don't have a server). So practically I need to make the same structure that the OS is doing (connect with the device, if the connected device is trying to send i can receive the info and so on).
If I managed to connect with the device, I want to listen all that it is emitting, no matter the data...I haven't researched this topic, but any advice will be nice.
The connection must be made with any device that supports bluetooth, and I don't have access to it (of course the device is giving me the permission to connect).
Grab the Android sample projects by doing this http://developer.android.com/tools/samples/index.html
They have an app called BluetoothChat that pretty much does just what you want.
The thing about the 'server' is just in the connection, one side needs to open a listening port and that side is arbitrarily the 'server'. Once they are connected they are merely peers and you can write/read data till the cows come home.

Categories

Resources