EC20功耗测试示例

本示例支持LINUX和OPEN-LINUX开发环境,将对讲中使用的数据通信做了抽象,意在能够尽可能的简化测试EC20模块上的功耗,以及网络延迟问题

1 功能说明

1.1 心跳维持

  • UDP心跳:默认10s
    #define TEST_UDP_TIMER 10.0 //UDP Ping Timer
    对讲终端2/3G制式时此值为3s, UDP端口有时效,无限增大此值,不同网络制式下一定会出现丢包。
    但是太小就会引起功耗上升。

  • TCP心跳:默认60s
    #define TEST_TCP_TIMER 60.0 //TCP Ping Timer
    对将默认为60秒,TCP作为保持链路使用,此值不是影响终端功耗上升的关键点。

1.2 业务流程

  • 开始讲话 「模拟终端A」
    static void start_speak(poc_context* poc_ctx);
    发送讲话请求消息,回应:
    static void on_request_mic_ack(poc_context* poc_ctx, char* msg);
    请求成功后,就开始发送语音数据:
    //start send udp data timer
    ev_timer_set(&(poc_ctx->timer_udp_data),TEST_UDP_DATA_TIMER,0);
    ev_timer_start(poc_ctx->loop,&(poc_ctx->timer_udp_data));
  • 停止讲话「模拟终端A」
    static void stop_speak(poc_context* poc_ctx);
    发送停止请求消息,回应:
    static void on_drop_mic_ack(poc_context* poc_ctx, char* msg);
    请求成功后,就会停止发送语音数据:
    ev_timer_stop(poc_ctx->loop,&(poc_ctx->timer_udp_data));

  • 发送语音「模拟终端A」
    开始发送语音数据,每200ms发送一包udp_data:
    send_udp_data(poc_ctx);

  • 有人开始讲话「模拟终端B」
    收到有人开始讲话通知:
    static void on_member_get_mic(poc_context* poc_ctx, char* msg);

  • 有人停止讲话「模拟终端B」
    收到有人停止讲话通知:
    static void on_member_drop_mic(poc_context* poc_ctx, char* msg);

  • 收到语音数据 「模拟终端B」
    收到语音数据:
    static void on_data(poc_context* poc_ctx, char* msg);

2 测试及统计

2.1 编译

终端使用cmake来管理的源码,需要安装cmake。
安装完后,配置系统根目录的路径, 修改./depends/arm-oe-linux-gnueabi.toolchain.sh:

set(OPENLINUX_TOOLCHAIN_DIR /opt/ql-oe/sysroots/x86_64-linux/usr/bin/arm-oe-linux-gnueabi)
set(OPENLINUX_ROOT_DIR /opt/ql-oe/sysroots/mdm9607)

对于EC20编译执行make-arm-oe.sh
对于LINUX编译执行make-linux.sh
无错误的话会生成poc_client应用(linux在build目录,openlinux在bb目录)

2.2 程序部署

  • 部署pocecho.py
    需要linux+python环境,并且服务器有外网IP,UDP/TCP各一个可用端口
    运行python pocecho.py start|stop|restart

  • PUSH终端应用
    连接EC20到PC,adb push poc_client /data/
    可以使用的组合:
    A(PC-LINUX) + B(EC20):A发送,B接收,统计B输出的数据
    A(EC20)+ B(EC20):统计接收端输出的数据

注:程序中用到了对时功能,需要root权限修改本地时间才会生效(PC-LINUX情况)

  • 修改服务器IP和端口
    poc_def.h中HAL_OPENLINUX表示为OPENLINUX(EC20):
//SERVER ADDRESS
#ifndef HAL_OPENLINUX
#define TEST_SERVER_IP "192.168.40.103"
#define TEST_SERVER_UDP_PORT 10071
#define TEST_SERVER_TCP_PORT 10073
#else
#define TEST_SERVER_IP "119.254.102.206"
#define TEST_SERVER_UDP_PORT 10075
#define TEST_SERVER_TCP_PORT 10078
#endif

2.3 数据统计:

条件:

  • UDP网络制式:电信/移动/联通,2G/3G/4G
  • 心跳间隔:3/5/8/10 秒等
  • POC对将消息

