Skip to content

Commit

Permalink
Merge branch 'task/get_ip4_address' into 'master'
Browse files Browse the repository at this point in the history
Added method to return the wireless network IP 4 address after successful provision

See merge request idf/esp-idf-provisioning-ios!35
  • Loading branch information
shahpiyushv committed Apr 28, 2022
2 parents 60d0599 + e690eac commit fbad43f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ESPProvision/ESPDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ open class ESPDevice {

}

/// Returns the wireless network IP 4 address after successful provision.
public func wifiConnectedIp4Addr() -> String? {
return self.provision?.wifiConnectedIp4Addr
}

private func provisionDevice(ssid: String, passPhrase: String = "", retryOnce: Bool, completionHandler: @escaping (ESPProvisionStatus) -> Void) {
provision = ESPProvision(session: session)
ESPLog.log("Configure wi-fi credentials in device.")
Expand Down
5 changes: 5 additions & 0 deletions ESPProvision/ESPProvision.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class ESPProvision {
private let session: ESPSession
private let transportLayer: ESPCommunicable
private let securityLayer: ESPCodeable
var wifiConnectedIp4Addr: String? = nil

public static let CONFIG_TRANSPORT_KEY = "transport"
public static let CONFIG_SECURITY_KEY = "security1"
Expand Down Expand Up @@ -233,6 +234,10 @@ class ESPProvision {
let configResponse = try Espressif_WiFiConfigPayload(serializedData: decryptedResponse)
responseStatus = configResponse.respGetStatus.staState
failReason = configResponse.respGetStatus.failReason

if (responseStatus == .connected){
self.wifiConnectedIp4Addr = configResponse.respGetStatus.connected.ip4Addr
}

return (responseStatus, failReason)
}
Expand Down

0 comments on commit fbad43f

Please sign in to comment.