Github messages for voidlinux
 help / color / mirror / Atom feed
From: jjsullivan5196 <jjsullivan5196@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] pinephone: add support for modem setup and audio routing.
Date: Sat, 06 Feb 2021 08:15:39 +0100	[thread overview]
Message-ID: <20210206071539.UpgHMbylY9FWiP97_oFKbiTeqsLNx-WVePd97xYIme8@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-25084@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 3560 bytes --]

There is an updated pull request by jjsullivan5196 against master on the void-packages repository

https://github.com/jjsullivan5196/void-packages pinephone-qol
https://github.com/void-linux/void-packages/pull/25084

pinephone: add support for modem setup and audio routing.
This pull adds the necessary components for 4G modem usage, with the following use-cases in mind:

- Configure audio setup to and from modem
- Make and receive calls
- Send and read SMS
- Use mobile broadband/cellular data
- Wake-on-Modem (for calls and texts)

For now I've tested this with ModemManager+NetworkManager, but this also provides the groundwork for environments that use `ofono` (or just plain AT commands with `atinout` or `screen`, if you feel clever :^) )

To get started, you first need to run `pinephone-modem-setup` once as root to do the initial modem configuration. (chances are postmarketOS already did this if you booted the phone once, but this might need to be done again incase of potential data loss)

Some use-cases might require further configuration of software (eg specific to NetworkManager) but the setup script should do most of the needed work. Make sure modem is powered up by running `echo 1 > /sys/class/modem-power/modem-power/device/powered_blocking` Some examples of usage that I've tested below:

Read sms with `mmcli`
```sh
$ mmcli -s '/org/freedesktop/ModemManager1/SMS/2'
  -----------------------------------
  Content    |              number: '+5555555555'
             |                text: 'Test'
  -----------------------------------
  Properties |            PDU type: 'deliver'
             |               state: 'received'
             |             storage: 'me'
             |                smsc: '+919810051829'
             |           timestamp: '160808142935+05'
```

Sample script for answering calls, using ModemManager dbus interface. Audio is setup thru `alsaucm`
```sh
#!/bin/bash

MM_IFACE="org.freedesktop.ModemManager1"
MATCH_CALLS="type='signal',sender='${MM_IFACE}',interface='${MM_IFACE}.Modem.Voice',member='CallAdded'"

do_accept() {
	while read TYPE TIME SENDER HEADER
	do
		if [[ "$HEADER" = *"Modem.Voice"* ]]; then
			read TYPE _P OBJ
			OBJ=$(echo "${OBJ}" | tr -d '"')
			echo "Pickup ${OBJ}"

			alsaucm \
				open PinePhone \
				set _verb 'Voice Call' \
				set _enadev 'Mic' \
				set _enadev 'Earpiece'
			
			dbus-send \
				--system \
				--dest="${MM_IFACE}" \
				--print-reply \
				"${OBJ}" \
				"${MM_IFACE}.Call.Accept"
		else
			read
		fi
	done
}

dbus-monitor --system "${MATCH_CALLS}" | do_accept
```

