Skip to main content
Version: 4.0

SCHC Datagram Interface

The content of Acklio FullSDK can be described in its simplistic view as an adaptation layer with the SCHC mechanisms, and a set of interfaces: the Management API, the Datagram API, the Network API and the L2A interface.
Refer to the diagram of layers and interfaces for a better understanding.

The "UDP Client" and "DLMS using Gurux" Demo examples both use the following AT commands in their communication sequences.

About the Error messages

Error messages of the SCHC interfaces use the following format: AT_ERROR,<layer_id>,<status> where:

  • The layer ID of the Management API is 1
  • The layer ID of the Datagram API is 2
    • The status is the numeric value returned by the library and listed in the header file 'fullsdkdtg.h'.

For example, the error message AT_Error,2,12 means that the session has been aborted by the receiver (error 12) at the level of the datagram interface (layer 2).

Error codes 4, 13, and 15 to 20 are not in the table because they are not returned by the FullSDK library.

info

The commands below are ordered from opening to closing a datagram socket.

Create a Datagram Socket

WhatDetail
CommandAT+SCHC=SOCKET
Parameter
Result codesThe socket ID and then OK, or an error (see below)
 AT_ERROR,2,<status>

The socket ID is a numeric value.

Error Messages

AT_ERROR,2,<status> reports a datagram layer error with the following possible values:

Numeric valueError codeComment
1DTG_ERRORError in socket allocation
2DTG_CONN_ERRNot joined yet
7DTG_NO_SOCKET_ERRNo socket available
8DTG_NOT_IMPL_ERRProtocol not implemented
21DTG_TPL_PARAMS_ERRTemplate parameters are not fully configured

Bind the IP Address and the Port of the Host to a Datagram Socket

WhatDetail
CommandAT+SCHC=BIND,<socket_id>,<dev_addr>,<dev_port>
Parameters<socket_id> - The socket ID
 <dev_addr> - See format below
 <dev_port> - See format below
Result codesOK
 AT_PARAM_ERROR
 AT_ERROR,1,<status> - See below
 AT_ERROR,2,<status> - See below

Recommendations

The device address may be an IPv6 or an IPv4 address, depending on the template in use. The expected formats must comply with the following rules:

  • IPv6 address Format must be 8 groups of 4 hexadecimal numbers: hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh
    Where h is an hexadecimal number (0 to 9, a to f or A to F).
    Leading zeros in an individual field may be omitted, but there must be at least one numeral in every field.
    The :: notation can be used instead of :.

  • IPv4 address Format must be n.n.n.n, n being a decimal number between 0 and 255.

The device port must be a number between 0 and 65535.

Error Messages

AT_ERROR,1,<status> reports a management layer error with the following possible values:

Numeric valueError codeComment
11MGT_NOT_INIT_ERRAcklio FullSDK has not been yet initialized
13MGT_NETWORK_PROTOCOL_ERRInvalid network protocol

AT_ERROR,2,<status> reports a datagram layer error with the following possible values:

Numeric valueError codeComment
2DTG_CONN_ERRNot joined yet
7DTG_NO_SOCKET_ERRNo socket available or socket not allocated
21DTG_TPL_PARAMS_ERRTemplate parameters are not fully configured

Send ASCII Data to a Remote Application

WhatDetail
CommandAT+SCHC=SEND,<socket_id>,<app_addr>,<app_port>,<ascii_data>
Parameters<socket_id> - The socket ID
 <app_addr> - See format below
 <app_port> - See format below
 <ascii_data> - The data to be sent in ASCII format
Result codesOK
 AT_PARAM_ERROR
 AT_ERROR,1,<status> - See below
 AT_ERROR,2,<status> - See below
 +SENDOK,<socket_id>
 +SENDFAIL,<socket_id>,<status>,<error>

Recommendations

The application address may be an IPv6 or an IPv4 address, depending on the template in use. The expected formats must comply with the following rules:

  • IPv6 address Format must be 8 groups of 4 hexadecimal numbers: hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh
    Where h is an hexadecimal number (0 to 9, a to f or A to F).
    Leading zeros in an individual field may be omitted, but there must be at least one numeral in every field.
    The :: notation can be used instead of :.

  • IPv4 address Format must be n.n.n.n, n being a decimal number between 0 and 255.

The application port must be a number between 0 and 65535.

Transmissions

The OK result code or an error is returned immediately. If OK was returned, a transmission is attempted.

  • If the transmission succeeds, +SENDOK and the associated socket ID are returned at the end of the transmission.
  • If the transmission fails, +SENDFAIL, the associated socket ID, a status and an error are returned at the end of the transmission.

The status that can be returned after a transmission failure are:

Numeric valueError codeComment
1DTG_ERRORInternal error
10DTG_L2_ERRError from L2 layer
11DTG_SEND_ABORT_ERRSession aborted by the sender
12DTG_RECV_ABORT_ERRSession aborted by the receiver

Error Messages

The errors depend on layer 2.

AT_ERROR,1,<status> reports a management layer error with the following possible values:

Numeric valueError codeComment
11MGT_NOT_INIT_ERRAcklio FullSDK has not been yet initialized
13MGT_NETWORK_PROTOCOL_ERRInvalid network protocol

AT_ERROR,2,<status> reports a datagram layer error with the following possible values:

Numeric valueError codeComment
1DTG_ERRORF/R layer unhandled error
2DTG_CONN_ERRNot joined yet or the connectivity is no more available
5DTG_BUSY_ERRLayer is busy, request is ignored
7DTG_NO_SOCKET_ERRNo socket available or socket is not allocated
3DTG_BUFFER_ERRProvided buffer size is bigger than supported
6DTG_NO_BIND_ERRBind has not been called and IP headers are requested
9DTG_TOO_BIG_ERRData is too large to be sent without fragmentation
10DTG_L2_ERRError from L2 layer
14DTG_CD_ERRORC/D layer error
21DTG_TPL_PARAMS_ERRTemplate parameters are not fully configured

Send Binary Data to a Remote Application

WhatDetail
CommandAT+SCHC=SENDB,<socket_id>,<app_addr>,<app_port>,<binary_data> - SENDB where the B stands for "binary"
Parameters<socket_id> - The socket ID
 <app_addr> - See format below
 <app_port> - See format below
 <binary_data> - The data to be sent as an ASCII string containing an hexadecimal value
Result codesOK
 AT_PARAM_ERROR
 AT_ERROR,1,<status>
 AT_ERROR,2,<status>
 +SENDOK,<socket_id>
 +SENDFAIL,<socket_id>,<status>,<error>

Recommendations

The application address may be an IPv6 or an IPv4 address, depending on the template in use. The expected formats must comply with the following rules:

  • IPv6 address Format must be 8 groups of 4 hexadecimal numbers: hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh
    Where h is an hexadecimal number (0 to 9, a to f or A to F).
    Leading zeros in an individual field may be omitted, but there must be at least one numeral in every field.
    The :: notation can be used instead of :.

  • IPv4 address Format must be n.n.n.n, n being a decimal number between 0 and 255.

The application port must be a number between 0 and 65535.

Transmissions

The OK result code or an error is returned immediately. If OK was returned, a transmission is attempted.

  • If the transmission succeeds, +SENDOK and the associated socket ID are returned at the end of the transmission.
  • If the transmission fails, +SENDFAIL, the associated socket ID, a status and an error are returned at the end of the transmission.

The status that can be returned after a transmission failure are:

Numeric valueError codeComment
1DTG_ERRORInternal error
10DTG_L2_ERRError from L2 layer
11DTG_SEND_ABORT_ERRSession aborted by the sender
12DTG_RECV_ABORT_ERRSession aborted by the receiver

Error Messages

The errors depend the layer 2.

AT_ERROR,1,<status> reports a management layer error with the following possible values:

Numeric valueError codeComment
11MGT_NOT_INIT_ERRAcklio FullSDK has not been yet initialized
13MGT_NETWORK_PROTOCOL_ERRInvalid network protocol

AT_ERROR,2,<status> reports a datagram layer error with the following possible values:

Numeric valueError codeComment
1DTG_ERRORF/R layer unhandled error
2DTG_CONN_ERRNot joined yet or the connectivity is no more available
5DTG_BUSY_ERRLayer is busy, request is ignored
7DTG_NO_SOCKET_ERRNo socket available or socket is not allocated
3DTG_BUFFER_ERRProvided buffer size is bigger than supported
6DTG_NO_BIND_ERRBind has not been called and IP headers are requested
9DTG_TOO_BIG_ERRData is too large to be sent without fragmentation
10DTG_L2_ERRError from L2 layer
14DTG_CD_ERRORC/D layer error
21DTG_TPL_PARAMS_ERRTemplate parameters are not fully configured

Reception of Data from a Remote Application

WhatDetail
Command
Parameters
Result codes+RECVOK,<socket_id>:<binary_data>

Received data is an ASCII string containing an hexadecimal value.

Close a Datagram Socket

WhatDetail
CommandAT+SCHC=CLOSE,<socket_id>
Parameter<socket_id> - The socket ID
Result codesOK
 AT_ERROR,2,<status>

Error Messages

AT_ERROR,2,<status> reports a datagram layer error with the following possible values:

Numeric valueError codeComment
2DTG_CONN_ERRNot joined yet
7DTG_NO_SOCKET_ERRNo socket available or the socket is not allocated