国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

OpenHarmony3.1適配移遠(yuǎn)EC20模組4G上網(wǎng)功能

這篇具有很好參考價(jià)值的文章主要介紹了OpenHarmony3.1適配移遠(yuǎn)EC20模組4G上網(wǎng)功能。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

OpenHarmony3.1適配移遠(yuǎn)EC20模組4G上網(wǎng)功能

一、概述

通過閱讀本篇文檔,您將學(xué)習(xí)到如何適配移遠(yuǎn)EC20模組到OpenHarmony3.1(以下簡稱OHOS),并添加4G上網(wǎng)功能。

本篇文檔,使用硬件為大禹RK3568開發(fā)板。

開發(fā)板資料:https://gitee.com/openharmony/device_board_hihope/blob/master/rk3568/README_zh.md

軟件方案分為PPP和QMI兩種,請(qǐng)讀者自行選擇。

二、PPP方案

2.1.內(nèi)核添加對(duì)應(yīng)配置

CONFIG_PPP=y
CONFIG_PPP_ASYNC=y
CONFIG_PPP_SYNC_TTY=y
CONFIG_PPP_DEFLATE=y

2.2.修改內(nèi)核驅(qū)動(dòng)源碼

2.2.1修改drivers/usb/serial/option.c
diff --git a/v5.10.11/drivers/usb/serial/option.c b/v5.10.11/drivers/usb/serial/option.c
index 3fe9591..2a3e20e 100644
--- a/v5.10.11/drivers/usb/serial/option.c
+++ b/v5.10.11/drivers/usb/serial/option.c
@@ -580,6 +580,32 @@ static void option_instat_callback(struct urb *urb);
 
 
 static const struct usb_device_id option_ids[] = {
+#if 1 //Added by Quectel
+	{ USB_DEVICE(0x05C6, 0x9090) }, /* Quectel UC15 */
+	{ USB_DEVICE(0x05C6, 0x9003) }, /* Quectel UC20 */
+	{ USB_DEVICE(0x05C6, 0x9215) }, /* Quectel EC20(MDM9215) */
+	{ USB_DEVICE(0x2C7C, 0x0125) }, /* Quectel EC20(MDM9x07)/EC25/EG25 */
+	{ USB_DEVICE(0x2C7C, 0x0121) }, /* Quectel EC21 */
+	{ USB_DEVICE(0x2C7C, 0x0191) }, /* Quectel EG91 */
+	{ USB_DEVICE(0x2C7C, 0x0195) }, /* Quectel EG95 */
+	{ USB_DEVICE(0x2C7C, 0x0306) }, /* Quectel EG06/EP06/EM06 */
+	{ USB_DEVICE(0x2C7C, 0x030B) }, /* Quectel EG065K/EG060K */
+	{ USB_DEVICE(0x2C7C, 0x0514) }, /* Quectel BL EG060K RNDIS Only */
+	{ USB_DEVICE(0x2C7C, 0x0512) }, /* Quectel EG12/EP12/EM12/EG16/EG18 */
+	{ USB_DEVICE(0x2C7C, 0x0296) }, /* Quectel BG96 */
+	{ USB_DEVICE(0x2C7C, 0x0700) }, /* Quectel BG95/BG77/BG600L-M3/BC69 */
+	{ USB_DEVICE(0x2C7C, 0x0435) }, /* Quectel AG35 */
+	{ USB_DEVICE(0x2C7C, 0x0415) }, /* Quectel AG15 */
+	{ USB_DEVICE(0x2C7C, 0x0452) }, /* Quectel AG520 */
+	{ USB_DEVICE(0x2C7C, 0x0455) }, /* Quectel AG550 */
+	{ USB_DEVICE(0x2C7C, 0x0620) }, /* Quectel EG20 */
+	{ USB_DEVICE(0x2C7C, 0x0800) }, /* Quectel RG500/RM500/RG510/RM510 */
+	{ USB_DEVICE(0x2C7C, 0x0801) }, /* Quectel RG520/RM520/SG520 */
+	{ USB_DEVICE(0x2C7C, 0x6026) }, /* Quectel EC200 */
+	{ USB_DEVICE(0x2C7C, 0x6120) }, /* Quectel UC200 */
+	{ USB_DEVICE(0x2C7C, 0x6000) }, /* Quectel EC200/UC200 */
+	{ .match_flags = USB_DEVICE_ID_MATCH_VENDOR, .idVendor = 0x2C7C }, /* Match All Quectel Modules */
+#endif
 	{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
 	{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
 	{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
@@ -2071,7 +2097,26 @@ MODULE_DEVICE_TABLE(usb, option_ids);
  * recognizes separately, thus num_port=1.
  */
 
+#if 1 //Added by Quectel
+static void cfmakeraw(struct ktermios *t)
+{
+	t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
+	t->c_oflag &= ~OPOST;
+	t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+	t->c_cflag &= ~(CSIZE|PARENB);
+	t->c_cflag |= CS8;
+	t->c_cc[VMIN] = 1;
+	t->c_cc[VTIME] = 0;
+}
+
+static void option_init_termios(struct tty_struct *tty)
+{
+	cfmakeraw(&tty->termios);
+}
+#endif
+
 static struct usb_serial_driver option_1port_device = {
+	.init_termios  = option_init_termios,
 	.driver = {
 		.owner =	THIS_MODULE,
 		.name =		"option1",
@@ -2098,6 +2143,9 @@ static struct usb_serial_driver option_1port_device = {
 #ifdef CONFIG_PM
 	.suspend           = usb_wwan_suspend,
 	.resume            = usb_wwan_resume,
+#if 1 //Added by Quectel
+	.reset_resume = usb_wwan_resume,
+#endif
 #endif
 };
 
@@ -2122,6 +2170,35 @@ static int option_probe(struct usb_serial *serial,
 				&serial->interface->cur_altsetting->desc;
 	unsigned long device_flags = id->driver_info;
 
+#if 1 //Added by Quectel
+	//Quectel UC20's interface 4 can be used as USB Network device
+	if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) && serial->dev->descriptor.idProduct == cpu_to_le16(0x9003)
+		&& serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
+		return -ENODEV;
+
+	//Quectel EC20(MDM9215)'s interface 4 can be used as USB Network device
+	if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) && serial->dev->descriptor.idProduct == cpu_to_le16(0x9215)
+		&& serial->interface->cur_altsetting->desc.bInterfaceNumber >= 4)
+		return -ENODEV;
+
+	if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C)) {
+		__u16 idProduct = le16_to_cpu(serial->dev->descriptor.idProduct);
+		struct usb_interface_descriptor *intf = &serial->interface->cur_altsetting->desc;
+
+		if (intf->bInterfaceClass != 0xFF || intf->bInterfaceSubClass == 0x42) {
+			//ECM, RNDIS, NCM, MBIM, ACM, UAC, ADB
+			return -ENODEV;
+		}
+
+		if ((idProduct&0xF000) == 0x0000) {
+			//MDM interface 4 is QMI
+			if (intf->bInterfaceNumber == 4 && intf->bNumEndpoints == 3
+				&& intf->bInterfaceSubClass == 0xFF && intf->bInterfaceProtocol == 0xFF)
+				return -ENODEV;
+		}
+	}
+#endif
+
 	/* Never bind to the CD-Rom emulation interface	*/
 	if (iface_desc->bInterfaceClass == USB_CLASS_MASS_STORAGE)
 		return -ENODEV;
@@ -2235,7 +2312,7 @@ static void option_instat_callback(struct urb *urb)
 		dev_dbg(dev, "%s: error %d\n", __func__, status);
 
 	/* Resubmit urb so we continue receiving IRQ data */
-	if (status != -ESHUTDOWN && status != -ENOENT) {
+	if (status != -ESHUTDOWN && status != -ENOENT && status != -EPROTO) {
 		usb_mark_last_busy(port->serial->dev);
 		err = usb_submit_urb(urb, GFP_ATOMIC);
 		if (err)
2.2.2修改drivers/usb/serial/qcserial.c
diff --git a/v5.10.11/drivers/usb/serial/qcserial.c b/v5.10.11/drivers/usb/serial/qcserial.c
index 83da823..469b202 100644
--- a/v5.10.11/drivers/usb/serial/qcserial.c
+++ b/v5.10.11/drivers/usb/serial/qcserial.c
@@ -63,7 +63,7 @@ static const struct usb_device_id id_table[] = {
 	{DEVICE_G1K(0x05c6, 0x9202)},	/* Generic Gobi Modem device */
 	{DEVICE_G1K(0x05c6, 0x9203)},	/* Generic Gobi Modem device */
 	{DEVICE_G1K(0x05c6, 0x9222)},	/* Generic Gobi Modem device */
-	{DEVICE_G1K(0x05c6, 0x9008)},	/* Generic Gobi QDL device */
+//	{DEVICE_G1K(0x05c6, 0x9008)},	/* Generic Gobi QDL device */
 	{DEVICE_G1K(0x05c6, 0x9009)},	/* Generic Gobi Modem device */
 	{DEVICE_G1K(0x05c6, 0x9201)},	/* Generic Gobi QDL device */
 	{DEVICE_G1K(0x05c6, 0x9221)},	/* Generic Gobi QDL device */
2.2.3修改drivers/usb/serial/usb_wwan.c
diff --git a/v5.10.11/drivers/usb/serial/usb_wwan.c b/v5.10.11/drivers/usb/serial/usb_wwan.c
index 4b98458..236102b 100644
--- a/v5.10.11/drivers/usb/serial/usb_wwan.c
+++ b/v5.10.11/drivers/usb/serial/usb_wwan.c
@@ -272,7 +272,7 @@ static void usb_wwan_indat_callback(struct urb *urb)
 			__func__, status, endpoint);
 
 		/* don't resubmit on fatal errors */
-		if (status == -ESHUTDOWN || status == -ENOENT)
+		if (status == -ESHUTDOWN || status == -ENOENT || status == -EPROTO)
 			return;
 	} else {
 		if (urb->actual_length) {
@@ -476,6 +476,19 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
 			  usb_sndbulkpipe(serial->dev, endpoint) | dir,
 			  buf, len, callback, ctx);
 
+#if 1 //Added by Quectel for Zero Packet
+	if (dir == USB_DIR_OUT) {
+		if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) && serial->dev->descriptor.idProduct == cpu_to_le16(0x9090))
+			urb->transfer_flags |= URB_ZERO_PACKET;
+		if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) && serial->dev->descriptor.idProduct == cpu_to_le16(0x9003))
+			urb->transfer_flags |= URB_ZERO_PACKET;
+		if (serial->dev->descriptor.idVendor == cpu_to_le16(0x05C6) && serial->dev->descriptor.idProduct == cpu_to_le16(0x9215))
+			urb->transfer_flags |= URB_ZERO_PACKET;
+		if (serial->dev->descriptor.idVendor == cpu_to_le16(0x2C7C))
+			urb->transfer_flags |= URB_ZERO_PACKET;
+	}
+#endif
+
 	if (intfdata->use_zlp && dir == USB_DIR_OUT)
 		urb->transfer_flags |= URB_ZERO_PACKET;

