You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.0 KiB
74 lines
2.0 KiB
#pragma once
|
|
#include <stdint.h>
|
|
|
|
#include "zaf_ecode.h"
|
|
#include "zaf_port.h"
|
|
#include "zaf_regs.hpp"
|
|
|
|
#pragma pack(1)
|
|
|
|
/*******************************************************************************
|
|
* 繫痰寧즈관 *
|
|
*******************************************************************************/
|
|
|
|
#define PACKET_HEADER 0x5A5A
|
|
#define PACKET_TAIL 0xA5A5
|
|
#define PROTOCOL_VERSION 1
|
|
|
|
/**
|
|
*
|
|
* 葵累관롸槨:
|
|
* 관庫(2Byte) 관잚謹(2Byte) Index(2Byte) 寧즈(2Byte) ndata(2byte) data[...] 뵨叫駱(1Byte) 관棺(2Byte)
|
|
*
|
|
*/
|
|
|
|
typedef struct {
|
|
uint16_t packet_header;
|
|
uint16_t packet_type; // zaf_protocol_packet_type_t
|
|
uint16_t index; //
|
|
uint16_t cmd; // zaf_protocol_cmd_t
|
|
uint16_t ndata; //
|
|
uint32_t data[]; // first is always checksum
|
|
} zaf_packet_header_t;
|
|
#pragma pack()
|
|
|
|
/**
|
|
* @brief CMD
|
|
*/
|
|
typedef enum {
|
|
kzaf_cmd_none = 0,
|
|
kzaf_cmd_reg_read = 1,
|
|
kzaf_cmd_reg_write = 2,
|
|
kzaf_cmd_reg_read_regs = 3,
|
|
kzaf_cmd_generator_new_mac = 4,
|
|
kzaf_cmd_factory_reset = 5,
|
|
kzaf_cmd_reboot = 6,
|
|
kzaf_cmd_storage_cfg = 7,
|
|
} zaf_protocol_cmd_t;
|
|
|
|
/**
|
|
* @brief 관잚謹
|
|
*/
|
|
typedef enum {
|
|
kzaf_packet_type_cmd = 0,
|
|
kzaf_packet_type_receipt = 1,
|
|
kzaf_packet_type_report = 2,
|
|
} zaf_protocol_packet_type_t;
|
|
|
|
/*******************************************************************************
|
|
* 撚蛟쭉서철앨 *
|
|
*******************************************************************************/
|
|
typedef enum {
|
|
obtaining_ip_mode_type_static = 0,
|
|
obtaining_ip_mode_type_dhcp = 1,
|
|
} obtaining_ip_mode_t;
|
|
static inline const char* obtaining_ip_mode_to_string(obtaining_ip_mode_t mode) {
|
|
switch (mode) {
|
|
case obtaining_ip_mode_type_static:
|
|
return "static";
|
|
case obtaining_ip_mode_type_dhcp:
|
|
return "dhcp";
|
|
default:
|
|
return "unknown";
|
|
}
|
|
}
|