zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.92k stars 6.65k forks source link

doc: Documentation issue in 'services/device_mgmt/smp_protocol' #81727

Open mscharrer-ask opened 23 hours ago

mscharrer-ask commented 23 hours ago

Describe the bug

The byte offsets of the SMP header are displayed in an confusing way which strikes me as incorrect. The first row of the header table "3, 2, 1, 0" should be in the opposite order "0, 1, 2, 3".

According to the description further below and the actual implementation of struct smp_hdr the first byte (#0) contains Res, Version and OP, but the table shows that as byte #3 in the first row / table header. Flags is the second byte (#1) but shown as the third (#2), etc.

The fix would be to swap the order of the first row. Also the description table could also include byte offsets for clarity.

+---------------+-------------------+---------------------+--------------------------+----------------------------------------------------+
| **Byte Offset** | **Field**        | **Type**            | **Bit-Field Size**       | **Description**                                      |
+===============+===================+=====================+==========================+====================================================+
| 0             | `_res1`           | `uint8_t`           | 3 bits                   | Reserved field, not currently used.                |
+---------------+-------------------+---------------------+--------------------------+----------------------------------------------------+
| 0             | `nh_version`      | `uint8_t`           | 2 bits                   | Protocol version (e.g., version number).           |
+---------------+-------------------+---------------------+--------------------------+----------------------------------------------------+
| 0             | `nh_op`           | `uint8_t`           | 3 bits                   | Operation code (e.g., MGMT_OP_[...]).              |
+---------------+-------------------+---------------------+--------------------------+----------------------------------------------------+
| 1             | `nh_flags`        | `uint8_t`           | Full byte                | Reserved for future flags.                         |
+---------------+-------------------+---------------------+--------------------------+----------------------------------------------------+
| 2             | `nh_len`          | `uint16_t`          | Full size                | Length of the payload.                             |
+---------------+-------------------+---------------------+--------------------------+----------------------------------------------------+
| 4             | `nh_group`        | `uint16_t`          | Full size                | Group ID (e.g., MGMT_GROUP_ID_[...]).              |
+---------------+-------------------+---------------------+--------------------------+----------------------------------------------------+
| 6             | `nh_seq`          | `uint8_t`           | Full byte                | Sequence number for tracking requests.             |
+---------------+-------------------+---------------------+--------------------------+----------------------------------------------------+
| 7             | `nh_id`           | `uint8_t`           | Full byte                | Message ID within the group.                       |
+---------------+-------------------+---------------------+--------------------------+----------------------------------------------------+

Environment

github-actions[bot] commented 23 hours ago

Hi @mscharrer-ask! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