Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when commissioning and communicating with the app (Failed to parse IP address) #15

Closed
Diegorro98 opened this issue Sep 27, 2022 · 11 comments

Comments

@Diegorro98
Copy link

Diegorro98 commented Sep 27, 2022

I'm trying to perform the commissioning process through this sample app, but it stays at the "Connecting with Matter device" during some long time and ends with a message that says something like "We have problems communicating with GHSAFM" and in the sample app there wasn't any device.

Investigating, I found that the app crashes with the following stacktrace:

2022-09-27 00:22:10.656 28832-28832/com.google.homesampleapp.default E/CTL: Failed to parse IP address.
2022-09-27 00:22:10.684 28832-28832/com.google.homesampleapp.default E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.google.homesampleapp.default, PID: 28832
    chip.devicecontroller.ChipDeviceControllerException: ../../src/controller/java/CHIPDeviceController-JNI.cpp:328: CHIP Error 0x0000002F: Invalid argument
        at chip.devicecontroller.ChipDeviceController.establishPaseConnectionByAddress(Native Method)
        at chip.devicecontroller.ChipDeviceController.establishPaseConnection(ChipDeviceController.java:135)
        at com.google.homesampleapp.chip.ChipClient.awaitEstablishPaseConnection(ChipClient.kt:113)
        at com.google.homesampleapp.commissioning.AppCommissioningService$onCommissioningRequested$1.invokeSuspend(AppCommissioningService.kt:93)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8751)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

As I saw that it had a problem with parsing the IP address, I debugged the app to obtain the values at com.google.homesampleapp.chip.ChipClient.awaitEstablishPaseConnection(ChipClient.kt:113):

deviceId = 15
ipAddress = "fe80::1252:1cff:fe62:b430%wlan0"
port = 5540
setupPinC0de = 71410408

Full Logcat

Although this problem, the device seems to be at the Google Home App, but I cannot toggle the light of the device (It pops a Toast notification saying that there was an error).

@mauimauer
Copy link
Collaborator

mauimauer commented Sep 27, 2022

Taking a closer look. For the issue in the Google Home App, can you confirm you have an eligible Home device connected to the same account (for now this is required to control devices via the Home app)?

How is your Android device connected to your network? The IP indicated is an IPv6 link-local address.

@Diegorro98
Copy link
Author

@mauimauer Yes, I flashed the light example from the esp-matter repo, and I created the integration at the Google home developer console specifying that the device type is a light.

My Android device is connected to via WiFi.

@mauimauer
Copy link
Collaborator

I am unable to directly reproduce the issue that you are seeing, however it is clear the IP as passed down is being rejected by the native matter library.

Could you try a rebuild of the app, replacing the "%wlan0" at the end?
Essentially replace
chipDeviceController.establishPaseConnection(deviceId, ipAddress, port, setupPinCode) in ChipClient.kt with
chipDeviceController.establishPaseConnection(deviceId, ipAddress.replace("%wlan0", ""), port, setupPinCode)

just so we can confirm this is indeed caused by the interface suffix and not the fact that this is a link-local address.

@Diegorro98
Copy link
Author

Diegorro98 commented Sep 27, 2022

Done!
Now commissioning process works, creates the device inside de sample app, but just like in the Google Home App, toggling the device doesn't do anything at the esp32.
These are remarkable errors from the logcat:

2022-09-27 19:00:09.808 12737-12737/com.google.homesampleapp.default E/ClustersHelper: Can't get connectedDevicePointer. Probably because of DNS-SD flakiness :-(.

2022-09-27 19:01:43.199 14980-15052/com.google.homesampleapp.default E/DIS: Operational discovery failed for 0x0000000000000012: 32
2022-09-27 19:01:43.201 14980-15052/com.google.homesampleapp.default E/ChipClient$getConnectedDevicePointer: Unable to get connected device with nodeId 18. mDNS flakiness???

2022-09-27 19:01:43.204 14980-14980/com.google.homesampleapp.default E/ClustersHelper: Can't get connectedDevicePointer.
2022-09-27 19:01:43.205 14980-14980/com.google.homesampleapp.default E/HomeViewModel$runDevicesPeriodicPing: runDevicesPeriodicUpdate: flakiness with mDNS

If it is useful, I have used this device with chip-tool and HomeAssistant Matter integration.

@Diegorro98
Copy link
Author

About the reproducibility of the issue, I can give you my system spececifications:

  • Device: Samsung Galaxy S21 FE 5G (SM-G990B/DS)
  • Android version: 12
  • Google Play services: 22.33.16 (190408-474895102)

I don't know which other system spececifications can I give you in order to help to reproduce the issue.

@lpfsue
Copy link

lpfsue commented Sep 28, 2022

Hi, I see the same issue on my test-setup since today (it still worked until yesterday from 22.09 on) with the exact same components, my chip device impl and my custom sample app build). So I can only assume something on the play-service side must have changed/updated?

  • Device: Nexus 5X, Android 8.1.0 (However have seen the same on my Pixel 3A)
  • Google Play services: 22.33.16 (190408-474895102)

Replacing the network interface suffix does work for pairing. Once pairing is completed I can also send control commands using the App, e.g. turning the device on/off .

I noticed that commissioning the device onto the Google fabric always works (e.g. with the Google Home App). But using this sample app to also commission a custom fabric after the Google fabric has been commissioned now fails.

@mauimauer
Copy link
Collaborator

Hmm thanks for the comment @lpfsue, did your ipAddress end up being a link local v6 address too (starting with fe80)?
I think it's safe to go ahead with a simple change to scrub addresses from any interface suffixes fo now.

@pierredelisle
Copy link
Contributor

Sebastian's PR #17 has been merged to temporarily fix this issue.
Note that the real fix will happen with this PR: project-chip/connectedhomeip#22945

@Diegorro98
Copy link
Author

Done! Now commissioning process works, creates the device inside de sample app, but just like in the Google Home App, toggling the device doesn't do anything at the esp32. These are remarkable errors from the logcat:

2022-09-27 19:00:09.808 12737-12737/com.google.homesampleapp.default E/ClustersHelper: Can't get connectedDevicePointer. Probably because of DNS-SD flakiness :-(.

2022-09-27 19:01:43.199 14980-15052/com.google.homesampleapp.default E/DIS: Operational discovery failed for 0x0000000000000012: 32
2022-09-27 19:01:43.201 14980-15052/com.google.homesampleapp.default E/ChipClient$getConnectedDevicePointer: Unable to get connected device with nodeId 18. mDNS flakiness???

2022-09-27 19:01:43.204 14980-14980/com.google.homesampleapp.default E/ClustersHelper: Can't get connectedDevicePointer.
2022-09-27 19:01:43.205 14980-14980/com.google.homesampleapp.default E/HomeViewModel$runDevicesPeriodicPing: runDevicesPeriodicUpdate: flakiness with mDNS

If it is useful, I have used this device with chip-tool and HomeAssistant Matter integration.

I think that I'm going to move this problem to another issue because it might be unrelated to this one.

@mauimauer
Copy link
Collaborator

@Diegorro98 our temporary workaround just ensure the ipAddress can be parsed by the native matter library. However, especially if your controlling device (your smartphone) has more than one interface (wifi & cellular) with link local addressing it might still fail due to the library now being unable to select the correct interface. We're awaiting resolution of project-chip/connectedhomeip#22945 and will then move to update our sample app to support your case.

@Diegorro98
Copy link
Author

@mauimauer I didn't know, should I keep this one open instead of opening a new one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants