78 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			78 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| 
								 | 
							
								/****************************************************************************
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
							 | 
						||
| 
								 | 
							
								be copied by any method or incorporated into another program without
							 | 
						||
| 
								 | 
							
								the express written consent of Aerospace C.Power. This Information or any portion
							 | 
						||
| 
								 | 
							
								thereof remains the property of Aerospace C.Power. The Information contained herein
							 | 
						||
| 
								 | 
							
								is believed to be accurate and Aerospace C.Power assumes no responsibility or
							 | 
						||
| 
								 | 
							
								liability for its use in any way and conveys no license or title under
							 | 
						||
| 
								 | 
							
								any patent or copyright and makes no representation or warranty that this
							 | 
						||
| 
								 | 
							
								Information is free from patent or copyright infringement.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								****************************************************************************/
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifndef _IOT_SMART_METER_H_
							 | 
						||
| 
								 | 
							
								#define _IOT_SMART_METER_H_
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "iot_task_api.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								extern "C" {
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define IOT_SMART_METER_DEBUG            0
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* define priorities for message to be handle */
							 | 
						||
| 
								 | 
							
								#define IOT_SMART_METER_TASK_QUEUE_HP                 0
							 | 
						||
| 
								 | 
							
								#define IOT_SMART_METER_PROTO_TASK_QUEUE_LP           1
							 | 
						||
| 
								 | 
							
								#define IOT_SMART_METER_PROTO_TASK_QUEUE_MAX_PRIO     2
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/** Message type defination: */
							 | 
						||
| 
								 | 
							
								#define IOT_SMART_METER_MT_UART          1 /** message from uart. */
							 | 
						||
| 
								 | 
							
								#define IOT_SMART_METER_MT_SG            2 /** message from sg-app. */
							 | 
						||
| 
								 | 
							
								#define IOT_SMART_METER_MT_WL            3 /** message from wrieless device. */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/** uart data process handle */
							 | 
						||
| 
								 | 
							
								typedef void (*iot_smart_meter_uart_data_handle)(
							 | 
						||
| 
								 | 
							
								    iot_pkt_t *p_pkt, uint32_t arg);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/** smart meter message */
							 | 
						||
| 
								 | 
							
								typedef struct _iot_smart_meter_msg {
							 | 
						||
| 
								 | 
							
								    /* iot task message */
							 | 
						||
| 
								 | 
							
								    iot_task_msg_t  task_msg;
							 | 
						||
| 
								 | 
							
								    /* pointer to message data */
							 | 
						||
| 
								 | 
							
								    void            *data;
							 | 
						||
| 
								 | 
							
								    /* another data field */
							 | 
						||
| 
								 | 
							
								    uint32_t        data2;
							 | 
						||
| 
								 | 
							
								} iot_smart_meter_msg_t;
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_smart_meter_uart_send() - Send data to uart port.
							 | 
						||
| 
								 | 
							
								 * @param p_pkt: packet for sending to uart port.
							 | 
						||
| 
								 | 
							
								 * @return: ERR_OK - send successfully.
							 | 
						||
| 
								 | 
							
								 *   ERR_FAIL - send failed.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint32_t iot_smart_meter_uart_send(iot_pkt_t *p_pkt);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 * @brief iot_smart_meter_ipc_send() - Send message to sg-app.
							 | 
						||
| 
								 | 
							
								 * @param p_pkt: packet for sending to sg-app.
							 | 
						||
| 
								 | 
							
								 * @param arg: argument for sending to sg-app.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								void iot_smart_meter_ipc_send(iot_pkt_t *p_pkt, uint32_t arg);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* @brief iot_smart_meter_get_mac_addr() - get mac addr of smart meter device.
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 * @return: return the meter's mac addr.
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								uint8_t *iot_smart_meter_get_mac_addr(void);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif /* _IOT_SMART_METER_H_ */
							 |