6 changed files with 203 additions and 114 deletions
-
6errorcode.c
-
11errorcode.h
-
95protocol.h
-
3protocol.hpp
@ -0,0 +1,95 @@ |
|||||
|
#pragma once |
||||
|
#include <stdint.h> |
||||
|
|
||||
|
#include "errorcode.h" |
||||
|
|
||||
|
#ifdef __cplusplus |
||||
|
extern "C" { |
||||
|
#endif |
||||
|
|
||||
|
#define HAND_ACID_BLE_BASE_SIZE 3 |
||||
|
typedef enum { |
||||
|
kproto_cmd = 1, |
||||
|
kproto_cmd_receipt = 2, |
||||
|
kproto_report = 3, |
||||
|
kproto_error_receipt = 4, |
||||
|
} hand_acid_ble_proto_packet_type_t; |
||||
|
|
||||
|
typedef enum { |
||||
|
kproto_cmd_set_state = 1, // set_state |
||||
|
kproto_cmd_reset = 2, // |
||||
|
kproto_cmd_setlong_key_delayms = 3, // |
||||
|
|
||||
|
kproto_cmd_ble_master_start_scan = 50, // process by ble master ble_master_start_scan |
||||
|
kproto_cmd_ble_master_enter_dfu = 51, // process by ble master ble_master_enter_dfu |
||||
|
kproto_cmd_ble_master_reset = 52, // process by ble master |
||||
|
|
||||
|
kproto_report_key_event = 101, // key_event |
||||
|
kproto_report_connected_event = 102, // generater by ble master and slave |
||||
|
kproto_report_heart = 104, // |
||||
|
} hand_acid_ble_proto_cmd_t; |
||||
|
|
||||
|
typedef enum { |
||||
|
khand_acid_m_unset_mode = 0, // unset_mode |
||||
|
khand_acid_m_jog_mode = 1, // jog_mode |
||||
|
khand_acid_m_continuous_mode = 2, // continuous_mode |
||||
|
} hand_acid_mode_t; |
||||
|
|
||||
|
typedef enum { |
||||
|
khand_acid_pump_is_idle = 0, // |
||||
|
khand_acid_pump_is_working = 1, // |
||||
|
} hand_pump_working_state_t; |
||||
|
|
||||
|
typedef enum { |
||||
|
kkey_short_press_event = 0, // |
||||
|
kkey_long_press_event = 1, // |
||||
|
} key_event_t; |
||||
|
|
||||
|
typedef enum { |
||||
|
kkey_id_mode_and_action_butt, |
||||
|
kkey_id_liquid_reflux_butt, |
||||
|
} key_id_t; |
||||
|
|
||||
|
#pragma pack(1) |
||||
|
typedef struct { |
||||
|
uint8_t frame_type; |
||||
|
uint8_t frame_index; |
||||
|
uint8_t cmd; |
||||
|
union { |
||||
|
struct { |
||||
|
uint8_t hand_acid_mode; // hand_acid_mode_t |
||||
|
uint8_t hand_pump_working_state; // hand_pump_working_state_t |
||||
|
} set_state; |
||||
|
// |
||||
|
struct { |
||||
|
uint8_t scanid[20]; // scan id |
||||
|
} ble_master_start_scan; |
||||
|
|
||||
|
struct { |
||||
|
uint8_t keyid; // key_id_t |
||||
|
uint8_t keyevent; // key_event_t |
||||
|
} key_event; |
||||
|
|
||||
|
struct { |
||||
|
uint8_t connected; |
||||
|
uint8_t from_ble_master; |
||||
|
} connected_event; |
||||
|
|
||||
|
struct { |
||||
|
uint8_t powerlevel; |
||||
|
} heart; |
||||
|
|
||||
|
struct { |
||||
|
uint32_t longkeydelay; |
||||
|
} setlong_key_delayms; |
||||
|
|
||||
|
struct { |
||||
|
int32_t ecode; |
||||
|
} errreceipt; |
||||
|
} data; |
||||
|
} hand_acid_ble_proto_t; |
||||
|
#pragma pack() |
||||
|
|
||||
|
#ifdef __cplusplus |
||||
|
} |
||||
|
#endif |
@ -1,3 +0,0 @@ |
|||||
#pragma once
|
|
||||
|
|
||||
#include "errorcode.hpp"
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue