Skip to content

Commit

Permalink
fix(#35): apply patch from issue to fix scanWifiList issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mateogianolio committed Jan 2, 2024
1 parent 7a08cc2 commit 27bccd3
Showing 1 changed file with 12 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,42 +212,31 @@ class EspIdfProvisioningModule internal constructor(context: ReactApplicationCon
else -> ESPConstants.SecurityType.SECURITY_2
}

// If no ESP device found in list (no scan has been performed), create a new one
val espDevice: ESPDevice;
if (espDevices[deviceName] != null) {
val result = Arguments.createMap()
result.putString("name", espDevices[deviceName]?.deviceName)
result.putArray("capabilities", Arguments.fromList(espDevices[deviceName]?.deviceCapabilities))
result.putInt("security", security)
result.putString("transport", transport)
result.putString("username", espDevices[deviceName]?.userName)
result.putString("versionInfo", espDevices[deviceName]?.versionInfo)

promise?.resolve(result)
return
espDevice = espDevices[deviceName]!!
} else {
espDevice = espProvisionManager.createESPDevice(transportEnum, securityEnum)
espDevice.deviceName = deviceName
espDevices[deviceName] = espDevice
}

// If no ESP device found in list (no scan has been performed), create a new one
val espDevice = espProvisionManager.createESPDevice(transportEnum, securityEnum)
var bleDevice = espDevice?.bluetoothDevice

// bluetoothDevice, deviceName and primaryServiceUuid were filled at onPeripheralFound
// If the bluetooth device does not contain service uuids, try using the bonded
// one (if it exists)
if (bleDevice?.uuids == null) {
bleDevice = bluetoothAdapter.bondedDevices.find {
bondedDevice -> bondedDevice.name == deviceName
if (espDevice.bluetoothDevice == null) {
espDevice.bluetoothDevice = bluetoothAdapter.bondedDevices.find {
bondedDevice -> bondedDevice.name == deviceName
}
}

// If the bluetooth device exists and contains service uuids, we will be able to connect to it
if (bleDevice?.uuids != null) {
espDevice.bluetoothDevice = bleDevice
espDevice.deviceName = deviceName
if (espDevice.bluetoothDevice != null) {
espDevice.proofOfPossession = proofOfPossession
if (username != null) {
espDevice.userName = username
}

espDevices[deviceName] = espDevice

val result = Arguments.createMap()
result.putString("name", espDevice.deviceName)
result.putArray("capabilities", Arguments.fromList(espDevice.deviceCapabilities))
Expand Down

0 comments on commit 27bccd3

Please sign in to comment.