2.3添加ppp撥號(hào)軟件

2.3.1pcap移植

主頁:https://www.tcpdump.org/index.html

https://www.tcpdump.org/release/libpcap-1.10.1.tar.gz

解壓到目錄third_party/libpcap

原生編譯:

./configure --host=arm-linux-gnueabi
#修改Makefile
#CC = arm-linux-gnueabi-gcc
#AR = arm-linux-gnueabi-ar
make

創(chuàng)建gn文件BUILD.gn,內(nèi)容如下:

import("http://build/ohos.gni")

ohos_static_library("libpcap") {
  sources = [
    "pcap-linux.c",
    "fad-getad.c",
    "pcap-usb-linux.c",
    "pcap-netfilter-linux.c",
    "pcap.c",
    "gencode.c",
    "optimize.c",
    "nametoaddr.c",
    "etherent.c",
    "fmtutils.c",
    "savefile.c",
    "sf-pcap.c",
    "sf-pcapng.c",
    "pcap-common.c",
    "bpf_image.c",
    "bpf_filter.c",
    "bpf_dump.c",
    "scanner.c",
    "grammar.c",
    "missing/strlcat.c",
    "missing/strlcpy.c"
  ]

  include_dirs = [
    "http://third_party/libpcap"
  ]

  cflags = [
    "-O2",
    "-g",
    "-fvisibility=hidden",
    "-fpic",
    "-DBUILDING_PCAP",
    "-Dpcap_EXPORTS",
    "-DHAVE_CONFIG_H",
    "-Wno-int-conversion",
  ]

  part_name = "libpcap"
  subsystem_name = "ppp"
}

