├── LICENSE ├── docs ├── 1 간단한 TCP 송수신 테스트 가이드 Hercules.md ├── Arduino_Guide_AMM592_gps.md ├── Arduino_get_started.md ├── Arduino_guide_AMM529_ping.md ├── Arduino_guide_AMM592_PSM.md ├── Arduino_guide_AMM592_SMS.md ├── Arduino_guide_AMM592_tcp.md ├── Arduino_guide_qc-bg96_gps.md ├── Arduino_guide_qc-bg96_http.md ├── Arduino_guide_qc-bg96_mqtt.md ├── Arduino_guide_qc-bg96_psm.md ├── Arduino_guide_qc-bg96_tcp.md ├── Arduino_guide_wm-n400mse_gps.md ├── Arduino_guide_wm-n400mse_http.md ├── Arduino_guide_wm-n400mse_ping.md ├── Arduino_guide_wm-n400mse_psm.md ├── Arduino_guide_wm-n400mse_tcp.md ├── Arduino_guide_wm_qc-bg96_sms.md └── imgs │ ├── Arduino_guide_ide_compile.png │ ├── Arduino_guide_wm-n400mse_ping_1.png │ ├── Arduino_guide_wm-n400mse_ping_2.png │ ├── Arduino_guide_wm-n400mse_ping_4.png │ ├── Arduino_guide_wm-n400mse_ping_5.png │ ├── Arduino_guide_wm-n400mse_psm_1.png │ ├── Arduino_guide_wm-n400mse_psm_2.png │ ├── Arduino_guide_wm-n400mse_psm_4.png │ ├── Arduino_guide_wm-n400mse_psm_5.png │ ├── arduino_get_started_10.png │ ├── arduino_get_started_5.png │ ├── arduino_get_started_6.png │ ├── arduino_get_started_7.png │ ├── arduino_get_started_8.png │ ├── arduino_get_started_9.png │ ├── arduino_guide_am01-psm-1.png │ ├── arduino_guide_am01-psm-2.png │ ├── arduino_guide_am01-psm-3.png │ ├── arduino_guide_bg96_gps-1.png │ ├── arduino_guide_bg96_gps-2.png │ ├── arduino_guide_bg96_gps-3.png │ ├── arduino_guide_bg96_gps-4.png │ ├── arduino_guide_bg96_gps-gnss.png │ ├── arduino_guide_bg96_http-1.png │ ├── arduino_guide_bg96_mqtt-1.png │ ├── arduino_guide_bg96_mqtt-2.png │ ├── arduino_guide_bg96_mqtt-3.png │ ├── arduino_guide_bg96_mqtt-4.png │ ├── arduino_guide_bg96_mqtt-5.png │ ├── arduino_guide_bg96_mqtt-6.png │ ├── arduino_guide_bg96_mqtt-7.PNG │ ├── arduino_guide_bg96_psm-1.png │ ├── arduino_guide_bg96_psm-2.png │ ├── arduino_guide_bg96_psm-3.png │ ├── arduino_guide_bg96_sms-1.png │ ├── arduino_guide_bg96_sms-2.png │ ├── arduino_guide_bg96_sms-3.png │ ├── arduino_guide_bg96_sms-4.png │ ├── arduino_guide_bg96_tcp-1.png │ ├── arduino_guide_bg96_tcp-2.png │ ├── arduino_guide_bg96_tcp-3.png │ ├── arduino_guide_bg96_tcp-4.png │ ├── arduino_guide_bg96_tcp-5.png │ ├── arduino_guide_bg96_tcp-9.png │ ├── arduino_guide_ide_compile_finish.png │ ├── arduino_guide_ide_serialmonitor.png │ ├── arduino_guide_wm_n400mse-gps-1.png │ ├── arduino_guide_wmn400-gps-1.png │ ├── arduino_guide_wmn400_http-2.png │ ├── arduino_guide_wmn400_http-3.png │ ├── arduino_guide_wmn400_tcp-2.png │ ├── arduino_guide_wmn400_tcp-3.png │ ├── arduino_guide_wmn400_tcp-4.png │ ├── arduino_guide_wmn400_tcp-5.png │ ├── device_manager_quectel_usbport.png │ ├── forum.jpg │ ├── hw │ ├── WIoT-AM01_JUMP_Arduino_serialD0_D1.png │ ├── WIoT-AM01_JUMP_Arduino_serialD2_D8.png │ ├── WIoT-QC01_JUMP_Arduino_serialD0_D1.png │ ├── WIoT-QC01_JUMP_Arduino_serialD2_D8.png │ ├── WIoT-Shield-AM01_top.png │ ├── WIoT-Shield-QC01_top.png │ ├── WIoT-Shield-WM01_top.png │ ├── WIoT-Shield_top.png │ ├── WIoT-WM01_JUMP_Arduino_serialD0_D1.png │ ├── WIoT-WM01_JUMP_Arduino_serialD2_D8.png │ ├── wiot-shield-qc01-arduinomega2560.png │ ├── wiot-shield-qc01-raspberrypi.png │ ├── wiot-shield-usbport.png │ ├── wiot-shield-wm01-arduinomega2560_stack.png │ └── wiot-shield-wm01-raspberrypi.png │ ├── youtube_arduino_gettingstarted.png │ ├── youtube_samplecode_tcpclient.png │ └── 그림1.png ├── readme.md └── samples ├── WIoT-AM01_AMM592 └── WIoT-AM01_Arduino_PSM │ ├── WIoT-AM01_Arduino_PSM.ino │ ├── at_cmd_parser.cpp │ ├── at_cmd_parser.h │ └── debug.h ├── WIoT-QC01_BG96 ├── WIoT-QC01_Arduino_GPS │ ├── WIoT-QC01_Arduino_GPS.ino │ ├── at_cmd_parser.cpp │ ├── at_cmd_parser.h │ └── debug.h ├── WIoT-QC01_Arduino_HTTP │ ├── WIoT-QC01_Arduino_HTTP.ino │ ├── at_cmd_parser.cpp │ ├── at_cmd_parser.h │ └── debug.h ├── WIoT-QC01_Arduino_MQTT │ ├── WIoT-QC01_Arduino_MQTT.ino │ ├── at_cmd_parser.cpp │ ├── at_cmd_parser.h │ └── debug.h ├── WIoT-QC01_Arduino_PSM │ ├── WIoT-QC01_Arduino_PSM.ino │ ├── at_cmd_parser.cpp │ ├── at_cmd_parser.h │ └── debug.h ├── WIoT-QC01_Arduino_Ping │ ├── WIoT-QC01_Arduino_Ping.ino │ ├── at_cmd_parser.cpp │ ├── at_cmd_parser.h │ └── debug.h ├── WIoT-QC01_Arduino_SMS │ ├── WIoT-QC01_Arduino_SMS.ino │ ├── at_cmd_parser.cpp │ ├── at_cmd_parser.h │ └── debug.h └── WIoT-QC01_Arduino_TCP │ ├── WIoT-QC01_Arduino_TCP.ino │ ├── at_cmd_parser.cpp │ ├── at_cmd_parser.h │ └── debug.h ├── WIoT-Shield ├── WIoT-Shield_SENSOR_CDS │ └── WIoT-Shield_SENSOR_CDS.ino └── WIoT-Shield_SENSOR_TEMP │ └── WIoT-Shield_SENSOR_TEMP.ino └── WIoT-WM01_WM-N400MSE ├── WIoT-WM01_Arduino_HTTP ├── WIoT-WM01_Arduino_HTTP.ino ├── at_cmd_parser.cpp ├── at_cmd_parser.h └── debug.h ├── WIoT-WM01_Arduino_PSM ├── WIoT-WM01_Arduino_PSM.ino ├── at_cmd_parser.cpp ├── at_cmd_parser.h └── debug.h ├── WIoT-WM01_Arduino_Ping ├── WIoT-WM01_Arduino_Ping.ino ├── at_cmd_parser.cpp ├── at_cmd_parser.h └── debug.h ├── WIoT-WM01_Arduino_SMS ├── WIoT-WM01_Arduino_SMS.ino ├── at_cmd_parser.cpp ├── at_cmd_parser.h └── debug.h └── WIoT-WM01_Arduino_TCP ├── WIoT-WM01_Arduino_TCP.ino ├── at_cmd_parser.cpp ├── at_cmd_parser.h └── debug.h /docs/1 간단한 TCP 송수신 테스트 가이드 Hercules.md: -------------------------------------------------------------------------------- 1 |

서버 클라이언트 테스트 방법 (TCP/IP, Hercules)

2 |

준비물

3 |

1. PC (혹은 노트북)

4 |

2. Hercules 프로그램 https://www.hw-group.com/software/hercules-setup-utility

5 |

3. 테스트 기기 (PC, Cat.m1 과 같은 TCP/IP를 지원하는 모든 디바이스)

6 |
7 |
8 |

체크리스트

9 |

네트워크 환경

10 |
->PC와 테스트 기기가 접근 가능한 네트워크(혹은 동일 네트워크)에 있는지 확인
11 |
12 |
13 |

PC에 TCP/IP 서버 생성하기

14 |

Step 1. 네트워크 환경 확인

15 |
-> PC(서버) 및 테스트 기기 IP 확인
16 | 20 |
21 |

Step 2. Hercules를 이용해 서버 만들기 (PC)

22 |
-> License information (Close)
23 |

Hercules License Information

24 |
-> TCP Server 정보 입력 후 서버 생성
25 |
-> 아래 그림과 같이, Hercules를 실행 -> TCP Server Click -> Server Port 설정 후, (그림에는 없지만) Server Port 설정 옆 Listen 버튼을 Click 하면, TCP Server가 생성됩니다.
26 |

Hercules TCP Server

27 |
28 |

Step 3. 테스트 기기에서 TCP/IP 서버 접속

29 |

-> 아래 내용과 같이 테스트 기기를 TCP Client로 설정하여, PC(서버)의 ip 주소와 Server Port로 접속하면 됩니다.

30 |
테스트 기기가 PC인 경우
31 |

-> Hercules TCP Client 를 이용하여 PC(서버)에 접속할 수 있습니다.

32 |
Cat.m1인 경우
33 |

-> 일반적인 TCP Connection AT Command를 사용하여 PC(서버)에 접속할 수 있습니다.

34 |
스마트폰인 경우
35 |

-> TCP Client 클라이언트 스마트폰 앱을 설치하여 테스트를 진행할 수 있습니다.

36 |

SmartPhone TCP Client

37 |

Step 4. 데이터 송수신 테스트 결과

38 |
-> 테스트 기기에서 PC(서버)로 데이터를 송신하면, PC(서버) 에 아래 내용과 같이 수신한 정보를 확인할 수 있다. 또한 서버에서 테스트 기기로 데이터를 송신할 수 있습니다.
39 |

-> 테스트 기기에서 PC(서버)로 데이터 송신의 예

40 |

Send to Server

41 |

-> PC(서버)에서 테스트 기기로 데이터 송신의 예

42 |

Server Reply

43 |

작성자: Matthew

44 |

연락처: matthew@wiznet.io

45 | -------------------------------------------------------------------------------- /docs/Arduino_Guide_AMM592_gps.md: -------------------------------------------------------------------------------- 1 | # Arduino 기반으로 Cat.M1 GPS 활용하기 2 | 3 | 4 | ## 목차 5 | 6 | - [시작하기 전에](#Prerequisites) 7 | - [소개](#Step-1-Overview) 8 | - [AT 명령어](#Step-2-ATCommand) 9 | - [동작 구조 예제](#Step-3-SampleCode) 10 | - [예제 코드 빌드 및 실행](#Step-4-Build-and-Run) 11 | 12 | 13 | ## 시작하기 전에 14 | 15 | > * 하드웨어 설정과 개발환경 구축은 **[Arduino 기반으로 Cat.M1 디바이스 개발 시작하기][arduino-getting-started]** 문서에 상세히 설명되어 있습니다. 16 | 17 | > * Cat.M1과 같은 Cellular IoT 디바이스는 통신 서비스 사업자의 운영 기준 및 규정에 따라 모듈 펌웨어 및 동작 방식에 차이가 있을 수 있습니다. 본 문서는 한국 **[SK Telecom Cat.M1 서비스][skt-iot-portal]** 를 기준으로 작성되었습니다. 18 | 19 | 20 | ### Development Environment 21 | * **[Arduino IDE][link-arduino-compiler]** 22 | 23 | ### Hardware Requirement 24 | 25 | | MCU Board | IoT Shield Interface Board | 26 | |:--------:|:--------:| 27 | | [Arduino Mega2560 Rev3][link-arduino Mega2560 Rev3] | WIoT-AM01 (AMM592SK) | 28 | 29 | 30 | 31 | ## 소개 32 | 33 | 본 문서에서는 Arduino IDE 기반 개발 환경에서 WIZnet IoT shield와 Arduino Mega2560 Rev3 보드를 이용하여 Cat.M1 단말의 GPS 활용 방법에 대한 가이드를 제공합니다. 34 | 35 | 대부분의 Cat.M1 장치는 GPS(Global Positioning System)를 지원하고 있습니다. GPS는 범지구 위성 항법 시스템(GNSS, Global Navigation Satellite System)의 한 종류로, 대중적으로 활용되는 글로벌 위성 위치 확인 시스템입니다. 36 | 37 | ![][gnss] 38 | 39 | Cat.M1 모듈의 GPS기능을 활용하면 아이나 반려동물, 귀중품의 위치를 실시간으로 파악하는 위치 트래커(GPS tracking unit) 등의 위치기반 서비스를 손쉽게 구현 할 수 있습니다. Cat.M1 기반의 위치 트래커는 기존의 블루투스 스마트 태그(Bluetooth Smart Tags)와 달리, 모듈 자체적으로 파악한 GPS 정보를 LTE망을 이용하여 사용자에게 전달함으로써 보다 빠르고 정확한 위치 파악이 가능한 것이 큰 장점입니다. 40 | 41 | Cat.M1 모듈 및 외장형 모뎀은 UART 인터페이스를 통해 활용하는 AT 명령어로 제어하는 것이 일반적입니다. GPS 정보의 획득 기능도 AT 명령어를 이용하여 활성화 할 수 있습니다. 42 | 43 | 44 | ## AT 명령어 45 | 46 | > AT 명령어에 대한 좀 더 상세한 설명은 AM Telecom AT Command Manual 에서 확인 하실 수 있습니다. 47 | 48 | ### 1. GPS 기능 활성화 49 | 50 | GPS 기능을 활성화 합니다. 51 | 52 | **AT Command:** AT@AMGSTART 53 | 54 | **Syntax:** 55 | 56 | | Type | Syntax | Response | Example 57 | |:--------|:--------|:--------|:--------| 58 | | Write | AT@AMGSTART| OK

@AMG: <state code>, [<lat>,<lon>] | AT@AMGSTART

OK | 59 | 60 | **Defined values:** 61 | 62 | | Parameter | 범위 | Description | 63 | |:--------|:--------|:--------| 64 | | <state code> | 0,1,2,3,4 | 0 : GPS positioning infomation
1 : Reference positioning information
2 : GPS positioning
3 : GPS error
4 : GPS time out | 65 | |<lat>|0.000000 - 90.000000|latitude (위도)| 66 | |<lon>|0.000000 - 90.000000|longitude (경도)| 67 | 68 | ### 2. GPS 기능 비활성화 69 | 70 | GPS 기능을 비활성화 합니다. 71 | 72 | **AT Command:** AT@AMGSTOP 73 | 74 | **Syntax:** 75 | 76 | | Type | Syntax | Response | Example 77 | |:--------|:--------|:--------|:--------| 78 | | Write | AT@AMGSTOP | OK

@AMG: <state code> | AT@AMGSTOP
OK

@AMG:7| 79 | 80 | **Defined values:** 81 | 82 | | Parameter | 범위 | Description | 83 | |:--------|:--------|:--------| 84 | | <state code>| 6,7 | 6 : GPS engine off
7 : User ended the session | 85 | 86 | ### 3. GPS Session Type 설정 87 | 88 | GPS 측위시의 Session Type를 설정합니다. 89 | 90 | **AT Command:** AT@AMGST 91 | 92 | **Syntax:** 93 | 94 | | Type | Syntax | Response | Example 95 | |:--------|:--------|:--------|:--------| 96 | | Test | AT@AMGST? | @AMGST:<session_type>
OK
| AT@AMGST?

@AMGST:2

OK| 97 | | Write | AT@AMGST=? | @AMGST:(range of session type) | AT@AMGSTOP=?
@AMGST:(0-2)

