Difference between revisions of "PinePhone MMS with Matrix"

From PINE64
Jump to navigation Jump to search
m (Update Mobian Wiki link)
 
(24 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This is a possible way to get mms fully working by running a localhost matrix server, a bridge between mmsd and matrix, and the fractal matrix client to interact with them. Most of this should be cut and pastable.  
[[File:Pinephonematrixfractalmmsscreenshot.jpg|thumb|upright=1.2|Screenshot of fractal displaying an MMS conversation]]
 
The one known way to get MMS fully (meaning pictures and group messages) working is by relaying all SMS and MMS to a matrix server and using a matrix client to interact with them. https://gitlab.com/untidylamp/mmmpuppet is the bridge used here
 
Outgoing messages over the max size are sent as a link. The link will not resolve if matrix is hosted on the PinePhone itself, so resize your images. An easy way might be to take a screenshot of your image viewer and send that image instead.
 
This method works with a local-to-the-pinephone matrix server but you could instead use a public one on the internet. Free accounts on matrix.org should work fine for example. Sleep may need to be disabled for non-local servers or the bridge can get stuck.


=Install packages=
=Install packages=
start with a nice and up to date danctnix arch arm pinephone install, mine is from April 20 2021. Ssh into the pinephone and then run this to install all the needed packages
==Arch==
Start with a nice and up-to-date Danctnix' Arch ARM PinePhone installation, mine is from April 20 2021. SSH into the PinePhone and then run this to install all the needed packages


<pre>
<pre>
Line 8: Line 15:
</pre>
</pre>


=Set up Matrix Synapse=
Start the service
 
<pre>
sudo systemctl enable synapse
sudo systemctl start synapse
</pre>
 
==Mobian==


Make a new config with the server name set to local host.  
Flash a fresh mobian nightly (Tested September 28 2021) and install the following:
 
<pre>sudo apt install matrix-synapse fractal mmsd-tng python3-matrix-nio python3-vobject python3-aiofiles git</pre>
 
=Set up Matrix Synapse on localhost=
 
Skip this if you will be using a remote homeserver. Make a new config with the server name set to local host.  
 
==Arch==


<pre>
<pre>
Line 17: Line 39:
</pre>
</pre>


Start the service and add a new user.
<pre>
sudo vi /usr/lib/systemd/user/matrix-synapse.service
</pre>
 
<pre>
[Unit]
Description=Multimedia Messaging Service Daemon
After=ModemManager.service
 
[Service]
ExecStart= python3 -m synapse.app.homeserver --config-path=/etc/matrix/homeserver.yaml
 
Restart=on-failure
RestartSec=10s
 
[Install]
WantedBy=default.target
</pre>
 
Start the service
<pre>
systemctl enable matrix-synapse --user
systemctl start matrix-synapse --user


</pre>
==mobian==
<pre>
<pre>
cd /etc/synapse/
cd /etc/matrix-synapse/
sudo systemctl enable synapse
sudo rm homeserver.*
sudo systemctl start synapse
sudo python3 -m synapse.app.homeserver --server-name localhost --config-path homeserver.yaml --generate-config --report-stats=no
register_new_matrix_user -c homeserver.yaml http://localhost:8008 # New user name and pw will both be pinephone
sudo service matrix-synapse start
register_new_matrix_user -c homeserver.yaml http://localhost:8008 # New user name and pw will both be mmsbridge
</pre>
 
== Add new matrix users ==
in /etc/synapse/ (arch) or /etc/matrix-synapse/ (mobian)
 
<pre>
register_new_matrix_user -c homeserver.yaml http://localhost:8008 # New user name and pw will both be pp
register_new_matrix_user -c homeserver.yaml http://localhost:8008 # New user name and pw will both be mm
</pre>
</pre>


Open fractal and log into the homeserver at http://localhost:8008 with username pinephone and password pinephone
Open fractal and log into the homeserver at http://localhost:8008 with username pp and password pp


=Install MMSD=
=Set up MMSD=
Grab the git repo and install it
 
==from git (historical, no longer needed, mmsdtng commonly packaged)==
Grab the git repository and install it:


<pre>
<pre>
Line 41: Line 97:
sudo meson install -C _build
sudo meson install -C _build
</pre>
</pre>
==Settings for tmobile==
This config works for me


<pre>
mkdir -p ~/.mms/modemmanager/
vi ~/.mms/modemmanager/ModemManagerSettings
[Modem Manager]
CarrierMMSC=http://mms.msg.eng.t-mobile.com/mms/wapenc
MMS_APN=fast.t-mobile.com
CarrierMMSProxy=NULL
AutoProcessOnConnection=true
</pre>
==Start MMSD ModemManager service==
<pre>
<pre>
sudo vi /usr/lib/systemd/user/mmsd-mm.service
sudo vi /usr/lib/systemd/user/mmsd-mm.service
Line 80: Line 121:
</pre>
</pre>


=Install mms bridge=
==Settings for T-Mobile==
This config works for me
 
After starting mmsdtng the first time it should generate a config. Edit the following 3 options:
<pre>
vi ~/.mms/modemmanager/ModemManagerSettings
 
CarrierMMSC=http://mms.msg.eng.t-mobile.com/mms/wapenc
MMS_APN=fast.t-mobile.com
AutoProcessSMSWAP=true
</pre>
 
==Restart MMSD ModemManager service==
 
<pre>
systemctl restart mmsdtng
</pre>
 
=Install MMS bridge=
Grab it from git and put things in places
Grab it from git and put things in places


Line 93: Line 152:
</pre>
</pre>


==Configure mms bridge==
==Configure MMS bridge==
This will mostly take care of editing the config for you
This will mostly take care of editing the config for you if you are running a local matrix server.


<pre>
<pre>
sed -i 's^"https://matrix-client.matrix.org"^"http://localhost:8008"^' $HOME/.config/mmm/conf.json
sed -i 's^"https://matrix-client.matrix.org"^"http://localhost:8008"^' $HOME/.config/mmm/conf.json
sed -i 's^"@bot_account:matrix.org"^"@mmsbridge:localhost"^' $HOME/.config/mmm/conf.json
sed -i 's^"@bot_account:matrix.org"^"@mm:localhost"^' $HOME/.config/mmm/conf.json
sed -i 's^"Change_me"^"mmsbridge"^' $HOME/.config/mmm/conf.json
sed -i 's^"Change_me"^"mm"^' $HOME/.config/mmm/conf.json
sed -i 's^"@your_accounts:matrix.org"^"@pinephone:localhost"^' $HOME/.config/mmm/conf.json
sed -i 's^"@your_accounts:matrix.org"^"@pp:localhost"^' $HOME/.config/mmm/conf.json
</pre>
</pre>


Line 112: Line 171:
</pre>
</pre>


 
Now we need to run it once to process the config file and remove secrets (It will say it has done this and exit on first run)
Now we need to run it once to process the config file and remove secrets


<pre>
<pre>
Line 137: Line 195:
</pre>
</pre>


==Set up mms bridge service==
==Set up MMS bridge service==


Make systemd unit
Make systemd unit
Line 178: Line 236:
</pre>
</pre>


=Done=
=Remove chatty=
At this point if you get a message a new room should be created by the bridge bot which you will be invited to. Needs more testing to find problems. Outgoing works for replies but I can't seem to find the 'set topic' button so new rooms can't be created that the mms bridge can use. The ones the bridge creates work fine though.
for arch do pacman stuff to remove chatty
 
mobian
<pre>
apt remove chatty
</pre>
 
=Don't forget to enable data=
 
You can get sms but not mms with mobile data off
 
=Launch fractal=
 
Log in with this homeserver
 
<pre>http://localhost:8008</pre>
 
username <pre>pp</pre> and password <pre>pp</pre>


I have gotten a test sms through this so far, and a test mms has not arrived yet.
Logins are not saved. You need to add a new item named login to the gnome keyring manually to fix it. See: https://wiki.mobian.org/doku.php?id=fractal


Incoming and outgoing images did work with matrix on a namecheap vps with fractal on mobian so I think it can be made to work here.
Basically apt install seahorse, open "passwords and keys" in the app drawer, click new (plus), select password keyring, and name it "login" (all lower no quotes). Then autologin will work as it should.


matrix-synapse 1.29.0-1, fractal 4.4.0-2, kop316 mmsd v0.3 -- Works, but images don't go through.
=Done=
At this point if you get a message a new room should be created by the bridge bot which you will be invited to. You can start a new conversation by creating a new room, setting the topic with phone numbers of participants, and then inviting the mm user. See the mmmpuppet readme for examples.


On mobian I'm using matrix-synapse-py3 1.30.0+bionic1 (on a remote VPS server), fractal 4.4.0-2 (and saving the login actually works), kop316 mmsd 0.1-2.2, and images DO go through.
=Other clients=


Going to try to downgrade mmsd and see if that helps... It does not. Might be worth trying a newer synapse on arch through pip. Maybe some support libs are missing? I'm working on redoing all of this for mobian.
quaternion also seems to work but has clunky UI issues. Might work better with scaling

Latest revision as of 11:33, 23 February 2022

Screenshot of fractal displaying an MMS conversation

The one known way to get MMS fully (meaning pictures and group messages) working is by relaying all SMS and MMS to a matrix server and using a matrix client to interact with them. https://gitlab.com/untidylamp/mmmpuppet is the bridge used here

Outgoing messages over the max size are sent as a link. The link will not resolve if matrix is hosted on the PinePhone itself, so resize your images. An easy way might be to take a screenshot of your image viewer and send that image instead.

This method works with a local-to-the-pinephone matrix server but you could instead use a public one on the internet. Free accounts on matrix.org should work fine for example. Sleep may need to be disabled for non-local servers or the bridge can get stuck.

Install packages

Arch

Start with a nice and up-to-date Danctnix' Arch ARM PinePhone installation, mine is from April 20 2021. SSH into the PinePhone and then run this to install all the needed packages

sudo pacman -Sy matrix-synapse fractal python-matrix_client python-gobject git meson ninja base-devel python-matrix-nio python-dbus

Start the service

sudo systemctl enable synapse
sudo systemctl start synapse

Mobian

Flash a fresh mobian nightly (Tested September 28 2021) and install the following:

sudo apt install matrix-synapse fractal mmsd-tng python3-matrix-nio python3-vobject python3-aiofiles git

Set up Matrix Synapse on localhost

Skip this if you will be using a remote homeserver. Make a new config with the server name set to local host.

Arch

cd /etc/synapse/
sudo python -m synapse.app.homeserver --server-name localhost --config-path homeserver.yaml --generate-config --report-stats=no
sudo vi /usr/lib/systemd/user/matrix-synapse.service
[Unit]
Description=Multimedia Messaging Service Daemon
After=ModemManager.service

[Service]
ExecStart= python3 -m synapse.app.homeserver --config-path=/etc/matrix/homeserver.yaml

Restart=on-failure
RestartSec=10s

[Install]
WantedBy=default.target

Start the service

systemctl enable matrix-synapse --user
systemctl start matrix-synapse --user

mobian

cd /etc/matrix-synapse/
sudo rm homeserver.*
sudo python3 -m synapse.app.homeserver --server-name localhost --config-path homeserver.yaml --generate-config --report-stats=no
sudo service matrix-synapse start

Add new matrix users

in /etc/synapse/ (arch) or /etc/matrix-synapse/ (mobian)

register_new_matrix_user -c homeserver.yaml http://localhost:8008 # New user name and pw will both be pp
register_new_matrix_user -c homeserver.yaml http://localhost:8008 # New user name and pw will both be mm

Open fractal and log into the homeserver at http://localhost:8008 with username pp and password pp

Set up MMSD

from git (historical, no longer needed, mmsdtng commonly packaged)

Grab the git repository and install it:

cd ~
git clone https://source.puri.sm/kop316/mmsd.git
cd mmsd
meson _build
meson compile -C _build
meson test -C _build
sudo meson install -C _build
sudo vi /usr/lib/systemd/user/mmsd-mm.service

[Unit]
Description=Multimedia Messaging Service Daemon
After=ModemManager.service

[Service]
ExecStart=/usr/local/bin/mmsd -n -d

Restart=on-failure
RestartSec=10s

[Install]
WantedBy=default.target
sudo chmod 644 /usr/lib/systemd/user/mmsd-mm.service
systemctl enable mmsd-mm.service --user
systemctl start mmsd-mm --user

Settings for T-Mobile

This config works for me

After starting mmsdtng the first time it should generate a config. Edit the following 3 options:

vi ~/.mms/modemmanager/ModemManagerSettings

CarrierMMSC=http://mms.msg.eng.t-mobile.com/mms/wapenc
MMS_APN=fast.t-mobile.com
AutoProcessSMSWAP=true

Restart MMSD ModemManager service

systemctl restart mmsdtng

Install MMS bridge

Grab it from git and put things in places

cd ~
git clone https://gitlab.com/untidylamp/mmmpuppet.git
cd mmmpuppet
chmod +x mmmpuppet.py
sudo cp mmm*.py /usr/local/bin/
mkdir -p $HOME/.config/mmm/
cp conf.json.sample $HOME/.config/mmm/conf.json

Configure MMS bridge

This will mostly take care of editing the config for you if you are running a local matrix server.

sed -i 's^"https://matrix-client.matrix.org"^"http://localhost:8008"^' $HOME/.config/mmm/conf.json
sed -i 's^"@bot_account:matrix.org"^"@mm:localhost"^' $HOME/.config/mmm/conf.json
sed -i 's^"Change_me"^"mm"^' $HOME/.config/mmm/conf.json
sed -i 's^"@your_accounts:matrix.org"^"@pp:localhost"^' $HOME/.config/mmm/conf.json

You actually have to fill these two out yourself. I put "US" and my +1 and rest of 10 digit number.

vi  $HOME/.config/mmm/conf.json

"cell_number":      "+15554441234",
"cell_country":     "CA",

Now we need to run it once to process the config file and remove secrets (It will say it has done this and exit on first run)

/usr/local/bin/mmmpuppet.py

check it out now

cat $HOME/.config/mmm/conf.json

If it doesn't change the file to remove all the linebreaks then it didn't like it. Figure out why by looking at the log file.

cat ~/.config/mmm/mmmpuppet.log

Go fix whatever went wrong. Which should be nothing. You should have seen a message like this as output before it returns you to a prompt:

Login successful. Config updated with token. Run again to start bridge.

Set up MMS bridge service

Make systemd unit

sudo vi /usr/lib/systemd/user/mmmpuppet.service

[Unit]
Description=Starts mmmpuppet interface
After=mmsd-mm.service

[Service]
ExecStart=/usr/bin/python3 /usr/local/bin/mmmpuppet.py
Restart=on-failure
RestartSec=10s

[Install]
WantedBy=default.target

and start it

sudo chmod 644 /usr/lib/systemd/user/mmmpuppet.service
systemctl enable mmmpuppet.service --user
systemctl start mmmpuppet.service --user

done? see if services are running:

ps aux | grep mm

should show something like this even after reboot

alarm       6374  0.0  0.3 235364  7752 ?        Ssl  22:44   0:00 /usr/local/bin/mmsd -n -d
alarm       6825  9.8  2.7 224976 54188 ?        Ssl  22:52   0:05 /usr/bin/python3 /usr/local/bin/mmmpuppet.py

Remove chatty

for arch do pacman stuff to remove chatty

mobian

apt remove chatty

Don't forget to enable data

You can get sms but not mms with mobile data off

Launch fractal

Log in with this homeserver

http://localhost:8008

username

pp

and password

pp

Logins are not saved. You need to add a new item named login to the gnome keyring manually to fix it. See: https://wiki.mobian.org/doku.php?id=fractal

Basically apt install seahorse, open "passwords and keys" in the app drawer, click new (plus), select password keyring, and name it "login" (all lower no quotes). Then autologin will work as it should.

Done

At this point if you get a message a new room should be created by the bridge bot which you will be invited to. You can start a new conversation by creating a new room, setting the topic with phone numbers of participants, and then inviting the mm user. See the mmmpuppet readme for examples.

Other clients

quaternion also seems to work but has clunky UI issues. Might work better with scaling