why ESP32 restarts when BLE enabled? - bluetooth-lowenergy

while working on a project I came across an issue that esp32 restarts whenever BLE enabled. I don't know why this happen. And also its not happening on all device, the issue raised randomly on tw0 devices which I'm making.

Related

Looking for BLE peripheral dongle for Windows IoT core with Raspberry Pi

I am developing a UWP project to run on Raspberry Pi 3b that will advertise a Gatt Server. I based my program on the 3rd scenario in the windows IoT samples provided by Microsoft. I am using unpaired communication. Initially using the on-board BLE of the raspberry pi I get BSOD/restarts.
I narrowed the problem and suspected that it happens when:
client is not disconnected properly, i.e. android device is not disconnected properly
i try to notify using IAsyncOperation<IReadOnlyList> NotifyValueAsync(IBuffer value) on all devices even on devices not properly disconnected.
I did find on Microsoft documentation that it only supports low bandwidth devices so I limited my mtu/packet size, and added intervals on notification.
To fix the crash issue, I added a check for session status before sending notification to each individual subscribers. This seem to solve my issue on the crash. it hasn't happened again on my recent test. I am using 10.0.17763.1397 so maybe they also have some fix.
foreach (var client in characteristic.SubscribedClients)
{
try{
if (client.Session.SessionStatus == GattSessionStatus.Active)
{
GattClientNotificationResult result = await characteristic.NotifyValueAsync(data.AsBuffer(), client);
}
}
catch(Exception ex)
{
//if client is not disconnected properly, like
// bluetooth in client is turned off or becomes out of
//range it throws and error that on client.Session.SessionStatus
}
}
I also restart the GATT server every 60 seconds, like stopping the advertising and creating/restarting it again every 60 seconds if no client is subscribed/connected.
Now my problem is if I try to cycle scanning-connecting-reading, after some tries (6-20 tries) my client stops detecting the device. Only rebooting the device could solve the issue as I already tried restarting radio from my app and from powershell (using devcon). It didn't solve the issue.
Since I needed a perfect stable solution. I am opting to use BLE dongle with peripheral mode. I did see suggested BLE dongles from (I couldn't reply because it was already archived).
https://social.msdn.microsoft.com/Forums/SECURITY/en-US/344fc709-7e13-499a-94ee-3c935ad503bb/ble-gatt-server?forum=WindowsIoT
but I was hoping for some proof of concept before I buy them. (I did buy a bunch of CSR BLE dongles from hardware compatibility list of microsoft but none of them work)
If anyone have already tested:
BLE-USB-CR (RoHS)
BT900-US Laird
Please let me know your thoughts and how you made it work. I also saw the Bluefruit LE Friend from Adafruit but I'm not sure if it is compatible with Windows IOT.
Suggestions on my current imperfect solution are also most welcome.

How do I recover when Arduino USB Port randomly disappears?

I'm using my computer remotely and have an Arduino Every attached to a powered USB 3.0 hub. Anyway, the Arduino is part of a hardware tool that does some nice things for me. I communicate with it through the COM port.
The problem is that sometimes, after several days or even weeks, the Arduino's COM port just disappears. Is there some way to recover that COM port without physically unplugging it?
Sometimes restarting the computer works, but since the Arduino is plugged into a Powered USB Hub, it doesn't lose its power during a computer reset, so it doesn't reset itself and the COM port doesn't show up.
This used to happen frequently when I was using Arduino Nano knock-offs. I changed over to using Genuine Arduino Every devices and it hasn't been a problem for the last couple months. However, I'm now seeing it happen again.
Does anybody have a solution for this problem, or is this just something that happens from time to time with an Arduino when its connected for weeks/months at a time?
So, I replaced all usages of String with char[] and the problem still persisted.
I finally went online and purchased an internal PCI-E USB expansion card with 7 ports. I started using that 2 weeks ago and haven't seen the problem since. The other benefit to the internal card is that when I reboot the computer, the card reboots and forces a disconnect/reconnect of all COM ports.
I guess there was just something about having an external USB Hub that was causing the problems in the first place and the internal card was much more stable.
UPDATE - After week 3, I lost communication with a couple of my Nano Every devices. Unplugging and replugging them in fixes the problem, but I need them to NOT have that problem again. I guess the internal PCI-E Usb Hub didn't solve the problem. Maybe if I plug the Every's directly into the Computers standard USB ports that might help. I'll give that a try...
UPDATE 2 - I ended up purchasing a couple wifi wall plugs. Now, I can remotely unplug my computer and remotely unplug the USB Hub Power. I just 'Shut Down' my computer remotely and then remotely power it off for a few minutes and power off the USB hub for a few minutes. I then power up the computer (I have it's BIOS set to auto boot on power-cycle) and after it boots up, I power up the USB HUB and get all devices recognized again. Sometimes, I can just power-cycle the USB HUB to get the COM Ports visible again. It's a pain, but unless somebody comes up with a better idea, that's what I'm goin' with...

Movesense customgatt example not working?

I've built the custom_gattsvc_app and updated it into my movesense sensor through DFU in AndroidSampleApp. Now I am not anymore able to connect to the sensor. The sensor can be found by AndroidSampleApp as well as NRF Connect, but connecting does not work.
The sensor itself blinks in short intervals, perhaps it is in reset loop? I don't have a programming jig, so I can't even update it anymore (Cannot connect -> cannot update). I am using version 1.9.1. I've tested other example apps, such as hello_world_app and ble_std_services, and they have worked just fine.
Is there a known problem here?
Building done with following commands:
cmake -G Ninja -DMOVESENSE_CORE_LIBRARY=../MovesenseCoreLib/ -DCMAKE_TOOLCHAIN_FILE=../MovesenseCoreLib/toolchain/gcc-nrf52.cmake ../samples/custom_gattsvc_app
ninja dfupkg
The device might be crashing and trying to restart continuously. If you are not blinking the led and have turned off the BLE advertising in your code.
You should be able to recover by taking out the battery, short the two contacts with your finger(dip your finger in water if you have dry skin) and insert the battery, release the contacts immediately when the led starts to flash.
Your sensor should no be in DFU mode(led constantly on) and ready to update firmware. You can use the "nRF Toolbox" app(from the producer of the Bluetooth chip used in the Movesense device) to upload a new build of your code/example.
Custom GATT Example seems to be working with version 1.8.1, so I will continue using that. Perhaps the problem is related to this: https://bitbucket.org/suunto/movesense-device-lib/issues/70/version-190-and-191-and-send_ble_nus_data

AndroidThings BluetoothAdapter not always enabling

First let me say that AndroidThings is AMAZING! I like everything about the concept of getting Android into IOT. I am trying to bring AndroidThings to my company for use in production lines. Onto the question!
I have been trying to use Bluetooth low energy for communication with devices. I have gotten the Bluetooth working sometimes. That is I enable the Bluetooth adapter and it very quickly starts and I get scan results thereafter. Now say I do this another time, I check the adapter enable state, I try to enable and it just sits there. One way that seemed to work was to call BluetoothAdapter.disable() no matter what (maybe clearing something?) then performing a BluetoothAdapter.enable().
It seems like when using AndroidThings enabling the bluetooth hardware on the Pi is very 'finicky'. Also I have noticed that it may take up to 1 minutes to enable the Bluetooth.
Things to know:
I have tested this on multiple PIs.
I am using DP7 (though i saw this on DP6 also)
The main problem I am seeing is the enabling of the
bluetooth hardware (BluetoothAdapter)
Yes I have all of the required permissions:
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Yes I have power cycled the PI after I have put the app
on it.
I have implemented a retry mechanism for enabling the adapter and it still sometimes does not work.
I have followed the bluetooth tutorial on the AndroidThings page and I still get inconsistent results.
Has anyone else seen this issue or related issues?
I think this issue is solved in the new updated version of Android Things (1.0.1,updated June 2018)
Resolved Issues:
Raspberry Pi 3 devices with UART hardware connected fail to boot up.
Bluetooth is disabled on the Raspberry Pi 3 due to an invalid hardware configuration. This hardware configuration is created by the starter kit settings in the Android Things Console.

Asterisk voice delay via 3G network issue

I build Asterisk system, and running Linphone app on iOS and Android system.
I find some issue on my solution. Only used voice service.
Running WiFi environment voice no any delay, When I accept ringing then immediately hear voice.
But running 3G environment voice had 3~5 seconds delay, and fix Jitter buffer configure on Asterisk, enable it, still not solve this issue.
At same device and environment, used Line and Wechat app, when press answer call still have voice delay. but more fast than my system.
Codec used min data packet GSM. Enable QoS.
I know maybe the biggest issue is client 3G network quality. and I still find flexible configure, can fix this.
I want running 3G environment on asterisk system, get best no delay experience.
How can I do fix this issue?
3G network have internal delay.
You can do nothing here.
But usualy it 0.5-1.
Your 3sec delay can be caused by bad 3g connection or overload on 3G or issues with your provider(or you just use 3G connection twice- in and out)

Resources