数据:

  • 待机情况下耗流(区分不同运营商及网络制式)

  • 收发数据情况下耗流
    待机情况,休眠情况

  • 开始/停止讲话时间

  • 收到有人开始讲话/停止讲话的通知时间(MODEM收到数据的时间)
    待机情况,休眠情况,关心的是服务端推送数据到达的延迟有多少

  • 收到第一包别人语音数据的时间(MODEM收到数据的时间)
    待机情况,休眠情况,关心的是服务端推送数据到达的延迟有多少

  • 待机进入休眠的时长

2.4 日志输出解释

poc_def.h定义了协议的标识,如下:

//PROTO
#define POC_REQUEST_MIC     "#RequestMic"   //#RequestMic:N:DUMP
#define POC_REQUEST_MIC_ACK "#RequestMicAck"

#define POC_DROP_MIC        "#DropMic"      //#DropMic:N:DUMP
#define POC_DROP_MIC_ACK    "#DropMicAck"

#define POC_MEMBER_GET_MIC  "#MemberGetMic" //#MemberGetMic:N:DUMP
#define POC_MEMBER_DROP_MIC "#MemberDropMic"

#define POC_LOST_MIC        "#LostMic"

#define POC_PING            "#Ping"         //#Ping:UDP:N:DUMP  #Ping:TCP:N:DUMP
#define POC_PONG            "#Pong"         //#Pong:UDP:N:DUMP  #Pong:TCP:N:DUMP

#define POC_DATA            "#Data"         //#Data:N:DUMP
#define POC_END             "#End"          //#End

#define POC_NTP             "#NTP"          //#NTP:t_request:t_request_recv:t_respone:t_response_recv

输出的日志:

