From 77000b525f992774d3b9a60933189f7437d3810b Mon Sep 17 00:00:00 2001 From: PgSocks Date: Mon, 13 Feb 2023 16:23:23 -0600 Subject: [PATCH] Combine cmdid and cmdset into cmd code --- include/chassis.h | 4 ++-- include/message.h | 9 +++++++-- include/sdk.h | 16 +++++++--------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/chassis.h b/include/chassis.h index ca790d8..cd7687d 100644 --- a/include/chassis.h +++ b/include/chassis.h @@ -8,7 +8,7 @@ static const uint8_t CHASSIS_HOST = 3; static const uint8_t CHASSIS_INDEX = 6; -static const uint8_t SET_WHEEL_SPEED_CMDID = 0x20; +static const uint16_t SET_WHEEL_SPEED_CMD = 0x203F; void set_wheel_speed ( @@ -18,7 +18,7 @@ set_wheel_speed ( int16_t w3, int16_t w4 ); -static const uint8_t CHASSIS_SPEED_MODE_CMDID = 0x21; +static const uint16_t CHASSIS_SPEED_MODE_CMD = 0x213F; void chassis_speed_mode ( diff --git a/include/message.h b/include/message.h index 09d5c6e..615dfae 100644 --- a/include/message.h +++ b/include/message.h @@ -40,8 +40,13 @@ struct PACKED Header { }; // Each command has a cmdset and cmdid that together make a cmd key - uint8_t cmdset; - uint8_t cmdid; + union { + uint16_t cmd; + struct { + uint8_t cmdset; + uint8_t cmdid; + }; + }; }; diff --git a/include/sdk.h b/include/sdk.h index 4991037..d7db7f0 100644 --- a/include/sdk.h +++ b/include/sdk.h @@ -8,7 +8,7 @@ static const uint8_t SDK_HOST = 9; static const uint8_t SDK_INDEX = 0; -static const uint8_t SET_SDK_CONNECTION_CMDID = 0xD4; +static const uint16_t SET_SDK_CONNECTION_CMD = 0xD43F; enum CONNECTION { CONNECTION_WIFI_AP = 0, @@ -23,18 +23,18 @@ set_sdk_connection( uint32_t ip_address, uint16_t port ); -static const uint8_t SDK_HEARTBEAT_CMDID = 0xD5; +static const uint16_t SDK_HEARTBEAT_CMD = 0xD53F; void sdk_heartbeat( Client session ); -static const uint8_t SET_SDK_MODE_CMDID = 0xd1; +static const uint16_t SET_SDK_MODE_CMD = 0xD13F; void set_sdk_mode(Client session, bool enable); -static const uint8_t SET_SYSTEM_LED_CMDID = 0x33; +static const uint16_t SET_SYSTEM_LED_CMD = 0x333F; enum LEDCOMP { LEDCOMP_BOTTOM_BACK = 0x1, @@ -67,7 +67,7 @@ void set_system_led ( uint16_t t1, uint16_t t2 ); -static const uint8_t SET_ROBOT_MODE_CMDID = 0x46; +static const uint16_t SET_ROBOT_MODE_CMD = 0x463F; enum MOVEMENTMODE { MOVEMENTMODE_FREE, @@ -80,15 +80,13 @@ set_robot_mode ( Client session, enum MOVEMENTMODE mode ); -// cmdset 0x48 -static const uint8_t SUBNODE_RESET_CMDID = 0x02; +static const uint16_t SUBNODE_RESET_CMD = 0x0248; void subnode_reset ( Client session ); -// cmdset 0x48 -static const uint8_t SUBSCRIBE_ADD_NODE_CMDID = 0x01; +static const uint16_t SUBSCRIBE_ADD_NODE_CMD = 0x0148; void subscribe_add_node (