Files
kunlun/app/ping/iot_ping.h
2024-09-28 14:24:04 +08:00

110 lines
3.6 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_PING_H
#define _IOT_PING_H
#include "iot_task_api.h"
#ifdef __cplusplus
extern "C" {
#endif
#define IOT_PING_SET_NID_CNT_LIMIT 20
/* define priorities for message to be handle */
#define IOT_PING_TASK_QUEUE_HP 0
#define IOT_PING_TASK_QUEUE_LP 1
#define IOT_PING_TASK_QUEUE_MAX_PRIO 2
#define IOT_PING_TASK_LIKE_ID 2
#define IOT_PING_TASK_POOL_SIZE 128
/* message type */
#define IOT_PING_MAC_MSG 0
#define IOT_PING_TIMER_MSG 1
/* message id for TIMER_MSG */
#define IOT_TIMER_QUERY_NB_NW 1 /* query neighbour network */
#define IOT_TIMER_QUERY_NID 2 /* query nid */
#define IOT_TIMER_SET_NID 3 /* set nid */
#define IOT_TIMER_QUERY_NW_TOPO 4 /* query network topo */
#define IOT_TIMER_QUERY_DEV_INTO 5 /* query device info */
/* check device state every 3 second before device is ready */
#define IOT_PING_CHECK_DEV_INTERVAL (3*1000)
/* check the topo structure and ping all STA/PCO every 15 seconds */
#define IOT_PING_CHECK_TOPO_INTERVAL (15*1000)
/* STA check if it shall send bcast every 5 seconds */
#define IOT_PING_STA_BCAST_INTERVAL (5*1000)
/* app_ping_entry() - entry point of ping app
* setup ipc and create a task for ping app
* @return:
* ERR_PENDING - if application want to delay the plc network formation.
* otherwise - plc network formation will be started automatically.
*/
uint32_t app_ping_entry();
/* message used in iot_ping_task.
*/
typedef struct _iot_plc_ping_msg {
/* standard iot_task message */
iot_task_msg_t msg;
/* pointer to message data */
void *data;
/* another data field */
uint32_t data2;
}iot_ping_task_msg_t;
typedef struct _iot_ping_task_data {
/* handle of the ping iot_task */
iot_task_h task_handle;
/* ping iot_task configuration */
iot_task_config_t task_cfg;
/* a flag indicating if app registered successfully */
uint8_t app_registered;
/* link id used for sending msdu */
uint8_t link_id;
/* is dev ready */
uint8_t dev_ready;
/* role of local device */
uint8_t dev_role;
/* flag to mark if ipv4 ping started */
uint8_t ipv4_ping_start;
/* flag to mark if ipv6 ping started */
uint8_t ipv6_ping_start;
/* mac address of local device */
uint8_t mac_addr[IOT_MAC_ADDR_LEN];
/* handle of this app */
iot_plc_app_h app_handle;
/* timer to call api periodically */
timer_id_t ping_timer;
/* index of whitelist read in last request*/
uint16_t wl_entry_index;
/* count of setting nid */
uint32_t set_nid_count;
/* nid to be set */
uint32_t nid;
}iot_ping_task_data_t;
#ifdef __cplusplus
}
#endif
#endif //_IOT_PING_H