espressif / esp-matter

Espressif's SDK for Matter
Apache License 2.0
694 stars 157 forks source link

Commisioning over Soft AP (CON-570) #467

Closed JonathanWitthoeft closed 1 year ago

JonathanWitthoeft commented 1 year ago

Continuation of https://github.com/espressif/esp-matter/issues/109

Matter v1.1 is released. How can we enable Soft-AP provisioning instead of BLE provisioning for the esp32?

jonsmirl commented 1 year ago

Provisioning using what? IOS and Google? Is that ever going to work? They'd have to support Soft-AP in their apps.

Provisioning using using your own app? You can do that right now. Use your custom app code with Soft-AP to get the node up on wifi, then do standard IP commissioning (Ethernet commissioning).

JonathanWitthoeft commented 1 year ago

Provisioning using what? IOS and Google? Is that ever going to work? They'd have to support Soft-AP in their apps.

iOS and Google yes. Apple already supports Soft-AP commissioning for HomeKit and Soft-AP commissioning has been in the Matter specification since release. Why is there skepticism?

Using a third party app with custom commissioning kind of defeats the purpose of a the unified commissioning in Matter. Google already mentions Soft-AP commisioning in their developer console. Why would they do that if they don't plan on supporting it?

https://developers.home.google.com/matter/primer/commissionable-and-operational-discovery

jonsmirl commented 1 year ago

I never noticed in the spec before, no one talks about it. Everyone is using BLE, Thread or IP based commissioning. You are going to need to whine at Apple and Google to implement this. Unfortunately you may be the first person in the world using it.

JonathanWitthoeft commented 1 year ago

I will do plenty of whining when the time comes :rofl:, but I am currently only interested in how to implement it in the esp-matter SDK. I see config options for it:

    menu "WiFi AP Options"

        config ENABLE_WIFI_AP
            depends on ESP_WIFI_SOFTAP_SUPPORT
            bool "Enable CHIP WIFI AP"
            default y
            help
                Enables WiFi AP for CHIP.

        config WIFI_AP_SSID_PREFIX
            string "WiFi AP SSID Prefix"
            default "MATTER-"
            depends on ENABLE_WIFI_AP
            help
                A prefix string used in forming the WiFi soft-AP SSID.  The remainder of the SSID
                consists of the final two bytes of the device's primary WiFi MAC address in hex.

        config WIFI_AP_CHANNEL
            int "WiFi AP Channel"
            range 1 14
            default 1
            depends on ENABLE_WIFI_AP
            help
                The WiFi channel number to be used by the soft-AP.

        config WIFI_AP_MAX_STATIONS
            int "WiFi AP Max Allowed Stations"
            range 1 10
            default 4
            depends on ENABLE_WIFI_AP
            help
                The maximum number of stations allowed to connect to the soft-AP.

        config WIFI_AP_BEACON_INTERVAL
            int "WiFi AP Beacon Interval (ms)"
            range 100 60000
            default 100
            depends on ENABLE_WIFI_AP
            help
                The beacon interval (in milliseconds) for the WiFi soft-AP.

        config WIFI_AP_IDLE_TIMEOUT
            int "WiFi AP Idle Timeout (ms)"
            range 0 600000
            default 120000
            depends on ENABLE_WIFI_AP
            help
                The amount of time (in milliseconds) after which the CHIP platform will deactivate the soft-AP
                if it has been idle.

    endmenu
JonathanWitthoeft commented 1 year ago

Imagine having thousands of products in the field right now without Bluetooth support because they were only FCC/IC certified for Wi-Fi. There needs to be a path for updating existing products without Bluetooth support to Matter.

jonsmirl commented 1 year ago

Doesn't look like they have implemented it. Only a single reference in the source code.

jonsmirl@ares:~/aosp/esp-matter/components$ grep -r PAIRING_MODE_SOFTAP * esp_matter_controller/esp_matter_controller_pairing_command.h: PAIRING_MODE_SOFTAP,

Did you consider amending your FCC filing to enable BLE?

jonsmirl commented 1 year ago

Feedback I have on soft-ap is that customers hate it. They don't understand when phone is in 5Ghz mode and device is at 2.4Ghz.

JonathanWitthoeft commented 1 year ago