/data # ./poc_client
[DEBUG] 2017-07-24 06:26:45.735 poc_ctx init event bindings sizeof(int):4
[DEBUG] 2017-07-24 06:26:45.742 poc_ctx initial mobile ap ...
[DEBUG] 2017-07-24 06:26:48.796 poc_ctx < retrived ip address:10.131.20.122 >
[DEBUG] 2017-07-24 06:26:49.027 poc_ctx connect to server success
[DEBUG] 2017-07-24 06:26:49.405 poc_ctx on_ntp msg:#NTP:1934022994:1500877591508:1500877591508:1934023101
[DEBUG] 2017-07-24 14:26:32.065 poc_ctx on_udp_readable buf:#Pong:UDP:0002:The quick brown fox jumps over the lazy dog. len:60
[DEBUG] 2017-07-24 14:26:43.181 poc_ctx on_udp_readable buf:#Pong:UDP:0003:The quick brown fox jumps over the lazy dog. len:60
[DEBUG] 2017-07-24 14:26:53.736 poc_ctx on_udp_readable buf:#Pong:UDP:0004:The quick brown fox jumps over the lazy dog. len:60
[DEBUG] 2017-07-24 14:27:03.621 poc_ctx on_udp_readable buf:#Pong:UDP:0005:The quick brown fox jumps over the lazy dog. len:60
[DEBUG] 2017-07-24 14:27:13.318 poc_ctx on_udp_readable buf:#Pong:UDP:0006:The quick brown fox jumps over the lazy dog. len:60
[DEBUG] 2017-07-24 14:27:23.281 poc_ctx on_data msg:#Data:0001:2017-07-24 14:27:20.332 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.283 poc_ctx on_tcp_readable msg:#MemberGetMic:0000:2017-07-24 14:27:20.107 len:43
[DEBUG] 2017-07-24 14:27:23.284 poc_ctx on_member_get_mic msg:#MemberGetMic:0000:2017-07-24 14:27:20.107
[DEBUG] 2017-07-24 14:27:23.284 poc_ctx on_data msg:#Data:0002:2017-07-24 14:27:20.533 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.284 poc_ctx on_data msg:#Data:0003:2017-07-24 14:27:20.733 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.285 poc_ctx on_data msg:#Data:0004:2017-07-24 14:27:20.934 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.285 poc_ctx on_data msg:#Data:0005:2017-07-24 14:27:21.134 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.285 poc_ctx on_data msg:#Data:0006:2017-07-24 14:27:21.334 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.285 poc_ctx on_data msg:#Data:0007:2017-07-24 14:27:21.535 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.286 poc_ctx on_data msg:#Data:0008:2017-07-24 14:27:21.735 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.287 poc_ctx on_data msg:#Data:0009:2017-07-24 14:27:21.936 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.288 poc_ctx on_data msg:#Data:0010:2017-07-24 14:27:22.136 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.292 poc_ctx on_data msg:#Data:0011:2017-07-24 14:27:22.336 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.292 poc_ctx on_data msg:#Data:0012:2017-07-24 14:27:22.537 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.292 poc_ctx on_data msg:#Data:0013:2017-07-24 14:27:22.737 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.293 poc_ctx on_data msg:#Data:0014:2017-07-24 14:27:22.938 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.382 poc_ctx on_udp_readable buf:#Pong:UDP:0007:The quick brown fox jumps over the lazy dog. len:60
[DEBUG] 2017-07-24 14:27:23.428 poc_ctx on_udp_readable buf:#Pong:UDP:0008:The quick brown fox jumps over the lazy dog. len:60
[DEBUG] 2017-07-24 14:27:23.449 poc_ctx on_data msg:#Data:0015:2017-07-24 14:27:23.138 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.651 poc_ctx on_data msg:#Data:0016:2017-07-24 14:27:23.339 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:23.951 poc_ctx on_data msg:#Data:0017:2017-07-24 14:27:23.540 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:24.051 poc_ctx on_data msg:#Data:0018:2017-07-24 14:27:23.740 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:24.252 poc_ctx on_data msg:#Data:0019:2017-07-24 14:27:23.940 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:24.491 poc_ctx on_data msg:#Data:0020:2017-07-24 14:27:24.141 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:24.652 poc_ctx on_data msg:#Data:0021:2017-07-24 14:27:24.341 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:24.946 poc_ctx on_data msg:#Data:0022:2017-07-24 14:27:24.542 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:25.053 poc_ctx on_data msg:#Data:0023:2017-07-24 14:27:24.742 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:25.253 poc_ctx on_data msg:#Data:0024:2017-07-24 14:27:24.943 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:25.455 poc_ctx on_data msg:#Data:0025:2017-07-24 14:27:25.143 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:25.651 poc_ctx on_data msg:#Data:0026:2017-07-24 14:27:25.344 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:25.855 poc_ctx on_data msg:#Data:0027:2017-07-24 14:27:25.544 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:26.086 poc_ctx on_data msg:#Data:0028:2017-07-24 14:27:25.744 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:26.257 poc_ctx on_data msg:#Data:0029:2017-07-24 14:27:25.945 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:26.455 poc_ctx on_data msg:#Data:0030:2017-07-24 14:27:26.145 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:26.655 poc_ctx on_data msg:#Data:0031:2017-07-24 14:27:26.345 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:26.857 poc_ctx on_data msg:#Data:0032:2017-07-24 14:27:26.546 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:27.058 poc_ctx on_data msg:#Data:0033:2017-07-24 14:27:26.746 The quick brown fox jumps over the lazy dog.
[DEBUG] 2017-07-24 14:27:27.112 poc_ctx on_tcp_readable msg:#MemberDropMic:0001:2017-07-24 14:27:26.803 len:44
[DEBUG] 2017-07-24 14:27:27.112 poc_ctx on_member_drop_mic msg:#MemberDropMic:0001:2017-07-24 14:27:26.803

上面日志有:
#NTP: UDP,服务端相应的#NTP
#Pong: UDP,服务端相应终端的#Ping
#MemberGetMic: TCP,服务器响应另外一个终端的#RequestMic, 推送的通知; 包含了发送端的时间戳
#MemberDropMic: TCP,服务器响应另外一个终端的#DropMic, 推送的通知; 包含了发送端的时间戳
#Data: UDP, 服务器收到另外一个终端的#Data数据,转发过来的; 包含了发送端的时间戳

你可能感兴趣的:(EC20功耗测试示例)