HM-10 not found by android device after setting IMME to 0 - android

I am new to using the HM-10, and I am trying to make it connect to my Android device.
With +IMME set to 0, my phone picks up the HM-10. If I connect to it through an app that I am making, a connection is successful. After connecting once, however, the HM-10 tries to connect to my phone automatically every time my phone's bluetooth is on.
I only want to start a connection via the phone, but with AT+IMME0, the HM-10 connects to the phone by itself. I thought that setting AT+IMME1 would fix this issue, but now my phone cannot find the HM-10 at all.
Am I going about this wrong? What do I need to do to get my desired outcome?

AT+IMME1 put the HM10 in manual mode, meaning the bluetooth radio is not turned on until it receives AT+START, AT+DISC?, AT+DISI? or AT+DISA over serial.
Here's the relevant section in the datasheet

Related

HM-10 BLE microcontroller connected without PIN

I'm using HM-10 controller to communicate with my Android App. In Arduino console I set pin with command AT+PIN112233 which should be Passkey for BLE device. This PIN was saved to my device but Android phone can connect to this device without any confirmation or PIN request. Is this normal behaviour?
I just find device through scanning in BroadcastReceiver and I get device under action BluetoothDevice.ACTION_FOUND. It will return BluetoothDevice and I just connect to this device with
bleGatt = bleDevice.connectGatt(this, true, bleGattCallback)
I did not get any Dialog window in my Android App asking for PIN. Also tried some other apps for Bluetooth or BLE connection and it was the same. None of them asked for PIN during pairing.
Also my HM-10 BLE controller does not react to some AT commands:
AT+TYPE2 returns +TYPE=0
AT+VERR? not responding
AT+VERS? not responding
AT+RESTART not responding
AT not responding but AT+ responds with OK
I believe this behavior is normal. The same thing happened with my Arduino Nano 33 BLE and Android app that I built. The pin code connection process is for bonding.
I had clone model MLT-BT05 where AT+TYPE2 is not working. That means I cant set pairing method only change PIN which is practically useless.
The AT+TYPE command only works with HM10 version >V515. The default for any module is
no need pincode(TYPE 1)
The command to get version of our module is AT+VERR?.
Data sheet of HM10 https://people.ece.cornell.edu/land/courses/ece4760/PIC32/uart/HM10/DSD%20TECH%20HM-10%20datasheet.pdf

Can I connect bluetooth device automatically with the device which already paired without showing choose dialog

I am developing a solution for connection between OBD2(Vehicle ECU scanner) with the mobile app.
I want that when ever that OBD device is found and it is already paired then the application automatically connect with the device and create a socket for transmission of data . without showing the dialog box to choose a paired device.
You can connect to any paired Bluetooth device, to do so, you have to know device's address and UUID. Embedded devices may have some defined uuid (for example, hc05 adapter), you can get that uuid from documentation.
The tricky part here is that you have to monitor failure and loss of connection so you can retry again. I'm implementing that feature in my home project, fell free to see code: https://github.com/AlexShutov/LEDLights

Android restart bluetooth socket after crash?

I'm working on my first app for a school project. It receives and proccesses data received over bluetooth (PC with terminal and bluetooth module).
Everything works as it should but if something happens that wasn't expected, the app could crash. this is not a big deal but the Bluetooth connection remains connected although my program doesn't know that and can't work. **Is there a function to request the active bluetooth connection (like restarting a socket with the adress or something?)
I cant connect it the default way because the bluetooth discvery cant find the device anymore.
If i restart the phone everything works fine again.
I'm using the default bluetooth threads from the Android develeoper website. If anyone needs to see the code I can put it here.
When you are working with BluetoothSockets you can use yourBluetoothSocket.getRemoteDevice(); This wil get the BluetoothDevice this socket is connected to.
If there is no device connected, you can hardcode the MAC-adres of the device you want to connect to.
BluetoothDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(MAC-ADDRESS);
after this you can try to reconnect.

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