iOS 13 NEHotspotConfigurationManager Auto-Join Wifi issues SSID nil - ios13

As of iOS 13 when we request to join a WiFi network using the NEHotspotConfigurationManager, after a successful connection we may or may not be able to see the SSID using key kCNNetworkInfoKeySSID.
Our app relies on seeing the SSID to set its state (if they are connected to our WiFi network show one version else show another).
So far we've seen the issue on various devices (iPhone 8 Plus, iPhone 11) using iOS 13.1.
A device reboot fixes the problem. Has anyone else seen this behavior?

Related

ESP32 can't connect to iPhone Personal Hotspot

This is my code
#include <WiFi.h>
const char* ssid = "wifiname";
const char* password = "12345678";
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA); // SETS TO STATION MODE!
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(1000);
}
Serial.print("IP is ");
Serial.println(WiFi.localIP());
}
void loop() {
}
I can found my iPhone's personal hotspot using the WiFiscan routine, but I can't connect to it.
I tested your code and I was able to connect my ESP32 to my iPhone 8+. Since you were able to scan your iPhone's hotspot, you could try the following:
Make sure that you are using the 2.4GHz hotspot and NOT the 5GHz. If you have a iPhone 12, which now supports 5GHz hotspot, disable 5GHz by going to Settings -> Personal Hotspot -> enable(!) "Maximize compatibility"
Try to connect with an other wifi (in the 2.4GHz range)
(sounds stupid but): did you try to change the SSID and PW on your iPhone? Are you sure that your "ssid" and "password"-variable are both correct (no spelling mistakes)? For testing purposes you could even try to exclude special characters and only use letters and numbers.
If all fails it might be a HW issue. Did you try to use a different ESP32?
FWIW: I have apparently been able to connect the ESP32 chip's Wifi to my iPhone13 pro running IOS 15.3.1. The line of code:
WiFi.mode(WIFI_STA); // SETS TO STATION MODE!
was the break thru allowing me to make this connection. Note that I can make the connection even with settings->personal hotspot->Maximize Compatibility DISABLED.
I believe the iPhone hotspot turns off (or at least stops broadcasting an SSID) shortly after leaving the "Personal Hotspot" screen in "Settings". Leaving the "Personal Hotspot" screen open with my iPhone unlocked allowed me to connect my ESP32.
This Apple support discussion from 2011 describes the behavior (assuming it hasn't changed in the last decade): https://discussions.apple.com/thread/2784174
For me, the apostrophe in the default hotspot SSID was problematic (ex: John Doe's iPhone). I changed the iPhone name (and therefore the SSID name) in Settings > General > About. Afterwards, my ESP32 was able to connect to the hotspot.
Potential caveat: instead of programming the firmware directly, I was using ESP Web Tools to configure the ESP32 with ESPHome, so my issue may have been specific to the ESPHome firmware (and how it handles character encodings).
I find a solution for that issue by trials and may be it could help :
1.You have to be in the iPhone hotspot settings when the ESP32 is trying to connect specially if there's no other device connected to the hotspot!
2.Hotspot works fine until the phone gets locked and ESP32 went to deep-sleep and after wake up the ESP32 cannot connect again in some cases until you go again to the hotspot page!

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.

BLE connection fails on Android - Invalid pin or passkey

I am working on a mobile app that connects to accessories over BLE. The app runs on Android as well as iOS.
I have a Raspberry Pi that is running a BLE server app.
When my Android app tries to connect to Pi over BLE, the connectivity just fails. I see a system notification popping up that Bluetooth connection failed because of an invalid pin or passkey.
However, my iOS app seems to connect just fine. There is no PIN or passkey requested.
I have tried Android testing with Pixel 2 as well as Pixel 3. The OS version is 10.
My Android app used to work fine until a few months ago. I feel it must be a recent change in Android OS.
I am wondering if anyone else has seen such a problem. Thanks.

What is the max concurrent Ble connections android M+ can have

My app required to connect 9 Ble devices concurrently.
In this article and any other resource it write that android 4.4+ can connect only to 7 devices.
Is there anything new in M or N versions?
Thanks.
The number of connections is limited by the constants MAX_L2CAP_LINKS and GATT_MAX_PHY_CHANNEL which is currently (still) set to 7.
If you try to connect the 8th device with autoConnect = true, the stack will hang and fail to connect again until you restart Bluetooth due to a bug introduced in Android M. If you use autoConnect = false to connect an 8th device you will immediately get an onConnectionStateChange callback with newState = disconnected and no attempt to connect will be made.
I don't know why these constants are so low. Often the hardware itself can do more than 7. For example, Nexus 6P can do 15 if you compile AOSP yourself and change the constants.
Samsung seems to have noticed the issue and increased the constants on some of their devices. For example, Samsung Galaxy Tab A 10.1 can handle 15 BLE connections without modifications.
It seems that those constants are global limits, and not per app. I am linking to the source of the BT stack in Android. I wonder why those constants are as they are... seem random.
#define GATT_MAX_PHY_CHANNEL 7
https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/master/include/bt_target.h#1428
#define BTA_GATTC_CONN_MAX GATT_MAX_PHY_CHANNEL
https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/master/bta/gatt/bta_gattc_int.h#89
tBTA_GATTC_CONN conn_track[BTA_GATTC_CONN_MAX];
https://android.googlesource.com/platform/external/bluetooth/bluedroid/+/master/bta/gatt/bta_gattc_int.h#424
NOTE
This is the official Android code. Up until Android 7.2 the vendors used to change that implementation a lot. The theory in Android 8 and above is that vendors should not modify it (not enough Android 8 devices on the field to see how this works in practice... at least at time of writing this reply).

USB Host Mode solution for Motorola-Droid phones

I would like to control an Arduino device with a Motorola phone.
I have a Lilypad (preferred), an Uno, and a Mega Arduino board and I have two Motorola phones (a Droid Bionic and a Droid Razr Maxx) both running Android 4.1.2. According to an App called "USB Host Diagnostics" neither phone has USB Host Mode capability.
A variety of sites suggest the problem is that the phone doesn't provide enough power to the Arduino. Their solution requires cutting up and reconnecting the wires inside the cables. Others say the creation of a special "dongle" solves the problem, as long as it is in the phone when it starts to boot up but is removed before it finishes. Others suggest that it requires rooting the phone, which I'm afraid is probably beyond my comfort level and skill set. And many of these postings are several years old.
Has anyone figured out an smarter/better way to either enable or work-around the host mode capability issue of these phones? Or would it just be easier to find a used Nexus or Galaxy phone?

Resources