From a767e1b6047229f6fcf1b8c5cbdc3e58fa5c6362 Mon Sep 17 00:00:00 2001
From: Stefan Schmidt <stefan.schmidt@huawei.com>
Date: Wed, 13 Oct 2021 10:08:36 +0200
Subject: [PATCH] networkmanager-softap-config: Add SoftAP solution for gateway
 blueprint

Deploy a system-connection which enables the networkmanager hotspot
feature and creates a WiFi SoftAP. WiFi properties like channel, band,
SSID and password stay the same as with the former hostapd based solution.

Signed-off-by: Stefan Schmidt <stefan.schmidt@huawei.com>
---
 .../distro/oniro-linux-blueprint-gateway.conf |  1 +
 .../SoftAP.nmconnection                       | 33 +++++++++++++++++++
 .../networkmanager-softap-config_git.bb       | 14 ++++++++
 3 files changed, 48 insertions(+)
 create mode 100644 meta-oniro-blueprints/recipes-connectivity/networkmanager/networkmanager-softap-config/SoftAP.nmconnection
 create mode 100644 meta-oniro-blueprints/recipes-connectivity/networkmanager/networkmanager-softap-config_git.bb

diff --git a/meta-oniro-blueprints/conf/distro/oniro-linux-blueprint-gateway.conf b/meta-oniro-blueprints/conf/distro/oniro-linux-blueprint-gateway.conf
index 6cf443b1..fd63e249 100644
--- a/meta-oniro-blueprints/conf/distro/oniro-linux-blueprint-gateway.conf
+++ b/meta-oniro-blueprints/conf/distro/oniro-linux-blueprint-gateway.conf
@@ -19,6 +19,7 @@ IMAGE_INSTALL_append = "\
     packagegroup-thread-client \
     mosquitto \
     coap \
+    networkmanager-softap-config \
     "
 # Avoid build warning(s) for ununsed extra partitions.
 ST_VENDORFS = "0"
diff --git a/meta-oniro-blueprints/recipes-connectivity/networkmanager/networkmanager-softap-config/SoftAP.nmconnection b/meta-oniro-blueprints/recipes-connectivity/networkmanager/networkmanager-softap-config/SoftAP.nmconnection
new file mode 100644
index 00000000..62a6a35e
--- /dev/null
+++ b/meta-oniro-blueprints/recipes-connectivity/networkmanager/networkmanager-softap-config/SoftAP.nmconnection
@@ -0,0 +1,33 @@
+[connection]
+id=SoftAP
+uuid=3b73c72c-be72-4458-9fd7-e8b1d6ee4e8d
+type=wifi
+autoconnect=true
+interface-name=wlan0
+permissions=
+
+[wifi]
+band=bg
+channel=6
+mac-address-blacklist=
+mode=ap
+ssid=Oniro Project WiFi
+
+[wifi-security]
+group=ccmp;
+key-mgmt=wpa-psk
+pairwise=ccmp;
+proto=rsn;
+psk=12345678
+
+[ipv4]
+address1=172.16.47.1/24,172.16.47.1
+dns-search=
+method=shared
+
+[ipv6]
+addr-gen-mode=stable-privacy
+dns-search=
+method=auto
+
+[proxy]
diff --git a/meta-oniro-blueprints/recipes-connectivity/networkmanager/networkmanager-softap-config_git.bb b/meta-oniro-blueprints/recipes-connectivity/networkmanager/networkmanager-softap-config_git.bb
new file mode 100644
index 00000000..4b804aea
--- /dev/null
+++ b/meta-oniro-blueprints/recipes-connectivity/networkmanager/networkmanager-softap-config_git.bb
@@ -0,0 +1,14 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
+
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${ONIRO_COREBASE}/LICENSES/Apache-2.0.txt;md5=ef3dabb8f39493f4ea410bebc1d01755"
+
+SRC_URI = "file://SoftAP.nmconnection"
+
+do_install_append() {
+    install -D -m0600 ${WORKDIR}/SoftAP.nmconnection ${D}${libdir}/NetworkManager/system-connections/SoftAP.nmconnection
+}
+
+FILES_${PN} += "${libdir}/NetworkManager/system-connections/"
-- 
GitLab