Skip to content

Commit

Permalink
omnia-5g-kit: Initial package to support 5G kit
Browse files Browse the repository at this point in the history
  • Loading branch information
miska committed Aug 30, 2024
1 parent a3c4f1c commit 5c2dc74
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
68 changes: 68 additions & 0 deletions hardware/omnia/omnia-5g-kit/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#
# Copyright (C) 2024 CZ.NIC z.s.p.o. (http://www.nic.cz/)
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=omnia-5g-kit
PKG_VERSION:=v0.1
PKG_RELEASE:=$(AUTORELEASE)

PKG_MAINTAINER:=CZ.NIC <[email protected]>
PKG_LICENSE:=GPL-2.0

include $(INCLUDE_DIR)/package.mk

define Package/omnia-5g-kit
TITLE:=Support for Turris Omnia 5G kit
DEPENDS:=@TARGET_mvebu_cortexa9_DEVICE_cznic_turris-omnia +nor-update
CONFLICTS:=modem-manager-autosetup modem-manager
endef

define Package/omnia-5g-kit/description
This package switches internal mPCIe slot into USB3 mode, reconfigures GSM
network to work with our Quectell RM500U-EA 5G modem and also connects to the
internet on every boot.
endef

define Build/Compile
true
endef

define Package/omnia-5g-kit/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/5g-kit.init $(1)/etc/init.d/5g-kit
endef

define Package/omnia-5g-kit/postinst
#!/bin/sh
[ -n "$$IPKG_INSTROOT" ] || {
/etc/init.d/5g-kit start
uci batch << EOF
delete network.gsm
set network.gsm=interface
set network.gsm.proto='dhcp'
set network.gsm.device='usb0'
set network.gsm.metric=2048
set network.gsm.ip6ifaceid='eui64'
set network.gsm.ip6assign='64
set network.gsm6=interface
set network.gsm6.device='@gsm'
set network.gsm6.proto='dhcpv6''
EOF
}


define Package/omnia-5g-kit/prerm
#!/bin/sh
[ -n "$$IPKG_INSTROOT" ] || {
fw_setenv omnia_wwan_slot pcie
uci -q delete network.gsm
uci -q delete network.gsm6
}
endef

$(eval $(call BuildPackage,omnia-5g-kit))
28 changes: 28 additions & 0 deletions hardware/omnia/omnia-5g-kit/files/5g-kit.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh /etc/rc.common

START=95
STOP=05

start() {
local limit=0
if [ "$(fw_printenv omnia_wwan_slot)" != "omnia_wwan_slot=usb3" ]; then
nor-update
fw_setenv omnia_wwan_slot usb3
create_notification -s restart "Please reboot your router to complete 5G kit installation"
return 0
fi
while [ ! -e /dev/ttyUSB2 ] && [ "$limit" -lt 20 ]; do
sleep 1
limit="$((limit + 1))"
done
if [ -e /dev/ttyUSB2 ]; then
echo -ne 'ATZ\r\n' > /dev/ttyUSB2
echo -ne 'AT+CGDATA="M-ETHER",1\r\n' > /dev/ttyUSB2
fi
}

stop() {
if [ -e /dev/ttyUSB2 ]; then
echo -ne 'ATZ\r\n' > /dev/ttyUSB2
fi
}

0 comments on commit 5c2dc74

Please sign in to comment.