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

Initial snap #1

Merged
merged 15 commits into from
Aug 27, 2023
Merged

Initial snap #1

merged 15 commits into from
Aug 27, 2023

Conversation

MonicaisHer
Copy link
Contributor

@MonicaisHer MonicaisHer commented Aug 22, 2023

Testing

snap remove --purge matter-mqtt-bridge 
snap install ./matter-mqtt-bridge_1.0.0-alpha_amd64.snap --dangerous
snap connect matter-mqtt-bridge:avahi-control 
snap set matter-mqtt-bridge server-address="tcp://localhost:1883"
snap set matter-mqtt-bridge topic-prefix="matter-bridge-version0.1"
snap start --enable matter-mqtt-bridge

Open a new terminal to subscribe messages:

mosquitto_sub -h localhost -t "#" -v

Open a new terminal to pair and control the app:

sudo chip-tool pairing onnetwork 110 20202021
sudo chip-tool onoff toggle 110 3

Check the messages:

$ mosquitto_sub -h localhost -t "#" -v
matter-bridge-version0.1/3/OnOff/OnOff {
        "attributeId" : 0,
        "clusterId" : 6,
        "command" : "on",
        "deviceName" : "Light 1",
        "endpointId" : 3,
        "location" : "Office",
        "parentEndpointId" : 1,
        "zone" : ""
}

snap/snapcraft.yaml Outdated Show resolved Hide resolved
snap/hooks/configure Outdated Show resolved Hide resolved
snap/snapcraft.yaml Outdated Show resolved Hide resolved
@MonicaisHer MonicaisHer marked this pull request as ready for review August 23, 2023 12:49
app/bridge-app/linux/entrypoint.sh Outdated Show resolved Hide resolved
snap/snapcraft.yaml Show resolved Hide resolved
app/bridge-app/linux/Dockerfile Outdated Show resolved Hide resolved
app/bridge-app/linux/BUILD.gn Outdated Show resolved Hide resolved
snap/snapcraft.yaml Show resolved Hide resolved
snap/hooks/configure Show resolved Hide resolved
snap/local/bin/run.sh Outdated Show resolved Hide resolved
@farshidtz
Copy link
Member

farshidtz commented Aug 24, 2023

I get the following error after starting the service: error while loading shared libraries: libpaho-mqttpp3.so.1: cannot open shared object file: No such file or directory

sudo snap install --dangerous *.snap
sudo snap connect matter-mqtt-bridge:avahi-control 
snap set matter-mqtt-bridge server-address="tcp://localhost:1883".
snap start matter-mqtt-bridge
2023-08-24T11:17:15+02:00 systemd[1]: Started snap.matter-mqtt-bridge.matter-mqtt-bridge.service - Service for snap application matter-mqtt-bridge.matter-mqtt-bridge.
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37596]: ++ snapctl get server-address
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37569]: + export SERVER_ADDRESS=tcp://localhost:1883
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37569]: + SERVER_ADDRESS=tcp://localhost:1883
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37601]: ++ snapctl get topic-prefix
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37569]: + export TOPIC_PREFIX=
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37569]: + TOPIC_PREFIX=
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37606]: ++ snapctl get args
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37569]: + ARGS=
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37569]: + /snap/matter-mqtt-bridge/x2/bin/chip-bridge-app
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37611]: /snap/matter-mqtt-bridge/x2/bin/chip-bridge-app: error while loading shared libraries: libpaho-mqttpp3.so.1: cannot open shared object file: No such file or directory
2023-08-24T11:17:15+02:00 systemd[1]: snap.matter-mqtt-bridge.matter-mqtt-bridge.service: Main process exited, code=exited, status=127/n/a
2023-08-24T11:17:15+02:00 systemd[1]: snap.matter-mqtt-bridge.matter-mqtt-bridge.service: Failed with result 'exit-code'.

$ snap run --shell matter-mqtt-bridge.matter-mqtt-bridge
$ ldd /snap/matter-mqtt-bridge/current/bin/chip-bridge-app 
	linux-vdso.so.1 (0x00007ffecb59e000)
	libpaho-mqttpp3.so.1 => not found
	libpaho-mqtt3a.so.1 => not found
	libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007f1bdfbfa000)
	libgio-2.0.so.0 => /lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f1bdfa21000)
	libgobject-2.0.so.0 => /lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f1bdf9c1000)
	libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f1bdf885000)
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1bdf65b000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1bdf574000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1bdf554000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1bdf32c000)
	libgmodule-2.0.so.0 => /lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f1bdf325000)
	libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f1bdf307000)
	libmount.so.1 => /lib/x86_64-linux-gnu/libmount.so.1 (0x00007f1bdf2c3000)
	libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f1bdf297000)
	libffi.so.8 => /lib/x86_64-linux-gnu/libffi.so.8 (0x00007f1bdf28a000)
	libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f1bdf214000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f1be039d000)
	libblkid.so.1 => /lib/x86_64-linux-gnu/libblkid.so.1 (0x00007f1bdf1db000)
	libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007f1bdf144000)

