Skip to content

Commit 7982d1c

Browse files
Use high-bit convention for hardware response codes
1 parent 49e7516 commit 7982d1c

1 file changed

Lines changed: 32 additions & 25 deletions

File tree

examples/kiss_modem/KissModem.h

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,38 @@
5252
#define HW_CMD_PING 0x17
5353
#define HW_CMD_REBOOT 0x18
5454

55-
#define HW_RESP_IDENTITY 0x21
56-
#define HW_RESP_RANDOM 0x22
57-
#define HW_RESP_VERIFY 0x23
58-
#define HW_RESP_SIGNATURE 0x24
59-
#define HW_RESP_ENCRYPTED 0x25
60-
#define HW_RESP_DECRYPTED 0x26
61-
#define HW_RESP_SHARED_SECRET 0x27
62-
#define HW_RESP_HASH 0x28
63-
#define HW_RESP_OK 0x29
64-
#define HW_RESP_ERROR 0x2A
65-
#define HW_RESP_RADIO 0x2B
66-
#define HW_RESP_TX_POWER 0x2C
67-
#define HW_RESP_CURRENT_RSSI 0x2D
68-
#define HW_RESP_CHANNEL_BUSY 0x2E
69-
#define HW_RESP_AIRTIME 0x2F
70-
#define HW_RESP_NOISE_FLOOR 0x30
71-
#define HW_RESP_VERSION 0x31
72-
#define HW_RESP_STATS 0x32
73-
#define HW_RESP_BATTERY 0x33
74-
#define HW_RESP_MCU_TEMP 0x34
75-
#define HW_RESP_SENSORS 0x35
76-
#define HW_RESP_DEVICE_NAME 0x36
77-
#define HW_RESP_PONG 0x37
78-
#define HW_RESP_TX_DONE 0x38
79-
#define HW_RESP_RX_META 0x39
55+
/* Response code = command code | 0x80. Generic / unsolicited use 0xF0+. */
56+
#define HW_RESP(cmd) ((cmd) | 0x80)
57+
58+
#define HW_RESP_IDENTITY HW_RESP(HW_CMD_GET_IDENTITY) /* 0x81 */
59+
#define HW_RESP_RANDOM HW_RESP(HW_CMD_GET_RANDOM) /* 0x82 */
60+
#define HW_RESP_VERIFY HW_RESP(HW_CMD_VERIFY_SIGNATURE) /* 0x83 */
61+
#define HW_RESP_SIGNATURE HW_RESP(HW_CMD_SIGN_DATA) /* 0x84 */
62+
#define HW_RESP_ENCRYPTED HW_RESP(HW_CMD_ENCRYPT_DATA) /* 0x85 */
63+
#define HW_RESP_DECRYPTED HW_RESP(HW_CMD_DECRYPT_DATA) /* 0x86 */
64+
#define HW_RESP_SHARED_SECRET HW_RESP(HW_CMD_KEY_EXCHANGE) /* 0x87 */
65+
#define HW_RESP_HASH HW_RESP(HW_CMD_HASH) /* 0x88 */
66+
#define HW_RESP_RADIO HW_RESP(HW_CMD_GET_RADIO) /* 0x8B */
67+
#define HW_RESP_TX_POWER HW_RESP(HW_CMD_GET_TX_POWER) /* 0x8C */
68+
#define HW_RESP_CURRENT_RSSI HW_RESP(HW_CMD_GET_CURRENT_RSSI) /* 0x8D */
69+
#define HW_RESP_CHANNEL_BUSY HW_RESP(HW_CMD_IS_CHANNEL_BUSY) /* 0x8E */
70+
#define HW_RESP_AIRTIME HW_RESP(HW_CMD_GET_AIRTIME) /* 0x8F */
71+
#define HW_RESP_NOISE_FLOOR HW_RESP(HW_CMD_GET_NOISE_FLOOR) /* 0x90 */
72+
#define HW_RESP_VERSION HW_RESP(HW_CMD_GET_VERSION) /* 0x91 */
73+
#define HW_RESP_STATS HW_RESP(HW_CMD_GET_STATS) /* 0x92 */
74+
#define HW_RESP_BATTERY HW_RESP(HW_CMD_GET_BATTERY) /* 0x93 */
75+
#define HW_RESP_MCU_TEMP HW_RESP(HW_CMD_GET_MCU_TEMP) /* 0x94 */
76+
#define HW_RESP_SENSORS HW_RESP(HW_CMD_GET_SENSORS) /* 0x95 */
77+
#define HW_RESP_DEVICE_NAME HW_RESP(HW_CMD_GET_DEVICE_NAME) /* 0x96 */
78+
#define HW_RESP_PONG HW_RESP(HW_CMD_PING) /* 0x97 */
79+
80+
/* Generic responses (shared by multiple commands) */
81+
#define HW_RESP_OK 0xF0
82+
#define HW_RESP_ERROR 0xF1
83+
84+
/* Unsolicited notifications (no corresponding request) */
85+
#define HW_RESP_TX_DONE 0xF8
86+
#define HW_RESP_RX_META 0xF9
8087

8188
#define HW_ERR_INVALID_LENGTH 0x01
8289
#define HW_ERR_INVALID_PARAM 0x02

0 commit comments

Comments
 (0)