修改ftmacros.h,宏_GNU_SOURCE重復(fù)定義:

  #ifndef _GNU_SOURCE
    #define _GNU_SOURCE
  #endif

修改config.h文件,屏蔽以下兩行:

/* define if we have the Linux getnetbyname_r() */
// #define HAVE_LINUX_GETNETBYNAME_R 1

/* define if we have the Linux getprotobyname_r() */
// #define HAVE_LINUX_GETPROTOBYNAME_R 1
2.3.2.ppp移植

主頁:https://download.samba.org/pub/ppp/

下載地址:https://download.samba.org/pub/ppp/ppp-2.4.9.tar.gz

代碼解壓到目錄third_party/ppp

原生編譯:

./configure --cross_compile=arm-linux-gnueabi-g
make

新建文件bundle.json,內(nèi)容如下:

{
    "name": "@ohos/ppp",
    "description": "the Point-to-Point Protocol (PPP) to provide Internet connections over serial lines",
    "version": "3.1",
    "license": "Public Domain",
    "publishAs": "code-segment",
    "segment": {
        "destPath": "third_party/ppp"
    },
    "dirs": {},
    "scripts": {},
    "licensePath": "",
    "readmePath": {
        "en": ""
    },
    "component": {
        "name": "ppp",
        "subsystem": "ppp",
        "syscap": [],
        "features": [],
        "adapted_system_type": [],
        "rom": "",
        "ram": "",
        "deps": {
            "components": [],
            "third_party": []
        },
        "build": {
            "sub_component": [
                "http://third_party/ppp:ppp_group"
            ],
            "inner_kits": [],
            "test": []
        }
    }
}

