CC2540/CC2541 : Set the Peripheral Being Advertising while It is Being Connected
2017-05-28 10:24
405 查看
ThereispossibletosetyourCC254Xbescanablewhenitisinconnection.But,basedonmytest,theconnectingwouldbesluggishifyoumodifythecodeasbelowsteps:
0.CheckyourBLEstackbeing1.3.2,ifthatisnot,Iapologize.ifitis,Backupthefile:TiBLEStackInstallationFolder\BLE-CC254x-1.3.2\Projects\ble\Profiles\Roles\peripheralBroadcaster.c.
1.Substitutethefileperipheral.casperipheralBroadcaster.cinyourIARproject.Thatis,enablePLUS_BROADCASTERmacroinpreprocessordefine,excludeperipheral.c,andincludeperipheralBroadcaster.cinyourproject.
OpentheperipheralBroadcaster.c,itshouldbemodified.
2.forline45:addtheline:
#include"hci_tl.h"
itisforpassingcompilation.
3.Forline641,changetheline:
As:
Theperipheralcouldadvertisenow.
3.Attheline927:
Modifyitas:
Thedevicewouldkeepadvertisingwhichitisconnected.
4.Fortheline937:
Thereshouldbeinsertalineforresumingadvertiseafterdisconnectioneventoccuring:
Itisall,nowthegoalhasbeenreached.Yourcc254xcouldkeepadvertisingwhileitisonconnection.
Inoetagagin,thatwouldleadyourperipheralbeslowonconnecting:itcosts5~8secondstodiscoverservicesbyusingBLEscaneronmySonyXperiaZ3compact,butforpureperipheral,itcosts1secondonlyatworstcase.
ThismethodisreferedfromTexasforumthreads:
https://e2e.ti.com/support/wireless_connectivity/f/538/t/197769
keyMatch=gaiger&tisearch=Search-CN-Everything">http://www.deyisupport.com/question_answer/wireless_connectivity/bluetooth/f/103/t/88540.aspx?
keyMatch=gaiger&tisearch=Search-CN-Everything
0.CheckyourBLEstackbeing1.3.2,ifthatisnot,Iapologize.ifitis,Backupthefile:TiBLEStackInstallationFolder\BLE-CC254x-1.3.2\Projects\ble\Profiles\Roles\peripheralBroadcaster.c.
1.Substitutethefileperipheral.casperipheralBroadcaster.cinyourIARproject.Thatis,enablePLUS_BROADCASTERmacroinpreprocessordefine,excludeperipheral.c,andincludeperipheralBroadcaster.cinyourproject.
OpentheperipheralBroadcaster.c,itshouldbemodified.
2.forline45:addtheline:
#include"hci_tl.h"
: #include"hci.h" #include"hci_tl.h" #include"l2cap.h" :
itisforpassingcompilation.
3.Forline641,changetheline:
//InitializetheProfileAdvertisingandConnectionParameters
gapRole_profileRole=GAP_PROFILE_PERIPHERAL;
As:
#if(1)//GAIGER
gapRole_profileRole=GAP_PROFILE_PERIPHERAL;
#else
gapRole_profileRole=(GAP_PROFILE_PERIPHERAL|GAP_PROFILE_BROADCASTER);
#endif
Theperipheralcouldadvertisenow.
3.Attheline927:
//SincegapRole_AdvertOffTimeissetto0,thedeviceshouldnot
//automaticallybecomediscoverableagainafteraperiodoftime.
//SetenablertoFALSE;devicewillbecomediscoverableagainwhen
//thisvaluegetssettoTRUE
gapRole_AdvEnabled=FALSE;
Modifyitas:
//SincegapRole_AdvertOffTimeissetto0,thedeviceshouldnot
//automaticallybecomediscoverableagainafteraperiodoftime.
//SetenablertoFALSE;devicewillbecomediscoverableagainwhen
//thisvaluegetssettoTRUE
#if(0)//GAIGER
gapRole_AdvEnabled=FALSE;
#else
osal_start_timerEx(gapRole_TaskID,START_ADVERTISING_EVT,1000);
#endif
Thedevicewouldkeepadvertisingwhichitisconnected.
4.Fortheline937:
//Checkwhetherupdateparameterrequestisenabled,andchecktheconnectionparameters
if((gapRole_ParamUpdateEnable==TRUE)&&
((pPkt->connInterval<gapRole_MinConnInterval)||
(pPkt->connInterval>gapRole_MaxConnInterval)||
(pPkt->connLatency!=gapRole_SlaveLatency)||
(pPkt->connTimeout!=gapRole_TimeoutMultiplier)))
{
gapRole_SendUpdateParam(pPkt->connInterval,pPkt->connLatency);
}
//NotifytheBondManagertotheconnection
VOIDGAPBondMgr_LinkEst(pPkt->devAddrType,pPkt->devAddr,pPkt->connectionHandle,GAP_PROFILE_PERIPHERAL);
Thereshouldbeinsertalineforresumingadvertiseafterdisconnectioneventoccuring:
//Checkwhetherupdateparameterrequestisenabled,andchecktheconnectionparameters
if((gapRole_ParamUpdateEnable==TRUE)&&
((pPkt->connInterval<gapRole_MinConnInterval)||
(pPkt->connInterval>gapRole_MaxConnInterval)||
(pPkt->connLatency!=gapRole_SlaveLatency)||
(pPkt->connTimeout!=gapRole_TimeoutMultiplier)))
{
gapRole_SendUpdateParam(pPkt->connInterval,pPkt->connLatency);
}
#if(1)//GAIGER
VOIDosal_set_event(gapRole_TaskID,START_ADVERTISING_EVT);
#endif
//NotifytheBondManagertotheconnection
VOIDGAPBondMgr_LinkEst(pPkt->devAddrType,pPkt->devAddr,pPkt->connectionHandle,GAP_PROFILE_PERIPHERAL);
Itisall,nowthegoalhasbeenreached.Yourcc254xcouldkeepadvertisingwhileitisonconnection.
Inoetagagin,thatwouldleadyourperipheralbeslowonconnecting:itcosts5~8secondstodiscoverservicesbyusingBLEscaneronmySonyXperiaZ3compact,butforpureperipheral,itcosts1secondonlyatworstcase.
ThismethodisreferedfromTexasforumthreads:
keyMatch=gaiger&tisearch=Search-CN-Everything">http://www.deyisupport.com/question_answer/wireless_connectivity/bluetooth/f/103/t/88540.aspx?
keyMatch=gaiger&tisearch=Search-CN-Everything
相关文章推荐
- CC2540/CC2541 : Set the Peripheral Being Advertising while It is Being Connected
- You may not call SetData on a resource while it is actively set on the GraphicsDevice. Unset it from
- Error 3724:Cannot drop the table 'object_name' because it is being used for replication.
- C#使用Create创建文件后,报The Process cannot access the file because it is being used by another process的异常
- the process cannot access the file because it is being used by another process
- Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jre7"
- IIS:The process cannot access the file because it is being used by another process.
- WARNING:Could not increase the asynch I/O limit to 64 for SQL direct I/O. It is set to 0
- 遇到WARNING:Could not lower the asynch I/O limit to 170 for SQL direct I/O. It is set to -1
- the process cannot access the file because it is being used by another process
- The way it is connected with wristwatches connected with almost any bunch of Diesel-engined is unique
- Oracle Bug: WARNING:Could not lower the asynch I/O limit to 224 for SQL direct I/O. It is set to -1
- The context cannot be used while the model is being created
- Cannot drop the database ‘XXX’ because it is being used for replication.
- the process cannot access the file because it is being used by another process
- C#使用Create创建文件后,报The Process cannot access the file because it is being used by another process的异常
- Cannot drop the database ‘XXX’ because it is being used for replication.
- The process cannot access the file because it is being used by another process.
- Issue 111( Most important discoveries or creation are accidental; it is usually while seeking the answer to one question that
- Cannot drop the database XXX because it is being used for replication