Hi,
I've been playing around with the rn-ble-example but have not been successful in connecting my P2. I've tried on both iOS and Android. Android wont even begin the BLE scan and says "Cannot start scanning operation". Quick google searching leads me to believe it doesn't have permissions/features enabled for BLE, but I'm unfamiliar with how to add them to the react native example.
On iOS I can't find the device when I input the device name (aabbcc) and mobile secret, but if I remove the device name and leave it blank, it says it "found aabbcc". When I tap continue it then gives me an error saying,
ReferenceError
Property 'TextEncoder' doesn't exist.
Interestingly, the Expo log does say that it's found 1 service and 3 characteristics, but the app clearly isn't playing nice with the P2.
I'm using the right setup code and mobile secret and I have my P2 printing those to the serial console. The P2 is running the ble-provisioning code found here.
Has anyone else gotten this to work yet?
I managed to get the P2 connected to wifi though BLE, but I had to use the older react-native-ble-setup-example. No idea why the newer one I was trying to use isn't working. This one also doesn't accept a setup code, but finds "aabbcc" regardless. Cool that the P2 does in fact see 2.4/5 GHz networks!
It would be neat if someone at Particle still took a look at the example they posted on Github a couple of months ago and confirmed that it works. Getting this sorted out would put my mind at ease as we begin transitioning to the P2.
I was able to reproduce the problem with rn-ble-setup on iOS.
I used the instructions in the instructions in the repo. And built an iOS development version with Expo.
I used the fixed mobile and fixed device name secret device firmware.
I was unable to find device named aabbcc
but I was able to find it using the last 6 digits of the serial number for the device. This could be a BLE device name caching issue, which wouldn't happen for a new device that was already flashed with BLE provisioning firmware, but may occur for a device that was seen by the iOS device prior to installing BLE provisioning firmware. Or it could be a bug.
After it was able to find the device using the wrong name, I did reproduce the Property 'TextEncoder' doesn't exist
error. This dependency comes from some dependency, presumably within react-native-ble-setup
. The mysterious part is fastestsmallesttextencoderdecoder
should implement TextEncoder and that library is imported. Also, I didn't run into this several months ago when I tried it.
In any case, I'm not particularly familiar with React Native so I didn't immediately see a solution.
1 Like
Thanks for taking a look Rick!
I'll keep trying to find differences between the two examples and figure out what would cause them not to work the same way.
I made this latest version of the react native app - I’ll take a look later as I am assuming an un-pinned dependency has sneaked in and broken it
Thanks!
2 Likes
I am working on a Photon 2 project where I need BLE-Setup for the WiFi-Credentials. I have testet the rn-ble-setup on Android, but also get a Reference Error: Property 'TextEncoder' doesn`t exist.
@mrlambchop: Have you got any updates for this issue?
Thanks,
Dieter
I think I solved the problem. The Package 'fastestsmallesttextencoderdecoder' was missing. I installed the Package: npm install fastestsmallesttextencoderdecoder --force and imported it in App.tsx: import 'fastestsmallesttextencoderdecoder';
Weird, I thought for sure I had tried including it directly in App.tsx. That makes it work for iOS, nice catch!
Android still throws an error but at least we'll be able to work on something for the iOS side.