Combine cmdid and cmdset into cmd code

refactor
PgSocks 2 years ago
parent 6e10db0e07
commit 77000b525f

@ -8,7 +8,7 @@
static const uint8_t CHASSIS_HOST = 3; static const uint8_t CHASSIS_HOST = 3;
static const uint8_t CHASSIS_INDEX = 6; 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 void
set_wheel_speed ( set_wheel_speed (
@ -18,7 +18,7 @@ set_wheel_speed (
int16_t w3, int16_t w3,
int16_t w4 ); int16_t w4 );
static const uint8_t CHASSIS_SPEED_MODE_CMDID = 0x21; static const uint16_t CHASSIS_SPEED_MODE_CMD = 0x213F;
void void
chassis_speed_mode ( chassis_speed_mode (

@ -40,8 +40,13 @@ struct PACKED Header {
}; };
// Each command has a cmdset and cmdid that together make a cmd key // Each command has a cmdset and cmdid that together make a cmd key
uint8_t cmdset; union {
uint8_t cmdid; uint16_t cmd;
struct {
uint8_t cmdset;
uint8_t cmdid;
};
};
}; };

@ -8,7 +8,7 @@
static const uint8_t SDK_HOST = 9; static const uint8_t SDK_HOST = 9;
static const uint8_t SDK_INDEX = 0; 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 { enum CONNECTION {
CONNECTION_WIFI_AP = 0, CONNECTION_WIFI_AP = 0,
@ -23,18 +23,18 @@ set_sdk_connection(
uint32_t ip_address, uint32_t ip_address,
uint16_t port ); uint16_t port );
static const uint8_t SDK_HEARTBEAT_CMDID = 0xD5; static const uint16_t SDK_HEARTBEAT_CMD = 0xD53F;
void void
sdk_heartbeat( sdk_heartbeat(
Client session ); Client session );
static const uint8_t SET_SDK_MODE_CMDID = 0xd1; static const uint16_t SET_SDK_MODE_CMD = 0xD13F;
void void
set_sdk_mode(Client session, bool enable); 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 { enum LEDCOMP {
LEDCOMP_BOTTOM_BACK = 0x1, LEDCOMP_BOTTOM_BACK = 0x1,
@ -67,7 +67,7 @@ void set_system_led (
uint16_t t1, uint16_t t1,
uint16_t t2 ); uint16_t t2 );
static const uint8_t SET_ROBOT_MODE_CMDID = 0x46; static const uint16_t SET_ROBOT_MODE_CMD = 0x463F;
enum MOVEMENTMODE { enum MOVEMENTMODE {
MOVEMENTMODE_FREE, MOVEMENTMODE_FREE,
@ -80,15 +80,13 @@ set_robot_mode (
Client session, Client session,
enum MOVEMENTMODE mode ); enum MOVEMENTMODE mode );
// cmdset 0x48 static const uint16_t SUBNODE_RESET_CMD = 0x0248;
static const uint8_t SUBNODE_RESET_CMDID = 0x02;
void void
subnode_reset ( subnode_reset (
Client session ); Client session );
// cmdset 0x48 static const uint16_t SUBSCRIBE_ADD_NODE_CMD = 0x0148;
static const uint8_t SUBSCRIBE_ADD_NODE_CMDID = 0x01;
void void
subscribe_add_node ( subscribe_add_node (

Loading…
Cancel
Save