Android学习——移植tr069程序到Android平台 - 京月飞鸿

时间:2024-03-06 13:42:53

原创作品,转载请注明出处,严禁非法转载。如有错误,请留言!

email:40879506@qq.com

声明:本系列涉及的开源程序代码学习和研究,严禁用于商业目的。 如有任何问题,欢迎和我交流。(企鹅号:408797506)

 淘宝店:https://shop484606081.taobao.com

本篇用到的代码下载路径:http://download.csdn.net/detail/eryunyong/9798889

Github维护:https://github.com/eryunyong/git_android_DataModel

代码结构说明:

core目录是tr069程序的协议栈部分代码编译出来的可执行档案(不开源)。

etc_config目录是cwmp程序执行用到的配置和测试数据。

include和src目录是DataModel数据部分的源码。

dep_packet.rar是依赖包的压缩文件(包括libcurl,libexpat,libuci)。

Makefile和Makefile.build是用于编译DataModel产生设备相关的device.so文件

一. 环境
1.编译环境GNU/Linux Centos6.5操作系统
2.NDK交叉编译工具链arm-linux-androideabi-gcc-4.8 (参考前一篇:Android学习——NDK交叉编译
二. 依赖包的安装

在我提供的csdn的下载路径里,可以看到我已经把相关的依赖程序编译并安装到了tmp目录下。可以直接把需要的动态库so放到安卓环境里。
如果一直看我的CWMP开源代码研究的系列文章,那么这些依赖安装也就很简单了。开源的程序用到的是libcurl, libexpat。libuci的测试程序是我重写了(前文已介绍),移植到安卓平台又出现了新的问题。

三. libuci测试程序

在移植libuci的程序过程出现如下类似错误:

caused by cannot locate symbol "glob" referenced by libuci.so

原因是在Android平台下并没有glob库。所以我在网上找到了glob.c和glob.h文件放在了libuci的源码程序里进行编译。

四. 程序的几处修改

1.cwmp程序运行的配置

由于安卓系统的目录结构和linux不一样,安卓提供给用户空间的操作数据一般放在/system/目录下

[file]
log=/system/etc/config/log1.conf
device=/system/etc/config/device.xml
attr=/system/usr/data/attr.conf
event=/system/usr/data/event1.conf

[cwmp]
retry_count=3
notify_interval=30

[stun]
port=50001
retry_count=3
timeout=2
timewait=30

2.device.so路径变化

在device.xml中定义了设备库存放路径为

 1   ........
 2       </obj>
 3     </obj>
 4   </trf>
 5   
 6   <devlib name="/system/lib/device.so"></devlib>
 7   <cwmpenable name="dev_cwmp_enable"/>
 8   <init name="dev_init"></init>  
 9   <bootstrap name="dev_bootstrap"></bootstrap>  
10 ......

3.Log的文件存储路径

1 [conf]
2 path=/system/usr/data
3 name=cwmp.log
4 enable=1
5 level=7
6 size=500000

程序启动的时候,可以追踪/system/usr/data/cwmp.log文件查看log信息输出。

4.测试数据存储路径变化

在uci.h文件里改变了数据存储的路径,以便于我们进行测试

#define UCI_CONFDIR "/system/usr/config"
#define UCI_BASEDIR "/system/etc/config"
#define UCI_SAVEDIR "/system/tmp/.uci"

同理,在device.so的程序里也要修改对应的路径:

cpeutil.h头文件内容:
#define UCI_ROOT_DEFAULT "/system/etc/config" #define UCI_USER_ROOT "/system/usr/config

5.cwmp程序

 1. 新增了debug调试的模块(可选)

五. 在Android4.4的AVD环境里测试

1.准备好动态库

把编译好的动态库libcurl.so, libexpat.so, libuci.so,device.so拷贝到安卓系统的/system/lib目录下。所有代码开源!!!

2.准备好CWMP程序

把已经编译好的cwmp协议栈的核心程序放置到安卓系统的/system/bin目录下,并赋予可执行权限。cwmp程序代码不开源,仅提供可执行档案!

3.准备好配置文件和测试数据部分

把源码包里面的etc_config目录下的文件全部拷贝到安卓系统的/system/etc/config/目录下(如果不存在就创建相应的目录)。并创建相应的配置或者数据存储的目录,比如/system/usr/data,/system/usr/config/

4.运行程序

执行命令:cwmp -F /system/etc/config/cwmp.conf

可以看到程序在Android4.4的模拟机上运行结果如下:

5.查看log

  1 2017-03-30 03:17:30.682 [INFO] [CWMP] [cwmp.c:cwmp_proc()] [0241] cwmp version 1.0.0
  2 2017-03-30 03:17:30.691 [DBUG] [Device] [device.c:init_cpe()] [1071] filename=/system/etc/config/device.xml
  3 2017-03-30 03:17:30.715 [DBUG] [Device] [device.c:parse_buf()] [0344] parse_buf end
  4 2017-03-30 03:17:30.716 [DBUG] [Device] [device.c:init_dev_func()] [0370] device library=/system/lib/device.so
  5 2017-03-30 03:17:30.739 [DBUG] [Device] [device.c:init_dev_func()] [0387] wanparamname_func=dev_get_wanparam_name
  6 2017-03-30 03:17:30.740 [DBUG] [Device] [device.c:init_dev_func()] [0399] bootstrap_func=dev_bootstrap
  7 2017-03-30 03:17:30.748 [DBUG] [Device] [device.c:init_dev_func()] [0448] init_func=dev_init
  8 2017-03-30 03:17:30.821 [DBUG] [Device] [device.c:init_dev_func()] [0469] reboot_func=dev_reboot
  9 2017-03-30 03:17:30.821 [DBUG] [Device] [device.c:init_dev_func()] [0486] factoryreset_func=dev_factoryreset
 10 2017-03-30 03:17:30.821 [DBUG] [Device] [device.c:init_dev_func()] [0503] download_func=dev_download
 11 2017-03-30 03:17:30.822 [DBUG] [Device] [device.c:init_dev_func()] [0520] upload_func=dev_upload
 12 2017-03-30 03:17:30.822 [DBUG] [Device] [device.c:init_dev_func()] [0556] debug_func=dev_debug
 13 2017-03-30 03:17:30.822 [DBUG] [Device] [device.c:init_dev_func()] [0573] cwmpeanble_func=dev_cwmp_enable
 14 2017-03-30 03:17:30.822 [DBUG] [Device] [device.c:init_dev_func()] [0590] dyninform func=dev_dyninform
 15 2017-03-30 03:17:30.822 [DBUG] [Device] [device.c:init_dev_func()] [0607] auth_func=dev_get_auth
 16 2017-03-30 03:17:30.823 [DBUG] [Device] [device.c:init_dev_func()] [0624] listenport_func=dev_get_listenport
 17 2017-03-30 03:17:30.825 [INFO] [EB-MIG] [low_level_func.c:dev_get_listenport()] [0668] get devlistenport
 18 2017-03-30 03:17:30.826 [DBUG] [Device] [device.c:init_dev_func()] [0647] port=25100
 19 2017-03-30 03:17:30.827 [DBUG] [Device] [device.c:init_dev_func()] [0654] func_set_acs_status=dev_set_acs_status
 20 2017-03-30 03:17:30.827 [DBUG] [Device] [device.c:init_dev_func()] [0671] func_set_cwmp_status=dev_set_cwmp_status
 21 2017-03-30 03:17:30.827 [DBUG] [Device] [device.c:init_dev_func()] [0688] func_url_dns_resolve=dev_url_dns_resolve
 22 2017-03-30 03:17:30.827 [DBUG] [Device] [device.c:init_dev_func()] [0719] init_dev_func end
 23 2017-03-30 03:17:30.828 [DBUG] [Device] [device.c:get_full_param_name()] [1175] fullname=InternetGatewayDevice.ObjTest
 24 2017-03-30 03:17:30.828 [DBUG] [Device] [device.c:init_multi_obj()] [0743] init_multi_obj refresh params=InternetGatewayDevice.ObjTest
 25 2017-03-30 03:17:30.835 [DBUG] [Device] [device.c:get_full_param_name()] [1175] fullname=InternetGatewayDevice.WANDevice
 26 2017-03-30 03:17:30.835 [DBUG] [Device] [device.c:init_multi_obj()] [0743] init_multi_obj refresh params=InternetGatewayDevice.WANDevice
 27 2017-03-30 03:17:30.836 [DBUG] [EB-MIG] [WANDevice.c:CpeRefreshWANDevice()] [0042] TRF_Refresh_WANDevice begin
 28 2017-03-30 03:17:30.853 [DBUG] [EB-MIG] [WANDevice.c:CpeRefreshWANDevice()] [0060] TRF_Refresh_WANDevice end
 29 2017-03-30 03:17:30.853 [DBUG] [Device] [device.c:get_full_param_name()] [1175] fullname=InternetGatewayDevice.WANDevice.0.WANConnectionDevice
 30 2017-03-30 03:17:30.853 [DBUG] [Device] [device.c:init_multi_obj()] [0743] init_multi_obj refresh params=InternetGatewayDevice.WANDevice.0.WANConnectionDevice
 31 2017-03-30 03:17:30.854 [DBUG] [Device] [device.c:get_full_param_name()] [1175] fullname=InternetGatewayDevice.WANDevice.0.WANConnectionDevice.0.WANIPConnection
 32 2017-03-30 03:17:30.854 [DBUG] [Device] [device.c:init_multi_obj()] [0743] init_multi_obj refresh params=InternetGatewayDevice.WANDevice.0.WANConnectionDevice.0.WANIPConnection
 33 2017-03-30 03:17:30.855 [DBUG] [Device] [device.c:get_full_param_name()] [1175] fullname=InternetGatewayDevice.WANDevice.1.WANConnectionDevice
 34 2017-03-30 03:17:30.855 [DBUG] [Device] [device.c:init_multi_obj()] [0743] init_multi_obj refresh params=InternetGatewayDevice.WANDevice.1.WANConnectionDevice
 35 2017-03-30 03:17:30.859 [DBUG] [Device] [device.c:get_full_param_name()] [1175] fullname=InternetGatewayDevice.WANDevice.1.WANConnectionDevice.0.WANIPConnection
 36 2017-03-30 03:17:30.859 [DBUG] [Device] [device.c:init_multi_obj()] [0743] init_multi_obj refresh params=InternetGatewayDevice.WANDevice.1.WANConnectionDevice.0.WANIPConnection
 37 2017-03-30 03:17:30.862 [DBUG] [Device] [device.c:get_full_param_name()] [1175] fullname=InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection
 38 2017-03-30 03:17:30.863 [DBUG] [Device] [device.c:init_multi_obj()] [0743] init_multi_obj refresh params=InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection
 39 2017-03-30 03:17:30.865 [INFO] [Device] [device.c:init_attr()] [0891] could not get count from /system/usr/data/attr.conf
 40 2017-03-30 03:17:30.872 [INFO] [CWMP] [cwmp.c:cwmp_proc()] [0266] cwmp is enabled
 41 2017-03-30 03:17:30.873 [INFO] [CWMP] [cwmp.c:cwmp_proc()] [0269] ============start  listen acs================
 42 2017-03-30 03:17:30.873 [INFO] [HTTPSERVER] [acs_req_conn.c:init_acs_req_conn()] [0373] init_acs_req_conn begin
 43 2017-03-30 03:17:30.874 [INFO] [HTTPSERVER] [acs_req_conn.c:init_acs_req_conn()] [0415] init_acs_req_conn end
 44 2017-03-30 03:17:30.874 [INFO] [NOTIFY] [notify_watch.c:init_notify_watch()] [0261] init_notify_watch begin
 45 2017-03-30 03:17:30.874 [INFO] [NOTIFY] [notify_watch.c:init_notify_watch()] [0301] init_notify_watch end
 46 2017-03-30 03:17:30.874 [INFO] [PERIODIC] [periodic_inform.c:init_periodic()] [0196] init_periodic begin
 47 2017-03-30 03:17:30.875 [INFO] [PERIODIC] [periodic_inform.c:init_periodic()] [0236] init_periodic end
 48 2017-03-30 03:17:30.875 [INFO] [TASK] [task.c:init_task()] [0447] init_stun begin
 49 2017-03-30 03:17:30.875 [INFO] [TASK] [task.c:init_task()] [0486] init_task end
 50 2017-03-30 03:17:30.876 [INFO] [Event] [event.c:init_event()] [0181] bootstrap_flag = 0
 51 2017-03-30 03:17:30.876 [DBUG] [Event] [event.c:init_event()] [0192] reboot_flag=0, key=
 52 2017-03-30 03:17:30.876 [DBUG] [Event] [event.c:event_set()] [0276] event_set begin, index=1, value=1
 53 2017-03-30 03:17:30.877 [DBUG] [Event] [event.c:event_set()] [0287] event_set end
 54 2017-03-30 03:17:30.877 [INFO] [Event] [event.c:init_event()] [0202] download_flag 0
 55 2017-03-30 03:17:30.877 [DBUG] [Event] [event.c:event_loop()] [1072] wait for informing acs
 56 2017-03-30 03:17:30.886 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.ManagementServer.PeriodicInformEnable
 57 2017-03-30 03:17:30.888 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.ManagementServer.PeriodicInformInterval
 58 2017-03-30 03:17:30.890 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.ManagementServer.PeriodicInformTime
 59 2017-03-30 03:17:30.892 [DBUG] [PERIODIC] [periodic_inform.c:periodic_loop()] [0142] PeriodicInformTime=2011-12-14T17:52:17
 60 2017-03-30 03:17:30.893 [ERRO] [PERIODIC] [periodic_inform.c:periodic_loop()] [0148] InternetGatewayDevice.ManagementServer.PeriodicInformTime is invalid tm
 61 2017-03-30 03:17:30.893 [DBUG] [PERIODIC] [periodic_inform.c:periodic_loop()] [0153] wait_tm=43200
 62 2017-03-30 03:17:30.893 [DBUG] [NOTIFY] [notify_watch.c:notify_watch()] [0134] monitor parameter value change
 63 2017-03-30 03:17:30.894 [INFO] [HTTPSERVER] [acs_req_conn.c:conn_req_ser()] [0316] acs listen port = 25100
 64 2017-03-30 03:17:30.905 [INFO] [util] [util.c:socket_tcp_server()] [0110] socket_tcp_server end
 65 2017-03-30 03:17:30.896 [DBUG] [Event] [event.c:event_loop()] [1082] begin to inform acs
 66 2017-03-30 03:17:30.906 [DBUG] [Event] [event.c:event_loop()] [1109] status=IDLE
 67 2017-03-30 03:17:30.906 [DBUG] [Event] [event.c:event_loop()] [1119] status=INIT
 68 2017-03-30 03:17:30.907 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.ManagementServer.Username
 69 2017-03-30 03:17:30.909 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.ManagementServer.Password
 70 2017-03-30 03:17:30.911 [DBUG] [Event] [event.c:http_init_curl()] [0505] acs usrname=test, passwd=test
 71 2017-03-30 03:17:30.912 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.ManagementServer.URL
 72 2017-03-30 03:17:30.917 [ERRO] [NOTIFY] [notify_watch.c:notify_watch()] [0240] Select error, interval=30!
 73 2017-03-30 03:17:30.924 [DBUG] [Event] [event.c:event_loop()] [1141] acs url=http://192.168.4.11:9090/ACS-server/ACS
 74 2017-03-30 03:17:30.925 [DBUG] [EB-MIG] [low_level_func.c:dev_url_dns_resolve()] [0603] ACS domain name=192.168.4.11
 75 2017-03-30 03:17:30.925 [INFO] [EB-MIG] [low_level_func.c:dev_url_dns_resolve()] [0615] Already IP address.
 76 2017-03-30 03:17:30.925 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.Manufacturer
 77 2017-03-30 03:17:30.926 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.ManufacturerOUI
 78 2017-03-30 03:17:30.927 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.ProductClass
 79 2017-03-30 03:17:30.929 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.SerialNumber
 80 2017-03-30 03:17:30.930 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.Time.CurrentLocalTime
 81 2017-03-30 03:17:30.930 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceSummary
 82 2017-03-30 03:17:30.930 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceSummary
 83 2017-03-30 03:17:30.931 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.SpecVersion
 84 2017-03-30 03:17:30.931 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.SpecVersion
 85 2017-03-30 03:17:30.931 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.HardwareVersion
 86 2017-03-30 03:17:30.932 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.HardwareVersion
 87 2017-03-30 03:17:30.932 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.SoftwareVersion
 88 2017-03-30 03:17:30.935 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.SoftwareVersion
 89 2017-03-30 03:17:30.936 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.ProvisioningCode
 90 2017-03-30 03:17:30.937 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.ProvisioningCode
 91 2017-03-30 03:17:30.937 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.ManagementServer.ConnectionRequestURL
 92 2017-03-30 03:17:30.941 [ERRO] [EB-MIG] [ManagementServer.c:CpeGetManagementServerConnectionRequestURL()] [0035] ============Andy debug: CpeGetManagementServerConnectionRequestURL debugip= 192.168.20.38.
 93 2017-03-30 03:17:30.943 [ERRO] [EB-MIG] [ManagementServer.c:CpeGetManagementServerConnectionRequestURL()] [0059] ============Andy debug: CpeGetManagementServerConnectionRequestURL *value = http://192.168.20.38:25100.
 94 2017-03-30 03:17:30.944 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.ManagementServer.ConnectionRequestURL
 95 2017-03-30 03:17:30.944 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.ManagementServer.ParameterKey
 96 2017-03-30 03:17:30.944 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.ManagementServer.ParameterKey
 97 2017-03-30 03:17:30.944 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.ModelName
 98 2017-03-30 03:17:30.945 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.ModelName
 99 2017-03-30 03:17:30.946 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.DeviceType
100 2017-03-30 03:17:30.947 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.DeviceInfo.DeviceType
101 2017-03-30 03:17:30.961 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress
102 2017-03-30 03:17:30.961 [ERRO] [EB-MIG] [WANIPConnection.c:CpeGetWANIPConnection_ExternalIPAddress()] [0494] TODO.............support yourself WAN interface ip addr
103 2017-03-30 03:17:30.965 [DBUG] [Device] [device.c:get_param_by_name()] [0772] name=InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress
104 2017-03-30 03:17:30.966 [INFO] [EB-MIG] [low_level_func.c:dev_set_cwmp_status()] [0766] dev_set_cwmp_status type(0) val(1) 
105 2017-03-30 03:17:30.971 [DBUG] [Event] [event.c:event_loop()] [1192] status=INRR
106 2017-03-30 03:17:30.971 [INFO] [Event] [event.c:event_loop()] [1202] send=<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cwmp="urn:dslforum-org:cwmp-1-0">
107     <SOAP-ENV:Header>
108         <cwmp:ID SOAP-ENV:mustUnderstand="1">1</cwmp:ID>
109     </SOAP-ENV:Header>
110     <SOAP-ENV:Body>
111         <cwmp:Inform>
112             <DeviceId xsi:type="cwmp:DeviceIdStruct">
113                 <Manufacturer>Google</Manufacturer>
114                 <OUI>AABBCC</OUI>
115                 <ProductClass>Android4.4</ProductClass>
116                 <SerialNumber>821281000054321</SerialNumber>
117             </DeviceId>
118             <Event SOAP-ENC:arrayType="cwmp:EventStruct[1]">
119                 <EventStruct>
120                     <EventCode>1 BOOT</EventCode>
121                     <CommandKey></CommandKey>
122                 </EventStruct>
123             </Event>
124             <MaxEnvelopes>1</MaxEnvelopes>
125             <CurrentTime>2017-03-30T03:17:30</CurrentTime>
126             <RetryCount>0</RetryCount>
127             <ParameterList SOAP-ENC:arrayType="cwmp:ParameterValueStruct[10]">
128                 <ParameterValueStruct>
129                     <Name>InternetGatewayDevice.DeviceSummary</Name>
130                     <Value xsi:type="xsd:string">InternetGatewayDevice:1.0[](Baseline:1, EthernetLAN:7, WiFiLAN:4, EthernetWAN:1, Time:1, IPPing:1)</Value>
131                 </ParameterValueStruct>
132                 <ParameterValueStruct>
133                     <Name>InternetGatewayDevice.DeviceInfo.SpecVersion</Name>
134                     <Value xsi:type="xsd:string">DomainName</Value>
135                 </ParameterValueStruct>
136                 <ParameterValueStruct>
137                     <Name>InternetGatewayDevice.DeviceInfo.HardwareVersion</Name>
138                     <Value xsi:type="xsd:string">hw_1.0</Value>
139                 </ParameterValueStruct>
140                 <ParameterValueStruct>
141                     <Name>InternetGatewayDevice.DeviceInfo.SoftwareVersion</Name>
142                     <Value xsi:type="xsd:string">soft_V1.0</Value>
143                 </ParameterValueStruct>
144                 <ParameterValueStruct>
145                     <Name>InternetGatewayDevice.DeviceInfo.ProvisioningCode</Name>
146                     <Value xsi:type="xsd:string">provisioning_code</Value>
147                 </ParameterValueStruct>
148                 <ParameterValueStruct>
149                     <Name>InternetGatewayDevice.ManagementServer.ConnectionRequestURL</Name>
150                     <Value xsi:type="xsd:string">http://192.168.20.38:25100</Value>
151                 </ParameterValueStruct>
152                 <ParameterValueStruct>
153                     <Name>InternetGatewayDevice.ManagementServer.ParameterKey</Name>
154                     <Value xsi:type="xsd:string">parameterkey</Value>
155                 </ParameterValueStruct>
156                 <ParameterValueStruct>
157                     <Name>InternetGatewayDevice.DeviceInfo.ModelName</Name>
158                     <Value xsi:type="xsd:string">modulename_test1</Value>
159                 </ParameterValueStruct>
160                 <ParameterValueStruct>
161                     <Name>InternetGatewayDevice.DeviceInfo.DeviceType</Name>
162                     <Value xsi:type="xsd:string">Andy_AVD</Value>
163                 </ParameterValueStruct>
164                 <ParameterValueStruct>
165                     <Name>InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.1.ExternalIPAddress</Name>
166                     <Value xsi:type="xsd:string">192.168.20.38</Value>
167                 </ParameterValueStruct>
168             </ParameterList>
169         </cwmp:Inform>
170     </SOAP-ENV:Body>
171 </SOAP-ENV:Envelope>
172 
173 2017-03-30 03:17:30.972 [INFO] [EB-MIG] [low_level_func.c:dev_debug()] [0682] call dev_debug
174 2017-03-30 03:17:30.974 [INFO] [EB-MIG] [low_level_func.c:dev_debug()] [0690] debug flag=1
175 2017-03-30 03:17:32.354 [DBUG] [Event] [event.c:event_loop()] [1290] resp=200
176 2017-03-30 03:17:32.355 [INFO] [Event] [event.c:event_loop()] [1321] recv=<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:cwmp="urn:dslforum-org:cwmp-1-0"><SOAP-ENV:Header><cwmp:ID SOAP-ENV:mustUnderstand="1">1</cwmp:ID></SOAP-ENV:Header><SOAP-ENV:Body><cwmp:InformResponse><MaxEnvelopes>1</MaxEnvelopes></cwmp:InformResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
177 
178 
179 2017-03-30 03:17:32.356 [DBUG] [Device] [event.c:handle_soap_msg()] [0656] soap methodname=cwmp:InformResponse
180 2017-03-30 03:17:32.356 [DBUG] [Event] [event.c:event_loop()] [1331] resp=1
181 2017-03-30 03:17:32.357 [INFO] [EB-MIG] [low_level_func.c:dev_set_cwmp_status()] [0766] dev_set_cwmp_status type(0) val(2) 
182 2017-03-30 03:17:32.364 [DBUG] [Event] [event.c:event_loop()] [1192] status=INRR
183 2017-03-30 03:17:32.364 [INFO] [Event] [event.c:event_loop()] [1196] send=""
184 2017-03-30 03:17:32.365 [INFO] [EB-MIG] [low_level_func.c:dev_debug()] [0682] call dev_debug
185 2017-03-30 03:17:32.367 [INFO] [EB-MIG] [low_level_func.c:dev_debug()] [0690] debug flag=1
186 2017-03-30 03:17:36.401 [DBUG] [Event] [event.c:event_loop()] [1290] resp=200
View Code

看到类似这样的错误:

2017-03-30 03:17:30.961 [ERRO] [EB-MIG] [WANIPConnection.c:CpeGetWANIPConnection_ExternalIPAddress()] [0494] TODO.............support yourself WAN interface ip addr

说明程序已经移植成功,但是此时并没有和acs对接成功,只是Inform发送出去。

 

六. 真实设备测试测试(略)

由于我手里没有Android设备,只能使用模拟器,因此在cwmp协议栈里增加了debug模块。但是又没有解决模拟器的ip地址和ACS互通性问题,有网友可以帮忙的可以留言。

如果你的安卓设备和ACS互通,只需要修改两个地方就可以完全和ACS对接:

1. 在ManagementServer.c的CpeGetManagementServerConnectionRequestURL函数里的ip地址改为你设备的真实ip地址。

  (如果启用debug模式,也可以修改配置文件cpeagent的debugip参数)

2. 修改ACS的url地址,即修改配置文件cpeagent的acsurl参数。

七. Android使用测试命令

 1 cd D:\Eclipse_Android\sdk\platform-tools
 2 adb.exe remount
 3 adb.exe remount
 4 
 5 把文件放到Android相应的目录下
 6 adb push cli system/bin
 7 adb push libuci.so  system/lib
 8 
 9 进入Android测试shell
10 adb shell

 更多精彩内容,等你来玩!!!!