OK| 98 | | Write | AT@AMGST=<session_type> | OK | AT@AMGST=2
OK| 99 | 100 | **Defined values:** 101 | 102 | | Parameter | 범위 | Description | 103 | |:--------|:--------|:--------| 104 | | <session_type>| (0-2) | 0 : Latest (마지막 측위되었던 위치 표시)
1 : New (1회 측위)
2: Tracking (연속 측위)| 105 | 106 | 107 | 108 | ## 동작 구조 예제 109 | 110 | WIZnet IoT Shield를 Standalone 모드로 동작시켜, 터미널 프로그램으로 직접 AT 명령어를 입력해 보면서 동작 순서를 확인합니다. 111 | 기본적인 GPS 기능 활용을 위해서는 `AT@AMGST=1`, `AT@AMGSTART`(GPS on), `AT@AMGSTOP`(GPS off) AT 명령어를 이용합니다. 112 | 113 | 다음과 같이 확인 할 수 있습니다. 114 | 115 | ![][1] 116 | 117 | > GPS 기능 활용 시, Quectel USB NMEA Port를 통해서도 GPS 정보가 출력됩니다. 118 | > NMEA Port는 WIZnet IoT Shield의 `P2 USB HOST` USB 포트를 PC와 연결하여 확인할 수 있습니다. 119 | > * [NMEA 0183](https://en.wikipedia.org/wiki/NMEA_0183) 구조의 log 메시지가 출력됩니다. (NMEA, National Marine Electronics Association) 120 | > 1. (윈도우의 경우) 장치 관리자에서 Quectel USB NMEA Port 의 COM 포트 확인 (그 외 OS의 경우, COM 포트 확인) 121 | > 2. 시리얼 터미널 프로그램의 Baudrate를 115200으로 설정하여 확인된 COM 포트로 연결 122 | > 3. NMEA 포트 출력 정보 확인 123 | 124 | ![][usbport] 125 | 126 | 127 | 128 | ## 예제 코드 빌드 및 실행 129 | 130 | ### 1. Import project 131 | 다음 링크에서 Arduino 예제 코드를 다운로드한 후, ino 확장자의 프로젝트 파일을 실행 시킵니다. 132 | 133 | > 예제에서 활용할 Ping test sample code는 저장소의 아래 경로에 위치하고 있습니다. 134 | > * `\samples\WIoT-QC01_BG96\WIoT-QC01_Arduino_GPS\` 135 | 136 | 137 | ### 2. Modify parameters 138 | 139 | Ping 테스트 예제 코드는 별도로 수정할 Parameter가 없습니다. 140 | 141 | ### 3. Compile 142 | 143 | 상단 메뉴의 Compile 버튼을 클릭합니다. 144 | 145 | ![][compile1] 146 | 147 | 컴파일이 완료 되면 다음과 같이 업로드를 수행하여 최종적으로 보드에 업로드를 수행 합니다. 148 | 업로드가 정상적으로 완료되면 'avrdude done. Thank you.' 메시지를 확인 할 수 있습니다. 149 | 150 | ![][compile2] 151 | 152 | ### 4. Run 153 | 154 | 예제 샘플 코드를 통해 Cat.M1 모듈의 GPS 서비스 운용에 대해 파악할 수 있습니다. 155 | 156 | #### 4.1 Connect your board 157 | 스타터 키트와 Arduino Mega2560과 Uart 통신을 하기위해서는 아래와 같이 점퍼 연결이 필요합니다. 158 | 예제 구동을 위해 WIZnet IoT Shield의 UART TXD와 RXD 핀을 Arduino Mega2560 보드의 'Serial 3' `TX3`(14), `RX3`(15) 에 연결합니다. 159 | 160 | | ArduinoMega2560 | TX3 (14) | RX3 (15) | 161 | |:----:|:----:|:----:| 162 | | WIZnet IoT Shield | RXD
(UART Rx for D1/D8) | TXD
(UART Tx for D0/D2) | 163 | 164 | > 보드 상단에 위치한 UART_SEL 점퍼를 제거한 후 (실크 기준) 오른쪽 핀을 Arduino 보드와 연결합니다. 165 | 166 | ![][hw-stack] 167 | 168 | #### 4.2 Functions 169 | 170 | 샘플 코드의 GPS관련 함수는 다음과 같습니다. 171 | 172 | ````cpp 173 | int8_t setGpsOnOff_BG96(bool onoff); 174 | ```` 175 | * 파라메터에 따라 GPS On / Off를 수행합니다. 176 | 177 | 178 | ````cpp 179 | int8_t getGpsLocation_BG96(gps_data *data); 180 | ```` 181 | * gps_data 구조체를 파라메터로 받아, Cat.M1 모듈로부터 획득한 GPS 정보를 저장하여 리턴합니다. 182 | 183 | 184 | #### 4.3 Set up serial monitor 185 | ![][serialMonitor] 186 | 187 | #### 4.3 Get GPS information through a serial terminal 188 | 189 | 성공적으로 연결이 완료된 후 보드를 리셋하면 다음과 같은 시리얼 출력을 확인 할 수 있습니다. 190 | 예제 코드는 Cat.M1 모듈의 상태를 확인한 후 GPS를 구동하여 정보를 출력하도록 구성되어 있습니다. 191 | 192 | > GPS 위치 정보가 확인 될 때까지 약간의 시간이 필요할 수 있습니다. 193 | 194 | ![][2] 195 | 196 | ![][3] 197 | 198 | 199 | 200 | #### 4.4 See the location via Google Maps service (latitude, longitude) 201 | 202 | GPS의 위치 정보 중 위도(latitude)와 경도(longitude)를 Google Maps에 입력하면 손쉽게 측정된 위치를 확인 할 수 있습니다. 203 | 204 | > Google Maps: https://www.google.com/maps/ 205 | 206 | 확인 결과, 분당구 수내동에 위치한 위즈네트 위치가 정확하게 표시되는 것을 알 수 있습니다. 207 | 208 | ![][4] 209 | 210 | 211 | 212 | 213 | [arduino-getting-started]: ./Arduino_get_started.md 214 | [skt-iot-portal]: https://www.sktiot.com/iot/developer/guide/guide/catM1/menu_05/page_01 215 | [link-arduino-compiler]: https://www.arduino.cc/en/Main/Software 216 | [link-arduino Mega2560 Rev3]: https://store.arduino.cc/usa/mega-2560-r3 217 | [link-bg96-atcommand-manual]: https://www.quectel.com/UploadImage/Downlad/Quectel_BG96_AT_Commands_Manual_V2.1.pdf 218 | [link-bg96-gnss-manual]: https://www.quectel.com/UploadImage/Downlad/Quectel_BG96_GNSS_AT_Commands_Manual_V1.1.pdf 219 | 220 | [mbed-guide-bg96-tcp]: ./mbed_guide_bg96_tcp.md 221 | [mbed-guide-bg96-http]: ./mbed_guide_bg96_http.md 222 | [mbed-guide-bg96-mqtt]: ./mbed_guide_bg96_mqtt.md 223 | 224 | [hw-stack]: ./imgs/hw/wiot-shield-wm01-arduinomega2560_stack.png 225 | [compile1]: ./imgs/arduino_guide_ide_compile.png 226 | [compile2]: ./imgs/arduino_guide_ide_compile_finish.png 227 | [serialMonitor]: ./imgs/arduino_guide_ide_serialmonitor.png 228 | 229 | [1]: ./imgs/arduino_guide_bg96_gps-1.png 230 | [2]: ./imgs/arduino_guide_bg96_gps-2.png 231 | [3]: ./imgs/arduino_guide_bg96_gps-3.png 232 | [4]: ./imgs/arduino_guide_bg96_gps-4.png 233 | [gnss]: ./imgs/arduino_guide_bg96_gps-gnss.png 234 | [usbport]: ./imgs/device_manager_quectel_usbport.png 235 | 236 | -------------------------------------------------------------------------------- /docs/Arduino_get_started.md: -------------------------------------------------------------------------------- 1 | # Arduino 기반으로 Cat.M1 개발 시작하기 2 | 3 | ## 목차 4 | 5 | - [소개](#Introduction) 6 | - [Step 1: 필수 구성 요소](#Step-1-Prerequisites) 7 | - [Step 2: 디바이스 준비](#Step-2-PrepareDevice) 8 | - [Step 3: 예제 코드 빌드 및 실행](#Step-3-Build) 9 | - [더 보기](#ReadMore) 10 | 11 | 12 | 13 | ## 소개 14 | 15 | **문서의 주요 내용** 16 | 17 | 이 문서는 [Arduino][link-arduino]를 기반으로 Cat.M1 장치의 개발 환경 구축 및 예제 코드 실행 과정에 대해 설명합니다. 18 | 19 | 각 과정에는 다음 내용들이 포함되어 있습니다: 20 | - WIZnet IoT Shield와 Arduino Mega2560 Rev3 하드웨어 설정 21 | - Arduino 예제 코드 실행 과정 22 | - 디바이스 상에서 Cat.M1 통신 기능 확인 과정 23 | 24 | 25 | ## Step 1: 필수 구성 요소 26 | 이 문서를 따라하기 전에 다음과 같은 것들이 준비되어야 합니다. 27 | 28 | - **Arduino IDE 개발환경을 활용 할 수 있는 컴퓨터** 29 | - 프로그래밍 및 디버깅을 위한 IDE 프로그램 ([Arduino IDE][link-arduino-compiler]) 30 | 31 | - **Cat.M1 디바이스 개발용 하드웨어** 32 | - [Arduino Mega2560 Rev3][link-arduino Mega2560 Rev3] 33 | - WIZnet IoT Shield 34 | - Cat.M1 Interface Board (택 1) 35 | - WIoT-QC01 (앰투앰넷 BG96) 36 | - WIoT-WM01 (우리넷 WM-N400MSE) 37 | - WIoT-AM01 (AM텔레콤 AMM5918K) 38 | 39 | - **Cat.M1 모듈의 (시험 망)개통** 40 | - Cat.M1 모듈로 통신 기능을 구현하려면 **망 개통 과정**이 선행되어야 합니다. 41 | - 한국의 경우, 국내 Cat.M1 서비스 사업자인 SK Telecom의 망 개통 과정이 필요합니다. 42 | 43 | > 모듈은 개발 단계에 따라 시험망 개통 - 상용망 개통 단계를 거쳐야 하며 외장형 모뎀은 즉시 상용망 개통이 가능합니다. 44 | > * 시험망 개통의 경우 [SKT IoT OpenHouse][skt-iot-portal]에 기술 지원 문의 45 | > * 상용망 개통의 경우 USIM 구매 대리점이나 디바이스 구매처에 개통 문의 46 | 47 | 48 | ## Step 2: 디바이스 준비 49 | 50 | ### 하드웨어 설정 51 | 52 | WIZnet IoT Shield를 Arduino Mega2560 Rev3 하드웨어와 결합합니다. 53 | - 두 장치 모두 Arduino UNO Rev3 호환 핀 헤더를 지원하므로 손쉽게 결합(Stacking) 할 수 있습니다. 54 | 55 | ![][1] 56 | 57 | IoT Shield는 다양한 밴더의 Cat.M1 모듈을 활용 할 수 있도록 하드웨어 설정을 제공합니다. 따라서 선택한 Cat.M1 Interface Board를 확인하여 장치 설정이 필요합니다. 58 | 59 | - 각각 밴더의 모듈은 동작 전압, PWRKEY 동작 등에 차이가 있습니다. 60 | - 따라서 Jumper 설정을 통해 인터페이스 보드에 적합한 하드웨어 설정이 선행되어야 합니다. 61 | 62 | Arduino 플랫폼 보드 활용 시, 각 인터페이스 보드에 따른 하드웨어 설정은 다음과 같습니다. 63 | 64 | > Arduino의 경우, 일반적으로 펌웨어 다운로드 및 디버그 용도 `D0`, `D1` UART 인터페이스를 활용합니다. 65 | > * 시리얼 모니터를 통한 디버그 메시지의 확인이 필요한 경우, `D0`, `D1` 이외의 추가 UART를 활용 하시기 바랍니다. 66 | > * Arduino M0 보드 등 여러 개의 UART 포트를 지원하는 경우 `D0`, `D1` 핀을 Cat.M1과 연결하고 다른 UART로 디버그 메시지를 출력하는 방법도 있습니다. 67 | > * 단, Arduino UNO 등 하나의 UART 포트만을 지원하는 경우에 Cat.M1 연결과 디버그 메시지 출력을 함께 수행하려는 경우, Software Serial을 활용하여 `D2`, `D8` 핀으로 Cat.M1 모듈에 연결 하시기 바랍니다. 68 | > * Baudrate에 따라 올바른 출력이 이루어지지 않을 수 있습니다. Arduino Software Serial 라이브러리 관련 내용을 참고 하십시오. 69 | 70 | #### Pin `D0` `D1`의 UART를 활용하는 경우 71 | 72 | | WIoT-QC01/TL01 Jumper settings
| WIoT-WM01 Jumper settings | WIoT-AM01 Jumper settings | 73 | |:--------------------------:|:--------------------------:|:--------------------------:| 74 | |![][hw-settings-arduino-qc01]|![][hw-settings-arduino-wm01]|![][hw-settings-arduino-am01]| 75 | 76 | 77 | #### Pin `D2` `D8`의 UART를 활용하는 경우 78 | 79 | | WIoT-QC01/TL01 Jumper settings
| :heavy_check_mark: WIoT-WM01 Jumper settings | WIoT-AM01 Jumper settings | 80 | |:--------------------------:|:--------------------------:|:--------------------------:| 81 | |![][hw-settings-nucleo-qc01]|![][hw-settings-nucleo-wm01]|![][hw-settings-nucleo-am01]| 82 | 83 | 84 | WIZnet IoT Shield와 Arduino Mega2560과 Uart 통신을 하기위해서는 아래와 같이 점퍼 연결이 필요합니다. 85 | 예제 구동을 위해 WIZnet IoT Shield의 UART TXD와 RXD 핀을 Arduino Mega2560 보드의 'Serial 3' `TX3`(14), `RX3`(15) 에 연결합니다. 86 | 87 | | ArduinoMega2560 | TX3 (14) | RX3 (15) | 88 | |:----:|:----:|:----:| 89 | | WIZnet IoT Shield | RXD
(UART Tx for D0/D2) | TXD
(UART Rx for D1/D8 ) | 90 | 91 | > 보드 상단에 위치한 UART_SEL 점퍼를 제거한 후 (실크 기준) 오른쪽 핀을 Arduino 보드와 연결합니다. 92 | 93 | ### 디바이스 연결 94 | 95 | 하드웨어 설정 후 USB 커넥터를 이용하여 Arduino Mega2560 Rev3 보드와 PC를 연결합니다. PC 운영체제 장치 관리자에서 장치와 연결된 COM 포트를 확인할 수 있습니다. 96 | 97 | ![][5] 98 | 99 | - Arduino IDE를 정상적으로 설치하면, 위와 같이 장치 관리자에서 COM 포트를 확인할 수 있습니다. 100 | 101 | 102 | 103 | 104 | ## Step 3: 예제 코드 빌드 및 실행 105 | 106 | ### Arduino 예제 코드 다운로드 107 | 108 | 다음 링크에서 Arduino 예제 코드를 다운로드한 후, ino 확장자의 프로젝트 파일을 실행 시킵니다. 109 | 110 | > 예제에서 활용할 Ping test sample code는 저장소의 아래 경로에 위치하고 있습니다. 111 | > * `\samples\WIoT-WM01_WM-N400MSE\WIoT-WM01_Arduino_Ping\` 112 | 113 | 본 가이드에서는 우리넷 WM-N400MSE 모듈이 탑재된 WIoT-WM01 인터페이스 보드를 기준으로 설명합니다. 114 | 115 | 116 | ## 프로그램 Build와 실행 117 | 다음 그림과 같이 Arduino Mega2560 보드와 포트를 선택하고, 컴파일을 수행합니다. 118 | 119 | ![][7] 120 | 121 | ![][8] 122 | 123 | 컴파일이 완료 되면 다음과 같이 업로드를 수행하여 최종적으로 보드에 업로드를 수행 합니다. 124 | 업로드가 정상적으로 완료되면 'avrdude done. Thank you.' 메시지를 확인 할 수 있습니다. 125 | 126 | ![][9] 127 | 128 | 업로드를 완료한 후, 시리얼 모니터를 이용하여 정상적으로 Arduino Mega2560 보드에 업로드 되었는지 확인할 수 있습니다. 129 | 130 | ![][10] 131 | 132 | 133 | ## 축하합니다 134 | 이제 여러분은 Arduino 보드 기반에서 WIZnet IoT Shield를 활용하여 LTE Cat.M1 응용을 개발할 모든 준비를 마쳤습니다! 135 | 136 | 137 | ## 더 보기 138 | * [Arduino 기반의 Cat.M1 Ping 테스트 가이드][arduino-guide-wm-n400mse-ping] 139 | * [Arduino 기반의 Cat.M1 PSM 설정 가이드][arduino-guide-wm-n400mse-psm] 140 | 141 | 142 | [skt-iot-portal]: https://www.sktiot.com/iot/developer/guide/guide/catM1/menu_05/page_01 143 | [link-arduino]: https://www.arduino.cc/ 144 | [link-arduino-compiler]: https://www.arduino.cc/en/Main/Software 145 | [link-arduino Mega2560 Rev3]: https://store.arduino.cc/usa/mega-2560-r3 146 | 147 | [arduino-guide-wm-n400mse-ping]: ./Arduino_guide_wm-n400mse_ping.md 148 | [arduino-guide-wm-n400mse-psm]: ./Arduino_guide_wm-n400mse_psm.md 149 | 150 | [hw-settings-arduino-qc01]: ./imgs/hw/WIoT-QC01_JUMP_Arduino_serialD0_D1.png 151 | [hw-settings-arduino-wm01]: ./imgs/hw/WIoT-WM01_JUMP_Arduino_serialD0_D1.png 152 | [hw-settings-arduino-am01]: ./imgs/hw/WIoT-AM01_JUMP_Arduino_serialD0_D1.png 153 | 154 | [hw-settings-nucleo-qc01]: ./imgs/hw/WIoT-QC01_JUMP_Arduino_serialD2_D8.png 155 | [hw-settings-nucleo-wm01]: ./imgs/hw/WIoT-WM01_JUMP_Arduino_serialD2_D8.png 156 | [hw-settings-nucleo-am01]: ./imgs/hw/WIoT-AM01_JUMP_Arduino_serialD2_D8.png 157 | 158 | [1]: ./imgs/hw/wiot-shield-wm01-arduinomega2560_stack.png 159 | [2]: ./imgs/ 160 | [3]: ./imgs/ 161 | [4]: ./imgs/ 162 | [5]: ./imgs/arduino_get_started_5.png 163 | [6]: ./imgs/arduino_get_started_6.png 164 | [7]: ./imgs/arduino_get_started_7.png 165 | [8]: ./imgs/arduino_get_started_8.png 166 | [9]: ./imgs/arduino_get_started_9.png 167 | [10]: ./imgs/arduino_get_started_10.png 168 | -------------------------------------------------------------------------------- /docs/Arduino_guide_AMM529_ping.md: -------------------------------------------------------------------------------- 1 | # Arduino 기반의 Cat.M1 Ping 테스트 가이드 2 | 3 | ## 목차 4 | 5 | - [시작하기 전에](#Prerequisites) 6 | - [소개](#Step-1-Overview) 7 | - [AT 명령어](#Step-2-ATCommand) 8 | - [동작 구조 예제](#Step-3-SampleCode) 9 | - [예제 코드 빌드 및 실행](#Step-4-Build-and-Run) 10 | 11 | 12 | ## 시작하기 전에 13 | 14 | > * 하드웨어 설정과 개발환경 구축은 **[Arduino 기반으로 Cat.M1 디바이스 개발 시작하기][arduino-getting-started]** 문서에 상세히 설명되어 있습니다. 15 | 16 | > * Cat.M1과 같은 Cellular IoT 디바이스는 통신 서비스 사업자의 운영 기준 및 규정에 따라 모듈 펌웨어 및 동작 방식에 차이가 있을 수 있습니다. 본 문서는 한국 **[SK Telecom Cat.M1 서비스][skt-iot-portal]** 를 기준으로 작성되었습니다. 17 | 18 | 19 | ### Development Environment 20 | * **[Arduino IDE][link-arduino-compiler]** 21 | 22 | ### Hardware Requirement 23 | 24 | | MCU Board | IoT Shield Interface Board | 25 | |:--------:|:--------:| 26 | | [Arduino Mega2560 Rev3][link-arduino Mega2560 Rev3] | WIoT-WM01 (WM-N400MSE) | 27 | 28 | 29 | ## 소개 30 | 본 문서에서는 Arduino IDE 기반 개발 환경에서 WIZnet IoT shield와 Arduino Mega2560 Rev3 보드를 이용하여 Cat.M1 단말의 Ping 테스트 방법에 대한 가이드를 제공합니다. 31 | 32 | Cat.M1 모듈 및 외장형 모뎀은 UART 인터페이스를 통해 활용하는 AT 명령어로 제어하는 것이 일반적입니다. Cat.M1 모듈 제조사에 따라 AT 명령어의 차이는 있지만, 일반적인 Ping 테스트를 위한 통신 과정은 다음과 같은 순서로 구현합니다. 33 | 34 | 1. Echo 모드 설정 35 | 2. USIM 상태 확인 36 | 3. 네트워크 접속 확인 37 | 4. 네트워크 인터페이스(PDP Context) 활성화 38 | 5. Ping 테스트 39 | 40 | 41 | ## AT 명령어 42 | 43 | ### 1. Echo 모드 설정 44 | 45 | **AT Command:** ATE 46 | 47 | **Syntax:** 48 | 49 | | Type | Syntax | Response | Example 50 | |:--------|:--------|:--------|:--------| 51 | | Write | ATE[n] | OK | ATE0
OK | 52 | 53 | **Defined values:** 54 | 55 | | Parameter | Type | Description | 56 | |:--------|:--------|:--------| 57 | | [n] | Integer | 0 : Echo mode OFF
1 : Echo mode ON | 58 | 59 | ### 2. USIM 상태 확인 60 | 61 | **AT Command:** AT+CPIN 62 | 63 | **Syntax:** 64 | 65 | | Type | Syntax | Response | Example 66 | |:--------|:--------|:--------|:--------| 67 | | Read | AT+CPIN? | +CPIN:[code]

OK | AT+CPIN?
+CPIN:READY