新建文件ohos.build,內(nèi)容如下:

{
  "subsystem": "ppp",
  "parts": {
    "ppp": {
      "module_list": [
        "http://third_party/ppp:ppp_group"
      ]
    }
  }
}

新建文件BUILD.gn,內(nèi)容如下:

import("http://build/ohos.gni")
group("ppp_group") {
  deps =[
    "pppd:pppd_group",
    "chat:chat",
    "etc:ppp_copy"
  ]
}
2.3.2.1pppd移植

原生交叉編譯:

./configure --host=arm-linux-gnueabi
make CC=arm-linux-gnueabi-gcc AR=arm-linux-gnueabi-ar

新建gn,并編譯:

import("http://build/ohos.gni")

group("pppd_group") {
  deps =[
    ":pppd",
    # "plugins:pppd_plugins",
  ]
}

ohos_executable("pppd") {
  sources = [
    "main.c",
    "magic.c",
    "fsm.c",
    "lcp.c",
    "ipcp.c",
    "upap.c",
    "chap-new.c",
    # "md5.c",
    "ccp.c",
    "ecp.c",
    "ipxcp.c",
    "auth.c",
    "options.c",
    "sys-linux.c",
    "md4.c",
    "chap_ms.c",
    "demand.c",
    "utils.c",
    "tty.c",
    "eap.c",
    "chap-md5.c",
    "session.c",
    # "sha1.c",
    "multilink.c",
    "tdb.c",
    "spinlock.c",
    "ipv6cp.c",
    "eui64.c",

    "pppcrypt.c",
    "eap-tls.c"
  ]

  include_dirs = [
    "http://third_party/ppp/include",
    "http://third_party/ppp/pppd",
    "http://third_party/openssl/include",
    "http://third_party/libpcap",
  ]

  defines = [
    "HAVE_PATHS_H",
    "IPX_CHANGE",
    "HAVE_MMAP",
    "DESTDIR=\"/usr/local\"",
    "CHAPMS=1",
    "MPPE=1",
    "USE_EAPTLS=1",
    "HAS_SHADOW",
    "HAVE_CRYPT_H=1",
    # "HAVE_LOGWTMP=1",
    "HAVE_MULTILINK",
    "USE_TDB=1",
    "PLUGIN",
    "PPP_FILTER",
    "INET6=1",
    "MAXOCTETS",
    "USE_CRYPT=1",
    "_PATH_VARRUN=\"/data/ppp/var/run/\""
  ]

  cflags = [
    "-Wno-implicit-function-declaration",
    "-O2",
    "-g",
    "-pipe",
  ]

  deps = [
      "http://third_party/openssl:libcrypto_static",
      "http://third_party/openssl:ssl_source",
      "http://third_party/libpcap:libpcap",
  ]

  install_enable = true
  part_name = "ppp"
  subsystem_name = "ppp"
  install_images = [
    "system",
    "updater",
  ]
}
2.3.2.2chat移植
import("http://build/ohos.gni")

ohos_executable("chat") {
  sources = [
    "chat.c",
  ]

  cflags = [
    "-O2",
    "-g",
    "-pipe",
    "-fPIC",
    "-UNO_SLEEP"
  ]

  defines = [
    "TERMIOS",
    "SIGTYPE=void",
    "FNDELAY=O_NDELAY"
  ]

  include_dirs = [
    "http://third_party/ppp/include",
    "http://third_party/ppp/chat",
    "http://third_party/ppp",
  ]

  deps = [
      "http://third_party/openssl:libcrypto_static",
      "http://third_party/openssl:ssl_source",
      "http://third_party/libpcap:libpcap",
  ]

  part_name = "ppp"
  subsystem_name = "ppp"
  install_enable = true
  install_images = [
    "system",
    "updater",
  ]
}
2.3.2.3etc配置

新建etc目錄,用于拷貝ppp配置到/data目錄。

注:因?yàn)镺HOS的/system分區(qū)為只讀,所以需要修改部分源碼將ppp配置文件路徑修改到/data下,這部分請(qǐng)讀者自行修改。

新建文件BUILD.gn,內(nèi)容如下:

import("http://build/ohos.gni")

group("ppp_copy") {
  deps =[
    ":ip-up",
    ":ip-down",
    ":ipv6-up",
    ":ipv6-down",
    ":options",
    ":options.pptp",
    ":chap-secrets",
    ":pap-secrets",
    ":resolv.conf",
    ":peers_provider",
    ":peers_quectel-ppp",
    ":peers_quectel-chat-connect",
    ":peers_quectel-chat-disconnect",
    ":ip-up.d_0000usepeerdns",
    ":ip-down.d_0000usepeerdns"
  ]
}

