====== Quectel BG96 LTE-M 拡張ボードの利用 (OB-SM) ====== XG-50 に [[https://www.quectel.com/product/bg96.htm|Quectel BG96]] を採用した LTE-M 回線用オプションボード [[https://www.centurysys.co.jp/products/industrial/xgb50.html|FutureNet OB-SM]] を搭載し、LTE-M 回線を利用してみます。 {{:xg_series_devel:quectel_bg96:ob-sm_001.jpg?400|XG-50 + OB-SM}} \\ ===== サンプル ===== BG96 の GPS により位置情報を取得し、BG96 の TCP/IP stack を利用して [[https://soracom.jp/services/harvest/|SORACOM Harvest]] に UDP でデータをアップロードする、というサンプルです。\\ PPP を利用しないため接続までの時間が短くなり、電池駆動に有利となります。 \\ ==== コードの準備 ==== Github から取得します。 * NuttX 本体 : [[https://github.com/centurysys/incubator-nuttx.git]] * NuttX App : [[https://github.com/centurysys/incubator-nuttx-apps.git]] branch は両方共 **XG-50/BG96-GPS-Harvest** となっています。 \\ ==== TCP/IP stack 利用の例 ==== ''apps/xg50/gps_bg96/bg96_task.c'' で、 * シリアルポートアクセスライブラリの利用 * BG96 設定 (APN等) * BG96 TCP, UDP 接続・切断 * BG96 TCP, UDP 送受信 を行っています。 以下に示す関数を使用することで、BG96 の TCP/IP スタックを用いて通信を行うことができます。 \\ === シリアルポートアクセスライブラリ 初期化 === #include "libserial.h" char *bg96_path = "/dev/ttyS2"; task->ser = serial_open(bg96_path, 115200, 0); \\ === [BG96] ATコマンドの送信 === int bg96_send_AT_command(serial_t *ser, const char *cmd) bg96_send_AT_command(task->ser, "AT+CFUN=4\r\n"); sleep(2); bg96_send_AT_command(task->ser, "AT+CFUN=1\r\n"); sleep(1); bg96_send_AT_command(task->ser, "AT+CGATT?\r\n"); sleep(1); \\ === [BG96] echo off (ATE0) === static int bg96_echo_off(serial_t *ser); res = bg96_echo_off(task->ser); \\ === [BG96] LTE 接続パラメータ設定 === static int bg96_setup_apn(serial_t *ser, int cid, char *apn, char *user, char *password) res = bg96_setup_apn(task->ser, 1, config->apn, config->user, config->password); \\ === [BG96] 時計合わせ (LTE 網より日時取得) === static int bg96_sync_clock(serial_t *ser) res = bg96_sync_clock(task->ser); \\ === [BG96] LTE 網への接続 === static int bg96_connect(serial_t *ser) /* activate PDP context */ res = bg96_connect(task->ser); \\ === [BG96] LTE 網からの切断 === static int bg96_disconnect(serial_t *ser) printf("! %s: open socket failed -> RESET\n", __FUNCTION__); bg96_disconnect(task->ser); \\ ==== マニュアル ==== BG96 のドキュメント一式です。 ^ File ^ Stat ^ SHA1SUM ^ Note | |{{ :xg_series_devel:quectel_bg96:bg96_docs.zip |}}|2020/11/28 16:10 13.5 MB|56f5692e9f630abe59cee1bf21fae513ece060ea| | \\ Archive: bg96_docs.zip Length Date Time Name --------- ---------- ----- ---- 0 2019-05-17 10:42 BG96/ 0 2019-05-17 10:42 BG96/AT_Commands/ 257842 2019-03-13 11:47 BG96/AT_Commands/Quectel_BG96_NIDD_AT_Commands_Manual_V1.0.pdf 397643 2019-03-13 11:48 BG96/AT_Commands/Quectel_BG96_GNSS_AT_Commands_Manual_V1.1.pdf 727911 2019-03-13 11:48 BG96/AT_Commands/Quectel_BG96_FILE_AT_Commands_Manual_V1.1.pdf 610405 2019-03-13 11:48 BG96/AT_Commands/Quectel_BG96_TCP(IP)_AT_Commands_Manual_V1.1.pdf 1536981 2019-03-13 11:48 BG96/AT_Commands/Quectel_BG96_AT_Commands_Manual_V2.3.pdf 316889 2019-03-13 11:47 BG96/AT_Commands/Quectel_BG96_QuecCell_AT_Commands_Manual_V1.0.pdf 884236 2019-03-13 11:48 BG96/AT_Commands/Quectel_BG96_HTTP(S)_AT_Commands_Manual_V1.0.pdf 869272 2019-03-13 11:48 BG96/AT_Commands/Quectel_BG96_SSL_AT_Commands_Manual_V1.0.pdf 348671 2019-03-13 11:47 BG96/AT_Commands/Quectel_BG96_FTP(S)_AT_Commands_Manual_V1.1.pdf 2307467 2019-03-13 11:54 BG96/Quectel_LTE_OPEN_EVB_User_Guide_V1.1.pdf 0 2019-05-17 10:42 BG96/Application_Note/ 690165 2019-03-13 11:50 BG96/Application_Note/Quectel_BG96_MQTT_Application_Note_V1.0.pdf 239343 2019-03-13 11:49 BG96/Application_Note/Quectel_BG96_QuecLocator_Application_Note_V1.0.pdf 1238857 2019-03-13 11:50 BG96/Application_Note/Quectel_BG96_PPP_Application_Note_V1.0.pdf 409401 2019-03-13 11:49 BG96/Application_Note/Quectel_BG96_PSM_Application_Note_V1.0.pdf 378761 2019-03-13 11:49 BG96/Application_Note/Quectel_BG96_Flash_Scrub_Application_Note_V1.1.pdf 1723053 2019-03-18 15:31 BG96/Quectel_BG96_Hardware_Design_V1.3.pdf 1451117 2019-03-18 15:31 BG96/Quectel_UMTS<E_EVB_User_Guide_V2.1.pdf --------- ------- 14388014 20 files \\