@MonicaisHer
Copy link
Contributor Author

MonicaisHer commented Aug 24, 2023

I get the following error after starting the service: error while loading shared libraries: libpaho-mqttpp3.so.1: cannot open shared object file: No such file or directory

sudo snap install --dangerous *.snap
sudo snap connect matter-mqtt-bridge:avahi-control 
snap set matter-mqtt-bridge server-address="tcp://localhost:1883".
snap start matter-mqtt-bridge
2023-08-24T11:17:15+02:00 systemd[1]: Started snap.matter-mqtt-bridge.matter-mqtt-bridge.service - Service for snap application matter-mqtt-bridge.matter-mqtt-bridge.
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37596]: ++ snapctl get server-address
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37569]: + export SERVER_ADDRESS=tcp://localhost:1883
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37569]: + SERVER_ADDRESS=tcp://localhost:1883
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37601]: ++ snapctl get topic-prefix
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37569]: + export TOPIC_PREFIX=
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37569]: + TOPIC_PREFIX=
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37606]: ++ snapctl get args
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37569]: + ARGS=
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37569]: + /snap/matter-mqtt-bridge/x2/bin/chip-bridge-app
2023-08-24T11:17:15+02:00 matter-mqtt-bridge.matter-mqtt-bridge[37611]: /snap/matter-mqtt-bridge/x2/bin/chip-bridge-app: error while loading shared libraries: libpaho-mqttpp3.so.1: cannot open shared object file: No such file or directory
2023-08-24T11:17:15+02:00 systemd[1]: snap.matter-mqtt-bridge.matter-mqtt-bridge.service: Main process exited, code=exited, status=127/n/a
2023-08-24T11:17:15+02:00 systemd[1]: snap.matter-mqtt-bridge.matter-mqtt-bridge.service: Failed with result 'exit-code'.

Did you perform a clean install or a refresh on the old version?

The issue can not be reproduced on my machine:

$ snap run --shell matter-mqtt-bridge.matter-mqtt-bridge
$ ldd /snap/matter-mqtt-bridge/current/bin/chip-bridge-app
        linux-vdso.so.1 (0x00007ffc51c8c000)
        libpaho-mqttpp3.so.1 => /usr/local/lib/libpaho-mqttpp3.so.1 (0x00007f409c714000)
        libpaho-mqtt3a.so.1 => /usr/local/lib/libpaho-mqtt3a.so.1 (0x00007f409c6e5000)
        libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007f409c2a3000)
        libgio-2.0.so.0 => /lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007f409c0ca000)
        libgobject-2.0.so.0 => /lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f409c068000)
        libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f409bf2e000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f409bd04000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f409bc1d000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f409bbfd000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f409b9d5000)
        libpaho-mqtt3as.so.1 => /usr/local/lib/libpaho-mqtt3as.so.1 (0x00007f409b99f000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f409cb90000)
        libgmodule-2.0.so.0 => /lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f409b998000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f409b97c000)
        libmount.so.1 => /lib/x86_64-linux-gnu/libmount.so.1 (0x00007f409b938000)
        libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007f409b90c000)
        libffi.so.8 => /lib/x86_64-linux-gnu/libffi.so.8 (0x00007f409b8ff000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f409b887000)
        libssl.so.3 => /lib/x86_64-linux-gnu/libssl.so.3 (0x00007f409b7e3000)
        libblkid.so.1 => /lib/x86_64-linux-gnu/libblkid.so.1 (0x00007f409b7ac000)
        libpcre2-8.so.0 => /lib/x86_64-linux-gnu/libpcre2-8.so.0 (0x00007f409b715000)
$ echo $LD_LIBRARY_PATH
/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void

The reason for causing different behaviors on different machines is still unclear

@farshidtz
Copy link
Member

farshidtz commented Aug 24, 2023

Did you perform a clean install or a refresh on the old version?

Same with both. Why should it make a difference? The snap has no install/refresh hooks.
Note that I installed it with confinement.