ohos_prebuilt_etc("ip-up") {
  source = "ppp/ip-up"
  relative_install_dir = "ppp"
  part_name = "ppp"
}

ohos_prebuilt_etc("ipv6-up") {
  relative_install_dir = "ppp"
  source = "ppp/ipv6-up"
  part_name = "ppp"
}

ohos_prebuilt_etc("ip-down") {
  relative_install_dir = "ppp"
  source = "ppp/ip-down"
  part_name = "ppp"
}

ohos_prebuilt_etc("ipv6-down") {
  relative_install_dir = "ppp"
  source = "ppp/ipv6-down"
  part_name = "ppp"
}

ohos_prebuilt_etc("options") {
  relative_install_dir = "ppp"
  source = "ppp/options"
  part_name = "ppp"
}

ohos_prebuilt_etc("options.pptp") {
  relative_install_dir = "ppp"
  source = "ppp/options.pptp"
  part_name = "ppp"
}

ohos_prebuilt_etc("chap-secrets") {
  relative_install_dir = "ppp"
  source = "ppp/chap-secrets"
  part_name = "ppp"
}

ohos_prebuilt_etc("pap-secrets") {
  relative_install_dir = "ppp"
  source = "ppp/pap-secrets"
  part_name = "ppp"
}

ohos_prebuilt_etc("resolv.conf") {
  relative_install_dir = "ppp"
  source = "ppp/resolv.conf"
  part_name = "ppp"
}

ohos_prebuilt_etc("peers_provider") {
  relative_install_dir = "ppp/peers"
  source = "ppp/peers/provider"
  part_name = "ppp"
}

ohos_prebuilt_etc("peers_quectel-ppp") {
  relative_install_dir = "ppp/peers"
  source = "ppp/peers/quectel-ppp"
  part_name = "ppp"
}

ohos_prebuilt_etc("peers_quectel-chat-connect") {
  relative_install_dir = "ppp/peers"
  source = "ppp/peers/quectel-chat-connect"
  part_name = "ppp"
}

ohos_prebuilt_etc("peers_quectel-chat-disconnect") {
  relative_install_dir = "ppp/peers"
  source = "ppp/peers/quectel-chat-disconnect"
  part_name = "ppp"

}

ohos_prebuilt_etc("ip-up.d_0000usepeerdns") {
  relative_install_dir = "ppp/ip-up.d"
  source = "ppp/ip-up.d/0000usepeerdns"
  part_name = "ppp"
}

ohos_prebuilt_etc("ip-down.d_0000usepeerdns") {
  relative_install_dir = "ppp/ip-down.d"
  source = "ppp/ip-down.d/0000usepeerdns"
  part_name = "ppp"
}

2.4添加route

原始OHOS3.1中沒有route程序,造成ppp撥號(hào)成功后無法設(shè)置路由。

需要添加route軟件到toybox中,修改文件third_party/toybox/generated/config.h,內(nèi)容如下:

#ifdef WITH_SELINUX
# define CFG_ROUTE 1
# define USE_ROUTE(...) __VA_ARGS__
#else
# define CFG_ROUTE 1
# define USE_ROUTE(...) __VA_ARGS__

2.5編譯配置

修改productdefine/common/products/rk3568.json,新增ppp:

"ppp:ppp":{}

修改build/subsystem_config.json,新增ppp:

  "ppp":{
    "path": "third_party/ppp",
    "name": "ppp"
  },

修改文件build/config/compiler/BUILD.gn

treat_warnings_as_errors = false

注:這里因?yàn)闊o需遵守編碼規(guī)范,故取消該設(shè)置。

2.6啟動(dòng)配置

修改文件base/startup/init_lite/services/etc/init.cfg。

新增jobs:

{
            "name" : "services:pppd_service",
            "cmds" : [
                "mkdir /data/ppp",
                "mkdir /data/ppp/var",
                "mkdir /data/ppp/var/lock",
                "mkdir /data/ppp/var/run",
                "mkdir /data/ppp/var/log",

                "mkdir /data/ppp/etc",
                "mkdir /data/ppp/etc/ppp",
                "copy /etc/ppp/ip-up /data/ppp/etc/ppp/ip-up",
                "copy /etc/ppp/ip-down /data/ppp/etc/ppp/ip-down",
                "chmod 0775 /data/ppp/etc/ppp/ip-up",
                "chmod 0775 /data/ppp/etc/ppp/ip-down",

                "copy /etc/ppp/ipv6-up /data/ppp/etc/ppp/ipv6-up",
                "copy /etc/ppp/ipv6-down /data/ppp/etc/ppp/ipv6-down",
                "chmod 0775 /data/ppp/etc/ppp/ipv6-up",
                "chmod 0775 /data/ppp/etc/ppp/ipv6-down",
                "copy /etc/ppp/options /data/ppp/etc/ppp/options",
                "copy /etc/ppp/options.pptp /data/ppp/etc/ppp/options.pptp",
                "copy /etc/ppp/chap-secrets /data/ppp/etc/ppp/chap-secrets",
                "copy /etc/ppp/pap-secrets /data/ppp/etc/ppp/pap-secrets",
                "copy /etc/ppp/resolv.conf /data/ppp/etc/ppp/resolv.conf",

                "mkdir /data/ppp/etc/ppp/ip-up.d",
                "copy /etc/ppp/ip-up.d/0000usepeerdns /data/ppp/etc/ppp/ip-up.d/0000usepeerdns",
                "mkdir /data/ppp/etc/ppp/ip-down.d",
                "copy /etc/ppp/ip-down.d/0000usepeerdns /data/ppp/etc/ppp/ip-down.d/0000usepeerdns",

                "mkdir /data/ppp/etc/ppp/peers",
                "copy /etc/ppp/peers/provider /data/ppp/etc/ppp/peers/provider",
                "copy /etc/ppp/peers/quectel-ppp /data/ppp/etc/ppp/peers/quectel-ppp",
                "copy /etc/ppp/peers/quectel-chat-connect /data/ppp/etc/ppp/peers/quectel-chat-connect",
                "copy /etc/ppp/peers/quectel-chat-disconnect /data/ppp/etc/ppp/peers/quectel-chat-disconnect"
            ]
        }

新增services:

{
            "name" : "pppd_service",
            "start-mode" : "condition",
            "path" : ["/system/bin/pppd", "call", "quectel-ppp"],
            "once" : 1,
            "disabled" : 1,
            "console" : 1,
            "uid" : "root",
            "gid" : ["shell", "log", "readproc"],
            "jobs" : {
                "on-start" : "services:pppd_service"
            }
        }

在init的最后新增:

            "name" : "init",
            "cmds" : [
#            ......
                "start pppd_service"
            ]

2.7最終效果

系統(tǒng)啟動(dòng)后,自動(dòng)啟動(dòng)pppd進(jìn)行撥號(hào),成功效果如下:

OpenHarmony3.1適配移遠(yuǎn)EC20模組4G上網(wǎng)功能,OHOS,c++,c語言,linux,驅(qū)動(dòng)開發(fā),Powered by 金山文檔

三、QMI方案

3.1內(nèi)核添加對(duì)應(yīng)配置

CONFIG_USB_NET_QMI_WWAN=y
CONFIG_USB_WDM=y

3.2修改內(nèi)核代碼

拷貝移遠(yuǎn)提供的qmi_wwan_q.c源碼到drivers/net/usb/目錄。

修改drivers/net/usb/Makefile,內(nèi)容如下:

obj-${CONFIG_USB_NET_QMI_WWAN} += qmi_wwan_q.o
obj-${CONFIG_USB_NET_QMI_WWAN} += qmi_wwan.o

3.3添加quectel-cm軟件

該軟件源碼由移遠(yuǎn)提供。

新建BUILD.gn,內(nèi)容如下:

import("http://build/ohos.gni")

group("quectel-cm-group") {
  deps = [
    ":quectel-CM",
#    ":quectel-qmi-proxy",
#    ":quectel-mbim-proxy",
#    ":quectel-atc-proxy",
    ":quectel-script"
  ]
}

ohos_prebuilt_etc("quectel-script") {
  # relative_install_dir = "quectel"
  source = "default.script"
  part_name = "quectel"
  module_install_dir = "quectel"
  subsystem_name = "quectel"
}

ohos_executable("quectel-CM") {
  sources = [
    "QmiWwanCM.c",
    "GobiNetCM.c",
    "main.c",
    "MPQMUX.c",
    "QMIThread.c",
    "util.c",
    "qmap_bridge_mode.c",
    "mbim-cm.c",
    "device.c",
    "atc.c",
    "atchannel.c",
    "at_tok.c",
    "udhcpc.c"
  ]

  defines = [
    "USE_OHOS"
  ]

  include_dirs = [
    "http://third_party/quectel/quectel-cm",
  ]

  install_enable = true
  part_name = "quectel"
  subsystem_name = "quectel"
  install_images = [
    "system",
    "updater",
  ]
}

3.4啟動(dòng)配置

修改文件base/startup/init_lite/services/etc/init.cfg。

添加trigger,用以啟動(dòng)軟件:文章來源地址http://www.zghlxwxcb.cn/news/detail-737484.html