OK | 68 | 69 | **Defined values:** 70 | 71 | 72 | | Parameter | Type | Description | 73 | |:--------|:--------|:--------| 74 | | [code] | String | READY: PIN1 코드 조합이 끝난 상태
SIM PIN: PIN1 코드 조합 대기
SIM PUK: PIN Lock 상태. PIN Lock 해제 코드 [PUK] %입력 대기
| 75 | 76 | ### 3. 네트워크 접속 확인 77 | 78 | **AT Command:** AT+CEREG 79 | 80 | **Syntax:** 81 | 82 | | Type | Syntax | Response | Example 83 | |:--------|:--------|:--------|:--------| 84 | | Read | AT+CEREG=[n] | OK | AT+CEREG=0
OK | 85 | | Read | AT+CEREG? | +CEREG: [n],[stat]
OK | AT+CEREG?
+CEREG:0,1
OK | 86 | | Read | AT+CEREG=?| +CEREG: (list of supported [n]s) | AT+CEREG=?
+CEREG: (0-2,4)
OK| 87 | 88 | 89 | **Defined values:** 90 | 91 | | Parameter | Type | Description | 92 | |:--------|:--------|:--------| 93 | | [n] | Integer | 0 : 알림하지 않습니다.
1 : +CEREG[stat]의 자동알림을 유효하게 합니다. 네트워크 등록 상태가 변화했을 경우, 외부장치에 알립니다.
2 : +CEREG[stat][[[tac],[rac_mme],[ci],[act]]의 자동알림을 유효하게 합니다. 네트워크 등록 상태가 변했을 경우, 외부장치에 알립니다.
4: +CEREG: [stat][,[[tac],[[ci],[[AcT][,,[,[[Active-Time]],[[Periodic TAU]]의 PSM을 사용하는 단말의 자동알림을 유효하게 합니다. 네트워크 등록상태가 변했을 경우, 외부장치에 알립니다. 94 | | [stat] | Integer | 0 : 등록 되지 않음(검색하지 않음)
1 : 등록됨
2 : 등록 되지 않음(검색 중)
3 : 등록 거부
4 : Unknown
5 : 등록됨(로밍)
| 95 | | [tac] | Max 1024 char | Tracking Area Code 값으로 Hexadecimal 형식입니다. | 96 | | [rac_or_mme] | Max 1024 char | RAC 값 혹은 MME 값을 표기합니다. Hexadecimal 형식입니다. | 97 | | [ci] | Max 1024 char | Cell ID 값을 표기합니다. Hexadecimal 형식입니다. | 98 | | [act] | Integer | Access Technology 값을 표기합니다.
0: GSM access technology
1: GSM Compact access technology
2:UMTS access technology
3:EGPRS access technology
4: HSDPA access technology
5:HSUPA access technology
6: HSDPA & HSUPA access technology
7: LTE access technology
8: LTE M1 (A/Gb) access technology
9: LTE NB (S1) access technology
10: Unspecified access technology | 99 | | [Active-Time] | One byte in an 8 bit format | Active Time value를 표시합니다.
3Bit: (단위)
-"000" 2초
-"001" 1분
-"010" 6분
5Bit: 시간

예) "00100100" = 4분 | 100 | |[Periodic-TAU]|One byte in an 8 bit format | Extended periodic TAU 를 표시합니다.
3Bit: (단위)
-"000" 10분
-"001" 1시간
-"010" 10시간
-"011" 2초
-"101" 1분
-"110" 320 시간
5Bit: 시간

예) "01000111" = 70 시간| 101 | 102 | ### 4. PDP Context 활성화 103 | > PDP(Packet Data Protocol)란 단말과 외부 패킷 데이터 네트워크 사이의 데이터 송수신을 위한 연결을 제공하기 위해 사용하는 네트워크 프로토콜을 뜻하며, PDP Context는 이러한 연결 과정에서 사용되는 정보의 집합을 의미합니다. 104 | 105 | ####CGATT, NETCONN 확인 필요 106 | 107 | **AT Command:** AT*RNDISDATA 108 | 109 | **Syntax:** 110 | 111 | | Type | Syntax | Response | Example 112 | |:--------|:--------|:--------|:--------| 113 | | Write | AT*RNDISDATA=(value1) | *RNDISDATA:(value1)

OK | AT\*RNDISDATA=1
*RNDISDATA: 1

OK | 114 | 115 | **Defined values:** 116 | 117 | | Parameter | Type | Description | 118 | |:--------|:--------|:--------| 119 | | (value) | Integer | 0 : Packet Data interface 와 연결 해제
1 : Packet Data interface 와 연결 | 120 | 121 | 122 | ### 5. Ping 테스트 123 | 124 | **AT Command:** AT@PING6 125 | 126 | **Syntax:** 127 | 128 | | Type | Syntax | Response | Example 129 | |:--------|:--------|:--------|:--------| 130 | | Write | AT@PING6="[IPv6 Addr] -c[count]" | OK | AT@PING6="2001:4860:4860::8888 -c 8"

OK
PING
2001:4860:4860::8888(2001:4860:4860::8888) 56 data bytes
64 bytes from 2001:4860:4860::8888: icmp_seq=1 ttl=49 time=391 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=2 ttl=49 time=102 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=3 ttl=49 time=123 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=4 ttl=49 time=99.9 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=5 ttl=49 time=143 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=6 ttl=49 time=80.8 ms
80
64 bytes from 2001:4860:4860::8888: icmp_seq=7 ttl=49 time=118 ms
64 bytes from 2001:4860:4860::8888: icmp_seq=8 ttl=49 time=76.0 ms


--- 2001:4860:4860::8888 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7011ms
rtt min/avg/max/mdev = 76.066/142.028/391.598/96.569 ms | 131 | 132 | 133 | **Defined values:** 134 | 135 | | Parameter | Type | Description | 136 | |:--------|:--------|:--------| 137 | | [IPv6 Addr] | String | Host IP address (URL, IPv6) | 138 | | [count] | Integer | Ping 송신 횟수 | 139 | 140 | ps. IPv4 (기존에 많이 사용되고 있는 IP 주소) 의 경우, IPv6로 주소를 변형하여야 합니다. (64:ff9b:: Header Use) 141 | ex) IPv4 주소 123.123.123.123 의 경우 -> HEX로 변환 7B.7B.7B.7B 142 | ->64:ff9b::7b7b:7b7b 143 | 144 | 145 | ## 동작 구조 예제 146 | 147 | ``` 148 | /* WM-N400MSE TCP Send/Recv */ 149 | 150 | // AT 명령어 echo 비활성화 151 | ATE0 152 | 153 | OK 154 | 155 | // USIM 상태 확인 (READY면 정상) 156 | AT+CPIN? 157 | +CPIN:READY 158 | 159 | OK 160 | 161 | // 망 접속 확인 (+CEREG: 0,1 이면 접속) 162 | AT+CEREG? 163 | +CEREG: 0,1 164 | 165 | OK 166 | 167 | ###확인해야할 부분 168 | // PDP context 활성화 169 | AT*RNDISDATA=1 170 | *RNDISDATA:1 171 | 172 | OK 173 | 174 | ###확인해야할 부분 175 | 176 | // Ping 테스트 177 | AT@PING6="2001:4860:4860::8888 -c 8" 178 | @PING6:ping6 2001:4860:4860::8888 179 | 180 | 181 | OK 182 | PING 183 | 2001:4860:4860::8888(2001:4860:4860::8888) 56 data bytes 184 | 64 bytes from 2001:4860:4860::8888: icmp_seq=1 ttl=49 time=329 ms 185 | 64 bytes from 2001:4860:4860::8888: icmp_seq=2 ttl=49 time=121 ms 186 | 64 bytes from 2001:4860:4860::8888: icmp_seq=3 ttl=49 time=137 ms 187 | 64 bytes from 2001:4860:4860::8888: icmp_seq=4 ttl=49 time=101 ms 188 | 189 | --- 2001:4860:4860::8888 ping statistics --- 190 | 4 packets transmitted, 4 received, 0% packet loss, time 3005ms 191 | rtt min/avg/max/mdev = 101.432/172.622/329.946/91.726 ms 192 | 193 | ``` 194 | 195 | 196 | 197 | 198 | 199 | 200 | [arduino-getting-started]: ./Arduino_get_started.md 201 | [skt-iot-portal]: https://www.sktiot.com/iot/developer/guide/guide/catM1/menu_05/page_01 202 | [link-arduino-compiler]: https://www.arduino.cc/en/Main/Software 203 | [link-arduino Mega2560 Rev3]: https://store.arduino.cc/usa/mega-2560-r3 204 | 205 | [hw-stack]: ./imgs/hw/wiot-shield-wm01-arduinomega2560_stack.png 206 | [compile1]: ./imgs/arduino_guide_ide_compile.png 207 | [compile2]: ./imgs/arduino_guide_ide_compile_finish.png 208 | [serialMonitor]: ./imgs/arduino_guide_ide_serialmonitor.png 209 | 210 | [1]: ./imgs/Arduino_guide_wm-n400mse_ping_1.png 211 | -------------------------------------------------------------------------------- /docs/Arduino_guide_AMM592_SMS.md: -------------------------------------------------------------------------------- 1 | # Arduino 기반의 Cat.M1 SMS 데이터 통신 가이드 2 | 3 | ## 목차 4 | 5 | - [시작하기 전에](#Prerequisites) 6 | - [소개](#Step-1-Overview) 7 | - [AT 명령어](#Step-2-ATCommand) 8 | - [동작 구조 예제](#Step-3-SampleCode) 9 | - [예제 코드 빌드 및 실행](#Step-4-Build-and-Run) 10 | 11 | 12 | ## 시작하기 전에 13 | 14 | > * 하드웨어 설정과 개발환경 구축은 **[Arduino 기반으로 Cat.M1 디바이스 개발 시작하기][arduino-getting-started]** 문서에 상세히 설명되어 있습니다. 15 | 16 | > * Cat.M1과 같은 Cellular IoT 디바이스는 통신 서비스 사업자의 운영 기준 및 규정에 따라 모듈 펌웨어 및 동작 방식에 차이가 있을 수 있습니다. 본 문서는 한국 **[SK Telecom Cat.M1 서비스][skt-iot-portal]** 를 기준으로 작성되었습니다. 17 | 18 | 19 | ### Development Environment 20 | * **[Arduino IDE][link-arduino-compiler]** 21 | 22 | ### Hardware Requirement 23 | 24 | | MCU Board | IoT Shield Interface Board | 25 | |:--------:|:--------:| 26 | | [Arduino Mega2560 Rev3][link-arduino Mega2560 Rev3] | WIoT-(AMM592SK)
WIoT-AM01 | 27 | 28 | 29 | ## 소개 30 | 본 문서에서는 Arduino IDE 기반 개발 환경에서 WIZnet IoT shield와 Arduino Mega2560 Rev3 보드를 이용하여 Cat.M1 단말의 SMS 데이터 송수신 방법에 대한 가이드를 제공합니다. 31 | 32 | Cat.M1 모듈 및 외장형 모뎀은 UART 인터페이스를 통해 활용하는 AT 명령어로 제어하는 것이 일반적입니다. Cat.M1 모듈 제조사에 따라 AT 명령어의 차이는 있지만, TCP/IP 소켓 통신에 비해서 비교적 간단한 AT Command로 테스트를 할 수 있습니다. 33 | 이번 테스트에서는 일반적인 스마트폰을 이용하여, Cat M1 모듈의 SMS 송수신 예제를 설명하도록 하겠습니다. 34 | 35 | 36 | ## AT 명령어 37 | 38 | > AT 명령어 설명은 AMTelecom AT Command Manual에서 확인 하실 수 있습니다. 39 | 40 | 41 | ### 1. Cat M1 모듈의 일반적인 동작 설명은 생략 42 | 43 | > Cat M1 모듈의 에코 모드 설명, USIM 상태 확인, 네트워크 접속 확인 등의 일반적인 내용은 TCP 가이드를 참고하시기 바랍니다. 44 | 45 | ### 2. AM Telecom SMS 명령어 46 | AM Telecom 모듈에서 제공하는 SMS 명령이 많이 있지만, 본 장에서는 테스트에 사용된 명령어에 대해서만 설명합니다. 자세한 내용은 AM Telecom 매뉴얼을 참고하시기 바랍니다. 47 | 48 | **AT Command:** AT+CMGS SMS 메시지 전송 49 | 50 | **Syntax:** 51 | 52 | | Type | Syntax | Response | Example 53 | |:--------|:--------|:--------|:--------| 54 | | Test | AT+CMGS=? | OK | - | 55 | | Write | AT+CMGS=(da),[(toda)]| +CMGS:(mr),[(scts)] | AT+CMGS="1502101xxxx",129
>This is a test from .... //보낼 SMS 데이터 입력 후
+CMGS:247
OK | 56 | 57 | ps. 파라미터[(toda)]를 생략하고 사용하는 경우 58 | - (da)의 첫번째 값이 (+)이면, International numbering scheme 로 설정 됩니다. 59 | - (da)의 첫번째 값이 (+)가 아닌 경우, National numbering scheme 로 설정 됩니다. 60 | 61 | **Defined values:** 62 | 63 | | Parameter | 범위 | Description | 64 | |:--------|:--------|:--------| 65 | | (da) | 0 ~ 20 | SMS를 보낼 수신(상대방) 전화번호 | 66 | | [(toda)] | 129, 145 | SMS 수신측 단말의 전화번호 타입
129:National numbering scheme
145:International numbering scheme("+"포함)| 67 | | (mr) | 0 ~ 255 | SMS 참조번호. 모듈이 자동으로 설정| 68 | |(scts) | 0 ~ 20 | SMS가 SMS 센터에 도착한 시간| 69 | 70 | 71 | 72 | **AT Command:** AT+CMGL 문자 메시지 수신 73 | 74 | **Syntax:** 75 | 76 | | Type | Syntax | Response | Example| 77 | |:--------|:--------|:--------|:--------| 78 | | Read | AT+CMGL=(stat) | (PDU Mode)
+CMGL (index),(stat),(alpha),(length)
(pdu)
OK

(TEXTMode)
+CMGL (index),(stat),(oa/da),(alpha),(scts)[,(tooa/toda),(length)]
(data)
OK| (PDU Mode)
AT+CMGL=4
+CMGL 0,1,,33
079128019291900204BA11020197701F500005110023132406310D3E614442DCFE9A066793E0F9FCB
OK

(TEXT Mode)
AT+CMGL="ALL"
+CMGL 0,"REC READ","01029177105",,"15/01/20,13:23:04+36"
SMS Test Message
OK | 79 | 80 | **Defined values:** 81 | 82 | | Parameter | 범위 | Description | 83 | |:--------|:--------|:--------| 84 | | (stat) | (PDU Mode)
0 ~ 4

(TEXT Mode)
("REC UNREAD", "REC READ", "STO UNSENT","STO SENT","ALL")|(PDU Mode)
0: 신규 SMS, 1: 읽은 SMS
2: 전송되지 않은 SMS, 3: 전송된 SMS
4: 모든 SMS
(TEXT Mode)
"REC UNREAD" : 신규 SMS, "REC READ" : 읽은 SMS
"STO UNSENT" : 전송되지 않은 SMS, "STO SENT" : 전송된 SMS
"ALL" : 모든 SMS | 85 | | (index) | 0 ~ 24 | 메모리에서 메시지의 위치 | 86 | | (alpha) | 0 ~ 90 | Phonebook 항목에 해당하는 (da)/(oa)번호의 영수자 표현 | 87 | | (length) | 0 ~ 255 | (PDU Mode)
PDU의 길이
(TEXT Mode)
문자의 길이 | 88 | | (pdu) | 0 ~ 255 | PDU data (3 GPP TS23 040) | 89 | | (oa/da) | 0 ~ 48 | 발신/착신 전화번호| 90 | | (scts) | 0 ~ 20 | 시간 문자열 형식의 TP-Service Centre Time Stamp | 91 | | (tooa/toda) | 129, 145 | 129 : National numbering scheme
145 : International numbering scheme("+"포함)| 92 | | (data) | 0 ~ 255 | TP-User-Data| 93 | 94 | **AT Command:** AT+CSCS Character Set 설정 명령어 95 | 96 | | Type | Syntax | Response | Example | 97 | |:--------|:--------|:--------|:--------| 98 | | READ | AT+CSCS? | +CSCS:(chset)
OK | AT+CSCS?
+CSCS:"GSM"
OK| 99 | | READ | AT+CSCS=? | +CSCS:(파라미터범위)
OK | AT+CSCS=?
+CSCS:"GSM","UCS2")
OK| 100 | | Write | AT+CSCS:(chset) | OK | AT+CSCS="GSM"
OK| 101 | 102 | 103 | **AT Command:** AT+CNMI 수신 SMS의 표시 설정 명령어 104 | 105 | **Syntax:** 106 | 107 | | Type | Syntax | Response | Example| 108 | |:--------|:--------|:--------|:--------| 109 | | Write | AT+CNMI=[(mode)[,(mt)[,(bm)[,(ds)[,(bfr)]]]]] | OK | AT+CNMI=2,1,0,0,0
OK| 110 | | Read | AT+CNMI? | +CNMI:(mode),(mt),(bm),(ds),(bfr)
OK | AT+CNMI?
+CNMI:2,1,0,0,0
OK| 111 | 112 | **Defined values:** 113 | 114 | | Parameter | 범위 | Description | 115 | |:--------|:--------|:--------| 116 | | (mode) | 0 ~ 2 | 수신한 SMS의 알림 방법 설정
0: SMS 알림과 SMS 전송알림을 모듈의 SMS 알림용 버퍼에 저장하고, 외부장치에는 전송하지 않음
1: SMS 알림과 SMS 전송 알림을 직접 외부장치에 전송, 전송불가 시 알림을 파기
2: SMS 알림과 SMS 전송알림을 직접 외부장치에 전송, 전송불가 시 SMS 알림을 모듈의 SMS 알림용 버퍼에 저장하고, 전송 가능한 때에 외부장치에 전송함 | 117 | | (mt) | 0 ~ 3 | 수신한 SMS의 저장 방법이나 알림 방법을 설정
0: SMS의 수신을 외부 장치에 알림하지 않음
1: 수신한 SMS를 모듈 또는 USIM 카드에 저장하고, 저장 위치를 외부 장치로 전송
2: 수신한 SMS를 모듈 또는 USIM 카드에 저장하지 않고, 직접 외부 장치에 전송
3: Class3 SMS의 경우는, 직접 전송(+CMT)수행함(mt=2 인 경우와 동일). Class3 이외의 SMS인 경우는, 모듈 내에 저장하고, 저장 위치를 전송(+CMTI)함(m5=1 인 경우와 동일)| 118 | | (bm) | 0, 2 | 0: Cell Broadcast Messages를 DTE에 전송하지 않음
2: Cell Broadcast Messages를 unsolicited result code와 함께 DTE에 전송 | 119 | | (ds) | 0 ~ 2 | SMS 전송 알림에 대해 설정
0: SMS 전송 알림을 모듈에 저장하지 않고, 외부 장치에도 전송하지 않음
1: SMS 전송 알림을 모듈에 저장하지 않고, 직접 외부 장치에 전송하고, Unsolicited result code(+CDS)로 전송 (mode)를 0또는 2로 설정하는 경우, 본 파라미터를 1로 설정하면 안됨
2: SMS의 전송 알림을 모듈에 저장하고, Unsolicited result code(+CDSI)로 저장 위치를 외부 장치로 전송| 120 | | (bfr) | 0, 1 | 0: (mode)=1..2가 입력된 경우, Unsolicited result code의 TA buffer를 TE에 전송
1: (mode)=1..2가 입력된 경우, Unsolicited result code의 TA buffer를 초기화| 121 | 122 | 123 | 124 | ## 동작 구조 예제 (AM Telecom Cat.M1 SMS) 125 | 126 | #작성예정 127 | 128 | ``` 129 | AT*SMSMO=0107576****,,1,1,48656C6C6F // “Hello” 전송 130 | OK 131 | 132 | *SMSACK 133 | 134 | AT*SMSMO=0107576****,,1,1,BFC0C7C2C7CFBFECBDBA // “오픈하우스” 전송 135 | OK 136 | 137 | *SMSACK 138 | 139 | AT*SKT*READMT=0 // “Hi” 수신 140 | *SKT*READMT:0,20190225165426,0107576****,4098,Hi 141 | 142 | OK 143 | 144 | AT*SKT*READMT=0 // “안녕하세요?” 수신 145 | *SKT*READMT:0,20190225165505,0107576****,4098,안녕하세요? 146 | 147 | OK 148 | ``` 149 | **[ Note ]** 150 | EUC-KR이 적용되지 않은 PC 일부 터미널에서는 한글이 깨져 보일 수 있으니 주의 하시기 바랍니다. 151 | > AT*SKT*READMT=0 152 | > *SKT*READMT:0,20190225165505,0107576****,4098,¾E³cCI¼¼¿a? 153 | > 154 | > OK 155 | 156 | 스마트폰에서 SMS 로그는 아래와 같습니다. 157 | ![][1] 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | [arduino-getting-started]: ./Arduino_get_started.md 166 | [skt-iot-portal]: https://www.sktiot.com/iot/developer/guide/guide/catM1/menu_05/page_01 167 | [link-arduino-compiler]: https://www.arduino.cc/en/Main/Software 168 | [link-arduino Mega2560 Rev3]: https://store.arduino.cc/usa/mega-2560-r3 169 | [link-bg96-atcommand-manual]: https://www.quectel.com/UploadImage/Downlad/Quectel_BG96_AT_Commands_Manual_V2.1.pdf 170 | [link-bg96-mqtt-an]: https://www.quectel.com/UploadImage/Downlad/Quectel_BG96_MQTT_Application_Note_V1.0.pdf 171 | 172 | [hw-stack]: ./imgs/hw/wiot-shield-wm01-arduinomega2560_stack.png 173 | [compile1]: ./imgs/arduino_guide_ide_compile.png 174 | [compile2]: ./imgs/arduino_guide_ide_compile_finish.png 175 | [serialMonitor]: ./imgs/arduino_guide_ide_serialmonitor.png 176 | 177 | [1]: ./imgs/arduino_guide_bg96_sms-1.png 178 | [2]: ./imgs/arduino_guide_bg96_sms-2.png 179 | [3]: ./imgs/arduino_guide_bg96_sms-3.png 180 | [4]: ./imgs/arduino_guide_bg96_sms-4.png 181 | -------------------------------------------------------------------------------- /docs/Arduino_guide_wm-n400mse_gps.md: -------------------------------------------------------------------------------- 1 | # Arduino 기반으로 Cat.M1 GPS 활용하기 2 | 3 | ## 목차 4 | 5 | - [시작하기 전에](#Prerequisites) 6 | - [소개](#Step-1-Overview) 7 | - [AT 명령어](#Step-2-ATCommand) 8 | - [동작 구조 예제](#Step-3-SampleCode) 9 | - [예제 코드 빌드 및 실행](#Step-4-Build-and-Run) 10 | 11 | 12 | ## 시작하기 전에 13 | 14 | > * 하드웨어 설정과 개발환경 구축은 **[Arduino 기반으로 Cat.M1 디바이스 개발 시작하기][arduino-getting-started]** 문서에 상세히 설명되어 있습니다. 15 | 16 | > * Cat.M1과 같은 Cellular IoT 디바이스는 통신 서비스 사업자의 운영 기준 및 규정에 따라 모듈 펌웨어 및 동작 방식에 차이가 있을 수 있습니다. 본 문서는 한국 **[SK Telecom Cat.M1 서비스][skt-iot-portal]** 를 기준으로 작성되었습니다. 17 | 18 | 19 | ### Development Environment 20 | * **[Arduino IDE][link-arduino-compiler]** 21 | 22 | ### Hardware Requirement 23 | 24 | | MCU Board | IoT Shield Interface Board | 25 | |:--------:|:--------:| 26 | | [Arduino Mega2560 Rev3][link-arduino Mega2560 Rev3] | WIoT-WM01 (WM-N400MSE) | 27 | 28 | > * 별도의 GNSS Antenna가 필요합니다. 29 | > * WM-N400MSE의 펌웨어 버전 S130xx.027 이후부터 GPS가 지원됩니다. ATI 혹은 AT$$SWVER 를 이용하여 펌웨어 버전을 확인 후, 이전 버전인 경우, 오픈하우스(openhouse@wiznet.io)에 문의하시기 바랍니다. 30 | 31 | 32 | ## 소개 33 | 34 | 본 문서에서는 Arduino 기반 개발 환경에서 WIZnet IoT shield와 Arduino Mega2560 Rev3 보드를 이용하여 Cat.M1 단말의 GPS 활용 방법에 대한 가이드를 제공합니다. 35 | 36 | 대부분의 Cat.M1 장치는 GPS(Global Positioning System)를 지원하고 있습니다. GPS는 범지구 위성 항법 시스템(GNSS, Global Navigation Satellite System)의 한 종류로, 대중적으로 활용되는 글로벌 위성 위치 확인 시스템입니다. 37 | 38 | ![][gnss] 39 | 40 | Cat.M1 모듈의 GPS기능을 활용하면 아이나 반려동물, 귀중품의 위치를 실시간으로 파악하는 위치 트래커(GPS tracking unit) 등의 위치기반 서비스를 손쉽게 구현 할 수 있습니다. Cat.M1 기반의 위치 트래커는 기존의 블루투스 스마트 태그(Bluetooth Smart Tags)와 달리, 모듈 자체적으로 파악한 GPS 정보를 LTE망을 이용하여 사용자에게 전달함으로써 보다 빠르고 정확한 위치 파악이 가능한 것이 큰 장점입니다. 41 | 42 | Cat.M1 모듈 및 외장형 모뎀은 UART 인터페이스를 통해 활용하는 AT 명령어로 제어하는 것이 일반적입니다. GPS 정보의 획득 기능도 AT 명령어를 이용하여 활성화 할 수 있습니다. 43 | 44 | 45 | ## AT 명령어 46 | 47 | > AT 명령어에 대한 좀 더 상세한 설명은 우리넷의 AT Command Manual에서 확인 하실 수 있습니다. 48 | > * [WM-N400MSE_AT_Commands_Guide_v1.1][link-wm-n400mse-atcommand-manual] 49 | > * [WM-N400S series_GPS_Guide][link-wm-n400mse-gnss-manual] 50 | 51 | ### 0. S/W Version 확인 52 | 53 | S/W Version S430XX.015 (2019년 12월 1일 이후 빌드 버전)의 경우 GPS 출력 인터페이스 설정을 해주어야만 GPS 기능이 활성화 됩니다. 54 | 55 | 이전 버전의 경우에는 "1. GPS 기능 활성화" AT Command를 바로 사용하시면 됩니다. 56 | 57 | **AT Command:** AT$$SWVER 58 | 59 | | Type | Syntax | Response | Example 60 | |:--------|:--------|:--------|:--------| 61 | | Read | AT$$SWVER | $$SWVER:,<빌드 시간 정보> | AT$$SWVER
$$SWVER: Sxx0XXX.000, Dec 01 2017 15:15:15
OK | 62 | 63 | ### 0-1. S/W Version 이 430XX.015 (2019년 12월 1일 이후 빌드 버전) 인 경우 GPS 기능 출력 인터페이스 설정 64 | 65 | S/W Version 430XX.015 (2019년 12월 1일 이후 빌드 버전)의 경우 아래 명령어를 사용하여 GPS Interface를 설정하고 활성화 합니다. 66 | 67 | **AT Command:** AT$$GPSCONF 68 | AT$$GPSCONF=1,0,1000,252,1,0,1,1 69 | 70 | ps. 각각의 파라미터 값은 수정이 가능하며, 상세한 파라미터에 대한 내용은 추후에 업데이트 할 예정입니다. 71 | 72 | 73 | ### 1. GPS 기능 활성화 74 | 75 | GPS 기능을 활성화 합니다. 76 | 77 | **AT Command:** AT$$GPS 78 | 79 | **Syntax:** 80 | 81 | | Type | Syntax | Response | Example 82 | |:--------|:--------|:--------|:--------| 83 | | Write | AT$$GPS | OK | AT$$GPS
OK | 84 | 85 | ### 2. GPS 기능 비활성화 86 | 87 | GPS 기능을 비활성화 합니다. 88 | 89 | **AT Command:** AT$$GPSSTOP 90 | 91 | **Syntax:** 92 | 93 | | Type | Syntax | Response | Example 94 | |:--------|:--------|:--------|:--------| 95 | | Write | AT$$GPSSTOP | OK | AT$$GPSSTOP
OK | 96 | 97 | 98 | ## 동작 구조 예제 99 | 100 | WIZnet IoT Shield를 Standalone 모드로 동작시켜, 터미널 프로그램으로 직접 AT 명령어를 입력해 보면서 동작 순서를 확인합니다. 101 | 기본적인 GPS 기능 활용을 위해서는 `AT$$GPS`(GPS on), `AT$$GPSSTOP`(GPS off) AT 명령어를 이용합니다. 102 | 103 | 다음과 같이 확인 할 수 있습니다. 104 | 105 | ![][1] 106 | 107 | 108 | ## 예제 코드 빌드 및 실행 109 | 110 | 111 | 112 | > Google Maps: https://www.google.com/maps/ 113 | 114 | 115 | 116 | [arduino-getting-started]: ./Arduino_get_started.md 117 | [skt-iot-portal]: https://www.sktiot.com/iot/developer/guide/guide/catM1/menu_05/page_01 118 | [link-arduino-compiler]: https://www.arduino.cc/en/Main/Software 119 | [link-arduino Mega2560 Rev3]: https://store.arduino.cc/usa/mega-2560-r3 120 | [link-bg96-atcommand-manual]: https://www.quectel.com/UploadImage/Downlad/Quectel_BG96_AT_Commands_Manual_V2.1.pdf 121 | [link-bg96-mqtt-an]: https://www.quectel.com/UploadImage/Downlad/Quectel_BG96_MQTT_Application_Note_V1.0.pdf 122 | [link-wm-n400mse-atcommand-manual]: ./datasheet/WM-N400MSE_AT_Commands_Guide_v1.1.pdf 123 | [link-wm-n400mse-gnss-manual]: ./datasheet/WM-N400S%20series_GPS_Guide.pdf 124 | 125 | [hw-stack]: ./imgs/hw/wiot-shield-wm01-arduinomega2560_stack.png 126 | [compile1]: ./imgs/arduino_guide_ide_compile.png 127 | [compile2]: ./imgs/arduino_guide_ide_compile_finish.png 128 | [serialMonitor]: ./imgs/arduino_guide_ide_serialmonitor.png 129 | 130 | [1]: ./imgs/arduino_guide_wmn400-gps-1.png 131 | 132 | [gnss]: ./imgs/mbed_guide_bg96_gps-gnss.png 133 | 134 | 135 | -------------------------------------------------------------------------------- /docs/Arduino_guide_wm-n400mse_ping.md: -------------------------------------------------------------------------------- 1 | # Arduino 기반의 Cat.M1 Ping 테스트 가이드 2 | 3 | ## 목차 4 | 5 | - [시작하기 전에](#Prerequisites) 6 | - [소개](#Step-1-Overview) 7 | - [AT 명령어](#Step-2-ATCommand) 8 | - [동작 구조 예제](#Step-3-SampleCode) 9 | - [예제 코드 빌드 및 실행](#Step-4-Build-and-Run) 10 | 11 | 12 | ## 시작하기 전에 13 | 14 | > * 하드웨어 설정과 개발환경 구축은 **[Arduino 기반으로 Cat.M1 디바이스 개발 시작하기][arduino-getting-started]** 문서에 상세히 설명되어 있습니다. 15 | 16 | > * Cat.M1과 같은 Cellular IoT 디바이스는 통신 서비스 사업자의 운영 기준 및 규정에 따라 모듈 펌웨어 및 동작 방식에 차이가 있을 수 있습니다. 본 문서는 한국 **[SK Telecom Cat.M1 서비스][skt-iot-portal]** 를 기준으로 작성되었습니다. 17 | 18 | 19 | ### Development Environment 20 | * **[Arduino IDE][link-arduino-compiler]** 21 | 22 | ### Hardware Requirement 23 | 24 | | MCU Board | IoT Shield Interface Board | 25 | |:--------:|:--------:| 26 | | [Arduino Mega2560 Rev3][link-arduino Mega2560 Rev3] | WIoT-WM01 (WM-N400MSE) | 27 | 28 | 29 | ## 소개 30 | 본 문서에서는 Arduino IDE 기반 개발 환경에서 WIZnet IoT shield와 Arduino Mega2560 Rev3 보드를 이용하여 Cat.M1 단말의 Ping 테스트 방법에 대한 가이드를 제공합니다. 31 | 32 | Cat.M1 모듈 및 외장형 모뎀은 UART 인터페이스를 통해 활용하는 AT 명령어로 제어하는 것이 일반적입니다. Cat.M1 모듈 제조사에 따라 AT 명령어의 차이는 있지만, 일반적인 Ping 테스트를 위한 통신 과정은 다음과 같은 순서로 구현합니다. 33 | 34 | 1. Echo 모드 설정 35 | 2. USIM 상태 확인 36 | 3. 네트워크 접속 확인 37 | 4. 네트워크 인터페이스(PDP Context) 활성화 38 | 5. Ping 테스트 39 | 40 | 41 | ## AT 명령어 42 | 43 | ### 1. Echo 모드 설정 44 | 45 | **AT Command:** ATE 46 | 47 | **Syntax:** 48 | 49 | | Type | Syntax | Response | Example 50 | |:--------|:--------|:--------|:--------| 51 | | Write | ATE(value) | OK | ATE0
OK | 52 | 53 | **Defined values:** 54 | 55 | | Parameter | Type | Description | 56 | |:--------|:--------|:--------| 57 | | (value) | Integer | 0 : Echo mode OFF
1 : Echo mode ON | 58 | 59 | ### 2. USIM 상태 확인 60 | 61 | **AT Command:** AT$$STAT 62 | 63 | **Syntax:** 64 | 65 | | Type | Syntax | Response | Example 66 | |:--------|:--------|:--------|:--------| 67 | | Read | AT$$STAT? | $$STAT:(status)

OK | AT$$STAT?
$$STAT:READY

OK | 68 | 69 | **Defined values:** 70 | 71 | | Parameter | Type | Description | 72 | |:--------|:--------|:--------| 73 | | (status) | String | INSERT : USIM card inserted
OPEN : MSISDN NULL
READY : 정상적으로 Card Initialization 마친 상태
MNCCARD : 다른 사업자 USIM
MCCRAD : 해외 사업자 USIM
TESTCARD : 장비 테스트 USIM
ONCHIP : onChip SIM mode
PIN : SIM PIN, SIM PUK 등 남은 시도 횟수
NET PIN : PLMN ID 이외의 값을 가진 카드
SIM PERM BLOCK : PUK 모두 실패. 카드 교체 필요
SIM PIN VERIFIED : PIN code 입력 성공
SIM PERSO OK : Personalization unlock 성공
FAILURE, REMOVED : USIM removed
FAILURE,NO_CARD : USIM 삽입 안됨
FAILURE,ERROR : USIM 인식 Error
| 74 | 75 | ### 3. 네트워크 접속 확인 76 | 77 | **AT Command:** AT+CEREG 78 | 79 | **Syntax:** 80 | 81 | | Type | Syntax | Response | Example 82 | |:--------|:--------|:--------|:--------| 83 | | Read | AT+CEREG? | $$STAT:(value),(status)

OK | AT+CEREG?
+CEREG:0,1

OK | 84 | 85 | **Defined values:** 86 | 87 | | Parameter | Type | Description | 88 | |:--------|:--------|:--------| 89 | | (value) | Integer | 0 : 네트워크 등록 unsolicited result code를 사용하지 않음
1 : 네트워크 등록 unsolicited result code를 사용: +CEREG:
2 : 네트워크 등록 및 위치정보 unsolicited result code를 사용: +CEREG: [, , [, ]]
4 : PSM을 적용하려는 사용자 단말(UE)에 대해 네트워크 등록 및 위치 정보 unsolicited result code를 사용: +CEREG: [,[],[],[][,,[,[],[ ]]]] | 90 | | (status) | Integer | 0 : 등록 되지 않음(검색하지 않음)
1 : 등록됨
2 : 등록 되지 않음(검색 중)
3 : 등록 거부
4 : Unknown
5 : 등록됨(로밍)
| 91 | 92 | 93 | ### 4. PDP Context 활성화 94 | > PDP(Packet Data Protocol)란 단말과 외부 패킷 데이터 네트워크 사이의 데이터 송수신을 위한 연결을 제공하기 위해 사용하는 네트워크 프로토콜을 뜻하며, PDP Context는 이러한 연결 과정에서 사용되는 정보의 집합을 의미합니다. 95 | 96 | **AT Command:** AT*RNDISDATA 97 | 98 | **Syntax:** 99 | 100 | | Type | Syntax | Response | Example 101 | |:--------|:--------|:--------|:--------| 102 | | Write | AT*RNDISDATA=(value1) | *RNDISDATA:(value1)

OK | AT\*RNDISDATA=1
*RNDISDATA: 1

OK | 103 | 104 | **Defined values:** 105 | 106 | | Parameter | Type | Description | 107 | |:--------|:--------|:--------| 108 | | (value) | Integer | 0 : Packet Data interface 와 연결 해제
1 : Packet Data interface 와 연결 | 109 | 110 | 111 | ### 5. Ping 테스트 112 | 113 | **AT Command:** AT*PING 114 | 115 | **Syntax:** 116 | 117 | | Type | Syntax | Response | Example 118 | |:--------|:--------|:--------|:--------| 119 | | Write | AT*PING=(Host),(Count) | OK | AT*PING=8.8.8.8,2
OK
PING 64:ff9b::8.8.8.8(64:ff9b::808:808) 56 data bytes
64 bytes from 64:ff9b::808:808: icmp_seq=1 ttl=115 time=150 ms
64 bytes from 64:ff9b::808:808: icmp_seq=2 ttl=115 time=102 ms

--- 64:ff9b::8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1004ms
rtt min/avg/max/mdev = 102.291/126.535/150.780/24.247 ms
rtt min/avg/max/mdev = 102.291/126.535/150.780/24.247 ms
AT+WSOCR=1,www.kma.go.kr,80,1,0
+WSOCR:1,1,64:ff9b::794e:2229/80,TCP | 120 | 121 | 122 | **Defined values:** 123 | 124 | | Parameter | Type | Description | 125 | |:--------|:--------|:--------| 126 | | (Host) | String | IP address (URL, IPv4, IPv6) | 127 | | (Count) | Integer | Ping 송신 횟수 | 128 | 129 | 130 | ## 동작 구조 예제 131 | 132 | ``` 133 | /* WM-N400MSE TCP Send/Recv */ 134 | 135 | // AT 명령어 echo 비활성화 136 | ATE0 137 | 138 | OK 139 | 140 | // USIM 상태 확인 (READY면 정상) 141 | AT$$STAT? 142 | $$STAT:READY 143 | 144 | OK 145 | 146 | // 망 접속 확인 (+CEREG: 0,1 이면 접속) 147 | AT+CEREG? 148 | +CEREG: 0,1 149 | 150 | OK 151 | 152 | // PDP context 활성화 153 | AT*RNDISDATA=1 154 | *RNDISDATA:1 155 | 156 | OK 157 | 158 | // Ping 테스트 159 | AT*PING=8.8.8.8,2 160 | OK 161 | PING 64:ff9b::8.8.8.8(64:ff9b::808:808) 56 data bytes 162 | 64 bytes from 64:ff9b::808:808: icmp_seq=1 ttl=115 time=150 ms 163 | 64 bytes from 64:ff9b::808:808: icmp_seq=2 ttl=115 time=102 ms 164 | 165 | --- 64:ff9b::8.8.8.8 ping statistics --- 166 | 2 packets transmitted, 2 received, 0% packet loss, time 1004ms 167 | rtt min/avg/max/mdev = 102.291/126.535/150.780/24.247 ms 168 | rtt min/avg/max/mdev = 102.291/126.535/150.780/24.247 ms 169 | AT+WSOCR=1,www.kma.go.kr,80,1,0 170 | +WSOCR:1,1,64:ff9b::794e:2229/80,TCP 171 | 172 | OK 173 | 174 | ``` 175 | 176 | 177 | ## 예제 코드 빌드 및 실행 178 | 179 | ### 1. Import project 180 | 다음 링크에서 Arduino 예제 코드를 다운로드한 후, ino 확장자의 프로젝트 파일을 실행 시킵니다. 181 | 182 | > 예제에서 활용할 Ping test sample code는 저장소의 아래 경로에 위치하고 있습니다. 183 | > * `\samples\WIoT-WM01_WM-N400MSE\WIoT-WM01_Arduino_Ping\` 184 | 185 | 186 | ### 2. Modify parameters 187 | 188 | Ping 테스트 예제 코드는 별도로 수정할 Parameter가 없습니다. 189 | 190 | ### 3. Compile 191 | 192 | 상단 메뉴의 Complie 버튼을 클릭합니다. 193 | 194 | ![][compile1] 195 | 196 | 컴파일이 완료 되면 다음과 같이 업로드를 수행하여 최종적으로 보드에 업로드를 수행 합니다. 197 | 업로드가 정상적으로 완료되면 'avrdude done. Thank you.' 메시지를 확인 할 수 있습니다. 198 | 199 | ![][compile2] 200 | 201 | ### 4. Run 202 | #### 4.1 Connect your board 203 | 스타터 키트와 Arduino Mega2560과 Uart 통신을 하기위해서는 아래와 같이 점퍼 연결이 필요합니다. 204 | 예제 구동을 위해 WIZnet IoT Shield의 UART TXD와 RXD 핀을 Arduino Mega2560 보드의 'Serial 3' `TX3`(14), `RX3`(15) 에 연결합니다. 205 | 206 | | ArduinoMega2560 | TX3 (14) | RX3 (15) | 207 | |:----:|:----:|:----:| 208 | | WIZnet IoT Shield | RXD
(UART Rx for D1/D8) | TXD
(UART Tx for D0/D2) | 209 | 210 | > 보드 상단에 위치한 UART_SEL 점퍼를 제거한 후 (실크 기준) 오른쪽 핀을 Arduino 보드와 연결합니다. 211 | 212 | ![][hw-stack] 213 | 214 | 215 | 216 | #### 4.2 Set up serial monitor 217 | ![][serialMonitor] 218 | 219 | #### 4.3 Ping test to Google DNS server 220 | ![][1] 221 | 222 | 223 | 224 | 225 | [arduino-getting-started]: ./Arduino_get_started.md 226 | [skt-iot-portal]: https://www.sktiot.com/iot/developer/guide/guide/catM1/menu_05/page_01 227 | [link-arduino-compiler]: https://www.arduino.cc/en/Main/Software 228 | [link-arduino Mega2560 Rev3]: https://store.arduino.cc/usa/mega-2560-r3 229 | 230 | [hw-stack]: ./imgs/hw/wiot-shield-wm01-arduinomega2560_stack.png 231 | [compile1]: ./imgs/arduino_guide_ide_compile.png 232 | [compile2]: ./imgs/arduino_guide_ide_compile_finish.png 233 | [serialMonitor]: ./imgs/arduino_guide_ide_serialmonitor.png 234 | 235 | [1]: ./imgs/Arduino_guide_wm-n400mse_ping_1.png 236 | -------------------------------------------------------------------------------- /docs/imgs/Arduino_guide_ide_compile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/Arduino_guide_ide_compile.png -------------------------------------------------------------------------------- /docs/imgs/Arduino_guide_wm-n400mse_ping_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/Arduino_guide_wm-n400mse_ping_1.png -------------------------------------------------------------------------------- /docs/imgs/Arduino_guide_wm-n400mse_ping_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/Arduino_guide_wm-n400mse_ping_2.png -------------------------------------------------------------------------------- /docs/imgs/Arduino_guide_wm-n400mse_ping_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/Arduino_guide_wm-n400mse_ping_4.png -------------------------------------------------------------------------------- /docs/imgs/Arduino_guide_wm-n400mse_ping_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/Arduino_guide_wm-n400mse_ping_5.png -------------------------------------------------------------------------------- /docs/imgs/Arduino_guide_wm-n400mse_psm_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/Arduino_guide_wm-n400mse_psm_1.png -------------------------------------------------------------------------------- /docs/imgs/Arduino_guide_wm-n400mse_psm_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/Arduino_guide_wm-n400mse_psm_2.png -------------------------------------------------------------------------------- /docs/imgs/Arduino_guide_wm-n400mse_psm_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/Arduino_guide_wm-n400mse_psm_4.png -------------------------------------------------------------------------------- /docs/imgs/Arduino_guide_wm-n400mse_psm_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/Arduino_guide_wm-n400mse_psm_5.png -------------------------------------------------------------------------------- /docs/imgs/arduino_get_started_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_get_started_10.png -------------------------------------------------------------------------------- /docs/imgs/arduino_get_started_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_get_started_5.png -------------------------------------------------------------------------------- /docs/imgs/arduino_get_started_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_get_started_6.png -------------------------------------------------------------------------------- /docs/imgs/arduino_get_started_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_get_started_7.png -------------------------------------------------------------------------------- /docs/imgs/arduino_get_started_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_get_started_8.png -------------------------------------------------------------------------------- /docs/imgs/arduino_get_started_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_get_started_9.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_am01-psm-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_am01-psm-1.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_am01-psm-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_am01-psm-2.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_am01-psm-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_am01-psm-3.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_gps-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_gps-1.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_gps-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_gps-2.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_gps-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_gps-3.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_gps-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_gps-4.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_gps-gnss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_gps-gnss.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_http-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_http-1.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_mqtt-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_mqtt-1.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_mqtt-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_mqtt-2.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_mqtt-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_mqtt-3.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_mqtt-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_mqtt-4.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_mqtt-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_mqtt-5.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_mqtt-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_mqtt-6.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_mqtt-7.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_mqtt-7.PNG -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_psm-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_psm-1.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_psm-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_psm-2.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_psm-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_psm-3.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_sms-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_sms-1.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_sms-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_sms-2.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_sms-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_sms-3.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_sms-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_sms-4.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_tcp-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_tcp-1.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_tcp-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_tcp-2.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_tcp-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_tcp-3.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_tcp-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_tcp-4.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_tcp-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_tcp-5.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_bg96_tcp-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_bg96_tcp-9.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_ide_compile_finish.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_ide_compile_finish.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_ide_serialmonitor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_ide_serialmonitor.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_wm_n400mse-gps-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_wm_n400mse-gps-1.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_wmn400-gps-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_wmn400-gps-1.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_wmn400_http-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_wmn400_http-2.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_wmn400_http-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_wmn400_http-3.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_wmn400_tcp-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_wmn400_tcp-2.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_wmn400_tcp-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_wmn400_tcp-3.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_wmn400_tcp-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_wmn400_tcp-4.png -------------------------------------------------------------------------------- /docs/imgs/arduino_guide_wmn400_tcp-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/arduino_guide_wmn400_tcp-5.png -------------------------------------------------------------------------------- /docs/imgs/device_manager_quectel_usbport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/device_manager_quectel_usbport.png -------------------------------------------------------------------------------- /docs/imgs/forum.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/forum.jpg -------------------------------------------------------------------------------- /docs/imgs/hw/WIoT-AM01_JUMP_Arduino_serialD0_D1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/WIoT-AM01_JUMP_Arduino_serialD0_D1.png -------------------------------------------------------------------------------- /docs/imgs/hw/WIoT-AM01_JUMP_Arduino_serialD2_D8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/WIoT-AM01_JUMP_Arduino_serialD2_D8.png -------------------------------------------------------------------------------- /docs/imgs/hw/WIoT-QC01_JUMP_Arduino_serialD0_D1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/WIoT-QC01_JUMP_Arduino_serialD0_D1.png -------------------------------------------------------------------------------- /docs/imgs/hw/WIoT-QC01_JUMP_Arduino_serialD2_D8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/WIoT-QC01_JUMP_Arduino_serialD2_D8.png -------------------------------------------------------------------------------- /docs/imgs/hw/WIoT-Shield-AM01_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/WIoT-Shield-AM01_top.png -------------------------------------------------------------------------------- /docs/imgs/hw/WIoT-Shield-QC01_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/WIoT-Shield-QC01_top.png -------------------------------------------------------------------------------- /docs/imgs/hw/WIoT-Shield-WM01_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/WIoT-Shield-WM01_top.png -------------------------------------------------------------------------------- /docs/imgs/hw/WIoT-Shield_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/WIoT-Shield_top.png -------------------------------------------------------------------------------- /docs/imgs/hw/WIoT-WM01_JUMP_Arduino_serialD0_D1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/WIoT-WM01_JUMP_Arduino_serialD0_D1.png -------------------------------------------------------------------------------- /docs/imgs/hw/WIoT-WM01_JUMP_Arduino_serialD2_D8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/WIoT-WM01_JUMP_Arduino_serialD2_D8.png -------------------------------------------------------------------------------- /docs/imgs/hw/wiot-shield-qc01-arduinomega2560.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/wiot-shield-qc01-arduinomega2560.png -------------------------------------------------------------------------------- /docs/imgs/hw/wiot-shield-qc01-raspberrypi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/wiot-shield-qc01-raspberrypi.png -------------------------------------------------------------------------------- /docs/imgs/hw/wiot-shield-usbport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/wiot-shield-usbport.png -------------------------------------------------------------------------------- /docs/imgs/hw/wiot-shield-wm01-arduinomega2560_stack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/wiot-shield-wm01-arduinomega2560_stack.png -------------------------------------------------------------------------------- /docs/imgs/hw/wiot-shield-wm01-raspberrypi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/hw/wiot-shield-wm01-raspberrypi.png -------------------------------------------------------------------------------- /docs/imgs/youtube_arduino_gettingstarted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/youtube_arduino_gettingstarted.png -------------------------------------------------------------------------------- /docs/imgs/youtube_samplecode_tcpclient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/youtube_samplecode_tcpclient.png -------------------------------------------------------------------------------- /docs/imgs/그림1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wiznet/wiznet-iot-shield-arduino-kr/784a6f8ffb05685d789d173fd9f84c5c432b9c10/docs/imgs/그림1.png -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # WIZnet IoT Shield for Arduino 2 | 3 | 이 저장소에는 다음 자료들이 포함되어 있습니다. 4 | * [Arduino 플랫폼][link-arduino] 기반으로 Cat.M1 응용 개발 환경을 구축하는 **개발 시작 가이드** 5 | * Cat.M1 장치의 TCP 데이터 송수신, SMS, GPS, SKT Thingplug 서비스 연동 등에 대한 **가이드 문서** 6 | * [Arduino IDE][link-arduino-compiler] 상에서 동작하는 **예제 코드** 7 | 8 | ![][hw-stack-arduinomega] 9 | 10 | ## Folder Structure 11 | 12 | ### /docs 13 | Arduino 플랫폼을 기반으로 WIZnet IoT shield의 Cat.M1 통신을 활용하는 응용 장치 구현 시 참고할 수 있는 다양한 문서가 위치합니다. 14 | * imgs: 문서에서 활용된 이미지들이 저장된 폴더입니다. 15 | 16 | ### /samples 17 | Arduino IDE에서 컴파일 및 업로드 하여 보드의 동작을 확인 할 수 있는 예제 코드가 위치합니다. 각 Cat.M1 모듈 벤더 별로 나뉘어 있으며, AT command 기반으로 구현되어 있습니다. 18 | * WIoT-QC01: 앰투앰넷 BG96(Quectel) 모듈의 예제 코드 19 | * WIoT-WM01: 우리넷 WM-N400MSE 모듈의 예제 코드 20 | * WIoT-AM01: AM텔레콤 AMM5918K 모듈의 예제 코드 21 | 22 | ## Key features and Roadmap 23 | 24 | :heavy_check_mark: 활용 가능 :heavy_multiplication_x: 지원 예정이며, 준비 중 :heavy_minus_sign: 지원 예정 없음 25 | 26 | ### Common Docs 27 | | Title | Doc | Description | 28 | |:------------------:|:------------------:|:----------------------------------------------------------------| 29 | | [Quickstart Guide](https://github.com/Wiznet/wiznet-iot-shield-kr/blob/master/docs/quickstartguide_standalone_mode.md) | :heavy_check_mark: | Standalone 모드를 활용한 Cat.M1 모듈 테스트 | 30 | | [Hardware Guide](https://github.com/Wiznet/wiznet-iot-shield-hardware-kr/blob/master/docs/wiot_hw_overview_n_settings.md) | :heavy_check_mark: | WIoT 제품군의 하드웨어 구성 및 설정 가이드 | 31 | | [SKT Thingplug Guide](https://github.com/Wiznet/wiznet-iot-shield-kr/blob/master/docs/thingplug_guide_common.md) | :heavy_check_mark: | Cat.M1 장치의 SKT Thingplug 연동 가이드 (공통) | 32 | 33 | 34 | ### Arduino Cat.M1 Samples and Docs 35 | 36 | > * [QC] WIoT-QC01 예제 코드 37 | > * [WM] WIoT-WM01 예제 코드 38 | > * [AM] WIoT-AM01 예제 코드 39 | 40 | | Title | Doc | QC | WM | AM | TL | Description | 41 | |:------------------:|:------------------:|:------------------:|:------------------------:|:------------------------:|:------------------------:|:----------------------------------------------------------------| 42 | | 개발 시작 가이드 | :heavy_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | 초기 개발환경 구축 | 43 | | Ping 테스트 | :heavy_check_mark: | :heavy_check_mark: | [:heavy_check_mark:](https://github.com/Wiznet/wiznet-iot-shield-arduino-kr/blob/master/docs/Arduino_guide_wm-n400mse_ping.md) | :heavy_check_mark: | :heavy_check_mark: | 네트워크 상의 지정된 목적지와 Ping 테스트 예제 | 44 | | TCP/IP 구현하기 | :heavy_check_mark: | :heavy_check_mark: | [:heavy_check_mark:](https://github.com/Wiznet/wiznet-iot-shield-arduino-kr/blob/master/docs/Arduino_guide_wm-n400mse_tcp.md) | :heavy_check_mark: | :heavy_check_mark: | TCP client로 동작하여 데이터 송신 및 수신하는 예제 | 45 | | HTTP 구현하기 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_minus_sign: | :heavy_multiplication_x: | HTTP client로 동작하여 데이터 송신 및 수신하는 예제 | 46 | | MQTT 구현하기 | :heavy_check_mark: | :heavy_check_mark: | :heavy_minus_sign: | :heavy_minus_sign: | :heavy_minus_sign: | MQTT client로 동작하여 데이터 송신 및 수신하는 예제 | 47 | | GPS 활용하기 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Cat.M1 모듈에 내장된 GPS 위치 측위 예제 | 48 | | SMS 활용하기 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Cat.M1 모듈에서 지원하는 SMS(단문 메시지 서비스)의 활용 예제 | 49 | | PSM 저전력 모드 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | Cat.M1 모듈에서 지원하는 저전력 모드(PSM) 활용 예제 | 50 | 51 | 52 | ### Other Arduino Samples 53 | | Title | Code | Description | 54 | |:------------------:|:------------------:|:----------------------------------------------------------------| 55 | | [WIoT-Shield_SENSOR_CDS](https://github.com/Wiznet/wiznet-iot-shield-arduino-kr/tree/master/samples/WIoT-Shield/WIoT-Shield_SENSOR_CDS) | :heavy_check_mark: | IoT Shield에 탑재된 CDS(조도센서) 활용 예제 (Pin: A0) | 56 | | [WIoT-Shield_SENSOR_TEMP](https://github.com/Wiznet/wiznet-iot-shield-arduino-kr/tree/master/samples/WIoT-Shield/WIoT-Shield_SENSOR_TEMP) | :heavy_check_mark: | IoT Shield에 탑재된 [LM35](http://www.ti.com/lit/ds/symlink/lm35.pdf)(온도센서) 활용 예제 (Pin: A1) | 57 | 58 | ## Documentation 59 | 개발 시작 가이드 및 응용 가이드 문서는 본 저장소의 **[Wiki](https://github.com/Wiznet/wiznet-iot-shield-arduino-kr/wiki/)** 에서 확인 할 수 있습니다. 60 | 61 | 62 | ## Other WIZnet IoT Shield Repository 63 | **[wiznet-iot-shield](https://github.com/Wiznet/wiznet-iot-shield-kr/)** 저장소를 방문하면 다른 플랫폼 보드를 기반으로 동작하는 다양한 예제에 대한 저장소 리스트를 확인 할 수 있습니다. 64 | 65 | ## IoT 오픈 하우스 66 | 67 | [IoT 오픈 하우스](https://github.com/Wiznet/IoTOpenHouse/)를 방문하시거나 [SK텔레콤 IoT 서포트 신청](http://b2b.tworld.co.kr/cs/counsel/iotOpenHouse.bc)을 하시면, LoRa, Cellular(Cat M1), WiFi, Ethernet 등을 활용한 IoT 개발에 대한 컨설팅과 상용화를 위한 지원을 무상으로 받으실 수 있습니다. 68 | 69 | ## Support 70 | 71 | [![WIZnet Developer Forum][forum]](https://forum.wiznet.io/c/korean-forum/oshw/) 72 | 73 | **[WIZnet Developer Forum](https://forum.wiznet.io/c/korean-forum/oshw/)** 에서 전세계의 WIZnet 기술 전문가들에게 질문하고 의견을 전달할 수 있습니다.
지금 방문하세요! 74 | 75 | ## License 76 | **WIZnet IoT Shield for Arduino** 저장소의 모든 문서와 예제는 [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)으로 배포됩니다. 77 | 78 | 79 | [skt-iot-portal]: https://www.sktiot.com/iot/developer/guide/guide/catM1/menu_05/page_01 80 | [link-arduino]: https://www.arduino.cc/ 81 | [link-arduino-compiler]: https://www.arduino.cc/en/Main/Software 82 | [link-arduino Mega2560 Rev3]: https://store.arduino.cc/usa/mega-2560-r3 83 | [link-Arduino-tcp]:https://github.com/Wiznet/wiznet-iot-shield-arduino-kr/blob/master/docs/Arduino_guide_wm-n400mse_tcp.md 84 | 85 | [hw-stack-arduinomega]: ./docs/imgs/hw/wiot-shield-qc01-arduinomega2560.png 86 | 87 | [forum]: ./docs/imgs/forum.jpg 88 | 89 | 90 | -------------------------------------------------------------------------------- /samples/WIoT-AM01_AMM592/WIoT-AM01_Arduino_PSM/at_cmd_parser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 ARM Limited 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * @section DESCRIPTION 16 | * 17 | * Parser for the AT command syntax 18 | * 19 | */ 20 | #ifndef SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 21 | #define SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 22 | 23 | #include 24 | #include 25 | 26 | /** \addtogroup platform */ 27 | /** @{*/ 28 | /** 29 | * \defgroup platform_ATCmdParser ATCmdParser class 30 | * @{ 31 | */ 32 | 33 | /** 34 | * Parser class for parsing AT commands 35 | * 36 | * Here are some examples: 37 | * @code 38 | * UARTSerial serial = UARTSerial(D1, D0); 39 | * ATCmdParser at = ATCmdParser(&serial, "\r\n"); 40 | * int value; 41 | * char buffer[100]; 42 | * 43 | * at.send("AT") && at.recv("OK"); 44 | * at.send("AT+CWMODE=%d", 3) && at.recv("OK"); 45 | * at.send("AT+CWMODE?") && at.recv("+CWMODE:%d\r\nOK", &value); 46 | * at.recv("+IPD,%d:", &value); 47 | * at.read(buffer, value); 48 | * at.recv("OK"); 49 | * @endcode 50 | */ 51 | 52 | typedef void (*Parser_Callback)(void); 53 | 54 | class ATCmdParser 55 | { 56 | private: 57 | // File handle 58 | // Not owned by ATCmdParser 59 | Stream *_serial; 60 | 61 | int _buffer_size; 62 | char *_buffer; 63 | int _timeout; 64 | 65 | // Parsing information 66 | const char *_output_delimiter; 67 | int _output_delim_size; 68 | char _in_prev; 69 | bool _dbg_on; 70 | bool _aborted; 71 | 72 | struct oob { 73 | unsigned len; 74 | const char *prefix; 75 | //mbed::Callback cb; 76 | Parser_Callback cb; 77 | oob *next; 78 | }; 79 | oob *_oobs; 80 | 81 | public: 82 | 83 | /** 84 | * Constructor 85 | * 86 | * @param fh A FileHandle to a digital interface to use for AT commands 87 | * @param output_delimiter end of command line termination 88 | * @param buffer_size size of internal buffer for transaction 89 | * @param timeout timeout of the connection 90 | * @param debug turns on/off debug output for AT commands 91 | */ 92 | ATCmdParser(Stream *serial, const char *output_delimiter = "\r", 93 | int buffer_size = 256, int timeout = 8000, bool debug = false) 94 | : _serial(serial), _buffer_size(buffer_size), _in_prev(0), _oobs(NULL) 95 | { 96 | _buffer = new char[buffer_size]; 97 | set_timeout(timeout); 98 | set_delimiter(output_delimiter); 99 | debug_on(debug); 100 | } 101 | 102 | /** 103 | * Destructor 104 | */ 105 | ~ATCmdParser() 106 | { 107 | while (_oobs) { 108 | struct oob *oob = _oobs; 109 | _oobs = oob->next; 110 | delete oob; 111 | } 112 | delete[] _buffer; 113 | } 114 | 115 | /** 116 | * Allows timeout to be changed between commands 117 | * 118 | * @param timeout timeout of the connection 119 | */ 120 | void set_timeout(int timeout) 121 | { 122 | _timeout = timeout; 123 | _serial->setTimeout(_timeout); 124 | } 125 | 126 | 127 | /** 128 | * Sets string of characters to use as line delimiters 129 | * 130 | * @param output_delimiter string of characters to use as line delimiters 131 | */ 132 | void set_delimiter(const char *output_delimiter) 133 | { 134 | _output_delimiter = output_delimiter; 135 | _output_delim_size = strlen(output_delimiter); 136 | } 137 | 138 | /** 139 | * Allows traces from modem to be turned on or off 140 | * 141 | * @param on set as 1 to turn on traces and vice versa. 142 | */ 143 | void debug_on(uint8_t on) 144 | { 145 | _dbg_on = (on) ? 1 : 0; 146 | } 147 | 148 | /** 149 | * Sends an AT command 150 | * 151 | * Sends a formatted command using printf style formatting 152 | * @see printf 153 | * 154 | * @param command printf-like format string of command to send which 155 | * is appended with a newline 156 | * @param ... all printf-like arguments to insert into command 157 | * @return true only if command is successfully sent 158 | */ 159 | //bool send(const char *command, ...) MBED_PRINTF_METHOD(1,2); 160 | bool send(const __FlashStringHelper* command, ...); 161 | bool send(const char *command, ...); 162 | 163 | bool vsend(const char *command, va_list args); 164 | 165 | /** 166 | * Receive an AT response 167 | * 168 | * Receives a formatted response using scanf style formatting 169 | * @see scanf 170 | * 171 | * Responses are parsed line at a time. 172 | * Any received data that does not match the response is ignored until 173 | * a timeout occurs. 174 | * 175 | * @param response scanf-like format string of response to expect 176 | * @param ... all scanf-like arguments to extract from response 177 | * @return true only if response is successfully matched 178 | */ 179 | //bool recv(const char *response, ...) MBED_SCANF_METHOD(1,2); 180 | bool recv(const __FlashStringHelper* response, ...); 181 | bool recv(const char *response, ...); 182 | 183 | bool vrecv(const char *response, va_list args); 184 | 185 | 186 | /** 187 | * Write a single byte to the underlying stream 188 | * 189 | * @param c The byte to write 190 | * @return The byte that was written or -1 during a timeout 191 | */ 192 | int p_putc(char c); 193 | 194 | /** 195 | * Get a single byte from the underlying stream 196 | * 197 | * @return The byte that was read or -1 during a timeout 198 | */ 199 | int p_getc(); 200 | 201 | /** 202 | * Write an array of bytes to the underlying stream 203 | * 204 | * @param data the array of bytes to write 205 | * @param size number of bytes to write 206 | * @return number of bytes written or -1 on failure 207 | */ 208 | int write(const char *data, int size); 209 | 210 | /** 211 | * Read an array of bytes from the underlying stream 212 | * 213 | * @param data the destination for the read bytes 214 | * @param size number of bytes to read 215 | * @return number of bytes read or -1 on failure 216 | */ 217 | int read(char *data, int size); 218 | 219 | /** 220 | * Direct printf to underlying stream 221 | * @see printf 222 | * 223 | * @param format format string to pass to printf 224 | * @param ... arguments to printf 225 | * @return number of bytes written or -1 on failure 226 | */ 227 | //int printf(const char *format, ...) MBED_PRINTF_METHOD(1,2); 228 | int printf(const char *format, ...); 229 | 230 | int vprintf(const char *format, va_list args); 231 | 232 | /** 233 | * Direct scanf on underlying stream 234 | * @see scanf 235 | * 236 | * @param format format string to pass to scanf 237 | * @param ... arguments to scanf 238 | * @return number of bytes read or -1 on failure 239 | */ 240 | //int scanf(const char *format, ...) MBED_SCANF_METHOD(1,2); 241 | int scanf(const char *format, ...); 242 | 243 | int vscanf(const char *format, va_list args); 244 | 245 | /** 246 | * Attach a callback for out-of-band data 247 | * 248 | * @param prefix string on when to initiate callback 249 | * @param func callback to call when string is read 250 | * @note out-of-band data is only processed during a scanf call 251 | */ 252 | //void oob(const char *prefix, mbed::Callback func); 253 | void oob(const char *prefix, Parser_Callback func); 254 | 255 | 256 | /** 257 | * Flushes the underlying stream 258 | */ 259 | void flush(); 260 | 261 | /** 262 | * Abort current recv 263 | * 264 | * Can be called from oob handler to interrupt the current 265 | * recv operation. 266 | */ 267 | void abort(); 268 | 269 | /** 270 | * Process out-of-band data 271 | * 272 | * Process out-of-band data in the receive buffer. This function 273 | * returns immediately if there is no data to process. 274 | * 275 | * @return true if oob data processed, false otherwise 276 | */ 277 | bool process_oob(void); 278 | }; 279 | 280 | /**@}*/ 281 | 282 | /**@}*/ 283 | 284 | #endif /* SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ */ 285 | -------------------------------------------------------------------------------- /samples/WIoT-AM01_AMM592/WIoT-AM01_Arduino_PSM/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_GPS/at_cmd_parser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 ARM Limited 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * @section DESCRIPTION 16 | * 17 | * Parser for the AT command syntax 18 | * 19 | */ 20 | #ifndef SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 21 | #define SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 22 | 23 | #include 24 | #include 25 | 26 | /** \addtogroup platform */ 27 | /** @{*/ 28 | /** 29 | * \defgroup platform_ATCmdParser ATCmdParser class 30 | * @{ 31 | */ 32 | 33 | /** 34 | * Parser class for parsing AT commands 35 | * 36 | * Here are some examples: 37 | * @code 38 | * UARTSerial serial = UARTSerial(D1, D0); 39 | * ATCmdParser at = ATCmdParser(&serial, "\r\n"); 40 | * int value; 41 | * char buffer[100]; 42 | * 43 | * at.send("AT") && at.recv("OK"); 44 | * at.send("AT+CWMODE=%d", 3) && at.recv("OK"); 45 | * at.send("AT+CWMODE?") && at.recv("+CWMODE:%d\r\nOK", &value); 46 | * at.recv("+IPD,%d:", &value); 47 | * at.read(buffer, value); 48 | * at.recv("OK"); 49 | * @endcode 50 | */ 51 | 52 | typedef void (*Parser_Callback)(void); 53 | 54 | class ATCmdParser 55 | { 56 | private: 57 | // File handle 58 | // Not owned by ATCmdParser 59 | Stream *_serial; 60 | 61 | int _buffer_size; 62 | char *_buffer; 63 | int _timeout; 64 | 65 | // Parsing information 66 | const char *_output_delimiter; 67 | int _output_delim_size; 68 | char _in_prev; 69 | bool _dbg_on; 70 | bool _aborted; 71 | 72 | struct oob { 73 | unsigned len; 74 | const char *prefix; 75 | //mbed::Callback cb; 76 | Parser_Callback cb; 77 | oob *next; 78 | }; 79 | oob *_oobs; 80 | 81 | public: 82 | 83 | /** 84 | * Constructor 85 | * 86 | * @param fh A FileHandle to a digital interface to use for AT commands 87 | * @param output_delimiter end of command line termination 88 | * @param buffer_size size of internal buffer for transaction 89 | * @param timeout timeout of the connection 90 | * @param debug turns on/off debug output for AT commands 91 | */ 92 | ATCmdParser(Stream *serial, const char *output_delimiter = "\r", 93 | int buffer_size = 256, int timeout = 8000, bool debug = false) 94 | : _serial(serial), _buffer_size(buffer_size), _in_prev(0), _oobs(NULL) 95 | { 96 | _buffer = new char[buffer_size]; 97 | set_timeout(timeout); 98 | set_delimiter(output_delimiter); 99 | debug_on(debug); 100 | } 101 | 102 | /** 103 | * Destructor 104 | */ 105 | ~ATCmdParser() 106 | { 107 | while (_oobs) { 108 | struct oob *oob = _oobs; 109 | _oobs = oob->next; 110 | delete oob; 111 | } 112 | delete[] _buffer; 113 | } 114 | 115 | /** 116 | * Allows timeout to be changed between commands 117 | * 118 | * @param timeout timeout of the connection 119 | */ 120 | void set_timeout(int timeout) 121 | { 122 | _timeout = timeout; 123 | _serial->setTimeout(_timeout); 124 | } 125 | 126 | 127 | /** 128 | * Sets string of characters to use as line delimiters 129 | * 130 | * @param output_delimiter string of characters to use as line delimiters 131 | */ 132 | void set_delimiter(const char *output_delimiter) 133 | { 134 | _output_delimiter = output_delimiter; 135 | _output_delim_size = strlen(output_delimiter); 136 | } 137 | 138 | /** 139 | * Allows traces from modem to be turned on or off 140 | * 141 | * @param on set as 1 to turn on traces and vice versa. 142 | */ 143 | void debug_on(uint8_t on) 144 | { 145 | _dbg_on = (on) ? 1 : 0; 146 | } 147 | 148 | /** 149 | * Sends an AT command 150 | * 151 | * Sends a formatted command using printf style formatting 152 | * @see printf 153 | * 154 | * @param command printf-like format string of command to send which 155 | * is appended with a newline 156 | * @param ... all printf-like arguments to insert into command 157 | * @return true only if command is successfully sent 158 | */ 159 | //bool send(const char *command, ...) MBED_PRINTF_METHOD(1,2); 160 | bool send(const __FlashStringHelper* command, ...); 161 | bool send(const char *command, ...); 162 | 163 | bool vsend(const char *command, va_list args); 164 | 165 | /** 166 | * Receive an AT response 167 | * 168 | * Receives a formatted response using scanf style formatting 169 | * @see scanf 170 | * 171 | * Responses are parsed line at a time. 172 | * Any received data that does not match the response is ignored until 173 | * a timeout occurs. 174 | * 175 | * @param response scanf-like format string of response to expect 176 | * @param ... all scanf-like arguments to extract from response 177 | * @return true only if response is successfully matched 178 | */ 179 | //bool recv(const char *response, ...) MBED_SCANF_METHOD(1,2); 180 | bool recv(const __FlashStringHelper* response, ...); 181 | bool recv(const char *response, ...); 182 | 183 | bool vrecv(const char *response, va_list args); 184 | 185 | 186 | /** 187 | * Write a single byte to the underlying stream 188 | * 189 | * @param c The byte to write 190 | * @return The byte that was written or -1 during a timeout 191 | */ 192 | int p_putc(char c); 193 | 194 | /** 195 | * Get a single byte from the underlying stream 196 | * 197 | * @return The byte that was read or -1 during a timeout 198 | */ 199 | int p_getc(); 200 | 201 | /** 202 | * Write an array of bytes to the underlying stream 203 | * 204 | * @param data the array of bytes to write 205 | * @param size number of bytes to write 206 | * @return number of bytes written or -1 on failure 207 | */ 208 | int write(const char *data, int size); 209 | 210 | /** 211 | * Read an array of bytes from the underlying stream 212 | * 213 | * @param data the destination for the read bytes 214 | * @param size number of bytes to read 215 | * @return number of bytes read or -1 on failure 216 | */ 217 | int read(char *data, int size); 218 | 219 | /** 220 | * Direct printf to underlying stream 221 | * @see printf 222 | * 223 | * @param format format string to pass to printf 224 | * @param ... arguments to printf 225 | * @return number of bytes written or -1 on failure 226 | */ 227 | //int printf(const char *format, ...) MBED_PRINTF_METHOD(1,2); 228 | int printf(const char *format, ...); 229 | 230 | int vprintf(const char *format, va_list args); 231 | 232 | /** 233 | * Direct scanf on underlying stream 234 | * @see scanf 235 | * 236 | * @param format format string to pass to scanf 237 | * @param ... arguments to scanf 238 | * @return number of bytes read or -1 on failure 239 | */ 240 | //int scanf(const char *format, ...) MBED_SCANF_METHOD(1,2); 241 | int scanf(const char *format, ...); 242 | 243 | int vscanf(const char *format, va_list args); 244 | 245 | /** 246 | * Attach a callback for out-of-band data 247 | * 248 | * @param prefix string on when to initiate callback 249 | * @param func callback to call when string is read 250 | * @note out-of-band data is only processed during a scanf call 251 | */ 252 | //void oob(const char *prefix, mbed::Callback func); 253 | void oob(const char *prefix, Parser_Callback func); 254 | 255 | 256 | /** 257 | * Flushes the underlying stream 258 | */ 259 | void flush(); 260 | 261 | /** 262 | * Abort current recv 263 | * 264 | * Can be called from oob handler to interrupt the current 265 | * recv operation. 266 | */ 267 | void abort(); 268 | 269 | /** 270 | * Process out-of-band data 271 | * 272 | * Process out-of-band data in the receive buffer. This function 273 | * returns immediately if there is no data to process. 274 | * 275 | * @return true if oob data processed, false otherwise 276 | */ 277 | bool process_oob(void); 278 | }; 279 | 280 | /**@}*/ 281 | 282 | /**@}*/ 283 | 284 | #endif /* SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ */ 285 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_GPS/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_HTTP/at_cmd_parser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 ARM Limited 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * @section DESCRIPTION 16 | * 17 | * Parser for the AT command syntax 18 | * 19 | */ 20 | #ifndef SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 21 | #define SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 22 | 23 | #include 24 | #include 25 | 26 | /** \addtogroup platform */ 27 | /** @{*/ 28 | /** 29 | * \defgroup platform_ATCmdParser ATCmdParser class 30 | * @{ 31 | */ 32 | 33 | /** 34 | * Parser class for parsing AT commands 35 | * 36 | * Here are some examples: 37 | * @code 38 | * UARTSerial serial = UARTSerial(D1, D0); 39 | * ATCmdParser at = ATCmdParser(&serial, "\r\n"); 40 | * int value; 41 | * char buffer[100]; 42 | * 43 | * at.send("AT") && at.recv("OK"); 44 | * at.send("AT+CWMODE=%d", 3) && at.recv("OK"); 45 | * at.send("AT+CWMODE?") && at.recv("+CWMODE:%d\r\nOK", &value); 46 | * at.recv("+IPD,%d:", &value); 47 | * at.read(buffer, value); 48 | * at.recv("OK"); 49 | * @endcode 50 | */ 51 | 52 | typedef void (*Parser_Callback)(void); 53 | 54 | class ATCmdParser 55 | { 56 | private: 57 | // File handle 58 | // Not owned by ATCmdParser 59 | Stream *_serial; 60 | 61 | int _buffer_size; 62 | char *_buffer; 63 | int _timeout; 64 | 65 | // Parsing information 66 | const char *_output_delimiter; 67 | int _output_delim_size; 68 | char _in_prev; 69 | bool _dbg_on; 70 | bool _aborted; 71 | 72 | struct oob { 73 | unsigned len; 74 | const char *prefix; 75 | //mbed::Callback cb; 76 | Parser_Callback cb; 77 | oob *next; 78 | }; 79 | oob *_oobs; 80 | 81 | public: 82 | 83 | /** 84 | * Constructor 85 | * 86 | * @param fh A FileHandle to a digital interface to use for AT commands 87 | * @param output_delimiter end of command line termination 88 | * @param buffer_size size of internal buffer for transaction 89 | * @param timeout timeout of the connection 90 | * @param debug turns on/off debug output for AT commands 91 | */ 92 | ATCmdParser(Stream *serial, const char *output_delimiter = "\r", 93 | int buffer_size = 256, int timeout = 8000, bool debug = false) 94 | : _serial(serial), _buffer_size(buffer_size), _in_prev(0), _oobs(NULL) 95 | { 96 | _buffer = new char[buffer_size]; 97 | set_timeout(timeout); 98 | set_delimiter(output_delimiter); 99 | debug_on(debug); 100 | } 101 | 102 | /** 103 | * Destructor 104 | */ 105 | ~ATCmdParser() 106 | { 107 | while (_oobs) { 108 | struct oob *oob = _oobs; 109 | _oobs = oob->next; 110 | delete oob; 111 | } 112 | delete[] _buffer; 113 | } 114 | 115 | /** 116 | * Allows timeout to be changed between commands 117 | * 118 | * @param timeout timeout of the connection 119 | */ 120 | void set_timeout(int timeout) 121 | { 122 | _timeout = timeout; 123 | _serial->setTimeout(_timeout); 124 | } 125 | 126 | 127 | /** 128 | * Sets string of characters to use as line delimiters 129 | * 130 | * @param output_delimiter string of characters to use as line delimiters 131 | */ 132 | void set_delimiter(const char *output_delimiter) 133 | { 134 | _output_delimiter = output_delimiter; 135 | _output_delim_size = strlen(output_delimiter); 136 | } 137 | 138 | /** 139 | * Allows traces from modem to be turned on or off 140 | * 141 | * @param on set as 1 to turn on traces and vice versa. 142 | */ 143 | void debug_on(uint8_t on) 144 | { 145 | _dbg_on = (on) ? 1 : 0; 146 | } 147 | 148 | /** 149 | * Sends an AT command 150 | * 151 | * Sends a formatted command using printf style formatting 152 | * @see printf 153 | * 154 | * @param command printf-like format string of command to send which 155 | * is appended with a newline 156 | * @param ... all printf-like arguments to insert into command 157 | * @return true only if command is successfully sent 158 | */ 159 | //bool send(const char *command, ...) MBED_PRINTF_METHOD(1,2); 160 | bool send(const __FlashStringHelper* command, ...); 161 | bool send(const char *command, ...); 162 | 163 | bool vsend(const char *command, va_list args); 164 | 165 | /** 166 | * Receive an AT response 167 | * 168 | * Receives a formatted response using scanf style formatting 169 | * @see scanf 170 | * 171 | * Responses are parsed line at a time. 172 | * Any received data that does not match the response is ignored until 173 | * a timeout occurs. 174 | * 175 | * @param response scanf-like format string of response to expect 176 | * @param ... all scanf-like arguments to extract from response 177 | * @return true only if response is successfully matched 178 | */ 179 | //bool recv(const char *response, ...) MBED_SCANF_METHOD(1,2); 180 | bool recv(const __FlashStringHelper* response, ...); 181 | bool recv(const char *response, ...); 182 | 183 | bool vrecv(const char *response, va_list args); 184 | 185 | 186 | /** 187 | * Write a single byte to the underlying stream 188 | * 189 | * @param c The byte to write 190 | * @return The byte that was written or -1 during a timeout 191 | */ 192 | int p_putc(char c); 193 | 194 | /** 195 | * Get a single byte from the underlying stream 196 | * 197 | * @return The byte that was read or -1 during a timeout 198 | */ 199 | int p_getc(); 200 | 201 | /** 202 | * Write an array of bytes to the underlying stream 203 | * 204 | * @param data the array of bytes to write 205 | * @param size number of bytes to write 206 | * @return number of bytes written or -1 on failure 207 | */ 208 | int write(const char *data, int size); 209 | 210 | /** 211 | * Read an array of bytes from the underlying stream 212 | * 213 | * @param data the destination for the read bytes 214 | * @param size number of bytes to read 215 | * @return number of bytes read or -1 on failure 216 | */ 217 | int read(char *data, int size); 218 | 219 | /** 220 | * Direct printf to underlying stream 221 | * @see printf 222 | * 223 | * @param format format string to pass to printf 224 | * @param ... arguments to printf 225 | * @return number of bytes written or -1 on failure 226 | */ 227 | //int printf(const char *format, ...) MBED_PRINTF_METHOD(1,2); 228 | int printf(const char *format, ...); 229 | 230 | int vprintf(const char *format, va_list args); 231 | 232 | /** 233 | * Direct scanf on underlying stream 234 | * @see scanf 235 | * 236 | * @param format format string to pass to scanf 237 | * @param ... arguments to scanf 238 | * @return number of bytes read or -1 on failure 239 | */ 240 | //int scanf(const char *format, ...) MBED_SCANF_METHOD(1,2); 241 | int scanf(const char *format, ...); 242 | 243 | int vscanf(const char *format, va_list args); 244 | 245 | /** 246 | * Attach a callback for out-of-band data 247 | * 248 | * @param prefix string on when to initiate callback 249 | * @param func callback to call when string is read 250 | * @note out-of-band data is only processed during a scanf call 251 | */ 252 | //void oob(const char *prefix, mbed::Callback func); 253 | void oob(const char *prefix, Parser_Callback func); 254 | 255 | 256 | /** 257 | * Flushes the underlying stream 258 | */ 259 | void flush(); 260 | 261 | /** 262 | * Abort current recv 263 | * 264 | * Can be called from oob handler to interrupt the current 265 | * recv operation. 266 | */ 267 | void abort(); 268 | 269 | /** 270 | * Process out-of-band data 271 | * 272 | * Process out-of-band data in the receive buffer. This function 273 | * returns immediately if there is no data to process. 274 | * 275 | * @return true if oob data processed, false otherwise 276 | */ 277 | bool process_oob(void); 278 | }; 279 | 280 | /**@}*/ 281 | 282 | /**@}*/ 283 | 284 | #endif /* SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ */ 285 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_HTTP/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_MQTT/at_cmd_parser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 ARM Limited 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * @section DESCRIPTION 16 | * 17 | * Parser for the AT command syntax 18 | * 19 | */ 20 | #ifndef SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 21 | #define SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 22 | 23 | #include 24 | #include 25 | 26 | /** \addtogroup platform */ 27 | /** @{*/ 28 | /** 29 | * \defgroup platform_ATCmdParser ATCmdParser class 30 | * @{ 31 | */ 32 | 33 | /** 34 | * Parser class for parsing AT commands 35 | * 36 | * Here are some examples: 37 | * @code 38 | * UARTSerial serial = UARTSerial(D1, D0); 39 | * ATCmdParser at = ATCmdParser(&serial, "\r\n"); 40 | * int value; 41 | * char buffer[100]; 42 | * 43 | * at.send("AT") && at.recv("OK"); 44 | * at.send("AT+CWMODE=%d", 3) && at.recv("OK"); 45 | * at.send("AT+CWMODE?") && at.recv("+CWMODE:%d\r\nOK", &value); 46 | * at.recv("+IPD,%d:", &value); 47 | * at.read(buffer, value); 48 | * at.recv("OK"); 49 | * @endcode 50 | */ 51 | 52 | typedef void (*Parser_Callback)(void); 53 | 54 | class ATCmdParser 55 | { 56 | private: 57 | // File handle 58 | // Not owned by ATCmdParser 59 | Stream *_serial; 60 | 61 | int _buffer_size; 62 | char *_buffer; 63 | int _timeout; 64 | 65 | // Parsing information 66 | const char *_output_delimiter; 67 | int _output_delim_size; 68 | char _in_prev; 69 | bool _dbg_on; 70 | bool _aborted; 71 | 72 | struct oob { 73 | unsigned len; 74 | const char *prefix; 75 | //mbed::Callback cb; 76 | Parser_Callback cb; 77 | oob *next; 78 | }; 79 | oob *_oobs; 80 | 81 | public: 82 | 83 | /** 84 | * Constructor 85 | * 86 | * @param fh A FileHandle to a digital interface to use for AT commands 87 | * @param output_delimiter end of command line termination 88 | * @param buffer_size size of internal buffer for transaction 89 | * @param timeout timeout of the connection 90 | * @param debug turns on/off debug output for AT commands 91 | */ 92 | ATCmdParser(Stream *serial, const char *output_delimiter = "\r", 93 | int buffer_size = 256, int timeout = 8000, bool debug = false) 94 | : _serial(serial), _buffer_size(buffer_size), _in_prev(0), _oobs(NULL) 95 | { 96 | _buffer = new char[buffer_size]; 97 | set_timeout(timeout); 98 | set_delimiter(output_delimiter); 99 | debug_on(debug); 100 | } 101 | 102 | /** 103 | * Destructor 104 | */ 105 | ~ATCmdParser() 106 | { 107 | while (_oobs) { 108 | struct oob *oob = _oobs; 109 | _oobs = oob->next; 110 | delete oob; 111 | } 112 | delete[] _buffer; 113 | } 114 | 115 | /** 116 | * Allows timeout to be changed between commands 117 | * 118 | * @param timeout timeout of the connection 119 | */ 120 | void set_timeout(int timeout) 121 | { 122 | _timeout = timeout; 123 | _serial->setTimeout(_timeout); 124 | } 125 | 126 | 127 | /** 128 | * Sets string of characters to use as line delimiters 129 | * 130 | * @param output_delimiter string of characters to use as line delimiters 131 | */ 132 | void set_delimiter(const char *output_delimiter) 133 | { 134 | _output_delimiter = output_delimiter; 135 | _output_delim_size = strlen(output_delimiter); 136 | } 137 | 138 | /** 139 | * Allows traces from modem to be turned on or off 140 | * 141 | * @param on set as 1 to turn on traces and vice versa. 142 | */ 143 | void debug_on(uint8_t on) 144 | { 145 | _dbg_on = (on) ? 1 : 0; 146 | } 147 | 148 | /** 149 | * Sends an AT command 150 | * 151 | * Sends a formatted command using printf style formatting 152 | * @see printf 153 | * 154 | * @param command printf-like format string of command to send which 155 | * is appended with a newline 156 | * @param ... all printf-like arguments to insert into command 157 | * @return true only if command is successfully sent 158 | */ 159 | //bool send(const char *command, ...) MBED_PRINTF_METHOD(1,2); 160 | bool send(const __FlashStringHelper* command, ...); 161 | bool send(const char *command, ...); 162 | 163 | bool vsend(const char *command, va_list args); 164 | 165 | /** 166 | * Receive an AT response 167 | * 168 | * Receives a formatted response using scanf style formatting 169 | * @see scanf 170 | * 171 | * Responses are parsed line at a time. 172 | * Any received data that does not match the response is ignored until 173 | * a timeout occurs. 174 | * 175 | * @param response scanf-like format string of response to expect 176 | * @param ... all scanf-like arguments to extract from response 177 | * @return true only if response is successfully matched 178 | */ 179 | //bool recv(const char *response, ...) MBED_SCANF_METHOD(1,2); 180 | bool recv(const __FlashStringHelper* response, ...); 181 | bool recv(const char *response, ...); 182 | 183 | bool vrecv(const char *response, va_list args); 184 | 185 | 186 | /** 187 | * Write a single byte to the underlying stream 188 | * 189 | * @param c The byte to write 190 | * @return The byte that was written or -1 during a timeout 191 | */ 192 | int p_putc(char c); 193 | 194 | /** 195 | * Get a single byte from the underlying stream 196 | * 197 | * @return The byte that was read or -1 during a timeout 198 | */ 199 | int p_getc(); 200 | 201 | /** 202 | * Write an array of bytes to the underlying stream 203 | * 204 | * @param data the array of bytes to write 205 | * @param size number of bytes to write 206 | * @return number of bytes written or -1 on failure 207 | */ 208 | int write(const char *data, int size); 209 | 210 | /** 211 | * Read an array of bytes from the underlying stream 212 | * 213 | * @param data the destination for the read bytes 214 | * @param size number of bytes to read 215 | * @return number of bytes read or -1 on failure 216 | */ 217 | int read(char *data, int size); 218 | 219 | /** 220 | * Direct printf to underlying stream 221 | * @see printf 222 | * 223 | * @param format format string to pass to printf 224 | * @param ... arguments to printf 225 | * @return number of bytes written or -1 on failure 226 | */ 227 | //int printf(const char *format, ...) MBED_PRINTF_METHOD(1,2); 228 | int printf(const char *format, ...); 229 | 230 | int vprintf(const char *format, va_list args); 231 | 232 | /** 233 | * Direct scanf on underlying stream 234 | * @see scanf 235 | * 236 | * @param format format string to pass to scanf 237 | * @param ... arguments to scanf 238 | * @return number of bytes read or -1 on failure 239 | */ 240 | //int scanf(const char *format, ...) MBED_SCANF_METHOD(1,2); 241 | int scanf(const char *format, ...); 242 | 243 | int vscanf(const char *format, va_list args); 244 | 245 | /** 246 | * Attach a callback for out-of-band data 247 | * 248 | * @param prefix string on when to initiate callback 249 | * @param func callback to call when string is read 250 | * @note out-of-band data is only processed during a scanf call 251 | */ 252 | //void oob(const char *prefix, mbed::Callback func); 253 | void oob(const char *prefix, Parser_Callback func); 254 | 255 | 256 | /** 257 | * Flushes the underlying stream 258 | */ 259 | void flush(); 260 | 261 | /** 262 | * Abort current recv 263 | * 264 | * Can be called from oob handler to interrupt the current 265 | * recv operation. 266 | */ 267 | void abort(); 268 | 269 | /** 270 | * Process out-of-band data 271 | * 272 | * Process out-of-band data in the receive buffer. This function 273 | * returns immediately if there is no data to process. 274 | * 275 | * @return true if oob data processed, false otherwise 276 | */ 277 | bool process_oob(void); 278 | }; 279 | 280 | /**@}*/ 281 | 282 | /**@}*/ 283 | 284 | #endif /* SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ */ 285 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_MQTT/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_PSM/at_cmd_parser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 ARM Limited 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * @section DESCRIPTION 16 | * 17 | * Parser for the AT command syntax 18 | * 19 | */ 20 | #ifndef SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 21 | #define SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 22 | 23 | #include 24 | #include 25 | 26 | /** \addtogroup platform */ 27 | /** @{*/ 28 | /** 29 | * \defgroup platform_ATCmdParser ATCmdParser class 30 | * @{ 31 | */ 32 | 33 | /** 34 | * Parser class for parsing AT commands 35 | * 36 | * Here are some examples: 37 | * @code 38 | * UARTSerial serial = UARTSerial(D1, D0); 39 | * ATCmdParser at = ATCmdParser(&serial, "\r\n"); 40 | * int value; 41 | * char buffer[100]; 42 | * 43 | * at.send("AT") && at.recv("OK"); 44 | * at.send("AT+CWMODE=%d", 3) && at.recv("OK"); 45 | * at.send("AT+CWMODE?") && at.recv("+CWMODE:%d\r\nOK", &value); 46 | * at.recv("+IPD,%d:", &value); 47 | * at.read(buffer, value); 48 | * at.recv("OK"); 49 | * @endcode 50 | */ 51 | 52 | typedef void (*Parser_Callback)(void); 53 | 54 | class ATCmdParser 55 | { 56 | private: 57 | // File handle 58 | // Not owned by ATCmdParser 59 | Stream *_serial; 60 | 61 | int _buffer_size; 62 | char *_buffer; 63 | int _timeout; 64 | 65 | // Parsing information 66 | const char *_output_delimiter; 67 | int _output_delim_size; 68 | char _in_prev; 69 | bool _dbg_on; 70 | bool _aborted; 71 | 72 | struct oob { 73 | unsigned len; 74 | const char *prefix; 75 | //mbed::Callback cb; 76 | Parser_Callback cb; 77 | oob *next; 78 | }; 79 | oob *_oobs; 80 | 81 | public: 82 | 83 | /** 84 | * Constructor 85 | * 86 | * @param fh A FileHandle to a digital interface to use for AT commands 87 | * @param output_delimiter end of command line termination 88 | * @param buffer_size size of internal buffer for transaction 89 | * @param timeout timeout of the connection 90 | * @param debug turns on/off debug output for AT commands 91 | */ 92 | ATCmdParser(Stream *serial, const char *output_delimiter = "\r", 93 | int buffer_size = 256, int timeout = 8000, bool debug = false) 94 | : _serial(serial), _buffer_size(buffer_size), _in_prev(0), _oobs(NULL) 95 | { 96 | _buffer = new char[buffer_size]; 97 | set_timeout(timeout); 98 | set_delimiter(output_delimiter); 99 | debug_on(debug); 100 | } 101 | 102 | /** 103 | * Destructor 104 | */ 105 | ~ATCmdParser() 106 | { 107 | while (_oobs) { 108 | struct oob *oob = _oobs; 109 | _oobs = oob->next; 110 | delete oob; 111 | } 112 | delete[] _buffer; 113 | } 114 | 115 | /** 116 | * Allows timeout to be changed between commands 117 | * 118 | * @param timeout timeout of the connection 119 | */ 120 | void set_timeout(int timeout) 121 | { 122 | _timeout = timeout; 123 | _serial->setTimeout(_timeout); 124 | } 125 | 126 | 127 | /** 128 | * Sets string of characters to use as line delimiters 129 | * 130 | * @param output_delimiter string of characters to use as line delimiters 131 | */ 132 | void set_delimiter(const char *output_delimiter) 133 | { 134 | _output_delimiter = output_delimiter; 135 | _output_delim_size = strlen(output_delimiter); 136 | } 137 | 138 | /** 139 | * Allows traces from modem to be turned on or off 140 | * 141 | * @param on set as 1 to turn on traces and vice versa. 142 | */ 143 | void debug_on(uint8_t on) 144 | { 145 | _dbg_on = (on) ? 1 : 0; 146 | } 147 | 148 | /** 149 | * Sends an AT command 150 | * 151 | * Sends a formatted command using printf style formatting 152 | * @see printf 153 | * 154 | * @param command printf-like format string of command to send which 155 | * is appended with a newline 156 | * @param ... all printf-like arguments to insert into command 157 | * @return true only if command is successfully sent 158 | */ 159 | //bool send(const char *command, ...) MBED_PRINTF_METHOD(1,2); 160 | bool send(const __FlashStringHelper* command, ...); 161 | bool send(const char *command, ...); 162 | 163 | bool vsend(const char *command, va_list args); 164 | 165 | /** 166 | * Receive an AT response 167 | * 168 | * Receives a formatted response using scanf style formatting 169 | * @see scanf 170 | * 171 | * Responses are parsed line at a time. 172 | * Any received data that does not match the response is ignored until 173 | * a timeout occurs. 174 | * 175 | * @param response scanf-like format string of response to expect 176 | * @param ... all scanf-like arguments to extract from response 177 | * @return true only if response is successfully matched 178 | */ 179 | //bool recv(const char *response, ...) MBED_SCANF_METHOD(1,2); 180 | bool recv(const __FlashStringHelper* response, ...); 181 | bool recv(const char *response, ...); 182 | 183 | bool vrecv(const char *response, va_list args); 184 | 185 | 186 | /** 187 | * Write a single byte to the underlying stream 188 | * 189 | * @param c The byte to write 190 | * @return The byte that was written or -1 during a timeout 191 | */ 192 | int p_putc(char c); 193 | 194 | /** 195 | * Get a single byte from the underlying stream 196 | * 197 | * @return The byte that was read or -1 during a timeout 198 | */ 199 | int p_getc(); 200 | 201 | /** 202 | * Write an array of bytes to the underlying stream 203 | * 204 | * @param data the array of bytes to write 205 | * @param size number of bytes to write 206 | * @return number of bytes written or -1 on failure 207 | */ 208 | int write(const char *data, int size); 209 | 210 | /** 211 | * Read an array of bytes from the underlying stream 212 | * 213 | * @param data the destination for the read bytes 214 | * @param size number of bytes to read 215 | * @return number of bytes read or -1 on failure 216 | */ 217 | int read(char *data, int size); 218 | 219 | /** 220 | * Direct printf to underlying stream 221 | * @see printf 222 | * 223 | * @param format format string to pass to printf 224 | * @param ... arguments to printf 225 | * @return number of bytes written or -1 on failure 226 | */ 227 | //int printf(const char *format, ...) MBED_PRINTF_METHOD(1,2); 228 | int printf(const char *format, ...); 229 | 230 | int vprintf(const char *format, va_list args); 231 | 232 | /** 233 | * Direct scanf on underlying stream 234 | * @see scanf 235 | * 236 | * @param format format string to pass to scanf 237 | * @param ... arguments to scanf 238 | * @return number of bytes read or -1 on failure 239 | */ 240 | //int scanf(const char *format, ...) MBED_SCANF_METHOD(1,2); 241 | int scanf(const char *format, ...); 242 | 243 | int vscanf(const char *format, va_list args); 244 | 245 | /** 246 | * Attach a callback for out-of-band data 247 | * 248 | * @param prefix string on when to initiate callback 249 | * @param func callback to call when string is read 250 | * @note out-of-band data is only processed during a scanf call 251 | */ 252 | //void oob(const char *prefix, mbed::Callback func); 253 | void oob(const char *prefix, Parser_Callback func); 254 | 255 | 256 | /** 257 | * Flushes the underlying stream 258 | */ 259 | void flush(); 260 | 261 | /** 262 | * Abort current recv 263 | * 264 | * Can be called from oob handler to interrupt the current 265 | * recv operation. 266 | */ 267 | void abort(); 268 | 269 | /** 270 | * Process out-of-band data 271 | * 272 | * Process out-of-band data in the receive buffer. This function 273 | * returns immediately if there is no data to process. 274 | * 275 | * @return true if oob data processed, false otherwise 276 | */ 277 | bool process_oob(void); 278 | }; 279 | 280 | /**@}*/ 281 | 282 | /**@}*/ 283 | 284 | #endif /* SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ */ 285 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_PSM/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_Ping/at_cmd_parser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 ARM Limited 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * @section DESCRIPTION 16 | * 17 | * Parser for the AT command syntax 18 | * 19 | */ 20 | #ifndef SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 21 | #define SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 22 | 23 | #include 24 | #include 25 | 26 | /** \addtogroup platform */ 27 | /** @{*/ 28 | /** 29 | * \defgroup platform_ATCmdParser ATCmdParser class 30 | * @{ 31 | */ 32 | 33 | /** 34 | * Parser class for parsing AT commands 35 | * 36 | * Here are some examples: 37 | * @code 38 | * UARTSerial serial = UARTSerial(D1, D0); 39 | * ATCmdParser at = ATCmdParser(&serial, "\r\n"); 40 | * int value; 41 | * char buffer[100]; 42 | * 43 | * at.send("AT") && at.recv("OK"); 44 | * at.send("AT+CWMODE=%d", 3) && at.recv("OK"); 45 | * at.send("AT+CWMODE?") && at.recv("+CWMODE:%d\r\nOK", &value); 46 | * at.recv("+IPD,%d:", &value); 47 | * at.read(buffer, value); 48 | * at.recv("OK"); 49 | * @endcode 50 | */ 51 | 52 | typedef void (*Parser_Callback)(void); 53 | 54 | class ATCmdParser 55 | { 56 | private: 57 | // File handle 58 | // Not owned by ATCmdParser 59 | Stream *_serial; 60 | 61 | int _buffer_size; 62 | char *_buffer; 63 | int _timeout; 64 | 65 | // Parsing information 66 | const char *_output_delimiter; 67 | int _output_delim_size; 68 | char _in_prev; 69 | bool _dbg_on; 70 | bool _aborted; 71 | 72 | struct oob { 73 | unsigned len; 74 | const char *prefix; 75 | //mbed::Callback cb; 76 | Parser_Callback cb; 77 | oob *next; 78 | }; 79 | oob *_oobs; 80 | 81 | public: 82 | 83 | /** 84 | * Constructor 85 | * 86 | * @param fh A FileHandle to a digital interface to use for AT commands 87 | * @param output_delimiter end of command line termination 88 | * @param buffer_size size of internal buffer for transaction 89 | * @param timeout timeout of the connection 90 | * @param debug turns on/off debug output for AT commands 91 | */ 92 | ATCmdParser(Stream *serial, const char *output_delimiter = "\r", 93 | int buffer_size = 256, int timeout = 8000, bool debug = false) 94 | : _serial(serial), _buffer_size(buffer_size), _in_prev(0), _oobs(NULL) 95 | { 96 | _buffer = new char[buffer_size]; 97 | set_timeout(timeout); 98 | set_delimiter(output_delimiter); 99 | debug_on(debug); 100 | } 101 | 102 | /** 103 | * Destructor 104 | */ 105 | ~ATCmdParser() 106 | { 107 | while (_oobs) { 108 | struct oob *oob = _oobs; 109 | _oobs = oob->next; 110 | delete oob; 111 | } 112 | delete[] _buffer; 113 | } 114 | 115 | /** 116 | * Allows timeout to be changed between commands 117 | * 118 | * @param timeout timeout of the connection 119 | */ 120 | void set_timeout(int timeout) 121 | { 122 | _timeout = timeout; 123 | _serial->setTimeout(_timeout); 124 | } 125 | 126 | 127 | /** 128 | * Sets string of characters to use as line delimiters 129 | * 130 | * @param output_delimiter string of characters to use as line delimiters 131 | */ 132 | void set_delimiter(const char *output_delimiter) 133 | { 134 | _output_delimiter = output_delimiter; 135 | _output_delim_size = strlen(output_delimiter); 136 | } 137 | 138 | /** 139 | * Allows traces from modem to be turned on or off 140 | * 141 | * @param on set as 1 to turn on traces and vice versa. 142 | */ 143 | void debug_on(uint8_t on) 144 | { 145 | _dbg_on = (on) ? 1 : 0; 146 | } 147 | 148 | /** 149 | * Sends an AT command 150 | * 151 | * Sends a formatted command using printf style formatting 152 | * @see printf 153 | * 154 | * @param command printf-like format string of command to send which 155 | * is appended with a newline 156 | * @param ... all printf-like arguments to insert into command 157 | * @return true only if command is successfully sent 158 | */ 159 | //bool send(const char *command, ...) MBED_PRINTF_METHOD(1,2); 160 | bool send(const __FlashStringHelper* command, ...); 161 | bool send(const char *command, ...); 162 | 163 | bool vsend(const char *command, va_list args); 164 | 165 | /** 166 | * Receive an AT response 167 | * 168 | * Receives a formatted response using scanf style formatting 169 | * @see scanf 170 | * 171 | * Responses are parsed line at a time. 172 | * Any received data that does not match the response is ignored until 173 | * a timeout occurs. 174 | * 175 | * @param response scanf-like format string of response to expect 176 | * @param ... all scanf-like arguments to extract from response 177 | * @return true only if response is successfully matched 178 | */ 179 | //bool recv(const char *response, ...) MBED_SCANF_METHOD(1,2); 180 | bool recv(const __FlashStringHelper* response, ...); 181 | bool recv(const char *response, ...); 182 | 183 | bool vrecv(const char *response, va_list args); 184 | 185 | 186 | /** 187 | * Write a single byte to the underlying stream 188 | * 189 | * @param c The byte to write 190 | * @return The byte that was written or -1 during a timeout 191 | */ 192 | int p_putc(char c); 193 | 194 | /** 195 | * Get a single byte from the underlying stream 196 | * 197 | * @return The byte that was read or -1 during a timeout 198 | */ 199 | int p_getc(); 200 | 201 | /** 202 | * Write an array of bytes to the underlying stream 203 | * 204 | * @param data the array of bytes to write 205 | * @param size number of bytes to write 206 | * @return number of bytes written or -1 on failure 207 | */ 208 | int write(const char *data, int size); 209 | 210 | /** 211 | * Read an array of bytes from the underlying stream 212 | * 213 | * @param data the destination for the read bytes 214 | * @param size number of bytes to read 215 | * @return number of bytes read or -1 on failure 216 | */ 217 | int read(char *data, int size); 218 | 219 | /** 220 | * Direct printf to underlying stream 221 | * @see printf 222 | * 223 | * @param format format string to pass to printf 224 | * @param ... arguments to printf 225 | * @return number of bytes written or -1 on failure 226 | */ 227 | //int printf(const char *format, ...) MBED_PRINTF_METHOD(1,2); 228 | int printf(const char *format, ...); 229 | 230 | int vprintf(const char *format, va_list args); 231 | 232 | /** 233 | * Direct scanf on underlying stream 234 | * @see scanf 235 | * 236 | * @param format format string to pass to scanf 237 | * @param ... arguments to scanf 238 | * @return number of bytes read or -1 on failure 239 | */ 240 | //int scanf(const char *format, ...) MBED_SCANF_METHOD(1,2); 241 | int scanf(const char *format, ...); 242 | 243 | int vscanf(const char *format, va_list args); 244 | 245 | /** 246 | * Attach a callback for out-of-band data 247 | * 248 | * @param prefix string on when to initiate callback 249 | * @param func callback to call when string is read 250 | * @note out-of-band data is only processed during a scanf call 251 | */ 252 | //void oob(const char *prefix, mbed::Callback func); 253 | void oob(const char *prefix, Parser_Callback func); 254 | 255 | 256 | /** 257 | * Flushes the underlying stream 258 | */ 259 | void flush(); 260 | 261 | /** 262 | * Abort current recv 263 | * 264 | * Can be called from oob handler to interrupt the current 265 | * recv operation. 266 | */ 267 | void abort(); 268 | 269 | /** 270 | * Process out-of-band data 271 | * 272 | * Process out-of-band data in the receive buffer. This function 273 | * returns immediately if there is no data to process. 274 | * 275 | * @return true if oob data processed, false otherwise 276 | */ 277 | bool process_oob(void); 278 | }; 279 | 280 | /**@}*/ 281 | 282 | /**@}*/ 283 | 284 | #endif /* SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ */ 285 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_Ping/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_SMS/at_cmd_parser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 ARM Limited 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * @section DESCRIPTION 16 | * 17 | * Parser for the AT command syntax 18 | * 19 | */ 20 | #ifndef SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 21 | #define SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 22 | 23 | #include 24 | #include 25 | 26 | /** \addtogroup platform */ 27 | /** @{*/ 28 | /** 29 | * \defgroup platform_ATCmdParser ATCmdParser class 30 | * @{ 31 | */ 32 | 33 | /** 34 | * Parser class for parsing AT commands 35 | * 36 | * Here are some examples: 37 | * @code 38 | * UARTSerial serial = UARTSerial(D1, D0); 39 | * ATCmdParser at = ATCmdParser(&serial, "\r\n"); 40 | * int value; 41 | * char buffer[100]; 42 | * 43 | * at.send("AT") && at.recv("OK"); 44 | * at.send("AT+CWMODE=%d", 3) && at.recv("OK"); 45 | * at.send("AT+CWMODE?") && at.recv("+CWMODE:%d\r\nOK", &value); 46 | * at.recv("+IPD,%d:", &value); 47 | * at.read(buffer, value); 48 | * at.recv("OK"); 49 | * @endcode 50 | */ 51 | 52 | typedef void (*Parser_Callback)(void); 53 | 54 | class ATCmdParser 55 | { 56 | private: 57 | // File handle 58 | // Not owned by ATCmdParser 59 | Stream *_serial; 60 | 61 | int _buffer_size; 62 | char *_buffer; 63 | int _timeout; 64 | 65 | // Parsing information 66 | const char *_output_delimiter; 67 | int _output_delim_size; 68 | char _in_prev; 69 | bool _dbg_on; 70 | bool _aborted; 71 | 72 | struct oob { 73 | unsigned len; 74 | const char *prefix; 75 | //mbed::Callback cb; 76 | Parser_Callback cb; 77 | oob *next; 78 | }; 79 | oob *_oobs; 80 | 81 | public: 82 | 83 | /** 84 | * Constructor 85 | * 86 | * @param fh A FileHandle to a digital interface to use for AT commands 87 | * @param output_delimiter end of command line termination 88 | * @param buffer_size size of internal buffer for transaction 89 | * @param timeout timeout of the connection 90 | * @param debug turns on/off debug output for AT commands 91 | */ 92 | ATCmdParser(Stream *serial, const char *output_delimiter = "\r", 93 | int buffer_size = 256, int timeout = 8000, bool debug = false) 94 | : _serial(serial), _buffer_size(buffer_size), _in_prev(0), _oobs(NULL) 95 | { 96 | _buffer = new char[buffer_size]; 97 | set_timeout(timeout); 98 | set_delimiter(output_delimiter); 99 | debug_on(debug); 100 | } 101 | 102 | /** 103 | * Destructor 104 | */ 105 | ~ATCmdParser() 106 | { 107 | while (_oobs) { 108 | struct oob *oob = _oobs; 109 | _oobs = oob->next; 110 | delete oob; 111 | } 112 | delete[] _buffer; 113 | } 114 | 115 | /** 116 | * Allows timeout to be changed between commands 117 | * 118 | * @param timeout timeout of the connection 119 | */ 120 | void set_timeout(int timeout) 121 | { 122 | _timeout = timeout; 123 | _serial->setTimeout(_timeout); 124 | } 125 | 126 | 127 | /** 128 | * Sets string of characters to use as line delimiters 129 | * 130 | * @param output_delimiter string of characters to use as line delimiters 131 | */ 132 | void set_delimiter(const char *output_delimiter) 133 | { 134 | _output_delimiter = output_delimiter; 135 | _output_delim_size = strlen(output_delimiter); 136 | } 137 | 138 | /** 139 | * Allows traces from modem to be turned on or off 140 | * 141 | * @param on set as 1 to turn on traces and vice versa. 142 | */ 143 | void debug_on(uint8_t on) 144 | { 145 | _dbg_on = (on) ? 1 : 0; 146 | } 147 | 148 | /** 149 | * Sends an AT command 150 | * 151 | * Sends a formatted command using printf style formatting 152 | * @see printf 153 | * 154 | * @param command printf-like format string of command to send which 155 | * is appended with a newline 156 | * @param ... all printf-like arguments to insert into command 157 | * @return true only if command is successfully sent 158 | */ 159 | //bool send(const char *command, ...) MBED_PRINTF_METHOD(1,2); 160 | bool send(const __FlashStringHelper* command, ...); 161 | bool send(const char *command, ...); 162 | 163 | bool vsend(const char *command, va_list args); 164 | 165 | /** 166 | * Receive an AT response 167 | * 168 | * Receives a formatted response using scanf style formatting 169 | * @see scanf 170 | * 171 | * Responses are parsed line at a time. 172 | * Any received data that does not match the response is ignored until 173 | * a timeout occurs. 174 | * 175 | * @param response scanf-like format string of response to expect 176 | * @param ... all scanf-like arguments to extract from response 177 | * @return true only if response is successfully matched 178 | */ 179 | //bool recv(const char *response, ...) MBED_SCANF_METHOD(1,2); 180 | bool recv(const __FlashStringHelper* response, ...); 181 | bool recv(const char *response, ...); 182 | 183 | bool vrecv(const char *response, va_list args); 184 | 185 | 186 | /** 187 | * Write a single byte to the underlying stream 188 | * 189 | * @param c The byte to write 190 | * @return The byte that was written or -1 during a timeout 191 | */ 192 | int p_putc(char c); 193 | 194 | /** 195 | * Get a single byte from the underlying stream 196 | * 197 | * @return The byte that was read or -1 during a timeout 198 | */ 199 | int p_getc(); 200 | 201 | /** 202 | * Write an array of bytes to the underlying stream 203 | * 204 | * @param data the array of bytes to write 205 | * @param size number of bytes to write 206 | * @return number of bytes written or -1 on failure 207 | */ 208 | int write(const char *data, int size); 209 | 210 | /** 211 | * Read an array of bytes from the underlying stream 212 | * 213 | * @param data the destination for the read bytes 214 | * @param size number of bytes to read 215 | * @return number of bytes read or -1 on failure 216 | */ 217 | int read(char *data, int size); 218 | 219 | /** 220 | * Direct printf to underlying stream 221 | * @see printf 222 | * 223 | * @param format format string to pass to printf 224 | * @param ... arguments to printf 225 | * @return number of bytes written or -1 on failure 226 | */ 227 | //int printf(const char *format, ...) MBED_PRINTF_METHOD(1,2); 228 | int printf(const char *format, ...); 229 | 230 | int vprintf(const char *format, va_list args); 231 | 232 | /** 233 | * Direct scanf on underlying stream 234 | * @see scanf 235 | * 236 | * @param format format string to pass to scanf 237 | * @param ... arguments to scanf 238 | * @return number of bytes read or -1 on failure 239 | */ 240 | //int scanf(const char *format, ...) MBED_SCANF_METHOD(1,2); 241 | int scanf(const char *format, ...); 242 | 243 | int vscanf(const char *format, va_list args); 244 | 245 | /** 246 | * Attach a callback for out-of-band data 247 | * 248 | * @param prefix string on when to initiate callback 249 | * @param func callback to call when string is read 250 | * @note out-of-band data is only processed during a scanf call 251 | */ 252 | //void oob(const char *prefix, mbed::Callback func); 253 | void oob(const char *prefix, Parser_Callback func); 254 | 255 | 256 | /** 257 | * Flushes the underlying stream 258 | */ 259 | void flush(); 260 | 261 | /** 262 | * Abort current recv 263 | * 264 | * Can be called from oob handler to interrupt the current 265 | * recv operation. 266 | */ 267 | void abort(); 268 | 269 | /** 270 | * Process out-of-band data 271 | * 272 | * Process out-of-band data in the receive buffer. This function 273 | * returns immediately if there is no data to process. 274 | * 275 | * @return true if oob data processed, false otherwise 276 | */ 277 | bool process_oob(void); 278 | }; 279 | 280 | /**@}*/ 281 | 282 | /**@}*/ 283 | 284 | #endif /* SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ */ 285 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_SMS/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_TCP/at_cmd_parser.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017 ARM Limited 2 | * 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * 15 | * @section DESCRIPTION 16 | * 17 | * Parser for the AT command syntax 18 | * 19 | */ 20 | #ifndef SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 21 | #define SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ 22 | 23 | #include 24 | #include 25 | 26 | /** \addtogroup platform */ 27 | /** @{*/ 28 | /** 29 | * \defgroup platform_ATCmdParser ATCmdParser class 30 | * @{ 31 | */ 32 | 33 | /** 34 | * Parser class for parsing AT commands 35 | * 36 | * Here are some examples: 37 | * @code 38 | * UARTSerial serial = UARTSerial(D1, D0); 39 | * ATCmdParser at = ATCmdParser(&serial, "\r\n"); 40 | * int value; 41 | * char buffer[100]; 42 | * 43 | * at.send("AT") && at.recv("OK"); 44 | * at.send("AT+CWMODE=%d", 3) && at.recv("OK"); 45 | * at.send("AT+CWMODE?") && at.recv("+CWMODE:%d\r\nOK", &value); 46 | * at.recv("+IPD,%d:", &value); 47 | * at.read(buffer, value); 48 | * at.recv("OK"); 49 | * @endcode 50 | */ 51 | 52 | typedef void (*Parser_Callback)(void); 53 | 54 | class ATCmdParser 55 | { 56 | private: 57 | // File handle 58 | // Not owned by ATCmdParser 59 | Stream *_serial; 60 | 61 | int _buffer_size; 62 | char *_buffer; 63 | int _timeout; 64 | 65 | // Parsing information 66 | const char *_output_delimiter; 67 | int _output_delim_size; 68 | char _in_prev; 69 | bool _dbg_on; 70 | bool _aborted; 71 | 72 | struct oob { 73 | unsigned len; 74 | const char *prefix; 75 | //mbed::Callback cb; 76 | Parser_Callback cb; 77 | oob *next; 78 | }; 79 | oob *_oobs; 80 | 81 | public: 82 | 83 | /** 84 | * Constructor 85 | * 86 | * @param fh A FileHandle to a digital interface to use for AT commands 87 | * @param output_delimiter end of command line termination 88 | * @param buffer_size size of internal buffer for transaction 89 | * @param timeout timeout of the connection 90 | * @param debug turns on/off debug output for AT commands 91 | */ 92 | ATCmdParser(Stream *serial, const char *output_delimiter = "\r", 93 | int buffer_size = 256, int timeout = 8000, bool debug = false) 94 | : _serial(serial), _buffer_size(buffer_size), _in_prev(0), _oobs(NULL) 95 | { 96 | _buffer = new char[buffer_size]; 97 | set_timeout(timeout); 98 | set_delimiter(output_delimiter); 99 | debug_on(debug); 100 | } 101 | 102 | /** 103 | * Destructor 104 | */ 105 | ~ATCmdParser() 106 | { 107 | while (_oobs) { 108 | struct oob *oob = _oobs; 109 | _oobs = oob->next; 110 | delete oob; 111 | } 112 | delete[] _buffer; 113 | } 114 | 115 | /** 116 | * Allows timeout to be changed between commands 117 | * 118 | * @param timeout timeout of the connection 119 | */ 120 | void set_timeout(int timeout) 121 | { 122 | _timeout = timeout; 123 | _serial->setTimeout(_timeout); 124 | } 125 | 126 | 127 | /** 128 | * Sets string of characters to use as line delimiters 129 | * 130 | * @param output_delimiter string of characters to use as line delimiters 131 | */ 132 | void set_delimiter(const char *output_delimiter) 133 | { 134 | _output_delimiter = output_delimiter; 135 | _output_delim_size = strlen(output_delimiter); 136 | } 137 | 138 | /** 139 | * Allows traces from modem to be turned on or off 140 | * 141 | * @param on set as 1 to turn on traces and vice versa. 142 | */ 143 | void debug_on(uint8_t on) 144 | { 145 | _dbg_on = (on) ? 1 : 0; 146 | } 147 | 148 | /** 149 | * Sends an AT command 150 | * 151 | * Sends a formatted command using printf style formatting 152 | * @see printf 153 | * 154 | * @param command printf-like format string of command to send which 155 | * is appended with a newline 156 | * @param ... all printf-like arguments to insert into command 157 | * @return true only if command is successfully sent 158 | */ 159 | //bool send(const char *command, ...) MBED_PRINTF_METHOD(1,2); 160 | bool send(const __FlashStringHelper* command, ...); 161 | bool send(const char *command, ...); 162 | 163 | bool vsend(const char *command, va_list args); 164 | 165 | /** 166 | * Receive an AT response 167 | * 168 | * Receives a formatted response using scanf style formatting 169 | * @see scanf 170 | * 171 | * Responses are parsed line at a time. 172 | * Any received data that does not match the response is ignored until 173 | * a timeout occurs. 174 | * 175 | * @param response scanf-like format string of response to expect 176 | * @param ... all scanf-like arguments to extract from response 177 | * @return true only if response is successfully matched 178 | */ 179 | //bool recv(const char *response, ...) MBED_SCANF_METHOD(1,2); 180 | bool recv(const __FlashStringHelper* response, ...); 181 | bool recv(const char *response, ...); 182 | 183 | bool vrecv(const char *response, va_list args); 184 | 185 | 186 | /** 187 | * Write a single byte to the underlying stream 188 | * 189 | * @param c The byte to write 190 | * @return The byte that was written or -1 during a timeout 191 | */ 192 | int p_putc(char c); 193 | 194 | /** 195 | * Get a single byte from the underlying stream 196 | * 197 | * @return The byte that was read or -1 during a timeout 198 | */ 199 | int p_getc(); 200 | 201 | /** 202 | * Write an array of bytes to the underlying stream 203 | * 204 | * @param data the array of bytes to write 205 | * @param size number of bytes to write 206 | * @return number of bytes written or -1 on failure 207 | */ 208 | int write(const char *data, int size); 209 | 210 | /** 211 | * Read an array of bytes from the underlying stream 212 | * 213 | * @param data the destination for the read bytes 214 | * @param size number of bytes to read 215 | * @return number of bytes read or -1 on failure 216 | */ 217 | int read(char *data, int size); 218 | 219 | /** 220 | * Direct printf to underlying stream 221 | * @see printf 222 | * 223 | * @param format format string to pass to printf 224 | * @param ... arguments to printf 225 | * @return number of bytes written or -1 on failure 226 | */ 227 | //int printf(const char *format, ...) MBED_PRINTF_METHOD(1,2); 228 | int printf(const char *format, ...); 229 | 230 | int vprintf(const char *format, va_list args); 231 | 232 | /** 233 | * Direct scanf on underlying stream 234 | * @see scanf 235 | * 236 | * @param format format string to pass to scanf 237 | * @param ... arguments to scanf 238 | * @return number of bytes read or -1 on failure 239 | */ 240 | //int scanf(const char *format, ...) MBED_SCANF_METHOD(1,2); 241 | int scanf(const char *format, ...); 242 | 243 | int vscanf(const char *format, va_list args); 244 | 245 | /** 246 | * Attach a callback for out-of-band data 247 | * 248 | * @param prefix string on when to initiate callback 249 | * @param func callback to call when string is read 250 | * @note out-of-band data is only processed during a scanf call 251 | */ 252 | //void oob(const char *prefix, mbed::Callback func); 253 | void oob(const char *prefix, Parser_Callback func); 254 | 255 | 256 | /** 257 | * Flushes the underlying stream 258 | */ 259 | void flush(); 260 | 261 | /** 262 | * Abort current recv 263 | * 264 | * Can be called from oob handler to interrupt the current 265 | * recv operation. 266 | */ 267 | void abort(); 268 | 269 | /** 270 | * Process out-of-band data 271 | * 272 | * Process out-of-band data in the receive buffer. This function 273 | * returns immediately if there is no data to process. 274 | * 275 | * @return true if oob data processed, false otherwise 276 | */ 277 | bool process_oob(void); 278 | }; 279 | 280 | /**@}*/ 281 | 282 | /**@}*/ 283 | 284 | #endif /* SKT_LTE_M1_SRC_UTILITY_AT_CMD_PARSER_H_ */ 285 | -------------------------------------------------------------------------------- /samples/WIoT-QC01_BG96/WIoT-QC01_Arduino_TCP/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | -------------------------------------------------------------------------------- /samples/WIoT-Shield/WIoT-Shield_SENSOR_CDS/WIoT-Shield_SENSOR_CDS.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | 3 | #define MYPRINTF(x) { Serial.print("[MAIN] "); Serial.println(x); } 4 | 5 | // Sensors 6 | #define IOTSHIELD_SENSOR_CDS A0 7 | #define IOTSHIELD_SENSOR_TEMP A1 8 | #define LEDPIN 13 9 | 10 | int val = 0; // CDS 측정 값 넣을 변수 11 | 12 | void setup() { 13 | serialPcInit(); 14 | pinMode(LEDPIN, OUTPUT); // LED 출력으로 지정 15 | 16 | MYPRINTF("WIZnet IoT Shield for Arduino"); 17 | MYPRINTF("LTE Cat.M1 Version"); 18 | MYPRINTF("================================================="); 19 | MYPRINTF(">> Sample Code: CDS Test"); 20 | MYPRINTF("=================================================\r\n"); 21 | } 22 | 23 | void loop() { 24 | //map : 특정 범위에 속하는 값을 다른 범위의 값으로 변환해주는 명령어 25 | val = map(analogRead(IOTSHIELD_SENSOR_CDS), 0, 1023, 0, 256); 26 | //val = (analogRead(IOTSHIELD_SENSOR_CDS) * 5v); // 다른 계산 방법 27 | 28 | if(val > 128){ // 조도 저항 값이 낮기 때문에 아날로그 값이 높음 29 | digitalWrite(LEDPIN, LOW); 30 | } 31 | else{ // 손가락으로 가리면 조도 저항값이 높아지기 때문에 아날로그 값이 낮아진다 32 | digitalWrite(LEDPIN, HIGH); 33 | } 34 | } 35 | 36 | 37 | void serialPcInit(void) 38 | { 39 | Serial.begin(115200); 40 | } 41 | -------------------------------------------------------------------------------- /samples/WIoT-Shield/WIoT-Shield_SENSOR_TEMP/WIoT-Shield_SENSOR_TEMP.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | 3 | #define MYPRINTF(x) { Serial.print("[MAIN] "); Serial.println(x); } 4 | 5 | // Sensors 6 | #define IOTSHIELD_SENSOR_CDS A0 7 | #define IOTSHIELD_SENSOR_TEMP A1 8 | 9 | int val = 0; // 온도 측정 값 넣을 변수 10 | float voltage = 0; // 전압 계산 값 넣을 변수 11 | float celsius = 0; // 섭씨 계산 값 넣을 변수 12 | float fahrenheit = 0; // 화씨 계산 값 넣을 변수 13 | 14 | void setup() { 15 | serialPcInit(); 16 | 17 | MYPRINTF("WIZnet IoT Shield for Arduino"); 18 | MYPRINTF("LTE Cat.M1 Version"); 19 | MYPRINTF("================================================="); 20 | MYPRINTF(">> Sample Code: TEMP Test"); 21 | MYPRINTF("=================================================\r\n"); 22 | } 23 | 24 | void loop() { 25 | // read the value from the sensor: 26 | val = analogRead(IOTSHIELD_SENSOR_TEMP); 27 | // 실제 전압 계산 28 | // 0~5V의 값을 구하기 위해 아래와 같이 5를 곱하고 1024를 나눈다. 29 | // (Analog값 * IC에 걸리는 전압 / Analog 10bit 분해능(1024)) 30 | // IC에 걸리는 전압은 측정기로 측정 31 | 32 | voltage = val * 4.87 / 1024.0; 33 | celsius = getTemperature_C(voltage); 34 | fahrenheit = getTemperature_F(celsius); 35 | 36 | delay(1000); 37 | Serial.println("[ Temperature Data ]"); 38 | Serial.print("Sensor value :"); 39 | Serial.println(val); 40 | Serial.print("Volt : "); 41 | Serial.print(voltage); 42 | 43 | Serial.println("mV"); 44 | Serial.print("Celsius temp : "); 45 | Serial.print(celsius); 46 | Serial.println("C"); 47 | Serial.print("Fahrenheit temp : "); 48 | Serial.print(fahrenheit); 49 | Serial.println("F"); 50 | delay(1000); 51 | } 52 | 53 | 54 | void serialPcInit(void) 55 | { 56 | Serial.begin(115200); 57 | } 58 | 59 | // ---------------------------------------------------------------- 60 | // Functions: Get Temperature 61 | // ---------------------------------------------------------------- 62 | 63 | float getTemperature_F(float _celsius) 64 | { 65 | // 섭씨에서 화씨 환산 -> (화씨온도 = 섭씽온*9/5+32) 66 | fahrenheit = celsius * 9.0 / 5.0 + 32.0; 67 | return fahrenheit; 68 | } 69 | 70 | float getTemperature_C(float _voltage) 71 | { 72 | // LM35는 섭씨 1도당 10mV의 전위차를 갖는다. 73 | // 센서핀의 전압이 0.28V라면 280mV이므로 온도는 28도씨. 74 | // 100을 곱해서 섭씨 온도로 나타냄 75 | celsius = voltage * 100.0; 76 | return celsius; 77 | } 78 | -------------------------------------------------------------------------------- /samples/WIoT-WM01_WM-N400MSE/WIoT-WM01_Arduino_HTTP/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | -------------------------------------------------------------------------------- /samples/WIoT-WM01_WM-N400MSE/WIoT-WM01_Arduino_PSM/WIoT-WM01_Arduino_PSM.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "at_cmd_parser.h" 3 | 4 | #define RESP_OK "OK\r\n" 5 | #define RET_OK 1 6 | #define RET_NOK -1 7 | #define DEBUG_ENABLE 1 8 | #define DEBUG_DISABLE 0 9 | 10 | #define WM_N400MSE_DEFAULT_BAUD_RATE 115200 11 | #define BG96_PARSER_DELIMITER "\r\n" 12 | 13 | #define CATM1_DEVICE_NAME_WMN400MSE "WM-N400MSE" 14 | #define DEVNAME CATM1_DEVICE_NAME_WMN400MSE 15 | 16 | #define LOGDEBUG(x) if(CATM1_DEVICE_DEBUG == DEBUG_ENABLE) { Serial.print("["); Serial.print(F(DEVNAME)); Serial.print("] "); Serial.println(x); } 17 | #define MYPRINTF(x) { Serial.print("[MAIN] "); Serial.println(x); } 18 | 19 | // Debug message settings 20 | #define BG96_PARSER_DEBUG DEBUG_DISABLE 21 | #define CATM1_DEVICE_DEBUG DEBUG_ENABLE 22 | 23 | #define REQUESTED_PERIODIC_TAU "10000110" 24 | #define REQUESTED_ACTIVE_TIME "00100001" 25 | 26 | ATCmdParser m_parser = ATCmdParser(&Serial3); 27 | 28 | char hour[5], minute[5], second[5]; 29 | char timeBuf[35]; 30 | 31 | void setup() { 32 | // put your setup code here, to run once: 33 | serialPcInit(); 34 | catm1DeviceInit(); 35 | 36 | MYPRINTF("Waiting for Cat.M1 Module Ready...\r\n"); 37 | 38 | waitCatM1Ready(); 39 | 40 | MYPRINTF("System Init Complete\r\n"); 41 | 42 | MYPRINTF("WIZnet IoT Shield for Arduino"); 43 | MYPRINTF("LTE Cat.M1 Version"); 44 | MYPRINTF("================================================="); 45 | MYPRINTF(">> Target Board: WIoT-WM01 (Woori-Net WM-N400MSE)"); 46 | MYPRINTF(">> Sample Code: PSM Test"); 47 | MYPRINTF("=================================================\r\n"); 48 | 49 | for (int i = 0; i < 5; i++) 50 | { 51 | Serial.println(""); 52 | if (initStatus() == true) { 53 | break; 54 | } 55 | else { 56 | LOGDEBUG("Please Check your H/W Status\r\n"); 57 | } 58 | delay(1000); 59 | } 60 | 61 | setContextActivate_wm01(); 62 | 63 | setPSMActivate(REQUESTED_PERIODIC_TAU, REQUESTED_ACTIVE_TIME); 64 | 65 | moduleReset(); 66 | } 67 | 68 | void loop() { 69 | // put your main code here, to run repeatedly: 70 | getcurrentTime(); 71 | delay(1000); 72 | 73 | } 74 | 75 | void serialPcInit(void) 76 | { 77 | Serial.begin(115200); 78 | } 79 | 80 | void serialDeviceInit() 81 | { 82 | Serial3.begin(WM_N400MSE_DEFAULT_BAUD_RATE); 83 | } 84 | 85 | void serialAtParserInit() 86 | { 87 | m_parser.set_timeout(1000); 88 | m_parser.set_delimiter("\r"); 89 | } 90 | void catm1DeviceInit() 91 | { 92 | serialDeviceInit(); 93 | serialAtParserInit(); 94 | } 95 | 96 | // ---------------------------------------------------------------- 97 | // Functions: Cat.M1 Status 98 | // ---------------------------------------------------------------- 99 | 100 | int8_t waitCatM1Ready() 101 | { 102 | bool initOK = false; 103 | for (int i = 0; i < 20; i++) 104 | { 105 | if (m_parser.send(F("AT")) && m_parser.recv(F(RESP_OK))) { 106 | MYPRINTF("WM-N400MSE AT Command Available\r\n"); 107 | initOK = true; 108 | return RET_OK; 109 | } 110 | delay(1000); 111 | } 112 | if (!initOK) { 113 | Serial.println("[WM-N400MSE] AT Command: Not Available"); 114 | return RET_NOK; 115 | } 116 | } 117 | 118 | bool initStatus() 119 | { 120 | 121 | if ( setEchoStatus_wm01(false) != RET_OK ) 122 | { 123 | return false; 124 | } 125 | 126 | if ( getUsimStatus_wm01() != RET_OK ) 127 | { 128 | return false; 129 | } 130 | 131 | if ( getNetworkStatus_wm01() != RET_OK ) 132 | { 133 | return false; 134 | } 135 | 136 | return true; 137 | } 138 | 139 | int8_t setEchoStatus_wm01(bool onoff) 140 | { 141 | if ( onoff == true ) 142 | { 143 | if ( !(m_parser.send(F("ATE1")) && m_parser.recv(F(RESP_OK))) ) { 144 | LOGDEBUG("Echo On: Failed\r\n"); 145 | return RET_NOK; 146 | } 147 | else 148 | { 149 | LOGDEBUG("Echo On: Success\r\n"); 150 | return RET_OK; 151 | } 152 | 153 | } 154 | else if ( onoff == false ) 155 | { 156 | if ( !(m_parser.send(F("ATE0")) && m_parser.recv(F(RESP_OK))) ) { 157 | LOGDEBUG("Echo Off: Failed\r\n"); 158 | return RET_NOK; 159 | } 160 | else 161 | { 162 | LOGDEBUG("Echo Off: Success\r\n"); 163 | return RET_OK; 164 | } 165 | } 166 | } 167 | 168 | int8_t getUsimStatus_wm01(void) 169 | { 170 | char usim_stat[10], detail[10]; 171 | char buf[40]; 172 | 173 | if ( m_parser.send(F("AT$$STAT?")) && 174 | m_parser.recv(F("$$STAT:READY\n")) && 175 | m_parser.recv(F(RESP_OK)) ) { 176 | LOGDEBUG("USIM Status: READY\r\n"); 177 | return RET_OK; 178 | } 179 | 180 | else if ( m_parser.send(F("AT$$STAT?")) && 181 | m_parser.recv(F("$$STAT:%[^,],%[^\n]\n"), usim_stat, detail) && 182 | m_parser.recv(F(RESP_OK)) ) { 183 | sprintf((char *)buf, "USIM Satatus: %s, %s", usim_stat, detail); 184 | LOGDEBUG(buf); 185 | return RET_NOK; 186 | } 187 | } 188 | 189 | int8_t getNetworkStatus_wm01(void) 190 | { 191 | char mode[10], stat[10]; 192 | char buf[10]; 193 | 194 | if ( m_parser.send(F("AT+CEREG?")) && 195 | m_parser.recv(F("+CEREG: %[^,],%[^\n]\n"), mode, stat) && 196 | m_parser.recv(F(RESP_OK)) ) { 197 | 198 | if ( (atoi(mode) == 0) && (atoi(stat) == 1) ) { 199 | LOGDEBUG("Network Status: Attach\r\n"); 200 | return RET_OK; 201 | } 202 | 203 | else if (( atoi(stat) != 1 )) { 204 | sprintf((char *)buf, "Network Status: %d, %d", atoi(mode), atoi(stat)); 205 | LOGDEBUG(buf); 206 | return RET_NOK; 207 | } 208 | } 209 | } 210 | 211 | void getIMEIInfo_wm01(void) 212 | { 213 | char m_imei[30]; 214 | char buf[25]; 215 | 216 | if ( (m_parser.send(F("AT*MINFO")) 217 | && m_parser.recv(F("*MINFO:%*[^,],%*[^,],%[^,],%*[^\n]\n"), m_imei) 218 | && m_parser.recv(F(RESP_OK))) ) { 219 | sprintf((char *)buf, "Module IME: %s\r\n", m_imei); 220 | LOGDEBUG(buf); 221 | } 222 | } 223 | 224 | void getSwVersion_wm01(void) 225 | { 226 | char m_sw_version[30]; 227 | char buf[35]; 228 | 229 | if ( (m_parser.send(F("AT$$SWVER")) 230 | && m_parser.recv(F("$$SWVER: %[^\n]\n"), m_sw_version) 231 | && m_parser.recv(F(RESP_OK))) ) { 232 | sprintf((char *)buf, "Module SW Ver: %s", m_sw_version); 233 | LOGDEBUG(buf); 234 | } 235 | } 236 | 237 | // ---------------------------------------------------------------- 238 | // Functions: Cat.M1 PDP context activate 239 | // ---------------------------------------------------------------- 240 | 241 | void setContextActivate_wm01(void) 242 | { 243 | if ( (m_parser.send(F("AT*RNDISDATA=1")) 244 | && m_parser.recv(F("\r\n")) 245 | && m_parser.recv(F(RESP_OK))) ) { 246 | LOGDEBUG("PDP Context Activation: Success\r\n"); 247 | } 248 | } 249 | 250 | // ---------------------------------------------------------------- 251 | // Functions: Cat.M1 PSM activate / deactivate 252 | // ---------------------------------------------------------------- 253 | 254 | void setPSMActivate(char *Requested_Periodic_TAU, char *Requested_Active_Time) 255 | { 256 | if ( (m_parser.send(F("AT+CPSMS=1,,,\"%s\",\"%s\""), Requested_Periodic_TAU, Requested_Active_Time) 257 | && m_parser.recv(F(RESP_OK))) ) { 258 | LOGDEBUG("PSM Activate: Success\r\n"); 259 | } 260 | } 261 | 262 | void setPSMDeactivate() 263 | { 264 | if ( (m_parser.send(F("AT+CPSMS=0")) 265 | && m_parser.recv(F(RESP_OK))) ) { 266 | LOGDEBUG("PSM Deactivate: Success\r\n"); 267 | } 268 | } 269 | 270 | // ---------------------------------------------------------------- 271 | // Functions: Cat.M1 module reset 272 | // ---------------------------------------------------------------- 273 | 274 | void moduleReset(void) 275 | { 276 | if ( (m_parser.send(F("AT*SKT*RESET")) 277 | && m_parser.recv(F("*SKT*RESET:1\r\n")) 278 | && m_parser.recv(F(RESP_OK))) ) { 279 | LOGDEBUG("Reset: Success\r\n"); 280 | } 281 | } 282 | 283 | // ---------------------------------------------------------------- 284 | // Functions: Cat.M1 module get current time 285 | // ---------------------------------------------------------------- 286 | 287 | void getcurrentTime(void) 288 | { 289 | if ( m_parser.send(F("AT$$MSTIME?")) && 290 | m_parser.recv(F("$$MSTIME: %*[^,],%*[^,],%*[^,],%*[^,],%[^,],%[^,],%[^\n]\n"), hour, minute, second) && 291 | m_parser.recv(F(RESP_OK)) ) { 292 | 293 | sprintf((char *)timeBuf, "Current Time: %d h %d m %d s", atoi(hour), atoi(minute), atoi(second) ); 294 | LOGDEBUG(timeBuf); 295 | } 296 | } 297 | -------------------------------------------------------------------------------- /samples/WIoT-WM01_WM-N400MSE/WIoT-WM01_Arduino_PSM/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | -------------------------------------------------------------------------------- /samples/WIoT-WM01_WM-N400MSE/WIoT-WM01_Arduino_Ping/WIoT-WM01_Arduino_Ping.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "at_cmd_parser.h" 3 | 4 | #define RESP_OK "OK\r\n" 5 | #define RET_OK 1 6 | #define RET_NOK -1 7 | #define DEBUG_ENABLE 1 8 | #define DEBUG_DISABLE 0 9 | 10 | #define WM_N400MSE_DEFAULT_BAUD_RATE 115200 11 | #define BG96_PARSER_DELIMITER "\r\n" 12 | 13 | #define CATM1_DEVICE_NAME_WMN400MSE "WM-N400MSE" 14 | #define DEVNAME CATM1_DEVICE_NAME_WMN400MSE 15 | 16 | #define LOGDEBUG(x) if(CATM1_DEVICE_DEBUG == DEBUG_ENABLE) { Serial.print("["); Serial.print(F(DEVNAME)); Serial.print("] "); Serial.println(x); } 17 | #define MYPRINTF(x) { Serial.print("[MAIN] "); Serial.println(x); } 18 | 19 | // Debug message settings 20 | #define BG96_PARSER_DEBUG DEBUG_DISABLE 21 | #define CATM1_DEVICE_DEBUG DEBUG_ENABLE 22 | 23 | ATCmdParser m_parser = ATCmdParser(&Serial3); 24 | 25 | void setup() { 26 | // put your setup code here, to run once: 27 | serialPcInit(); 28 | catm1DeviceInit(); 29 | 30 | MYPRINTF("Waiting for Cat.M1 Module Ready...\r\n"); 31 | 32 | waitCatM1Ready(); 33 | 34 | MYPRINTF("System Init Complete\r\n"); 35 | 36 | MYPRINTF("WIZnet IoT Shield for Arduino"); 37 | MYPRINTF("LTE Cat.M1 Version"); 38 | MYPRINTF("================================================="); 39 | MYPRINTF(">> Target Board: WIoT-WM01 (Woori-Net WM-N400MSE)"); 40 | MYPRINTF(">> Sample Code: Ping Test"); 41 | MYPRINTF("=================================================\r\n"); 42 | 43 | for (int i = 0; i < 5; i++) 44 | { 45 | Serial.println(""); 46 | if (initStatus() == true) { 47 | break; 48 | } 49 | else { 50 | LOGDEBUG("Please Check your H/W Status\r\n"); 51 | } 52 | delay(1000); 53 | } 54 | 55 | setContextActivate_wm01(); 56 | 57 | testPing_wm01(); 58 | } 59 | 60 | void loop() { 61 | // put your main code here, to run repeatedly: 62 | } 63 | 64 | void serialPcInit(void) 65 | { 66 | Serial.begin(115200); 67 | } 68 | 69 | void serialDeviceInit() 70 | { 71 | Serial3.begin(WM_N400MSE_DEFAULT_BAUD_RATE); 72 | } 73 | 74 | void serialAtParserInit() 75 | { 76 | m_parser.set_timeout(1000); 77 | m_parser.set_delimiter("\r"); 78 | } 79 | void catm1DeviceInit() 80 | { 81 | serialDeviceInit(); 82 | serialAtParserInit(); 83 | } 84 | 85 | // ---------------------------------------------------------------- 86 | // Functions: Cat.M1 Status 87 | // ---------------------------------------------------------------- 88 | 89 | int8_t waitCatM1Ready() 90 | { 91 | bool initOK = false; 92 | for (int i = 0; i < 20; i++) 93 | { 94 | if (m_parser.send(F("AT")) && m_parser.recv(F(RESP_OK))) { 95 | MYPRINTF("WM-N400MSE AT Command Available\r\n"); 96 | initOK = true; 97 | return RET_OK; 98 | } 99 | delay(1000); 100 | } 101 | if (!initOK) { 102 | Serial.println("[WM-N400MSE] AT Command: Not Available"); 103 | return RET_NOK; 104 | } 105 | } 106 | 107 | bool initStatus() 108 | { 109 | 110 | if ( setEchoStatus_wm01(false) != RET_OK ) 111 | { 112 | return false; 113 | } 114 | 115 | if ( getUsimStatus_wm01() != RET_OK ) 116 | { 117 | return false; 118 | } 119 | 120 | if ( getNetworkStatus_wm01() != RET_OK ) 121 | { 122 | return false; 123 | } 124 | 125 | return true; 126 | } 127 | 128 | int8_t setEchoStatus_wm01(bool onoff) 129 | { 130 | if ( onoff == true ) 131 | { 132 | if ( !(m_parser.send(F("ATE1")) && m_parser.recv(F(RESP_OK))) ) { 133 | LOGDEBUG("Echo On: Failed\r\n"); 134 | return RET_NOK; 135 | } 136 | else 137 | { 138 | LOGDEBUG("Echo On: Success\r\n"); 139 | return RET_OK; 140 | } 141 | 142 | } 143 | else if ( onoff == false ) 144 | { 145 | if ( !(m_parser.send(F("ATE0")) && m_parser.recv(F(RESP_OK))) ) { 146 | LOGDEBUG("Echo Off: Failed\r\n"); 147 | return RET_NOK; 148 | } 149 | else 150 | { 151 | LOGDEBUG("Echo Off: Success\r\n"); 152 | return RET_OK; 153 | } 154 | } 155 | } 156 | 157 | 158 | 159 | int8_t getUsimStatus_wm01(void) 160 | { 161 | char usim_stat[10], detail[10]; 162 | char buf[40]; 163 | 164 | if ( m_parser.send(F("AT$$STAT?")) && 165 | m_parser.recv(F("$$STAT:READY\n")) && 166 | m_parser.recv(F(RESP_OK)) ) { 167 | LOGDEBUG("USIM Status: READY\r\n"); 168 | return RET_OK; 169 | } 170 | 171 | else if ( m_parser.send(F("AT$$STAT?")) && 172 | m_parser.recv(F("$$STAT:%[^,],%[^\n]\n"), usim_stat, detail) && 173 | m_parser.recv(F(RESP_OK)) ) { 174 | sprintf((char *)buf, "USIM Satatus: %s, %s", usim_stat, detail); 175 | LOGDEBUG(buf); 176 | return RET_NOK; 177 | } 178 | } 179 | 180 | int8_t getNetworkStatus_wm01(void) 181 | { 182 | char mode[10], stat[10]; 183 | char buf[10]; 184 | 185 | if ( m_parser.send(F("AT+CEREG?")) && 186 | m_parser.recv(F("+CEREG: %[^,],%[^\n]\n"), mode, stat) && 187 | m_parser.recv(F(RESP_OK)) ) { 188 | 189 | if ( (atoi(mode) == 0) && (atoi(stat) == 1) ) { 190 | LOGDEBUG("Network Status: Attach\r\n"); 191 | return RET_OK; 192 | } 193 | 194 | else if (( atoi(stat) != 1 )) { 195 | sprintf((char *)buf, "Network Status: %d, %d", atoi(mode), atoi(stat)); 196 | LOGDEBUG(buf); 197 | return RET_NOK; 198 | } 199 | } 200 | } 201 | 202 | void getIMEIInfo_wm01(void) 203 | { 204 | char m_imei[30]; 205 | char buf[25]; 206 | 207 | if ( (m_parser.send(F("AT*MINFO")) 208 | && m_parser.recv(F("*MINFO:%*[^,],%*[^,],%[^,],%*[^\n]\n"), m_imei) 209 | && m_parser.recv(F(RESP_OK))) ) { 210 | sprintf((char *)buf, "Module IME: %s\r\n", m_imei); 211 | LOGDEBUG(buf); 212 | } 213 | } 214 | 215 | void getSwVersion_wm01(void) 216 | { 217 | char m_sw_version[30]; 218 | char buf[35]; 219 | 220 | if ( (m_parser.send(F("AT$$SWVER")) 221 | && m_parser.recv(F("$$SWVER: %[^\n]\n"), m_sw_version) 222 | && m_parser.recv(F(RESP_OK))) ) { 223 | sprintf((char *)buf, "Module SW Ver: %s", m_sw_version); 224 | LOGDEBUG(buf); 225 | } 226 | } 227 | 228 | // ---------------------------------------------------------------- 229 | // Functions: Cat.M1 PDP context activate 230 | // ---------------------------------------------------------------- 231 | 232 | void setContextActivate_wm01(void) 233 | { 234 | if ( (m_parser.send(F("AT*RNDISDATA=1")) 235 | && m_parser.recv(F("\r\n")) 236 | && m_parser.recv(F(RESP_OK))) ) { 237 | LOGDEBUG("PDP Context Activation: Success\r\n"); 238 | } 239 | } 240 | 241 | // ---------------------------------------------------------------- 242 | // Functions: Cat.M1 Ping test 243 | // ---------------------------------------------------------------- 244 | 245 | void testPing_wm01(void) 246 | { 247 | String resp_str; 248 | 249 | if ( (m_parser.send(F("AT*PING=8.8.8.8,1")) 250 | && m_parser.recv(F("OK"))) ) { 251 | resp_str = Serial3.readString(); 252 | const char* chr = resp_str.c_str(); 253 | if ( strstr(chr, "connect: Network is unreachable") != NULL ) 254 | { 255 | LOGDEBUG("Ping Test: Unreachable"); 256 | } 257 | 258 | else if ( strstr(chr, "unknown host") != NULL ) 259 | { 260 | LOGDEBUG("Ping Test: Network Status Check"); 261 | } 262 | 263 | else if ( strstr(chr, "PING 64") != NULL ) { 264 | LOGDEBUG(resp_str); 265 | } 266 | 267 | 268 | } 269 | } 270 | -------------------------------------------------------------------------------- /samples/WIoT-WM01_WM-N400MSE/WIoT-WM01_Arduino_Ping/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | -------------------------------------------------------------------------------- /samples/WIoT-WM01_WM-N400MSE/WIoT-WM01_Arduino_SMS/WIoT-WM01_Arduino_SMS.ino: -------------------------------------------------------------------------------- 1 | #include "Arduino.h" 2 | #include "at_cmd_parser.h" 3 | 4 | #define RESP_OK "OK\r\n" 5 | #define RET_OK 1 6 | #define RET_NOK -1 7 | #define DEBUG_ENABLE 1 8 | #define DEBUG_DISABLE 0 9 | 10 | #define WM_N400MSE_DEFAULT_BAUD_RATE 115200 11 | #define BG96_PARSER_DELIMITER "\r\n" 12 | 13 | #define CATM1_DEVICE_NAME_WMN400MSE "WM-N400MSE" 14 | #define DEVNAME CATM1_DEVICE_NAME_WMN400MSE 15 | 16 | #define LOGDEBUG(x) if(CATM1_DEVICE_DEBUG == DEBUG_ENABLE) { Serial.print("["); Serial.print(F(DEVNAME)); Serial.print("] "); Serial.println(x); } 17 | #define MYPRINTF(x) { Serial.print("[MAIN] "); Serial.println(x); } 18 | 19 | // Debug message settings 20 | #define BG96_PARSER_DEBUG DEBUG_DISABLE 21 | #define CATM1_DEVICE_DEBUG DEBUG_ENABLE 22 | 23 | char *phone_number = "Insert Your Phone Numer"; 24 | char *send_message = "Insert Your Message"; 25 | String rxdata; 26 | 27 | ATCmdParser m_parser = ATCmdParser(&Serial3); 28 | 29 | void setup() { 30 | // put your setup code here, to run once: 31 | serialPcInit(); 32 | catm1DeviceInit(); 33 | 34 | MYPRINTF("Waiting for Cat.M1 Module Ready...\r\n"); 35 | 36 | waitCatM1Ready(); 37 | 38 | MYPRINTF("System Init Complete\r\n"); 39 | 40 | MYPRINTF("WIZnet IoT Shield for Arduino"); 41 | MYPRINTF("LTE Cat.M1 Version"); 42 | MYPRINTF("================================================="); 43 | MYPRINTF(">> Target Board: WIoT-WM01 (Woori-Net WM-N400MSE)"); 44 | MYPRINTF(">> Sample Code: SMS Test"); 45 | MYPRINTF("=================================================\r\n"); 46 | 47 | for (int i = 0; i < 5; i++) 48 | { 49 | Serial.println(""); 50 | if (initStatus() == true) { 51 | break; 52 | } 53 | else { 54 | LOGDEBUG("Please Check your H/W Status\r\n"); 55 | } 56 | delay(1000); 57 | } 58 | 59 | setRecvSMSUart(); 60 | 61 | sendSMS(phone_number, send_message); 62 | 63 | } 64 | 65 | void loop() { 66 | // put your main code here, to run repeatedly: 67 | rxdataHandling(); 68 | } 69 | 70 | void serialPcInit(void) 71 | { 72 | Serial.begin(115200); 73 | } 74 | 75 | void serialDeviceInit() 76 | { 77 | Serial3.begin(WM_N400MSE_DEFAULT_BAUD_RATE); 78 | } 79 | 80 | void serialAtParserInit() 81 | { 82 | m_parser.set_timeout(1000); 83 | m_parser.set_delimiter("\r"); 84 | } 85 | void catm1DeviceInit() 86 | { 87 | serialDeviceInit(); 88 | serialAtParserInit(); 89 | } 90 | 91 | // ---------------------------------------------------------------- 92 | // Functions: Cat.M1 Status 93 | // ---------------------------------------------------------------- 94 | 95 | int8_t waitCatM1Ready() 96 | { 97 | bool initOK = false; 98 | for (int i = 0; i < 20; i++) 99 | { 100 | if (m_parser.send(F("AT")) && m_parser.recv(F(RESP_OK))) { 101 | MYPRINTF("WM-N400MSE AT Command Available\r\n"); 102 | initOK = true; 103 | return RET_OK; 104 | } 105 | delay(1000); 106 | } 107 | if (!initOK) { 108 | MYPRINTF("WM-N400MSE AT Command Not Available\r\n"); 109 | return RET_NOK; 110 | } 111 | } 112 | 113 | bool initStatus() 114 | { 115 | 116 | if ( setEchoStatus_wm01(false) != RET_OK ) 117 | { 118 | return false; 119 | } 120 | 121 | if ( getUsimStatus_wm01() != RET_OK ) 122 | { 123 | return false; 124 | } 125 | 126 | if ( getNetworkStatus_wm01() != RET_OK ) 127 | { 128 | return false; 129 | } 130 | 131 | return true; 132 | } 133 | 134 | int8_t setEchoStatus_wm01(bool onoff) 135 | { 136 | if ( onoff == true ) 137 | { 138 | if ( !(m_parser.send(F("ATE1")) && m_parser.recv(F(RESP_OK))) ) { 139 | LOGDEBUG("Echo On: Failed\r\n"); 140 | return RET_NOK; 141 | } 142 | else 143 | { 144 | LOGDEBUG("Echo On: Success\r\n"); 145 | return RET_OK; 146 | } 147 | 148 | } 149 | else if ( onoff == false ) 150 | { 151 | if ( !(m_parser.send(F("ATE0")) && m_parser.recv(F(RESP_OK))) ) { 152 | LOGDEBUG("Echo Off: Failed\r\n"); 153 | return RET_NOK; 154 | } 155 | else 156 | { 157 | LOGDEBUG("Echo Off: Success\r\n"); 158 | return RET_OK; 159 | } 160 | } 161 | } 162 | 163 | int8_t getUsimStatus_wm01(void) 164 | { 165 | char usim_stat[10], detail[10]; 166 | char buf[40]; 167 | 168 | if ( m_parser.send(F("AT$$STAT?")) && 169 | m_parser.recv(F("$$STAT:READY\n")) && 170 | m_parser.recv(F(RESP_OK)) ) { 171 | LOGDEBUG("USIM Status: READY\r\n"); 172 | return RET_OK; 173 | } 174 | 175 | else if ( m_parser.send(F("AT$$STAT?")) && 176 | m_parser.recv(F("$$STAT:%[^,],%[^\n]\n"), usim_stat, detail) && 177 | m_parser.recv(F(RESP_OK)) ) { 178 | sprintf((char *)buf, "USIM Satatus: %s, %s", usim_stat, detail); 179 | LOGDEBUG(buf); 180 | return RET_NOK; 181 | } 182 | } 183 | 184 | int8_t getNetworkStatus_wm01(void) 185 | { 186 | char mode[10], stat[10]; 187 | char buf[10]; 188 | 189 | if ( m_parser.send(F("AT+CEREG?")) && 190 | m_parser.recv(F("+CEREG: %[^,],%[^\n]\n"), mode, stat) && 191 | m_parser.recv(F(RESP_OK)) ) { 192 | 193 | if ( (atoi(mode) == 0) && (atoi(stat) == 1) ) { 194 | LOGDEBUG("Network Status: Attach\r\n"); 195 | return RET_OK; 196 | } 197 | 198 | else if (( atoi(stat) != 1 )) { 199 | sprintf((char *)buf, "Network Status: %d, %d\r\n", atoi(mode), atoi(stat)); 200 | LOGDEBUG(buf); 201 | return RET_NOK; 202 | } 203 | } 204 | } 205 | 206 | void getIMEIInfo_wm01(void) 207 | { 208 | char m_imei[30]; 209 | char buf[25]; 210 | 211 | if ( (m_parser.send(F("AT*MINFO")) 212 | && m_parser.recv(F("*MINFO:%*[^,],%*[^,],%[^,],%*[^\n]\n"), m_imei) 213 | && m_parser.recv(F(RESP_OK))) ) { 214 | sprintf((char *)buf, "Module IME: %s\r\n", m_imei); 215 | LOGDEBUG(buf); 216 | } 217 | } 218 | 219 | void getSwVersion_wm01(void) 220 | { 221 | char m_sw_version[30]; 222 | char buf[35]; 223 | 224 | if ( (m_parser.send(F("AT$$SWVER")) 225 | && m_parser.recv(F("$$SWVER: %[^\n]\n"), m_sw_version) 226 | && m_parser.recv(F(RESP_OK))) ) { 227 | sprintf((char *)buf, "Module SW Ver: %s", m_sw_version); 228 | LOGDEBUG(buf); 229 | } 230 | } 231 | 232 | // ---------------------------------------------------------------- 233 | // Functions: Cat.M1 SMS 234 | // ---------------------------------------------------------------- 235 | 236 | void sendSMS(char *_phone_number, char *_send_message) 237 | { 238 | char buf[100]; 239 | if ( (m_parser.send(F("AT*SMSMO=%s,,1,1,%s"), _phone_number, _send_message) 240 | //&& m_parser.recv(F(RESP_OK)) 241 | && m_parser.recv(F("*SMSACK"))) ) { 242 | 243 | sprintf((char *)buf, "[SMS Send] to %s, \"%s\"\r\n", _phone_number, _send_message); 244 | 245 | LOGDEBUG(">> SMS send success\r\n"); 246 | MYPRINTF(buf); 247 | } 248 | } 249 | 250 | void setRecvSMSUart(void) 251 | { 252 | if ( (m_parser.send(F("AT*SKT*NEWMSG=4098")) 253 | && m_parser.recv(F(RESP_OK))) ) { 254 | LOGDEBUG("Set to receive SMS from UART: Success\r\n"); 255 | } 256 | } 257 | 258 | void rxdataHandling(void) 259 | { 260 | char buf[100]; 261 | if (Serial3.available()) 262 | { 263 | rxdata = Serial3.readStringUntil('\n'); 264 | const char* chr = rxdata.c_str(); 265 | 266 | if ( strstr(chr, "*SKT*NEWMSG:") != NULL ) 267 | { 268 | sprintf((char *)buf, "[SMS Recv] %s\r\n", chr); 269 | 270 | LOGDEBUG("<< SMS recv success\r\n"); 271 | MYPRINTF(buf); 272 | 273 | m_parser.send(F("AT*SKT*MTACK=0")); 274 | m_parser.recv(F(RESP_OK)); 275 | m_parser.flush(); 276 | } 277 | } 278 | } 279 | 280 | 281 | 282 | -------------------------------------------------------------------------------- /samples/WIoT-WM01_WM-N400MSE/WIoT-WM01_Arduino_SMS/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | -------------------------------------------------------------------------------- /samples/WIoT-WM01_WM-N400MSE/WIoT-WM01_Arduino_TCP/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) WIZnet, Inc. All rights reserved. 3 | * Use is subject to license terms. 4 | */ 5 | #ifndef __DEBUG_H__ 6 | #define __DEBUG_H__ 7 | 8 | #include 9 | 10 | 11 | // Change _SKT_LTE_M1_LOGLEVEL_ to set tracing and logging verbosity 12 | // 0: DISABLED: no logging 13 | // 1: ERROR: errors 14 | // 2: WARN: errors and warnings 15 | // 3: INFO: errors, warnings and informational (default) 16 | // 4: DEBUG: errors, warnings, informational and debug 17 | 18 | #define _SKT_LTE_M1_LOGLEVEL_ 3 19 | 20 | #if defined(ARDUINO_ARCH_SAMD) 21 | 22 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 23 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 24 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 25 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 26 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.println(x); } 27 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { SerialUSB.print("[SKT_LTE_M1] "); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 28 | 29 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x); } 30 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); } 31 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.println(y); } 32 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x); SerialUSB.print(" "); SerialUSB.print(y); SerialUSB.print(" "); SerialUSB.println(z); } 33 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.print(x,y); } 34 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1] ")); SerialUSB.println(x,y); } 35 | #else 36 | 37 | #define LOGERROR(x) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 38 | #define LOGERROR1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>0) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 39 | #define LOGWARN(x) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 40 | #define LOGWARN1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>1) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 41 | #define LOGINFO(x) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.println(x); } 42 | #define LOGINFO1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>2) { Serial.print(F("[SKT_LTE_M1] ")); Serial.print(x); Serial.print(" "); Serial.println(y); } 43 | 44 | #define LOGDEBUG(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x); } 45 | #define LOGDEBUG0(x) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); } 46 | #define LOGDEBUG1(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.println(y); } 47 | #define LOGDEBUG2(x,y,z) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x); Serial.print(F(" ")); Serial.print(y); Serial.print(F(" ")); Serial.println(z); } 48 | #define LOGDEBUG_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.print(x,y); } 49 | #define LOGDEBUG_LN_TYPE(x,y) if(_SKT_LTE_M1_LOGLEVEL_>3) { Serial.print(F("[SKT_LTE_M1_Debug] ")); Serial.println(x,y); } 50 | 51 | #endif // defined(ARDUINO_ARCH_SAMD) 52 | 53 | #endif // __DEBUG_H__ 54 | 55 | --------------------------------------------------------------------------------