snap/snapcraft.yaml Outdated Show resolved Hide resolved
MonicaisHer and others added 2 commits August 25, 2023 10:43
Co-authored-by: Farshid Tavakolizadeh <email@farshid.ws>
Copy link
Member

@farshidtz farshidtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Works as expected.

I noticed the following error and AppArmor denials, but they don't seem to affect functionality of the text cases.

2023-08-25T13:42:31+02:00 matter-mqtt-bridge.matter-mqtt-bridge[58118]: [1692963751.168702][58118:58119] CHIP:DL: TRACE: Bus acquired for name MATTER-3840
2023-08-25T13:42:31+02:00 matter-mqtt-bridge.matter-mqtt-bridge[58118]: [1692963751.168752][58118:58119] CHIP:DL: CREATE service object at /chipoble/e306/service
2023-08-25T13:42:31+02:00 matter-mqtt-bridge.matter-mqtt-bridge[58118]: [1692963751.168917][58118:58119] CHIP:DL: Create characteristic object at /chipoble/e306/service/c1
2023-08-25T13:42:31+02:00 matter-mqtt-bridge.matter-mqtt-bridge[58118]: [1692963751.169052][58118:58119] CHIP:DL: Create characteristic object at /chipoble/e306/service/c2
2023-08-25T13:42:31+02:00 matter-mqtt-bridge.matter-mqtt-bridge[58118]: [1692963751.169112][58118:58119] CHIP:DL: CHIP BTP C1 /chipoble/e306/service
2023-08-25T13:42:31+02:00 matter-mqtt-bridge.matter-mqtt-bridge[58118]: [1692963751.169115][58118:58119] CHIP:DL: CHIP BTP C2 /chipoble/e306/service
2023-08-25T13:42:31+02:00 matter-mqtt-bridge.matter-mqtt-bridge[58118]: [1692963751.169117][58118:58119] CHIP:DL: CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING is FALSE
2023-08-25T13:42:31+02:00 matter-mqtt-bridge.matter-mqtt-bridge[58118]: [1692963751.169997][58118:58119] CHIP:DL: FAIL: Error getting object manager client: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.164" (uid=0 pid=58118 comm="/snap/matter-mqtt-bridge/x1/bin/chip-bridge-app" label="snap.matter-mqtt-bridge.matter-mqtt-bridge (enforce)") interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" error name="(unset)" requested_reply="0" destination=":1.12" (uid=0 pid=1296 comm="/usr/lib/bluetooth/bluetoothd" label="unconfined")
= Seccomp =
Time: 2023-08-25T13:4
Log: auid=4294967295 uid=0 gid=0 ses=4294967295 subj=snap.matter-mqtt-bridge.matter-mqtt-bridge pid=57974 comm="gmain-matter" exe="/snap/matter-mqtt-bridge/x1/bin/chip-bridge-app" sig=0 arch=c000003e 314(sched_setattr) compat=0 ip=0x7fb696f4ca3d code=0x50000
Syscall: sched_setattr
Suggestion:
* add 'process-control' to 'plugs'

= AppArmor =
Time: 2023-08-25T13:4
Log: apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name=":1.12" pid=57974 label="snap.matter-mqtt-bridge.matter-mqtt-bridge" peer_pid=1296 peer_label="unconfined"
DBus access

= Seccomp =
Time: 2023-08-25T13:4
Log: auid=4294967295 uid=0 gid=0 ses=4294967295 subj=snap.matter-mqtt-bridge.matter-mqtt-bridge pid=58118 comm="gmain-matter" exe="/snap/matter-mqtt-bridge/x1/bin/chip-bridge-app" sig=0 arch=c000003e 314(sched_setattr) compat=0 ip=0x7f00ef6dda3d code=0x50000
Syscall: sched_setattr
Suggestion:
* add 'process-control' to 'plugs'

= AppArmor =
Time: 2023-08-25T13:4
Log: apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name=":1.12" pid=58118 label="snap.matter-mqtt-bridge.matter-mqtt-bridge" peer_pid=1296 peer_label="unconfined"
DBus access

app/bridge-app/linux/main.cpp Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@farshidtz
Copy link
Member

Note that there is no MQTT client reconnection logic, so if the connection to broker is lost for a moment, the client will not reconnect. It needs to have auto reconnection set.

MonicaisHer and others added 2 commits August 25, 2023 15:32
Co-authored-by: Farshid Tavakolizadeh <farshid.tavakolizadeh@canonical.com>
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@farshidtz farshidtz merged commit ba0eee0 into canonical:main Aug 27, 2023
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

Successfully merging this pull request may close these issues.

2 participants