Page 1
DFCM - NN N4 0 - DT x R BLE/WIFI Command Line Interface Document BLE/WIFI Command Line Interface Sheet 1 of 45 Feb 11, 2015 Proprietary Information and Specifications are Subject to Change...
DFCM - NN N4 0 - DT x R Index: Introduction........................ 6 Commands Status Responses ................. 8 OK ..........................8 ERROR .......................... 8 BLE Commands Description .................. 10 GPIO ..........................10 System Off ........................10 BLE Disconnection ....................... 11 Reset ..........................11 System Information .......................
Page 3
DFCM - NN N4 0 - DT x R Wi-Fi TCP Socket Server Command ................23 4.3.1 TCP Socket Server Bind....................23 4.3.2 TCP Socket Server Listen ..................... 23 4.3.3 TCP Socket Server Accept .................... 24 4.3.4 TCP Socket Server Blocking ..................24 4.3.5 TCP Socket Server Close ....................
Page 4
DFCM - NN N4 0 - DT x R WIFI Example for connecting to AP by command ..........38 Tools Preparation ......................38 Wi-Fi Connection ......................39 Wi-Fi Communication Protocol..................39 TCP client ........................39 TCP server ........................40 UDP client ........................40 UDP Server ........................
Page 5
DFCM - NN N4 0 - DT x R Revision History Version Date Reason of change Maker MARCUS 2015/01/16 Initial release (Internal) CHIOU Modify command description, error message, and add 2015/02/03 Gill Wei demonstration to create a GATT profile 2015/02/11 Initial release Gill Wei 2015/03/02...
Wi-Fi/BLE Combo Module. 1. Introduction This document describes the function of each command within DFCM-NNN40-DTxR command line interface; include BLE connection, Wi-Fi enable/disable, sleep mode, and so on. This document also makes a demonstration of how to set up environment in PC and create a BLE profile in GATT server;...
Page 7
DFCM - NN N4 0 - DT x R Figure.1 Glucose role and services After define all the data in Glucose sensor, let’s see how BLE device set up the connection and transmit data, Figure.2 show how BLE device in and out from different state; only in connecting state, sensor data will transfer in profile-defined format.
DFCM - NN N4 0 - DT x R 2. Commands Status Responses Whenever a command is received by device, an “OK” or “ERROR” response will be send back to host side. ERROR case will output with specific error string; OK will output with additional response for some specific commands.
Page 9
DFCM - NN N4 0 - DT x R Example: RESPONSE: ERROR; Argument out of range;<cr_lf> <cr_lf> BLE/WIFI Command Line Interface Sheet 9 of 45 Feb 11, 2015 Proprietary Information and Specifications are Subject to Change...
DFCM - NN N4 0 - DT x R 3. BLE Commands Description This section describes the detail function of each command, including command format, argument format, and command description. 3.1 GPIO CONTROL GPIO PIN Function: Set or Clear a specific GPIO pin on BLE module Command Format: cynb gpio <GPIO-NO>...
DFCM - NN N4 0 - DT x R 3.3 BLE Disconnection BLE DISCONNECTION Function: Disconnect from current BLE connection. Command Format: cynb disconn Example: COMMAND: cynb disconn<cr> RESPONSE: <cr_lf> OK<cr_lf> <cr_lf> Note: If the connection does not create, system show error message for invalid state.
DFCM - NN N4 0 - DT x R 3.5 System Information MODULE INFORMATION Function: List system information in DFCM-NNN40-DTxR, system information include FW version and Module name Command Format: cynb info Example: COMMAND: cynb info<cr> RESPONSE: <cr_lf> OK; F/W version:DELTA_CLI_V1.0;Module name: DFCM-NNN40-DTxR;...
DFCM - NN N4 0 - DT x R GET BLE DEVICE NAME Function: Get the current device name for BLE module. Command Format: cynb name Example: COMMAND: cynb name<cr> RESPONSE: <cr_lf> DELTA_CLI;<cr_lf> <cr_lf> 3.7 BLE Advertising START DEVICE ADVERTISING Function: Start BLE advertising with specific timeout and interval.
DFCM - NN N4 0 - DT x R STOP DEVICE ADVERTISING Function: Stop BLE advertising. Command Format: cynb adv <STOP> Example: COMMAND: cynb adv stop<cr> RESPONSE: <cr_lf> OK<cr_lf> <cr_lf> Note: If the system is not in advertising state, error message show that the system in invalid state for operation.
DFCM - NN N4 0 - DT x R 3.9 BLE Address SET BLE Address Function: Set BLE MAC address at run time. Command Format: cynb bleAddr <BLE ADDR> Example: COMMAND: cynb <cr> bleAddr 0xE6BCA12B322F RESPONSE: <cr_lf> OK<cr_lf> <cr_lf> Note: BLE MAC address should be 12 hex number. GET BLE ADDRESS Function: Get current BLE MAC address.
DFCM - NN N4 0 - DT x R 3.10 BLE GATT Service GATT SERVICE SETTING Function: Set service UUID, characteristic UUID, characteristic property and value for BLE module. Command Format: cynb gattSet <SERVICE UUID> <CHAR UUID> <ATTR PROP> <ATTR VALUE> Example: COMMAND: cynb 0x180D 0x2A39 rw...
DFCM - NN N4 0 - DT x R Note: If the specified characteristic property contains notify/indicate, data update require Central (ex.mobile phone) enable the notify/indicate previously. Attribute value type is uint8_t, so the input hex number must be even number, ex.
DFCM - NN N4 0 - DT x R 4.1 Wi-Fi Device Command 4.1.1 Device Sleep WIFI DEVICE SLEEP Function: Disable Wi-Fi and set into sleep mode (no Wi-Fi function is available). Command Format: cynw device_sleep Example: COMMAND: <cr> cynw device_sleep RESPONSE: <cr_lf>...
DFCM - NN N4 0 - DT x R 4.2 Ethernet Interface Command 4.2.1 Ethernet Interface Initiation INITIALIZE ETHERNET INTERFACE WITH DHCP Function: Initialize the interface and configure it to use DHCP (no connection at this step). Command Format: cynw ethernet_init Example: COMMAND: <cr>...
DFCM - NN N4 0 - DT x R 4.2.4 Ethernet Interface MAC Address GET MAC ADDRESS Function: Get the MAC address of your Ethernet interface. Command Format: cynw ethernet_mac Example: COMMAND: <cr> cynw ethernet_mac RESPONSE: <cr_lf> OK;00:50:c2:5e:10:dd <cr_lf> <cr_lf> 4.2.5 Ethernet Interface IP Address GET IP ADDRESS Function: Get the IP address of your Ethernet interface.
Page 23
DFCM - NN N4 0 - DT x R 4.3 Wi-Fi TCP Socket Server Command 4.3.1 TCP Socket Server Bind BIND A SPECIFIC PORT Function: Bind a socket to a specific port. Command Format: cynw tcp_server_bind <PORT> Example: COMMAND: <cr> cynw tcp_server_bind 5567 RESPONSE: <cr_lf>...
Page 24
DFCM - NN N4 0 - DT x R 4.3.3 TCP Socket Server Accept ACCEPT A NEW CONNECTION Function: Accept a new connection. Command Format: cynw tcp_server_accept Example: COMMAND: <cr> cynw tcp_server_accept RESPONSE: <cr_lf> OK;<cr_lf> <cr_lf> 4.3.4 TCP Socket Server Blocking SET TCP SOCKET SERVER BLOCKING Function: Set blocking or non-blocking mode of socket and a timeout on blocking socket operations.
Page 25
DFCM - NN N4 0 - DT x R 4.3.5 TCP Socket Server Close CLOSE TCP SOCKET SERVER Function: Close the socket. Command Format: cynw tcp_server_close <SHUTDOWN> Example: COMMAND: <cr> cynw tcp_server_close 1 RESPONSE: <cr_lf> OK;<cr_lf> <cr_lf> Note: <SHUTDOWN> is set to 1 to free left-over data in message queue, and set to 0 to keep the data.
Page 26
DFCM - NN N4 0 - DT x R 4.4.2 TCP Connection Is Connected TCP CONNECTION STATE Function: Check if the socket is connected. Command Format: cynw tcp_connection_is_connect Example: COMMAND: <cr> cynw tcp_connection_is_connect RESPONSE: <cr_lf> OK;TRUE<cr_lf> <cr_lf> Note: If TCP connection is connected, the output will be TRUE, otherwise the output is FALSE.
Page 27
DFCM - NN N4 0 - DT x R 4.4.4 TCP Connection Send All SEND ALL THE DATA THROUGH TCP CONNECTION Function: Send all the data to the remote host. Command Format: cynw tcp_connection_send_all <DATA> Example: COMMAND: <cr> cynw tcp_connection_send_all Hello RESPONSE: <cr_lf>...
Page 28
DFCM - NN N4 0 - DT x R 4.4.6 TCP Connection Receive All RECEIVE ALL THE DATA THROUGH TCP CONNECTION Function: Receive all the data from remote host. Command Format: cynw tcp_connection_receive_all <DATA LENGTH> Example: COMMAND: <cr> cynw tcp_connection_receive_all 10 RESPONSE: <cr_lf>...
Page 29
DFCM - NN N4 0 - DT x R 4.4.8 TCP Connection Close CLOSE TCP CONNECTION Function: Close the socket. Command Format: cynw tcp_connection_close <SHUTDOWN> Example: COMMAND: <cr> cynw tcp_connection_close 1 RESPONSE: <cr_lf> OK;<cr_lf> <cr_lf> Note: <SHUTDOWN> is set to 1 to free left-over data in message queue, and set to 0 to keep the data.
Page 30
DFCM - NN N4 0 - DT x R 4.5.2 UDP Socket Server Bind BIND UDP SERVER SOCKET Function: Bind a UDP Server Socket to a specific port. Command Format: cynw udp_bind <PORT> Example: COMMAND: <cr> cynw udp_bind 5520 RESPONSE: <cr_lf>...
Page 31
DFCM - NN N4 0 - DT x R 4.5.4 UDP Socket Send SEND UDP SOCKET Function: Send a packet to a remote endpoint. Command Format: cynw udp_send_to <DATA> Example: COMMAND: <cr> cynw udp_send_to Hello RESPONSE: <cr_lf> OK;<cr_lf> <cr_lf> Note: The <DATA LENGTH> should not be exceeding 128. (UDP max data length is 128 byte) 4.5.5 UDP Socket Receive RECEIVE UDP SOCKET...
Page 32
DFCM - NN N4 0 - DT x R 4.5.6 UDP Socket Blocking SET UDP SOCKET BLOCKING Function: Set blocking or non-blocking mode of the socket and a timeout on blocking socket operations. Command Format: cynw udp_blocking <MODE> <TIMEOUT MS> Example: COMMAND: <cr>...
Page 33
DFCM - NN N4 0 - DT x R 4.6 Wi-Fi UDP Endpoint 4.6.1 UDP ENDPOINT RESET RESET UDP ENDPOINT Function: Reset the address of this endpoint. Command Format: cynw udp_endpoint_reset Example: COMMAND: <cr> cynw udp_endpoint_reset RESPONSE: <cr_lf> OK;<cr_lf> <cr_lf> 4.6.2 UDP ENDPOINT ADDRESS SET UDP ENDPOINT ADDRESS Function: Set the address of this endpoint.
Page 34
DFCM - NN N4 0 - DT x R GET UDP ENDPOINT ADDRESS Function: Get the IP address of this endpoint. Command Format: cynw udp_endpoint_address Example: COMMAND: <cr> cynw udp_endpoint_address RESPONSE: <cr_lf> OK;192.168.1.24<cr_lf> <cr_lf> Note: Host address is only support IP Address, not support DNS. 4.6.3 UDP ENDPOINT PORT GET UDP ENDPOINT PORT Function: Get the port of this endpoint.
Page 35
DFCM - NN N4 0 - DT x R mobile phone or other BLE central system, at least support BLE 4.0) to verify the configuration and input data. Here we use Nordic’s Wireless APP name “nRF Master Control Panel”, which can be found on PLAY store for Android system. 5.2 Procedure for creating an Profile Before connect the USB-to-UART convertor to NNN40, the resistors on SB13 and SB14 should be removed.
Page 36
DFCM - NN N4 0 - DT x R Figure 3. Terminal emulator configuration-2 BLE sensor device (in this case means NNN40 with glucose sensor) have 6 possible states, when module power on, transit to Initializing state. After initialization, device transit to Configure state, in this state, Collector can configure device name and BLE address and build desired GATT services, etc.
Page 37
DFCM - NN N4 0 - DT x R Figure.2 BLE state change diagram Step1. Sensor power on, transit to Initializing state. Typically with software reset first, then check the module information and firmware information. cynb reset cynb info Step2. Device transit to Configure state, configure by collector, with device name and transmit power, user can also build GATT services and characteristics, here 0x1808 correspond to Glucose Service, and 0x180A correspond to Device Information Service, and Number...
Page 38
DFCM - NN N4 0 - DT x R cynb gattSet 0x1808 0x2A52 <Property> <Value> cynb gattSet 0x180A 0x2A29 <Property> <Value> cynb gattSet 0x180A 0x2A24 <Property> <Value> cynb gattSet 0x180A 0x2A23 <Property> <Value> Step3. Glucose Sensor will typically remain powered off between uses, after sleep command execute, device transit to Sleep state, and will only advertise and allow a Collector to connect when it is turned on by the user and has data to send, key in any input will make device transit to Standby state.
Page 39
DFCM - NN N4 0 - DT x R 2. Wi-Fi Access Point: A Wi-Fi AP (Access Point) is needed for NNN40 to connect. 6.2 Wi-Fi Connection Below steps show how to use command sets to connect to AP. Step 1: “cynw device_switch 1”, switch RF to Wi-Fi Step 2: “cynw device_network DELTA_AP 12345678 0”, set SSID and PASSWORD of the AP Step 3: “cynw ethernet_init”, Initialize the Ethernet interface Step 4: “cynw ethernet_connect 40000”, Connect to the AP with timeout 40000ms, it is notice...
Page 41
DFCM - NN N4 0 - DT x R Step 4: “cynw udp_blocking 0 1500” Step 5: “cynw udp_send_to test” Step 6: “cynw udp_received_from 10” Step 7: “cynw udp_close” Step 8: “cynw ethernet_disconnect” Note that you should prepare the UDP Server to correspond the client. Below is the python file to implement the UDP Server in this case: UDP Client.py 6.7 UDP Server...
Page 42
DFCM - NN N4 0 - DT x R 7. BLE Command Set Summary Table Command Format Command Response Description cynb gpio Set or reset (high/low) a GPIO pin <GPIO-NO> <SET/CLEAR> ERROR;<error reason>; Go to system off mode, wake up cynb sleep <GPIO-NO>...
Page 43
DFCM - NN N4 0 - DT x R 8. WIFI Command Set Summary Table Command Format Command Response Description cynw device_sleep Set WIFI module to sleep mode cynw device_switch Set device switch for WIFI module <SWITCH> ERROR;<error reason> cynw device_switch OK;<RF SWITCH>...
Page 44
DFCM - NN N4 0 - DT x R cynw tcp_connection_is_connect OK;<IS_CONNECTED> Check if the socket is connected cynw tcp_connection_send Send data to the remote host <DATA> ERROR;<error reason> Send all the data to the remote cynw tcp_connection_send_all <DATA> ERROR;<error reason> host cynw tcp_connection_receive <DATA...
DFCM - NN N4 0 - DT x R cynw udp_endpoint_port OK;<ENPOINT PORT> Get the port of this endpoint BLE/WIFI Command Line Interface Sheet 45 of 45 Feb 11, 2015 Proprietary Information and Specifications are Subject to Change...
Need help?
Do you have a question about the DFCM-NNN40-DTxR and is the answer not in the manual?
Questions and answers