SamsungInternet / SamsungBluetoothWiFiManager

This is a node.js application that will allow WiFi configuration of a server. Designed to be used on Gateway devices or devices that need to be configured that may not have a UI to allow user configuration.
MIT License
15 stars 10 forks source link

Calling the NetworkCharacteristic function via BLE on your handset causes an error or the embdedded device. #5

Closed nherriot closed 6 years ago

nherriot commented 6 years ago

During testing of the embedded Bluetooth WiFi manager - an error happens when calling up the NetworkCharaceristic.onreadRequest method.

To reproduce run on a Raspberry pi zero with the latest raspbian image.

  1. Use LightBlue Explorer BLE Android test app.
  2. Pair with bluetooth 'IoT Gateway WiFi Setup' device.
  3. Run Bluetooth WiFi Manager manually: /$ node bluetooth-wifi-manager.js
  4. On the LightBlue Explorer app select 'the currently visible network names'.
  5. Select the 'READ AGAIN' button

The will generate an error like:

WiFi -> stateChange: COMPLETED WARNING! NetworkCharacteristic state is: srt2 srguest srg2 srtest srsec srbackup RandomPhone SWIFT_1 daliwifi srtest-g AGAH Guest WiFi BTWifi-X BTWi-fi Redmi but the wifi manager has it as: [object Set] updating BLE values buffer.js:202 throw new TypeError(kFromErrorMsg); ^

TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object. at Function.Buffer.from (buffer.js:202:9) at new Buffer (buffer.js:158:17) at NetworkCharacteristic.onReadRequest (/home/pi/samsung/SamsungBluetoothWiFiManager/bleno/bluetooth-wifi-manager/wifi-networks-characteristic.js:47:14) at emitTwo (events.js:126:13) at NetworkCharacteristic.emit (events.js:214:7) at Gatt.handleReadOrReadBlobRequest (/home/pi/samsung/SamsungBluetoothWiFiManager/bleno/node_modules/bleno/lib/hci-socket/gatt.js:787:29) at Gatt.handleRequest (/home/pi/samsung/SamsungBluetoothWiFiManager/bleno/node_modules/bleno/lib/hci-socket/gatt.js:335:23) at Gatt.onAclStreamData (/home/pi/samsung/SamsungBluetoothWiFiManager/bleno/node_modules/bleno/lib/hci-socket/gatt.js:274:8) at emitTwo (events.js:131:20) at AclStream.emit (events.js:214:7)

nherriot commented 6 years ago

Fixed in a number of commits for the BLE embedded device and the Sapper/Svelte application:

https://github.com/SamsungInternet/SamsungBluetoothWiFiManager/commit/8928753e9dc2a489b5b9841038dd92e0868e3a9b

https://github.com/SamsungInternet/SamsungBluetoothWiFiManager/commit/4e5d6db8c6f17a4a72116158acd28bad2096ce09

This fixes: 1) SSID's that have spaces between them. 2) Properly stores local values for the BLE manager as simple coma delimited strings. 3) Ensures the PWA delimiter is ','. 4) Converts between JS SET and strings properly.