Add a NetworkManager connection for LTE (sub `<operator_apn>` for your carrier's data APN)
```sh
$ nmcli c add type gsm ifname '*' con-name LTE apn <operator_apn>
```

For Wake-on-Modem: I tested by doing `loginctl suspend` from a sway session, then calling the phone. It wakes up within 2 rings.

fwiw: these examples are only good for making sure the hardware/software interface works. More work still needs to be done to get some telephony front-end software in the repo, like #24538 Sxmo also should work out-of-the box with the NetworkManager+ModemManager pair https://git.sr.ht/~mil/sxmo-docs

For any concerns about the `COPYING` file, the [original author approves](https://matrix.to/#/!ToPtLQdvveNEbXcHqE:fam-ribbers.com/$YEfAo9NI3WPApA1QbhmQrhwizjmlYXnLkMjby4PU7z4?via=matrix.org&via=feneas.org&via=kde.org).

A patch file from https://github.com/void-linux/void-packages/pull/25084.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-pinephone-qol-25084.patch --]
[-- Type: text/x-diff, Size: 6819 bytes --]

From 0d22968acd2e0321afd768099bdc03064ec2a517 Mon Sep 17 00:00:00 2001
From: John Sullivan <jsullivan@csumb.edu>
Date: Fri, 25 Sep 2020 00:44:17 -0700
Subject: [PATCH 1/3] New package: atinout-0.9.1

---
 srcpkgs/atinout/template | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
 create mode 100644 srcpkgs/atinout/template

diff --git a/srcpkgs/atinout/template b/srcpkgs/atinout/template
new file mode 100644
index 00000000000..e292bf9c9c7
--- /dev/null
+++ b/srcpkgs/atinout/template
@@ -0,0 +1,14 @@
+# Template file for 'atinout'
+pkgname=atinout
+version=0.9.1
+revision=1
+build_style=gnu-makefile
+short_desc="Send AT commands to modem and print responses"
+maintainer="John Sullivan <jsullivan@csumb.edu>"
+license="GPL-3.0-or-later"
+homepage="http://atinout.sourceforge.net"
+distfiles="${SOURCEFORGE_SITE}/project/${pkgname}/v${version}/${pkgname}-${version}.tar.gz"
+checksum=4d15c8288aca414e11cd304686b172696104c5e42bf776300311c005634854a2
+
+# Disable -Werror (GCC9+ turns switch fallthrough into error)
+CFLAGS="-W -Wall -Wextra -DVERSION=\\\"${version}\\\" -g"

From affc562d9d3302025dbe9cadf823b15bc4e522c8 Mon Sep 17 00:00:00 2001
From: John Sullivan <jsullivan@csumb.edu>
Date: Fri, 5 Feb 2021 21:31:03 -0800
Subject: [PATCH 2/3] New package: pinephone-utils-0.1

---
 srcpkgs/pinephone-utils/files/COPYING         |  6 ++++
 .../patches/vendor/modem-rules.patch          |  8 +++++
 srcpkgs/pinephone-utils/template              | 34 +++++++++++++++++++
 3 files changed, 48 insertions(+)
 create mode 100644 srcpkgs/pinephone-utils/files/COPYING
 create mode 100644 srcpkgs/pinephone-utils/patches/vendor/modem-rules.patch
 create mode 100644 srcpkgs/pinephone-utils/template

diff --git a/srcpkgs/pinephone-utils/files/COPYING b/srcpkgs/pinephone-utils/files/COPYING
new file mode 100644
index 00000000000..f70a8d3fd2e
--- /dev/null
+++ b/srcpkgs/pinephone-utils/files/COPYING
@@ -0,0 +1,6 @@
+Some files used in this package originate from postmarketOS, and are used with
+some modifications under the terms of the MIT license
+https://opensource.org/licenses/MIT
+
+see for sources:
+https://gitlab.com/postmarketOS/pmaports/-/tree/master/device/main/device-pine64-pinephone
diff --git a/srcpkgs/pinephone-utils/patches/vendor/modem-rules.patch b/srcpkgs/pinephone-utils/patches/vendor/modem-rules.patch
new file mode 100644
index 00000000000..2157c2184d0
--- /dev/null
+++ b/srcpkgs/pinephone-utils/patches/vendor/modem-rules.patch
@@ -0,0 +1,8 @@
+--- device/main/device-pine64-pinephone/90-modem-eg25.rules	2021-01-27 07:11:44.000000000 -0800
++++ srcpkgs/pinephone-utils/files/90-modem-eg25.rules	2020-09-25 01:37:55.390496779 -0700
+@@ -3,5 +3,3 @@
+ SUBSYSTEMS=="usb", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.LOCAL_ifNum}=="01", SYMLINK+="EG25.NMEA", MODE="0660"
+ SUBSYSTEMS=="usb", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.LOCAL_ifNum}=="02", SYMLINK+="EG25.AT", MODE="0660"
+ SUBSYSTEMS=="usb", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.LOCAL_ifNum}=="03", SYMLINK+="EG25.MODEM", MODE="0660"
+-
+-ACTION=="add", SUBSYSTEM=="tty", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.LOCAL_ifNum}=="02", RUN+="/usr/bin/pinephone_setup-modem '%E{DEVNAME}'"
diff --git a/srcpkgs/pinephone-utils/template b/srcpkgs/pinephone-utils/template
new file mode 100644
index 00000000000..0444fb51b9f
--- /dev/null
+++ b/srcpkgs/pinephone-utils/template
@@ -0,0 +1,34 @@
+# Template file for 'pinephone-utils'
+pkgname=pinephone-utils
+version=0.1
+revision=1
+archs="aarch64*"
+create_wrksrc=yes
+depends="alsa-ucm-conf"
+short_desc="Scripts/configs for managing pinephone hardware"
+maintainer="John Sullivan <jsullivan@csumb.edu>"
+license="MIT"
+homepage="https://postmarketos.org/"
+
+_commit_pmos=c48037d5ed307d865903ef3aecd302f1fa4417f8
+_pmos_device='device/main/device-pine64-pinephone'
+_pmos_checkout="pmaports-${_commit_pmos}-$(echo ${_pmos_device} | tr '/' '-')/${_pmos_device}"
+
+distfiles="https://gitlab.com/postmarketOS/pmaports/-/archive/${_commit_pmos}/pmaports-${_commit_pmos}.tar.gz?path=${_pmos_device}>pmos-scripts.tar.gz"
+checksum="d73200da438b6a5641ccd0e73f778cad07301c83b5bbf7286722c74a98675d2e"
+
+do_patch() {
+	patch "${_pmos_checkout}/90-modem-eg25.rules" -slNp1 -i "${PATCHESDIR}/vendor/modem-rules.patch"
+	sed -i 's/postmarketOS/void/' "${_pmos_checkout}/setup-modem.sh"
+}
+
+do_install() {
+	vinstall "${_pmos_checkout}/90-modem-eg25.rules" 644 usr/lib/udev/rules.d
+	vinstall "${_pmos_checkout}/00_alsa_pinephone_dshare.conf" 644 etc/alsa/conf.d "00-alsa-pinephone-dshare.conf"
+	vbin "${_pmos_checkout}/setup-modem.sh" "pinephone-modem-setup"
+
+	vmkdir usr/share/alsa/ucm2
+	vcopy "${_pmos_checkout}/ucm" usr/share/alsa/ucm2/PinePhone
+
+	vlicense "${FILESDIR}/COPYING"
+}

