/*
 * at_command.h
 *
 *  Created on: 2019Äê1ÔÂ6ÈÕ
 *      Author: JinXi
 */

#ifndef AT_COMMAND_H_
#define AT_COMMAND_H_

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdbool.h>
#include "myType.h"

#define CMD_BUFFER_SIZE 	256

typedef const char* ptr_const;
typedef char* ptr;
//static ptr parseUartData( ptr src, ptr e );
struct uartCmdProcess_t{
	bool	continual;
	const ptr_const		cmdString;
	void 	(*processer)( ptr s, char len );
	};

typedef struct uartCmdProcess_t uartCmdProcess;


extern void at_command_buf_clean(void);
extern SHORT at_command_process(CHAR* strBuf, USHORT len);
extern bool Uart_frame_over(UCHAR*buf, USHORT len);


typedef struct
{
	SHORT Acc_x;
	SHORT Acc_y;
	SHORT Acc_z;
	SHORT Gro_x;
	SHORT Gro_y;
	SHORT Gro_z;
	SHORT Mag_x;
	SHORT Mag_y;
	SHORT Mag_z;
}Ciss_data_motion_struct;

typedef struct
{
	SHORT temp;
	USHORT humid;
	UINT pressure;
	SHORT noise;
	UINT light;
	USHORT reserve;
}Ciss_data_evr_struct;

typedef struct
{
	UCHAR dev_sn[20];
	USHORT	dev_mod;
	USHORT dev_state;
	DOUBLE  send_tim;
	Ciss_data_motion_struct motion_data;
	Ciss_data_evr_struct evr_data;
}Ciss_data_struct;

typedef enum
{
	STATE_IDLE = 0,
	STATE_CONNECTED,
	STATE_CH_OPEN,
	STATE_SAMPLE,
	STATE_DISCONNECT
};


#endif /* AT_COMMAND_H_ */
