Bluedroid AV connection fails (BTAV_CONNECTION_STATE_DISCONNECTED state) - bluetooth

I am using Bluedroid stack for developiong my bluetooth apllication.
I am using A2DP src profile to make connection between Mobile and my device.
I have issue in following scenario:
When i switch from A2DP SINK profile to A2DP Source profile, the first connection request from Mobile site is always failure.
And after first connection request its always success.
I found the reason for fail is:
AV connection state is changing from
BTAV_CONNECTION_STATE_CONNECTING
...
...
BTAV_CONNECTION_STATE_DISCONNECTED
I have checked the flow in Bluedrod Stack, and found that streamming open is failed and due to this i gets BTAV_CONNECTION_STATE_DISCONNECTED event to my app.
Any help would be appreciated.
For more information please comment.
The fail status is BTA_AV_FAIL_STREAM in bluedroid stack

I got the answer/solution of this problem.
Qualcomm engineer has provided a patch to solve the issue.
Whenever there were switch between A2DP sync to A2DP src profile the SDP records is not set properly due to that the first connection request is rejected.
When the rejection happens on first time it sets the value of A2DP SRC in SDP records properly and due to that further connection request is accepted.

Related

ESP32 A2DP Headphones bonding issue

I am fairly new to working with Bluetooth and the ESP32 Bluetooth stack, so forgive me if I don't use the right terminology.
I can get the ESP-IDF Development example "A2DP_Source" working perfect only if I enable the headphones pairing mode first. After it is paired, and the bonding is stored in the Bluetooth, it will reconnect to the headphones without issue, but it then does not notify the app through the call back functions that it has connected. The app then continues to search for a bluetooth device and the audio streams sporadically, or not at all.
I've tried multiple speakers, and headphones, all with the same results.
I can see the bonded device list also and the device is there.
Is there callback function in the bluetooth stack that needs to be initialized to notify the app that the bluetooth connected to a previously paired device instead of just a device in pairing mode?
These are the three callback functions setup currently that run when connected through pairing mode, but don't run when the bluetooth connects in non-pairing mode.
...
/* register GAP callback function */
esp_bt_gap_register_callback(bt_app_gap_cb);
/* initialize AVRCP controller */
esp_avrc_ct_init();
esp_avrc_ct_register_callback(bt_app_rc_ct_cb);
/* initialize A2DP source */
esp_a2d_register_callback(&bt_app_a2d_cb);
esp_a2d_source_register_data_callback(bt_app_a2d_data_cb);
...
Any help or pointers would be appreciated. Thanks.
Did you mean ESP32 A2DP cannot connect a device without the push of a PAIR button?
The example "A2DP_Source" does not seem to connect the bonded device.
It just tries to discover the device with the certain name ("ESP_SPEAKER" in the original code) calling the function esp_bt_gap_start_discovery.
If the device is found, bt_app_gap_cb is called and then the connect to peer will start via esp_a2d_source_connect.
So I suggest fixing the code so as to connect peer instead of calling esp_bt_gap_start_discovery if there is any bonded device.
You can use the function esp_bt_gap_get_bond_device_list and find out the address of the bonded device which is required by esp_a2d_source_connect.
The API reference is available in https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/bluetooth/esp_gap_bt.html and https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/bluetooth/esp_a2dp.html.
Working through this problem more, I found that using C++ to call the native C code was the issue. I don't have a strong enough background in coding to understand the "why" it did not work, but once I returned all the code back to "C" it started working without issue. Hope this helps someone else who may make the same mistake.

How to keep information synchronized between the cloud and the device

I'm coding a project which needs cloud control device operation, and want to keep information in sync.
The cloud needs to know the state of device, such as when the network is interrupted and when the network is restored.
When the network is restored, the modified information on the cloud is synchronized to device.
anyone got an idea of how my approach should be like? any tips?
I intend to add resident programs in the background at both ends to determine, but in fact, it is impossible for the cloud in the project to connect only one device, and multiple apps may run in one device, which is very tedious to do. Is there any simple component to realize this function?
I wish control information and data information to be synchronized on the cloud and device
Based on your tag, I'm assuming that you are using MQTT as a messaging protocol for your system. If so, to address your need for tracking the device-cloud connection state, MQTT specifies a feature called "Last Will and Testament".
From the MQTT 3.1.1 Standard Section 3.1.2.5:
If the Will Flag is set to 1 this indicates that, if the Connect request is accepted, a Will Message MUST be stored on the Server and associated with the Network Connection. The Will Message MUST be published when the Network Connection is subsequently closed unless the Will Message has been deleted by the Server on receipt of a DISCONNECT Packet [MQTT-3.1.2-8].
This can be leveraged to let the remote MQTT client on the cloud know when the device is connected and when it disconnects by publishing an online payload to a topic (for example) device/conn_status after a successful connection, and registering a Last Will offline message to the same topic. Now, whenever the device client goes offline, the broker will publish the offline payload on his behalf to the cloud client that can now act accordingly.

No Authentication after Probe Response modified for security

I am working on 802.11i security implementation and I am stuck quite at the beginning. My work is based on existing framework which broadcasts open WiFi network and devices are successfully able to connect.
In order to inform STAs of access restrictions, I added RSN (Robust Security Network) element into Tagged parameters of Beacons and Probe Response frames. I defined both suites (Group and Pairwise) with 802.11 standardized values setting to AES and AuthKey setting to both PSK and 802.1X.
After this frame is sent, no Authentication Request is generated from STAs and I got response on all of them (Win7, Android and iOS) that device cannot connect. I compared Wireshark traces with multiple connection establishments, and cannot figure out what doesn't add up. Only thing I modified is addition of RSN and this RSN is absolutely the same as in other production connection attempts.
What I thought is that either device rejects frame because of improper implementation/format, or it doesn't support offered security mechanisms. But then - removing RSN field (making network open) allows STAs to proceed with Authentication Req; and looking into Probe Responses from real APs, they have the exact same structure and contents of RSN.
And other interesting behavior is that Apple device (iPad) doesn't even recognize network as secured with RSN field implemented while both Win7 and Android do.
Any ideas what am I missing or misunderstanding?
Screenshots: First is working real communication, second is my implemented modification.

No response for RPC requests from opendaylight testtool simulator devices

I was able to simulate netconf devices with opendaylight simulators. During startup, I provided the yang schemas path too.
But, when I login to the device through netconf and send any RPC request applicable for the yang schemas, there is no response from the device.
Though the simulator device throws error if there is any syntax errors in my rpc requests, it is not responding with any data.
It is mentioned in the opendaylight github page that, for "set" requests, there will be OK response by default, but I dont see any response for any request.
Also, I do not see any error log in the simulator running bash session.
Any ideas on what is going wrong?

ElementaryOS: Failed to open connection to "session" message bus

I just installed the latest Elementary OS Freya and did all the updates.
anytime I use the terminal as root, I see this warning message:
Failed to open connection to "session" message bus: Did not receive a
reply. Possible causes include: the remote application did not send a
reply, the message bus security policy blocked the reply, the reply
timeout expired, or the network connection was broken.
I read this is because there are two graphical interfaces conflicting, but that's a little confusing as I'm just running the base configuration without any modifications.
anyone has an idea of how to fix this?

Resources