From 46489cec6cdf268174a456471b75c10915ba44d8 Mon Sep 17 00:00:00 2001
From: John Sullivan <jsullivan@csumb.edu>
Date: Fri, 5 Feb 2021 21:32:10 -0800
Subject: [PATCH 3/3] pinephone-base: get utilities from pinephone-utils

---
 srcpkgs/pinephone-base/files/90-modem-eg25.rules | 5 -----
 srcpkgs/pinephone-base/template                  | 8 ++------
 2 files changed, 2 insertions(+), 11 deletions(-)
 delete mode 100644 srcpkgs/pinephone-base/files/90-modem-eg25.rules

diff --git a/srcpkgs/pinephone-base/files/90-modem-eg25.rules b/srcpkgs/pinephone-base/files/90-modem-eg25.rules
deleted file mode 100644
index cd0031422cb..00000000000
--- a/srcpkgs/pinephone-base/files/90-modem-eg25.rules
+++ /dev/null
@@ -1,5 +0,0 @@
-SUBSYSTEMS=="usb", ENV{.LOCAL_ifNum}="$attr{bInterfaceNumber}"
-
-SUBSYSTEMS=="usb", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.LOCAL_ifNum}=="01", SYMLINK+="EG25.NMEA", MODE="0660"
-SUBSYSTEMS=="usb", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.LOCAL_ifNum}=="02", SYMLINK+="EG25.AT", MODE="0660"
-SUBSYSTEMS=="usb", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.LOCAL_ifNum}=="03", SYMLINK+="EG25.MODEM", MODE="0660"
diff --git a/srcpkgs/pinephone-base/template b/srcpkgs/pinephone-base/template
index 6c750a92bd5..a4741e24cb7 100644
--- a/srcpkgs/pinephone-base/template
+++ b/srcpkgs/pinephone-base/template
@@ -1,15 +1,11 @@
 # Template file for 'pinephone-base'
 pkgname=pinephone-base
-version=0.1
+version=0.2
 revision=1
 archs="aarch64*"
 build_style=meta
-depends="pinephone-kernel pinephone-uboot"
+depends="pinephone-kernel pinephone-uboot pinephone-utils"
 short_desc="Void Linux PinePhone platform package"
 maintainer="John Sullivan <jsullivan@csumb.edu>"
 license="Public Domain"
 homepage="https://www.voidlinux.org"
-
-do_install() {
-	vinstall "${FILESDIR}/90-modem-eg25.rules" 644 usr/lib/udev/rules.d
-}

  parent reply	other threads:[~2021-02-06  7:15 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25  9:18 [PR PATCH] " jjsullivan5196
2021-01-29  3:10 ` ericonr
2021-01-29  4:08 ` jjsullivan5196
2021-02-05 10:17 ` [PR PATCH] [Updated] " jjsullivan5196
2021-02-05 10:19 ` jjsullivan5196
2021-02-05 10:20 ` jjsullivan5196
2021-02-05 10:22 ` jjsullivan5196
2021-02-06  5:00 ` [PR REVIEW] " the-maldridge
2021-02-06  5:13 ` jjsullivan5196
2021-02-06  5:15 ` the-maldridge
2021-02-06  5:19 ` ericonr
2021-02-06  5:32 ` [PR PATCH] [Updated] " jjsullivan5196
2021-02-06  5:35 ` [PR REVIEW] " jjsullivan5196
2021-02-06  7:06 ` [PR PATCH] [Updated] " jjsullivan5196
2021-02-06  7:09 ` jjsullivan5196
2021-02-06  7:15 ` jjsullivan5196 [this message]
2021-02-06  7:21 ` jjsullivan5196
2021-02-22 21:39 ` MungFuSensei
2021-02-24  4:03 ` [PR REVIEW] " ericonr
2021-02-24  4:03 ` ericonr
2021-02-24  4:03 ` ericonr
2021-02-25 19:38 ` Piraty
2021-03-01  0:14 ` [PR PATCH] [Updated] " jjsullivan5196
2021-03-01  0:15 ` [PR REVIEW] " jjsullivan5196
2021-03-01  0:15 ` jjsullivan5196
2021-03-01  0:17 ` the-maldridge
2021-03-01  0:18 ` [PR REVIEW] " jjsullivan5196
2022-04-09  9:28 ` JamiKettunen
2022-04-18 20:17 ` HadetTheUndying
2022-07-19  2:14 ` github-actions
2022-08-07  2:13 ` [PR PATCH] [Closed]: " github-actions

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210206071539.UpgHMbylY9FWiP97_oFKbiTeqsLNx-WVePd97xYIme8@z \
    --to=jjsullivan5196@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).