#ifndef __MESSAGE_HPP__
#define __MESSAGE_HPP__
#include <stdint.h>
#include <time.h>

struct zistream;

#define CHAR_LOCATEDATA_TOF_EXTEND 0x843b			// TOF实时定位数据，请求、应答
#define CHAR_LOCATEDATAHIS_TOF_EXTEND 0x853b		// TOF历史定位数据，请求、应答
#define CHAR_LOCATEDATA_TDOA_EXTEND 0x863b			// TDOA实时定位数据，请求、应答
#define CHAR_LOCATEDATAHIS_TDOA_EXTEND 0x873b		// TDOA历史定位数据，请求、应答
#define CHAR_TDOA_READER_SYNC_TIME 0xa78d			// TDOA分站时间同步
#define CHAR_ADHOC	0x803b							// 上传自组网数据
#define CHAR_CTRL_READER_CMD 0x804c					// 向分站发送控制指令，控制分站向上位机发送数据

//	分站传上来的卡定位数据,包括tof,tdoa
struct message_locinfo
{
	uint64_t m_time_stamp;
	uint32_t m_site_id;
	time_t   m_site_time;

	uint32_t m_card_type;
	uint32_t m_card_id;
	uint64_t m_tof;
	uint16_t m_card_ct;
	uint8_t  m_batty_status;
	uint8_t  m_callinfo;//0x80-呼救，0x01-一般呼叫，0x02-紧急呼叫
	uint8_t  m_rav;
	uint8_t  m_acc;
	uint8_t  m_ant_id;
	uint16_t m_sync_ct;
	uint16_t m_rssi;

	void zero_this();
    void load(zistream&is,bool tdoa);

	int64_t long_id()const 
	{
		return (((int64_t)m_card_type)<<32)|m_card_id;
	}
};

//tdoa分站同步数据
struct message_tdoasync
{
	uint32_t m_local_site_id;
	uint32_t m_parent_site_id;
	uint16_t m_local_ant_id;
	uint16_t m_parent_ant_id;
	uint16_t m_sync_ct;
	uint16_t m_local_level;
	uint64_t m_recv_time;
	uint64_t m_send_time;

	void zero_this();
    void load(zistream&is);
};

#endif


