/**************************************************************************** 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_CLI_RATTE_TEST_H #define IOT_CLI_RATTE_TEST_H /* os shim includes */ #include "os_types.h" #include "iot_utils_api.h" #ifdef __cplusplus extern "C" { #endif #pragma pack(push) /* save the pack status */ #pragma pack(1) /* 1 byte align */ #define IOT_PLC_RATE_TEST_INTERVAL 100 #define IOT_PLC_RATE_TEST_TICKS_SECOND (1000 / IOT_PLC_RATE_TEST_INTERVAL) #define IOT_PLC_RATE_TEST_INIT 0 #define IOT_PLC_RATE_TEST_SENDER 1 #define IOT_PLC_RATE_TEST_RECVER 2 #define IOT_PLC_RATE_TEST_STOP 3 #define IOT_PLC_RATE_TEST_IN_TEST 4 #define IOT_PLC_RATE_TEST_HEADER_SIZE 100 #define IOT_PLC_RATE_TEST_DEFAULT_MSDU_SIZE 520 #define IOT_PLC_RATE_TEST_DEFAULT_DURATION 10000 #define IOT_PLC_RATE_TEST_MAX_TICKS 50 #define IOT_PLC_RATE_TEST_RESULT_TICKS 20 #define IOT_PLC_RATE_TEST_STOP_TICKS 10 typedef struct _iot_plc_host_rate_test_t { /* if down link rate test */ uint8_t downlink; /* rate test state */ uint8_t rate_test_state; /* recv packets num */ uint16_t msdu_size; /* rate test send rate */ uint16_t send_rate; /* rate test duration */ uint16_t test_duration; /* recv packets */ uint32_t recv_packets; /* rate test id */ uint32_t test_id; /* timer for retry sending */ timer_id_t rate_test_timer; /* send packet index */ uint32_t send_packet_idx; /* packets per second */ uint16_t pakcets_per_second; /* ticks count */ uint16_t ticks_count; /* dst for rate test */ uint8_t dst[6]; uint8_t rate_test_result; /*define which device launch the rate test*/ uint8_t launch_mac[6]; } iot_plc_host_rate_test_t; /** rate test param */ typedef struct _cli_host_rate_test_param { uint32_t test_id; /** if downlink test */ uint8_t downlink; /** msdu size */ uint16_t msdu_size; /** send rate */ uint16_t send_rate; /** test duration */ uint16_t test_duration; /** test dst addr */ uint8_t dst[6]; } cli_host_rate_test_param; /** rate test start ack */ typedef struct _cli_host_rate_test_param_ack { /** if downlink test */ uint8_t downlink; } cli_host_rate_test_param_ack; /** rate test stop */ typedef struct _cli_host_rate_test_stop { /** if downlink test */ uint8_t downlink; } cli_host_rate_test_stop; /** rate test stop ack */ typedef struct _cli_host_rate_test_stop_ack { /** if downlink test */ uint8_t downlink; } cli_host_rate_test_stop_ack; /** rate test packet */ typedef struct _cli_host_test_rate_packet { /** test id */ uint32_t test_id; /** packet id */ uint32_t packet_idx; /** test duration */ uint16_t test_duration; } cli_host_test_rate_packet; /** test rate result */ typedef struct _cli_host_test_rate_result { uint32_t test_id; /** result rate */ uint32_t recv_pkts; /** if downlink test */ uint8_t downlink; /** test dst addr */ uint8_t dst[6]; } cli_host_test_rate_result; void cli_recv_rate_test_packet( uint8_t *buffer, uint32_t bufferlen, uint8_t *src_mac); void cli_recv_rate_test_result( uint8_t *buffer, uint32_t bufferlen, uint8_t *src_mac); void cli_rate_test_start(uint8_t *buffer, uint32_t bufferlen, uint8_t *src_mac); void cli_rate_test_stop(uint8_t *buffer, uint32_t bufferlen, uint8_t *src_mac); void cli_rate_test_stop_ack(uint8_t *buffer, uint32_t bufferlen); void iot_cli_rate_test_handle_timer_msg(); void iot_cli_rate_test_init(); void iot_cli_rate_test_deinit(); #pragma pack(pop) /* restore the pack status */ #ifdef __cplusplus } #endif #endif