1# SMP over console
2
3This document specifies how the mcumgr Simple Management Procotol (SMP) is
4transmitted over text consoles.
5
6## Overview
7
8Mcumgr packets sent over serial are fragmented into frames of 127 bytes or
9fewer.  This 127-byte maximum applies to the entire frame, including header,
10CRC, and terminating newline.
11
12The initial frame in a packet has the following format:
13
14```
15    offset 0:    0x06 0x09
16    === Begin base64 encoding ===
17    offset 2:    <16-bit packet-length>
18    offset ?:    <body>
19    offset ?:    <crc16> (if final frame)
20    === End base64 encoding ===
21    offset ?:    0x0a (newline)
22```
23
24All subsequent frames have the following format:
25
26```
27    offset 0:    0x04 0x14
28    === Begin base64 encoding ===
29    offset 2:    <body>
30    offset ?:    <crc16> (if final frame)
31    === End base64 encoding ===
32    offset ?:    0x0a (newline)
33```
34
35All integers are represented in big-endian.  The packet fields are described
36below:
37
38| Field | Description |
39| ----- | ----------- |
40| 0x06 0x09 | Byte pair indicating the start of a packet. |
41| 0x04 0x14 | Byte pair indicating the start of a continuation frame. |
42| Packet length | The combined total length of the *unencoded* body plus the final CRC (2 bytes). Length is in Big-Endian format. |
43| Body | The actual SMP data (i.e., 8-byte header and CBOR key-value map). |
44| CRC16 | A CRC16 of the *unencoded* body of the entire packet.  This field is only present in the final frame of a packet. |
45| Newline | A 0x0a byte; terminates a frame. |
46
47The packet is fully received when <packet-length> bytes of body has been
48received.
49
50## CRC details
51
52The CRC16 should be calculated with the following parameters:
53
54| Field         | Value         |
55| ------------- | ------------- |
56| Polynomial    | 0x1021        |
57| Initial Value | 0             |
58