Did you consider amending your FCC filing to enable BLE?

Yes unfortunately they will not amend it and it would need a full new certification with new FCC ID. Enabling a wireless interface is not small enough to be a permissible change.

They don't understand when phone is in 5Ghz mode and device is at 2.4Ghz

BLE and Soft-AP commissioning should act the same with regards to the 5Ghz issue. It all depends on the Wi-Fi band the phone is on when commissioning starts. Matter actually has devices specify the bands they support in the Network Commissioning Cluster so I think the 5Ghz incompatibility will be caught early on during commissioning and an error should be displayed by Google/Apple etc.

jonsmirl commented 1 year ago

BLE does not experience the 5Ghz issue. BLE only works on 2.4Ghz. Once the device is commissioned it attaches to the router at 2.4GHz. The phone is attached to the router at 5Ghz. The router translates and the customer is unaware.

JonathanWitthoeft commented 1 year ago

BLE does not experience the 5Ghz issue. BLE only works on 2.4Ghz. Once the device is commissioned it attaches to the router at 2.4GHz. The phone is attached to the router at 5Ghz. The router translates and the customer is unaware.

But then how does it know the proper SSID to connect to the router with? Is this with the assumption that both 5Ghz and 2.4Ghz of the desired network have the same SSID and Password?

jonsmirl commented 1 year ago

The phones use your saved wifi list to get the SSID/Password. Most people have the same SSID/PW on 2.4Ghz and 5Ghz since it is the same router. If you don't, then you will have needed to have used the phone to attach to the 2.4Ghz SSID and saved it. This is considered a security feature since the vendor app never sees the wifi password.

jonsmirl commented 1 year ago

Same SSID/PW on 2.4Ghz and 5Ghz is preferred because your phone will measure both signal strengths and connect using the better one. I can see this walking around my house. Near the routers it will use 5Ghz. If I go outside onto the deck it will drop down to 2.4Ghz which has better signal propagation.

shubhamdp commented 1 year ago

@JonathanWitthoeft If you have devices in field, then they will be already connected to the WiFi right? In that case nothing extra is required in the firmware and device will be commissioned using on-network.

There may be some work required after factory reset. But, you may have some flow already present right? So, use the vendor app and commission the device to WiFi network and then on-network commissioning. (This is non-standard commissioning flow, as documented in the specification)

JonathanWitthoeft commented 1 year ago

@shubhamdp I appreciate the suggestions, but new devices will also be produced, and there will be instances where devices are factory reset. We can not assume all devices will already be commissioned to a network. Part of the appeal of Matter is that you don't require a third party/manufacturer app.

I guess I would just like to know if the standard Soft-AP commissioning (according to the Matter specification) is implemented in the esp-matter SDK, or if there are plans to implement it. From what I can tell it is now implemented in the upstream connectedhomeip repository and it could be as simple as setting some config values.

From the specification it looks like it is just a Soft-AP SSID format "MATTER-ddd-vvvv-pppp" and a flag or 2 in the network commissioning cluster to show it is supported.

I will attempt to implement it myself and offer a push request if successful

JonathanWitthoeft commented 1 year ago

Matter Soft AP creation in ConnectivityManager: https://github.com/project-chip/connectedhomeip/blob/master/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp#L933

Matter commit regarding Soft-AP rendezvous mode: https://github.com/project-chip/connectedhomeip/commit/5f94d380c22c46267c521a008aff36653b902ecb

shubhamdp commented 1 year ago

Current code only starts AP and communication after that is not there. Soft AP commissioning would require adding support for Matter Vendor-specific IE, that is not there yet.

And the commit you shared... both soft ap and wifi code was getting compiled and soft ap related code is not required if you have BLE, so this commit just disabled the softap feature at compile time.

dhrishi commented 1 year ago

@JonathanWitthoeft Soft-AP based commissioning, even though present in the spec, is not fully supported in the upstream connectedhomeip since Matter v1.0 release. There are no chances of supporting this in the subsequent releases too. AFAIK, there's a Wi-Fi effort going on to deprecate Soft-AP and instead use some other modern approach. At this moment, I am not sure of the timelines about it getting into the spec version.

I will close this as the question is answered.