例程SPP有点问题, 编译可以通过, 但在链接时会找不到变量:
ld: Undefined symbols:
$_sppGetServiceHandle
$_sppStoreServiceHandle
需要在ADK1.1下加入SPP的fix文件, 并重新编译库.SPP_SERVER中 ConnectionInit()即把task和connection事件连接在一起, 这样在调用loop()以后, 底层会马上抛出CL_INIT_CFM和SPP_START_SERVICE_CFM这两个case, 可以在task中作相应处理或者忽略.
真正开始spp server功能的其实是ConnectionWriteScanEnable()和SppStartService()这两个函数, 可以根据自己实际情况调用, 不一定非在CL_INIT_CFM case中, 调用后底层会抛出一系列连接请求case, 所以task中一定要有SPP_STOP_SERVICE_CFM, SPP_CONNECT_IND, SPP_SERVICE_CONNECT_CFM等case并处理连接请求.
SPP server 端要stop SPP server service 时, 如果曾经成功连接过android client, SPP_STOP_SERVICE_CFM会报错: app_stop_sdp_unreg_fail, 出现一次不能复现;
第一次连接时, 配对成功后不能连接成功.
如果手机端删除了server的配对信息, 再运行程序时将不能再次连接.
spp server 与android第一次连接时的打印信息:
android发起连接:
spp_server.c 328 CL_DM_ACL_OPENED_IND :- 0
spp_server.c 273 CL_SM_REMOTE_IO_CAPABILITY_IND
spp_server.c 282 Remote Addr: nap f8db uap 7f lap 006e3f47
spp_server.c 291 CL_SM_IO_CAPABILITY_REQ_IND
spp_server.c 362 Unhandled Message: 20483, 0x5003
android允许配对, 连接失败:
spp_server.c 346 CL_SM_AUTHENTICATE_CFM :-
spp_server.c 353 Remote Addr: nap f8db uap 7f lap 006e3f47
spp_server.c 354 Status: 0
spp_server.c 355 Key type 3
spp_server.c 356 Bonded 1
spp_server.c 310 CL_SM_AUTHORISE_IND :-
spp_server.c 311 protocol_id: 0
spp_server.c 312 channel: 3
spp_server.c 313 incoming: 1
spp_server.c 184 SPP_CONNECT_IND
spp_server.c 310 CL_SM_AUTHORISE_IND :-
spp_server.c 311 protocol_id: 0
spp_server.c 312 channel: 1
spp_server.c 313 incoming: 1
spp_server.c 310 CL_SM_AUTHORISE_IND :-
spp_server.c 311 protocol_id: 1
spp_server.c 312 channel: 1
spp_server.c 313 incoming: 1
spp_server.c 310 CL_SM_AUTHORISE_IND :-
spp_server.c 311 protocol_id: 0
spp_server.c 312 channel: 1
spp_server.c 313 incoming: 1
spp_server.c 338 CL_RFCOMM_CONTROL_IND
spp_server.c 205 SPP_SERVER_CONNECT_CFM_T :
spp_server.c 211 Success
spp_server.c 212 Memory Slots: 25
spp_server.c 258 SPP_DISCONNECT_IND - status 1
spp_server.c 259 The SPP Client disconnected!
spp_server.c 310 CL_SM_AUTHORISE_IND :-
spp_server.c 311 protocol_id: 0
spp_server.c 312 channel: 1
spp_server.c 313 incoming: 1
spp_server.c 333 CL_DM_ACL_CLOSED_IND :- 22
重启程序:
spp_server.c 328 CL_DM_ACL_OPENED_IND :- 0
spp_server.c 362 Unhandled Message: 20483, 0x5003
spp_server.c 310 CL_SM_AUTHORISE_IND :-
spp_server.c 311 protocol_id: 0
spp_server.c 312 channel: 3
spp_server.c 313 incoming: 1
spp_server.c 184 SPP_CONNECT_IND
spp_server.c 310 CL_SM_AUTHORISE_IND :-
spp_server.c 311 protocol_id: 1
spp_server.c 312 channel: 1
spp_server.c 313 incoming: 1
spp_server.c 338 CL_RFCOMM_CONTROL_IND
spp_server.c 205 SPP_SERVER_CONNECT_CFM_T :
spp_server.c 211 Success
spp_server.c 212 Memory Slots: 25