----------------- base/startup/init_lite/services/etc/init.cfg -----------------
index 3a1e0b1f3d..b093e0fb6c 100755
@@ -166,7 +166,8 @@
                 "trigger post-fs-data",
                 "trigger firmware_mounts_complete",
                 "trigger early-boot",
-                "trigger boot"
+                "trigger boot",
+                "trigger quectel-cm"
             ]
         }, {
             "name" : "early-fs",
@@ -431,6 +432,11 @@
                 "chmod 0773 /data/misc/trace",
                 "chmod 0775 /data/misc/wmtrace"
             ]
+        }, {
+            "name" : "quectel-cm",
+            "cmds" : [
+                "exec /system/bin/quectel-CM &"
+            ]
         }
     ],
     "services" : [{

3.5最終效果

OpenHarmony3.1適配移遠(yuǎn)EC20模組4G上網(wǎng)功能,OHOS,c++,c語言,linux,驅(qū)動(dòng)開發(fā),Powered by 金山文檔

到了這里,關(guān)于OpenHarmony3.1適配移遠(yuǎn)EC20模組4G上網(wǎng)功能的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 移遠(yuǎn)4G模塊 EC200x EC600 系列AT命令手冊(cè)

    本文是譯至移遠(yuǎn)官方文檔 xxx_AT_Commands_Manual 這款芯片的AT命令集是遵循國際標(biāo)準(zhǔn)3GPPTS27.007、3GPPTS27.005以及Quectel開發(fā)的專用AT命令的組合。 AT命令要以前綴的“AT”或“at”為每個(gè)命令行的開頭,以回車符號(hào)為每行結(jié)尾。命令后面通常會(huì)有一個(gè)響應(yīng),其中包括“”。在本文檔中,

    2024年02月09日
    瀏覽(27)
  • 嵌入式linux驅(qū)動(dòng)開發(fā)之移遠(yuǎn)4G模塊EC800驅(qū)動(dòng)移植指南

    嵌入式linux驅(qū)動(dòng)開發(fā)之移遠(yuǎn)4G模塊EC800驅(qū)動(dòng)移植指南

    回顧下移遠(yuǎn)4G模塊移植過程, 還是蠻簡單的。一通百通,無論是其他4G模塊都是一樣的。這里記錄下過程,分享給有需要的人。環(huán)境使用正點(diǎn)原子的imax6ul開發(fā)板,板子默認(rèn)支持中興和移遠(yuǎn)EC20的驅(qū)動(dòng),這里要移植使用的是移遠(yuǎn)4G模塊EC800。 imax6ul開發(fā)板 虛擬機(jī)(Ubuntu18.04) 交叉編譯

    2024年02月17日
    瀏覽(52)
  • Air700E開發(fā)板|移芯EC618|4G Cat.1模組:概述及PinOut

    Air700E開發(fā)板|移芯EC618|4G Cat.1模組:概述及PinOut

    Air700E文檔中心 EVB-Air700E 開發(fā)板是合宙通信推出的基于 Air700E 模組所開發(fā)的,包含電源,SIM 卡,USB,PCB 天線等必要功能的最小硬件系統(tǒng)。以方便用戶在設(shè)計(jì)前期對(duì) Air700E 模塊進(jìn) 行性能評(píng)估,功能調(diào)試,軟件開發(fā)等用途。 內(nèi)置 PCB 天線 一個(gè)下載/調(diào)試串口,兩個(gè)通用串口 IO 口

    2024年02月01日
    瀏覽(18)
  • 移遠(yuǎn)EC200 EC20 EC600 EC800連接MQTT服務(wù)器

    前言 移遠(yuǎn)的CAT1模塊EC200S連接MQTT大致流程 ,經(jīng)過測試,完全有效 A:開機(jī) ? ? ?就是對(duì)模塊進(jìn)行斷電2S在上電. B:基礎(chǔ)配置 ? ?這部分跟連TCP服務(wù)器一樣 ?(1):發(fā)送AT,確認(rèn)模塊是否正常 ? ? ?\\\"ATrn\\\" ? ? 模塊返回:OK ?(2):取消模塊回顯 ? ? \\\"ATE0rn\\\" ? ? 模塊返回:OK (3)檢查SIM是否正常

    2024年02月05日
    瀏覽(24)
  • 嵌入式linux之iMX6ULL驅(qū)動(dòng)開發(fā) | 移遠(yuǎn)4G模塊EC800驅(qū)動(dòng)移植指南

    嵌入式linux之iMX6ULL驅(qū)動(dòng)開發(fā) | 移遠(yuǎn)4G模塊EC800驅(qū)動(dòng)移植指南

    回顧下移遠(yuǎn)4G模塊移植過程, 還是蠻簡單的。一通百通,無論是其他4G模塊都是一樣的。這里記錄下過程,分享給有需要的人。環(huán)境使用正點(diǎn)原子的imax6ul開發(fā)板,板子默認(rèn)支持中興和移遠(yuǎn)EC20的驅(qū)動(dòng),這里要移植使用的是移遠(yuǎn)4G模塊EC800。 imax6ul開發(fā)板 虛擬機(jī)(Ubuntu18.04) 交叉編譯

    2024年02月12日
    瀏覽(29)
  • RK3568 OpenHarmony3.2 RTL系列 WIFI6 驅(qū)動(dòng)適配(RTL8723DU、RTL8723DS)

    RK3568 OpenHarmony3.2 RTL系列 WIFI6 驅(qū)動(dòng)適配(RTL8723DU、RTL8723DS)

    一、概述 由于AP系列的WIFI模塊社區(qū)已經(jīng)做了適配,而且基本上不需要做什么過多修改,拿過來就能用,這里就不做過多介紹。本文主要介紹在RTL的WIFI模塊在OpenHarmony3.2上的驅(qū)動(dòng)適配,平臺(tái)基于RK3568,主要的適配芯片型號(hào)為RTL8723DU、RTL8723DS,讀者可以進(jìn)行區(qū)分學(xué)習(xí)和參考。 二

    2024年02月13日
    瀏覽(190)
  • STM32+EC20實(shí)現(xiàn)4G無線通信

    STM32+EC20實(shí)現(xiàn)4G無線通信

    EC20是一款集成度非常高的4G無線通信模塊,支持多種常見通信頻段,能滿足幾乎所有的M2M(MachinetoMachine)應(yīng)用需求。模塊支持TCP/UDP/FTP等一眾網(wǎng)絡(luò)協(xié)議,內(nèi)置多星座高精度定位GNSS接收機(jī),快速提供準(zhǔn)確的經(jīng)緯度信息,UART接口提供AT命令控制和數(shù)據(jù)傳輸。 物聯(lián)網(wǎng)很多的網(wǎng)關(guān)設(shè)備因

    2024年02月03日
    瀏覽(26)
  • 4G模塊 :EC20模塊———AT指令收發(fā)短信

    4G模塊 :EC20模塊———AT指令收發(fā)短信

    EC20是一款4G LTE模塊,由華為旗下的海思半導(dǎo)體公司生產(chǎn)。下面是EC20模塊的一些主要特點(diǎn)和功能: 通信技術(shù):EC20支持4G LTE網(wǎng)絡(luò),能夠?qū)崿F(xiàn)快速、穩(wěn)定的無線通信。 頻段支持:EC20支持多種頻段,適用于全球范圍內(nèi)的不同市場和運(yùn)營商要求。 數(shù)據(jù)速率:EC20支持Cat.4數(shù)據(jù)傳輸標(biāo)準(zhǔn)

    2024年02月06日
    瀏覽(19)
  • 驅(qū)動(dòng)程序開發(fā):基于EC20 4G模塊自動(dòng)撥號(hào)聯(lián)網(wǎng)的兩種方式(GobiNet工具撥號(hào)和PPP工具撥號(hào))

    驅(qū)動(dòng)程序開發(fā):基于EC20 4G模塊自動(dòng)撥號(hào)聯(lián)網(wǎng)的兩種方式(GobiNet工具撥號(hào)和PPP工具撥號(hào))

    與EC20 4G模組所需的文件,下載鏈接,請(qǐng)點(diǎn)擊即可 ??關(guān)于 EC20 4G 模塊的詳細(xì)資料請(qǐng)找賣家索要! ??EC20 有多種不同的配置,比如全網(wǎng)通純數(shù)據(jù)版本、語音版、帶 GNSS 版等等,建議大家購買的時(shí)候至少要選擇全網(wǎng)通數(shù)據(jù)版,因?yàn)槲覀兪褂?4G 模塊主要還是用于數(shù)據(jù)通信的。移遠(yuǎn)

    2023年04月26日
    瀏覽(27)
  • 搭建HarmonyOS開發(fā)環(huán)境(OpenHarmony3.2)

    搭建HarmonyOS開發(fā)環(huán)境(OpenHarmony3.2)

    目前HarmonyOS的熱度愈演愈烈,本文將介紹如何搭建HarmonyOS嵌入式開發(fā)環(huán)境,幫助想要使用HarmonyOS進(jìn)行嵌入式開發(fā)的人員進(jìn)行入門。 其實(shí)博主以前已經(jīng)介紹過如何搭建HarmonyOS開發(fā)環(huán)境了,但是當(dāng)時(shí)還是HarmonyOS1.0,目前開源版本,OpenHarmony已經(jīng)更新到OpenHarmony3.2了,開發(fā)也相比于

    2024年02月03日
    瀏覽(23)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包