Skip to content

Commit cad23be

Browse files
committed
app: coap, http: Add CRLF after data in auto receive mode
Aligns with the behavior of #XRECVFROM and #XRECV. Signed-off-by: Juha Ylinen <juha.ylinen@nordicsemi.no>
1 parent 5527218 commit cad23be

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

app/src/sm_at_coap.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ static void coap_send_data(struct coap_request *req, const uint8_t *payload, siz
176176
} else {
177177
data_send(req->pipe, payload, payload_len);
178178
}
179+
/* CRLF after the data chunk, consistent with socket auto-receive behaviour. */
180+
rsp_send_to(req->pipe, "\r\n");
179181
}
180182

181183
/* Notify host that a response block is ready to pull in manual receive mode. */

app/src/sm_at_httpc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,8 @@ static void http_send_data(struct http_request *req, const uint8_t *data, int le
511511
} else {
512512
data_send(req->pipe, data, len);
513513
}
514+
/* CRLF after the data chunk, consistent with socket auto-receive behaviour. */
515+
rsp_send_to(req->pipe, "\r\n");
514516
}
515517

516518
/*

doc/app/at_coap.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Unsolicited notification
146146

147147
#XCOAPCDATA: <handle>,<offset>,<length>
148148

149-
The notification line is terminated with ``\r\n`` and the response data follows immediately with no additional separator.
149+
The notification line is terminated with ``\r\n``, the response data follows immediately, and a ``\r\n`` terminator follows the data bytes.
150150
In binary mode (default), the data is ``<length>`` raw bytes.
151151
In hex mode (``<format>=1``), the data is ``2×<length>`` lower-case ASCII hex characters.
152152

@@ -221,6 +221,10 @@ CoAP GET (automatic mode, binary):
221221
AT#XCLOSE=0
222222
OK
223223

224+
.. note::
225+
226+
In automatic mode, a ``\r\n`` terminator is appended after the data bytes of each ``#XCOAPCDATA`` notification.
227+
224228
CoAP GET (automatic mode, hex-encoded response, ``format=1``):
225229

226230
::
@@ -233,6 +237,10 @@ CoAP GET (automatic mode, hex-encoded response, ``format=1``):
233237

234238
#XCOAPCSTAT: 0,69,12
235239

240+
.. note::
241+
242+
The hex string and the line break after it represent the ``2×<length>`` hex characters followed by the ``\r\n`` terminator.
243+
236244
CoAP GET (manual mode):
237245

238246
::

doc/app/at_httpc.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ Unsolicited notification
127127
``#XHTTPCDATA`` is emitted in automatic mode for each received body chunk::
128128

129129
#XHTTPCDATA: <handle>,<offset>,<length>
130+
<data>
130131

131-
The notification line is terminated with ``\r\n``.
132-
In binary mode (``<format>=0``, default), the raw body bytes follow immediately with no additional separator.
133-
In hex mode (``<format>=1``), ``2×<length>`` lower-case ASCII hex characters follow instead of raw bytes.
132+
The notification line is terminated with ``\r\n``, the response data follows immediately, and a ``\r\n`` terminator follows the data bytes.
133+
In binary mode (``<format>=0``, default), the data is ``<length>`` raw bytes.
134+
In hex mode (``<format>=1``), the data is ``2×<length>`` lower-case ASCII hex characters.
134135

135136
* The ``<handle>`` parameter is an integer.
136137
It identifies the socket.
@@ -190,6 +191,10 @@ HTTP GET (automatic mode):
190191

191192
#XHTTPCSTAT: 0,200,261,0
192193

194+
.. note::
195+
196+
In automatic mode, a ``\r\n`` terminator is appended after the data bytes of each ``#XHTTPCDATA`` notification.
197+
193198
HTTP GET (manual mode):
194199

195200
::
@@ -222,6 +227,8 @@ HTTP GET with hex-encoded response body (``format=1``, automatic mode):
222227

223228
#XHTTPCSTAT: 0,200,12,0
224229

230+
The hex string and the line break after it represent the ``2×<length>`` hex characters followed by the ``\r\n`` terminator.
231+
225232
HTTP POST with JSON body and custom header:
226233

227234
::

0 commit comments

Comments
 (0)