wchble.h 237 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910
  1. /********************************** (C) COPYRIGHT ******************************
  2. * File Name : wchble.h
  3. * Author : WCH
  4. * Version : V1.40
  5. * Date : 2024/01/02
  6. * Description : head file
  7. * Copyright (c) 2022 Nanjing Qinheng Microelectronics Co., Ltd.
  8. * Attention: This software (modified or not) and binary are used for
  9. * microcontroller manufactured by Nanjing Qinheng Microelectronics.
  10. *******************************************************************************/
  11. /******************************************************************************/
  12. #ifndef __WCHBLE_H
  13. #define __WCHBLE_H
  14. #ifdef __cplusplus
  15. extern "C"
  16. {
  17. #endif
  18. #include "stdint.h"
  19. #ifndef BOOL
  20. typedef unsigned char BOOL;
  21. #endif
  22. #ifndef TRUE
  23. #define TRUE 1
  24. #endif
  25. #ifndef FALSE
  26. #define FALSE 0
  27. #endif
  28. #ifndef NULL
  29. #define NULL 0
  30. #endif
  31. #ifndef SUCCESS
  32. #define SUCCESS 0x00
  33. #endif
  34. #ifndef bStatus_t
  35. typedef uint8_t bStatus_t;
  36. #endif
  37. #ifndef tmosTaskID
  38. typedef uint8_t tmosTaskID;
  39. #endif
  40. #ifndef tmosEvents
  41. typedef uint16_t tmosEvents;
  42. #endif
  43. #ifndef tmosTimer
  44. typedef uint32_t tmosTimer;
  45. #endif
  46. #ifndef tmosSnvId_t
  47. typedef uint16_t tmosSnvId_t;
  48. #endif
  49. #ifndef tmosSnvLen_t
  50. typedef uint16_t tmosSnvLen_t;
  51. #endif
  52. // Define function type that generate a random seed callback
  53. typedef uint32_t (*pfnSrandCB)( void );
  54. // Define function type that switch to idle mode callback
  55. typedef uint32_t (*pfnIdleCB)( uint32_t );
  56. // Define function type that run LSI clock calibration callback
  57. typedef void (*pfnLSICalibrationCB)( void );
  58. // Define function type that get temperature callback
  59. typedef uint16_t (*pfnTempSampleCB)( void );
  60. // Define function type that connect/advertise event complete callback.
  61. typedef void (*pfnEventCB)( uint32_t timeUs );
  62. // Define function type that library status callback.
  63. typedef void (*pfnLibStatusErrorCB)( uint8_t code, uint32_t status );
  64. // Define function type that process event
  65. typedef tmosEvents (*pTaskEventHandlerFn)( tmosTaskID taskID, tmosEvents event );
  66. // Define function type that read flash
  67. typedef uint32_t (*pfnFlashReadCB)( uint32_t addr, uint32_t num, uint32_t *pBuf );
  68. // Define function type that write flash
  69. typedef uint32_t (*pfnFlashWriteCB)( uint32_t addr, uint32_t num, uint32_t *pBuf );
  70. // Define function type that get system clock count
  71. typedef uint32_t (*pfnGetSysClock)( void );
  72. /* BLE library config struct */
  73. typedef struct tag_ble_config
  74. {
  75. uint32_t MEMAddr; // library memory start address
  76. uint16_t MEMLen; // library memory size
  77. uint32_t SNVAddr; // SNV flash start address( if NULL,bonding information will not be saved )
  78. uint16_t SNVBlock; // SNV flash block size ( default 256 )
  79. uint8_t SNVNum; // SNV flash block number ( default 1 )
  80. uint8_t BufNumber; // Maximum number of sent and received packages cached by the controller( default 5 )
  81. // Must be greater than the number of connections.
  82. uint16_t BufMaxLen; // Maximum length (in octets) of the data portion of each HCI data packet( default 27 )
  83. // SC enable,must be greater than 69
  84. // ATT_MTU = BufMaxLen-4,Range[23,ATT_MAX_MTU_SIZE]
  85. uint8_t TxNumEvent; // Maximum number of TX data in a connection event ( default 1 )
  86. uint8_t RxNumEvent; // Maximum number of RX data in a connection event ( default equal to BufNumber )
  87. uint8_t TxPower; // Transmit power level( default LL_TX_POWEER_0_DBM(0dBm) )
  88. uint8_t ConnectNumber; // Connect number,lower two bits are peripheral number,followed by central number
  89. uint8_t WindowWidening; // Wait rf start window(us)
  90. uint8_t WaitWindow; // Wait event arrive window in one system clock
  91. uint8_t MacAddr[6]; // MAC address,little-endian
  92. uint16_t ClockFrequency; // The timing clock frequency(Hz)
  93. uint16_t ClockAccuracy; // The timing clock accuracy(ppm)
  94. pfnSrandCB srandCB; // Register a program that generate a random seed
  95. pfnIdleCB idleCB; // Register a program that set idle
  96. pfnTempSampleCB tsCB; // Register a program that read the current temperature,determine whether calibration is need
  97. pfnLSICalibrationCB rcCB; // Register a program that LSI clock calibration
  98. pfnLibStatusErrorCB staCB; // Register a program that library status callback
  99. pfnFlashReadCB readFlashCB; // Register a program that read flash
  100. pfnFlashWriteCB writeFlashCB; // Register a program that write flash
  101. } bleConfig_t; // Library initialization call BLE_LibInit function
  102. /* BLE pa control config struct */
  103. typedef struct tag_ble_clock_config
  104. {
  105. pfnGetSysClock getClockValue;
  106. uint32_t ClockMaxCount; // The maximum count value
  107. uint16_t ClockFrequency; // The timing clock frequency(Hz)
  108. uint16_t ClockAccuracy; // The timing clock accuracy(ppm)
  109. uint8_t irqEnable; // resv
  110. }bleClockConfig_t;
  111. /* BLE pa control config struct */
  112. typedef struct tag_ble_pa_control_config
  113. {
  114. uint32_t txEnableGPIO; // tx enable gpio register
  115. uint32_t txDisableGPIO; // tx disable gpio register
  116. uint32_t tx_pin; // tx pin define
  117. uint32_t rxEnableGPIO; // rx enable gpio register
  118. uint32_t rxDisableGPIO; // rx disable gpio register
  119. uint32_t rx_pin; // tx pin define
  120. } blePaControlConfig_t;
  121. // defined for all task
  122. #define SYS_EVENT_MSG (0x8000) // A message is waiting event
  123. #define INVALID_TASK_ID 0xFF // Task ID isn't setup properly
  124. #define TASK_NO_TASK 0xFF
  125. typedef struct
  126. {
  127. uint8_t event;
  128. uint8_t status;
  129. } tmos_event_hdr_t;
  130. /*********************************************************************
  131. * GLOBAL MACROS
  132. */
  133. #define VER_FILE "CH32V20x_BLE_LIB_V1.4"
  134. extern const uint8_t VER_LIB[]; // LIB version
  135. #define SYSTEM_TIME_MICROSEN 625 // unit of process event timer is 625us
  136. #define MS1_TO_SYSTEM_TIME(x) ((x)*1000/SYSTEM_TIME_MICROSEN) // transform unit in ms to unit in 625us ( attentional bias )
  137. #define TMOS_TIME_VALID (30*1000*1000) // the maximum task time = RTC MAX clock - TMOS_TIME_VALID
  138. /* takes a byte out of a uint32_t : var - uint32_t, ByteNum - byte to take out (0 - 3) */
  139. #define BREAK_UINT32( var, ByteNum ) (uint8_t)((uint32_t)(((var) >>((ByteNum) * 8)) & 0x00FF))
  140. #define HI_UINT16(a) (((a) >> 8) & 0xFF)
  141. #define LO_UINT16(a) ((a) & 0xFF)
  142. #define HI_UINT8(a) (((a) >> 4) & 0x0F)
  143. #define LO_UINT8(a) ((a) & 0x0F)
  144. #define BUILD_UINT32(Byte0, Byte1, Byte2, Byte3) \
  145. ((uint32_t)(((uint32_t)(Byte0) & 0x00FF) \
  146. + (((uint32_t)(Byte1) & 0x00FF) << 8) \
  147. + (((uint32_t)(Byte2) & 0x00FF) << 16) \
  148. + (((uint32_t)(Byte3) & 0x00FF) << 24)))
  149. #define BUILD_UINT16(loByte, hiByte) ((uint16_t)(((loByte) & 0x00FF)|(((hiByte) & 0x00FF)<<8)))
  150. #define ACTIVE_LOW !
  151. #define ACTIVE_HIGH !! // double negation forces result to be '1'
  152. #ifndef BV
  153. #define BV(n) (1 << (n))
  154. #endif
  155. #ifndef BF
  156. #define BF(x,b,s) (((x) & (b)) >> (s))
  157. #endif
  158. #ifndef MIN
  159. #define MIN(n,m) (((n) < (m)) ? (n) : (m))
  160. #endif
  161. #ifndef MAX
  162. #define MAX(n,m) (((n) < (m)) ? (m) : (n))
  163. #endif
  164. #ifndef ABS
  165. #define ABS(n) (((n) < 0) ? -(n) : (n))
  166. #endif
  167. /* Tx_POWER define(Accuracy:卤2dBm) */
  168. #define LL_TX_POWEER_MINUS_18_DBM 0x01
  169. #define LL_TX_POWEER_MINUS_10_DBM 0x03
  170. #define LL_TX_POWEER_MINUS_5_DBM 0x05
  171. #define LL_TX_POWEER_MINUS_3_DBM 0x07
  172. #define LL_TX_POWEER_0_DBM 0x09
  173. #define LL_TX_POWEER_1_DBM 0x0B
  174. #define LL_TX_POWEER_2_DBM 0x0D
  175. #define LL_TX_POWEER_3_DBM 0x11
  176. #define LL_TX_POWEER_4_DBM 0x15
  177. #define LL_TX_POWEER_5_DBM 0x1B
  178. #define LL_TX_POWEER_6_DBM 0x25
  179. #define LL_TX_POWEER_7_DBM 0x3F
  180. /* ERR_LIB_INIT define */
  181. #define ERR_LLE_IRQ_HANDLE 0x01
  182. #define ERR_MEM_ALLOCATE_SIZE 0x02
  183. #define ERR_SET_MAC_ADDR 0x03
  184. #define ERR_GAP_ROLE_CONFIG 0x04
  185. #define ERR_CONNECT_NUMBER_CONFIG 0x05
  186. #define ERR_SNV_ADDR_CONFIG 0x06
  187. #define ERR_CLOCK_SELECT_CONFIG 0x07
  188. //! Default Public and Random Address Length
  189. #define B_ADDR_LEN 6
  190. //! Random Number Size
  191. #define B_RANDOM_NUM_SIZE 8
  192. //! Default key length
  193. #define KEYLEN 16
  194. #define PUBLIC_KEY_LEN 64
  195. //! Maximum Advertising Packet Length
  196. #define B_MAX_ADV_LEN 31 // maximum legacy advertising packet length
  197. #define B_MAX_ADV_EXT_LEN 460 // maximum extended advertising packet length
  198. #define B_MAX_ADV_PERIODIC_LEN 460 // maximum periodic advertising packet length
  199. #define FAILURE 0x01 //!< Failure
  200. #define INVALIDPARAMETER 0x02 //!< Invalid request field
  201. #define INVALID_TASK 0x03 //!< Task ID isn't setup properly
  202. #define MSG_BUFFER_NOT_AVAIL 0x04 //!< No buffer is available.
  203. #define INVALID_MSG_POINTER 0x05 //!< No message pointer.
  204. #define INVALID_EVENT_ID 0x06 //!< Invalid event id.
  205. #define INVALID_TIMEOUT 0x07 //!< Invalid timeout.
  206. #define NO_TIMER_AVAIL 0x08 //!< No event is available.
  207. #define NV_OPER_FAILED 0x0A //!< read a data item to NV failed.
  208. #define INVALID_MEM_SIZE 0x0B //!< The tokens take up too much space and don't fit into Advertisement data and Scan Response Data
  209. /** BLE_STATUS_VALUES BLE Default BLE Status Values
  210. * returned as bStatus_t
  211. */
  212. #define bleInvalidTaskID INVALID_TASK //!< Task ID isn't setup properly
  213. #define bleEecKeyRequestRejected 0x06 //!< key missing
  214. #define bleNotReady 0x10 //!< Not ready to perform task
  215. #define bleAlreadyInRequestedMode 0x11 //!< Already performing that task
  216. #define bleIncorrectMode 0x12 //!< Not setup properly to perform that task
  217. #define bleMemAllocError 0x13 //!< Memory allocation error occurred
  218. #define bleNotConnected 0x14 //!< Can't perform function when not in a connection
  219. #define bleNoResources 0x15 //!< There are no resource available
  220. #define blePending 0x16 //!< Waiting
  221. #define bleTimeout 0x17 //!< Timed out performing function
  222. #define bleInvalidRange 0x18 //!< A parameter is out of range
  223. #define bleLinkEncrypted 0x19 //!< The link is already encrypted
  224. #define bleProcedureComplete 0x1A //!< The Procedure is completed
  225. #define bleInvalidMtuSize 0x1B //!< SDU size is larger than peer MTU.
  226. /********************************LinkDB****************************************/
  227. // Special case connection handles
  228. #define INVALID_CONNHANDLE 0xFFFF // Invalid connection handle, used for no connection handle
  229. #define LOOPBACK_CONNHANDLE 0xFFFE // Loopback connection handle, used to loopback a message
  230. // Link state flags
  231. #define LINK_NOT_CONNECTED 0x00 // Link isn't connected
  232. #define LINK_CONNECTED 0x01 // Link is connected
  233. #define LINK_AUTHENTICATED 0x02 // Link is authenticated
  234. #define LINK_BOUND 0x04 // Link is bonded
  235. #define LINK_ENCRYPTED 0x10 // Link is encrypted
  236. // Link Database Status callback changeTypes
  237. #define LINKDB_STATUS_UPDATE_NEW 0 // New connection created
  238. #define LINKDB_STATUS_UPDATE_REMOVED 1 // Connection was removed
  239. #define LINKDB_STATUS_UPDATE_STATEFLAGS 2 // Connection state flag changed
  240. /*******************************gattUUID***************************************/
  241. /**
  242. * GATT Services
  243. */
  244. #define GAP_SERVICE_UUID 0x1800 // Generic Access Profile
  245. #define GATT_SERVICE_UUID 0x1801 // Generic Attribute Profile
  246. /**
  247. * GATT Declarations
  248. */
  249. #define GATT_PRIMARY_SERVICE_UUID 0x2800 // Primary Service
  250. #define GATT_SECONDARY_SERVICE_UUID 0x2801 // Secondary Service
  251. #define GATT_INCLUDE_UUID 0x2802 // Include
  252. #define GATT_CHARACTER_UUID 0x2803 // Characteristic
  253. /**
  254. * GATT Descriptors
  255. */
  256. #define GATT_CHAR_EXT_PROPS_UUID 0x2900 // Characteristic Extended Properties
  257. #define GATT_CHAR_USER_DESC_UUID 0x2901 // Characteristic User Description
  258. #define GATT_CLIENT_CHAR_CFG_UUID 0x2902 // Client Characteristic Configuration
  259. #define GATT_SERV_CHAR_CFG_UUID 0x2903 // Server Characteristic Configuration
  260. #define GATT_CHAR_FORMAT_UUID 0x2904 // Characteristic Presentation Format
  261. #define GATT_CHAR_AGG_FORMAT_UUID 0x2905 // Characteristic Aggregate Format
  262. #define GATT_VALID_RANGE_UUID 0x2906 // Valid Range
  263. #define GATT_EXT_REPORT_REF_UUID 0x2907 // External Report Reference Descriptor
  264. #define GATT_REPORT_REF_UUID 0x2908 // Report Reference Descriptor
  265. /**
  266. * GATT Characteristics
  267. */
  268. #define DEVICE_NAME_UUID 0x2A00 // Device Name
  269. #define APPEARANCE_UUID 0x2A01 // Appearance
  270. #define PERI_PRIVACY_FLAG_UUID 0x2A02 // Peripheral Privacy Flag
  271. #define RECONNECT_ADDR_UUID 0x2A03 // Reconnection Address
  272. #define PERI_CONN_PARAM_UUID 0x2A04 // Peripheral Preferred Connection Parameters
  273. #define SERVICE_CHANGED_UUID 0x2A05 // Service Changed
  274. #define CENTRAL_ADDRESS_RESOLUTION_UUID 0x2AA6 // Central Address Resolution
  275. #define RL_PRIVATE_ADDR_ONLY_UUID 0x2AC9 // Resolvable Private Address Only
  276. #define ENC_DATA_KEY_MATERIAL_UUID 0x2B88 // Encrypted Data Key Material
  277. #define LE_GATT_SEC_LEVELS_UUID 0x2BF5 // LE GATT Security Levels
  278. /**
  279. * GATT Service UUIDs
  280. */
  281. #define IMMEDIATE_ALERT_SERV_UUID 0x1802 // Immediate Alert
  282. #define LINK_LOSS_SERV_UUID 0x1803 // Link Loss
  283. #define TX_PWR_LEVEL_SERV_UUID 0x1804 // Tx Power
  284. #define CURRENT_TIME_SERV_UUID 0x1805 // Current Time Service
  285. #define REF_TIME_UPDATE_SERV_UUID 0x1806 // Reference Time Update Service
  286. #define NEXT_DST_CHANGE_SERV_UUID 0x1807 // Next DST Change Service
  287. #define GLUCOSE_SERV_UUID 0x1808 // Glucose
  288. #define THERMOMETER_SERV_UUID 0x1809 // Health Thermometer
  289. #define DEVINFO_SERV_UUID 0x180A // Device Information
  290. #define NWA_SERV_UUID 0x180B // Network Availability
  291. #define HEARTRATE_SERV_UUID 0x180D // Heart Rate
  292. #define PHONE_ALERT_STS_SERV_UUID 0x180E // Phone Alert Status Service
  293. #define BATT_SERV_UUID 0x180F // Battery Service
  294. #define BLOODPRESSURE_SERV_UUID 0x1810 // Blood Pressure
  295. #define ALERT_NOTIF_SERV_UUID 0x1811 // Alert Notification Service
  296. #define HID_SERV_UUID 0x1812 // Human Interface Device
  297. #define SCAN_PARAM_SERV_UUID 0x1813 // Scan Parameters
  298. #define RSC_SERV_UUID 0x1814 // Running Speed and Cadence
  299. #define CSC_SERV_UUID 0x1816 // Cycling Speed and Cadence
  300. #define CYCPWR_SERV_UUID 0x1818 // Cycling Power
  301. #define LOC_NAV_SERV_UUID 0x1819 // Location and Navigation
  302. /**
  303. * GATT Characteristic UUIDs
  304. */
  305. #define ALERT_LEVEL_UUID 0x2A06 // Alert Level
  306. #define TX_PWR_LEVEL_UUID 0x2A07 // Tx Power Level
  307. #define DATE_TIME_UUID 0x2A08 // Date Time
  308. #define DAY_OF_WEEK_UUID 0x2A09 // Day of Week
  309. #define DAY_DATE_TIME_UUID 0x2A0A // Day Date Time
  310. #define EXACT_TIME_256_UUID 0x2A0C // Exact Time 256
  311. #define DST_OFFSET_UUID 0x2A0D // DST Offset
  312. #define TIME_ZONE_UUID 0x2A0E // Time Zone
  313. #define LOCAL_TIME_INFO_UUID 0x2A0F // Local Time Information
  314. #define TIME_WITH_DST_UUID 0x2A11 // Time with DST
  315. #define TIME_ACCURACY_UUID 0x2A12 // Time Accuracy
  316. #define TIME_SOURCE_UUID 0x2A13 // Time Source
  317. #define REF_TIME_INFO_UUID 0x2A14 // Reference Time Information
  318. #define TIME_UPDATE_CTRL_PT_UUID 0x2A16 // Time Update Control Point
  319. #define TIME_UPDATE_STATE_UUID 0x2A17 // Time Update State
  320. #define GLUCOSE_MEAS_UUID 0x2A18 // Glucose Measurement
  321. #define BATT_LEVEL_UUID 0x2A19 // Battery Level
  322. #define TEMP_MEAS_UUID 0x2A1C // Temperature Measurement
  323. #define TEMP_TYPE_UUID 0x2A1D // Temperature Type
  324. #define IMEDIATE_TEMP_UUID 0x2A1E // Intermediate Temperature
  325. #define MEAS_INTERVAL_UUID 0x2A21 // Measurement Interval
  326. #define BOOT_KEY_INPUT_UUID 0x2A22 // Boot Keyboard Input Report
  327. #define SYSTEM_ID_UUID 0x2A23 // System ID
  328. #define MODEL_NUMBER_UUID 0x2A24 // Model Number String
  329. #define SERIAL_NUMBER_UUID 0x2A25 // Serial Number String
  330. #define FIRMWARE_REV_UUID 0x2A26 // Firmware Revision String
  331. #define HARDWARE_REV_UUID 0x2A27 // Hardware Revision String
  332. #define SOFTWARE_REV_UUID 0x2A28 // Software Revision String
  333. #define MANUFACTURER_NAME_UUID 0x2A29 // Manufacturer Name String
  334. #define IEEE_11073_CERT_DATA_UUID 0x2A2A // IEEE 11073-20601 Regulatory Certification Data List
  335. #define CURRENT_TIME_UUID 0x2A2B // Current Time
  336. #define SCAN_REFRESH_UUID 0x2A31 // Scan Refresh
  337. #define BOOT_KEY_OUTPUT_UUID 0x2A32 // Boot Keyboard Output Report
  338. #define BOOT_MOUSE_INPUT_UUID 0x2A33 // Boot Mouse Input Report
  339. #define GLUCOSE_CONTEXT_UUID 0x2A34 // Glucose Measurement Context
  340. #define BLOODPRESSURE_MEAS_UUID 0x2A35 // Blood Pressure Measurement
  341. #define IMEDIATE_CUFF_PRESSURE_UUID 0x2A36 // Intermediate Cuff Pressure
  342. #define HEARTRATE_MEAS_UUID 0x2A37 // Heart Rate Measurement
  343. #define BODY_SENSOR_LOC_UUID 0x2A38 // Body Sensor Location
  344. #define HEARTRATE_CTRL_PT_UUID 0x2A39 // Heart Rate Control Point
  345. #define NETWORK_AVAIL_UUID 0x2A3E // Network Availability
  346. #define ALERT_STATUS_UUID 0x2A3F // Alert Status
  347. #define RINGER_CTRL_PT_UUID 0x2A40 // Ringer Control Point
  348. #define RINGER_SETTING_UUID 0x2A41 // Ringer Setting
  349. #define ALERT_CAT_ID_BMASK_UUID 0x2A42 // Alert Category ID Bit Mask
  350. #define ALERT_CAT_ID_UUID 0x2A43 // Alert Category ID
  351. #define ALERT_NOTIF_CTRL_PT_UUID 0x2A44 // Alert Notification Control Point
  352. #define UNREAD_ALERT_STATUS_UUID 0x2A45 // Unread Alert Status
  353. #define NEW_ALERT_UUID 0x2A46 // New Alert
  354. #define SUP_NEW_ALERT_CAT_UUID 0x2A47 // Supported New Alert Category
  355. #define SUP_UNREAD_ALERT_CAT_UUID 0x2A48 // Supported Unread Alert Category
  356. #define BLOODPRESSURE_FEATURE_UUID 0x2A49 // Blood Pressure Feature
  357. #define HID_INFORMATION_UUID 0x2A4A // HID Information
  358. #define REPORT_MAP_UUID 0x2A4B // Report Map
  359. #define HID_CTRL_PT_UUID 0x2A4C // HID Control Point
  360. #define REPORT_UUID 0x2A4D // Report
  361. #define PROTOCOL_MODE_UUID 0x2A4E // Protocol Mode
  362. #define SCAN_INTERVAL_WINDOW_UUID 0x2A4F // Scan Interval Window
  363. #define PNP_ID_UUID 0x2A50 // PnP ID
  364. #define GLUCOSE_FEATURE_UUID 0x2A51 // Glucose Feature
  365. #define RECORD_CTRL_PT_UUID 0x2A52 // Record Access Control Point
  366. #define RSC_MEAS_UUID 0x2A53 // RSC Measurement
  367. #define RSC_FEATURE_UUID 0x2A54 // RSC Feature
  368. #define SC_CTRL_PT_UUID 0x2A55 // SC Control Point
  369. #define CSC_MEAS_UUID 0x2A5B // CSC Measurement
  370. #define CSC_FEATURE_UUID 0x2A5C // CSC Feature
  371. #define SENSOR_LOC_UUID 0x2A5D // Sensor Location
  372. #define CYCPWR_MEAS_UUID 0x2A63 // Cycling Power Measurement
  373. #define CYCPWR_VECTOR_UUID 0x2A64 // Cycling Power Vector
  374. #define CYCPWR_FEATURE_UUID 0x2A65 // Cycling Power Feature
  375. #define CYCPWR_CTRL_PT_UUID 0x2A66 // Cycling Power Control Point
  376. #define LOC_SPEED_UUID 0x2A67 // Location and Speed
  377. #define NAV_UUID 0x2A68 // Navigation
  378. #define POS_QUALITY_UUID 0x2A69 // Position Quality
  379. #define LN_FEATURE_UUID 0x2A6A // LN Feature
  380. #define LN_CTRL_PT_UUID 0x2A6B // LN Control Point
  381. #define ELE_UUID 0x2A6C // Elevation
  382. #define PRESSURE_UUID 0x2A6D // Pressure
  383. #define TEMP_UUID 0x2A6E // Temperature
  384. #define HUMI_UUID 0x2A6F // Humidity
  385. #define TRUE_WIND_SPEED_UUID 0x2A70 // True Wind Speed
  386. #define TRUE_WIND_DIRECTION_UUID 0x2A71 // True Wind Direction
  387. #define URI_UUID 0x2AB6 // URI
  388. #define MEDIA_STATE_UUID 0x2BA3 // Media State
  389. #define MEDIA_CTRL_PT_UUID 0x2BA4 // Media Control Point
  390. #define MEDIA_CTRL_PT_OS_UUID 0x2BA5 // Media Control Point Opcodes Supported
  391. #define CALL_STATE_UUID 0x2BBD // Call State
  392. #define CALL_CTRL_PT_UUID 0x2BBE // Call Control Point
  393. #define CALL_CTRL_PT_OO_UUID 0x2BBF // Call Control Point Optional Opcodes
  394. #define TERM_REASON_UUID 0x2BC0 // Termination Reason
  395. #define INCOMING_CALL_UUID 0x2BC1 // Incoming Call
  396. #define MUTE_UUID 0x2BC3 // Mute
  397. #define ESL_ADDR_UUID 0x2BF6 // ESL Address
  398. #define AP_SYNC_KEY_MATERIAL_UUID 0x2BF7 // AP Sync Key Material
  399. #define ESL_RSP_KEY_MATERIAL_UUID 0x2BF8 // ESL Response Key Material
  400. #define ESL_CURR_ABS_TIME_UUID 0x2BF9 // ESL Current Absolute Time
  401. #define ESL_DISPLAY_INFO_UUID 0x2BFA // ESL Display Information
  402. #define ESL_IMAGE_INFO_UUID 0x2BFB // ESL Image Information
  403. #define ESL_SENSOR_INFO_UUID 0x2BFC // ESL Sensor Information
  404. #define ESL_LED_INFO_UUID 0x2BFD // ESL LED Information
  405. #define ESL_CTL_POINT_UUID 0x2BFE // ESL Control Point
  406. /**
  407. * GATT Unit UUIDs
  408. */
  409. #define GATT_UNITLESS_UUID 0x2700 // unitless
  410. #define GATT_UNIT_LENGTH_METER_UUID 0x2701 // m, m
  411. #define GATT_UNIT_MASS_KGRAM_UUID 0x2702 // kg, kg
  412. #define GATT_UNIT_TIME_SECOND_UUID 0x2703 // s, s
  413. #define GATT_UNIT_ELECTRIC_CURRENT_A_UUID 0x2704 // A, A
  414. #define GATT_UNIT_THERMODYN_TEMP_K_UUID 0x2705 // K, K
  415. #define GATT_UNIT_AMOUNT_SUBSTANCE_M_UUID 0x2706 // mol, mol
  416. #define GATT_UNIT_LUMINOUS_INTENSITY_C_UUID 0x2707 // cd, cd
  417. #define GATT_UNIT_AREA_SQ_MTR_UUID 0x2710 // m^2, m^2
  418. #define GATT_UNIT_VOLUME_CUBIC_MTR_UUID 0x2711 // m^3, m^3
  419. #define GATT_UNIT_VELOCITY_MPS_UUID 0x2712 // m/s, m s^-1
  420. #define GATT_UNIT_ACCELERATION_MPS_SQ_UUID 0x2713 // m/s^2, m s^-2
  421. #define GATT_UNIT_WAVENUMBER_RM_UUID 0x2714 // ? m^-1
  422. #define GATT_UNIT_DENSITY_KGPCM_UUID 0x2715 // p, kg m^-3
  423. #define GATT_UNIT_SURFACE_DENSITY_KGPSM_UUID 0x2716 // pA, kg m^-2
  424. #define GATT_UNIT_SPECIFIC_VOLUME_CMPKG_UUID 0x2717 // v, m^3 kg^-1
  425. #define GATT_UNIT_CURRENT_DENSITY_APSM_UUID 0x2718 // j, A m^-2
  426. #define GATT_UNIT_MAG_FIELD_STRENGTH_UUID 0x2719 // H, A m
  427. #define GATT_UNIT_AMOUNT_CONC_MPCM_UUID 0x271A // c, mol m^-3
  428. #define GATT_UNIT_MASS_CONC_KGPCM_UUID 0x271B // c, kg m^-3
  429. #define GATT_UNIT_LUMINANCE_CPSM_UUID 0x271C // Lv, cd m^-2
  430. #define GATT_UNIT_REFRACTIVE_INDEX_UUID 0x271D // n, 1
  431. #define GATT_UNIT_RELATIVE_PERMEABLILTY_UUID 0x271E // u, 1
  432. #define GATT_UNIT_PLANE_ANGLE_RAD_UUID 0x2720 // rad, m m-1
  433. #define GATT_UNIT_SOLID_ANGLE_STERAD_UUID 0x2721 // sr, m2 m-2
  434. #define GATT_UNIT_FREQUENCY_HTZ_UUID 0x2722 // Hz, s-1
  435. #define GATT_UNIT_FORCE_NEWTON_UUID 0x2723 // N, m kg s-2
  436. #define GATT_UNIT_PRESSURE_PASCAL_UUID 0x2724 // Pa, N/m2 = m2 kg s-2
  437. #define GATT_UNIT_ENERGY_JOULE_UUID 0x2725 // J, N m = m2 kg s-2
  438. #define GATT_UNIT_POWER_WATT_UUID 0x2726 // W, J/s = m2 kg s-3
  439. #define GATT_UNIT_E_CHARGE_C_UUID 0x2727 // C, sA
  440. #define GATT_UNIT_E_POTENTIAL_DIF_V_UUID 0x2728 // V, W/A = m2 kg s-3 A-1
  441. #define GATT_UNIT_CELSIUS_TEMP_DC_UUID 0x272F // oC, t/oC = T/K - 273.15
  442. #define GATT_UNIT_TIME_MINUTE_UUID 0x2760 // min, 60 s
  443. #define GATT_UNIT_TIME_HOUR_UUID 0x2761 // h, 3600 s
  444. #define GATT_UNIT_TIME_DAY_UUID 0x2762 // d, 86400 s
  445. #define GATT_UNIT_PLANE_ANGLE_DEGREE_UUID 0x2763 // o, (pi/180) rad
  446. #define GATT_UNIT_PLANE_ANGLE_MINUTE_UUID 0x2764 // ', (pi/10800) rad
  447. #define GATT_UNIT_PLANE_ANGLE_SECOND_UUID 0x2765 // '', (pi/648000) rad
  448. #define GATT_UNIT_AREA_HECTARE_UUID 0x2766 // ha, 10^4 m^2
  449. #define GATT_UNIT_VOLUME_LITRE_UUID 0x2767 // l, 10^-3 m^3
  450. #define GATT_UNIT_MASS_TONNE_UUID 0x2768 // t, 10^3 kg
  451. #define GATT_UINT_LENGTH_YARD_UUID 0x27A0 // yd, 0.9144 m
  452. #define GATT_UNIT_LENGTH_PARSEC_UUID 0x27A1 // pc, 3.085678 ?1016 m
  453. #define GATT_UNIT_LENGTH_INCH_UUID 0x27A2 // in, 0.0254 m
  454. #define GATT_UNIT_LENGTH_FOOT_UUID 0x27A3 // ft, 0.3048 m
  455. #define GATT_UNIT_LENGTH_MILE_UUID 0x27A4 // mi, 1609.347 m
  456. #define GATT_UNIT_PRESSURE_PFPSI_UUID 0x27A5 // psi, 6.894757 ?103 Pa
  457. #define GATT_UNIT_VELOCITY_KMPH_UUID 0x27A6 // km/h, 0.2777778 m^s-1
  458. #define GATT_UNIT_VELOCITY_MPH_UUID 0x27A7 // mi/h, 0.44704 m^ s-1
  459. #define GATT_UNIT_ANGULAR_VELOCITY_RPM_UUID 0x27A8 // r/min, 0.1047198 rad s-1
  460. #define GATT_UNIT_ENERGY_GCAL_UUID 0x27A9 // energy (gram calorie)
  461. #define GATT_UNIT_ENERGY_KCAL_UUID 0x27AA // kcal, 4190.02 J
  462. #define GATT_UNIT_ENERGY_KWH_UUID 0x27AB // kWh, 3600000 J
  463. #define GATT_UNIT_THERMODYN_TEMP_DF_UUID 0x27AC // oF, t/oF = T/K ?1.8 - 459.67
  464. #define GATT_UNIT_PERCENTAGE_UUID 0x27AD // percentage,%
  465. #define GATT_UNIT_PER_MILE_UUID 0x27AE // per mille
  466. #define GATT_UNIT_PERIOD_BPM_UUID 0x27AF // period (beats per minute),BPM
  467. #define GATT_UNIT_E_CHARGE_AH_UUID 0x27B0 // electric charge (ampere hours)
  468. #define GATT_UNIT_MASS_DENSITY_MGPD_UUID 0x27B1 // mass density (milligram per decilitre)
  469. #define GATT_UNIT_MASS_DENSITY_MMPL_UUID 0x27B2 // mass density (millimole per litre)
  470. #define GATT_UNIT_TIME_YEAR_UUID 0x27B3 // time (year)
  471. #define GATT_UNIT_TIME_MONTH_UUID 0x27B4 // time (month)
  472. /*********************************Messages IDs*********************************/
  473. // GATT - Messages IDs
  474. #define GATT_MSG_EVENT 0xB0 //!< Incoming GATT message
  475. #define GATT_SERV_MSG_EVENT 0xB1 //!< Incoming GATT ServApp message
  476. // GAP - Messages IDs
  477. #define GAP_MSG_EVENT 0xD0 //!< Incoming GAP message
  478. /************************************ATT***************************************/
  479. #define ATT_MTU_SIZE 23 //!< Minimum ATT MTU size
  480. #define ATT_MAX_MTU_SIZE 512 //!< Maximum ATT MTU size
  481. // ATT Methods
  482. #define ATT_ERROR_RSP 0x01 //!< ATT Error Response
  483. #define ATT_EXCHANGE_MTU_REQ 0x02 //!< ATT Exchange MTU Request
  484. #define ATT_EXCHANGE_MTU_RSP 0x03 //!< ATT Exchange MTU Response
  485. #define ATT_FIND_INFO_REQ 0x04 //!< ATT Find Information Request
  486. #define ATT_FIND_INFO_RSP 0x05 //!< ATT Find Information Response
  487. #define ATT_FIND_BY_TYPE_VALUE_REQ 0x06 //!< ATT Find By Type Value Request
  488. #define ATT_FIND_BY_TYPE_VALUE_RSP 0x07 //!< ATT Find By Type Value Response
  489. #define ATT_READ_BY_TYPE_REQ 0x08 //!< ATT Read By Type Request
  490. #define ATT_READ_BY_TYPE_RSP 0x09 //!< ATT Read By Type Response
  491. #define ATT_READ_REQ 0x0a //!< ATT Read Request
  492. #define ATT_READ_RSP 0x0b //!< ATT Read Response
  493. #define ATT_READ_BLOB_REQ 0x0c //!< ATT Read Blob Request
  494. #define ATT_READ_BLOB_RSP 0x0d //!< ATT Read Blob Response
  495. #define ATT_READ_MULTI_REQ 0x0e //!< ATT Read Multiple Request
  496. #define ATT_READ_MULTI_RSP 0x0f //!< ATT Read Multiple Response
  497. #define ATT_READ_BY_GRP_TYPE_REQ 0x10 //!< ATT Read By Group Type Request
  498. #define ATT_READ_BY_GRP_TYPE_RSP 0x11 //!< ATT Read By Group Type Response
  499. #define ATT_WRITE_REQ 0x12 //!< ATT Write Request
  500. #define ATT_WRITE_RSP 0x13 //!< ATT Write Response
  501. #define ATT_PREPARE_WRITE_REQ 0x16 //!< ATT Prepare Write Request
  502. #define ATT_PREPARE_WRITE_RSP 0x17 //!< ATT Prepare Write Response
  503. #define ATT_EXECUTE_WRITE_REQ 0x18 //!< ATT Execute Write Request
  504. #define ATT_EXECUTE_WRITE_RSP 0x19 //!< ATT Execute Write Response
  505. #define ATT_HANDLE_VALUE_NOTI 0x1b //!< ATT Handle Value Notification
  506. #define ATT_HANDLE_VALUE_IND 0x1d //!< ATT Handle Value Indication
  507. #define ATT_HANDLE_VALUE_CFM 0x1e //!< ATT Handle Value Confirmation
  508. #define ATT_WRITE_CMD 0x52 //!< ATT Write Command
  509. #define ATT_SIGNED_WRITE_CMD 0xD2 //!< ATT Signed Write Command
  510. // ATT Error Codes
  511. #define ATT_ERR_INVALID_HANDLE 0x01 //!< The attribute handle given was not valid on this server
  512. #define ATT_ERR_READ_NOT_PERMITTED 0x02 //!< The attribute cannot be read
  513. #define ATT_ERR_WRITE_NOT_PERMITTED 0x03 //!< The attribute cannot be written
  514. #define ATT_ERR_INVALID_PDU 0x04 //!< The attribute PDU was invalid
  515. #define ATT_ERR_INSUFFICIENT_AUTHEN 0x05 //!< The attribute requires authentication before it can be read or written
  516. #define ATT_ERR_UNSUPPORTED_REQ 0x06 //!< Attribute server does not support the request received from the client
  517. #define ATT_ERR_INVALID_OFFSET 0x07 //!< Offset specified was past the end of the attribute
  518. #define ATT_ERR_INSUFFICIENT_AUTHOR 0x08 //!< The attribute requires authorization before it can be read or written
  519. #define ATT_ERR_PREPARE_QUEUE_FULL 0x09 //!< Too many prepare writes have been queued
  520. #define ATT_ERR_ATTR_NOT_FOUND 0x0a //!< No attribute found within the given attribute handle range
  521. #define ATT_ERR_ATTR_NOT_LONG 0x0b //!< The attribute cannot be read using the Read Blob Request
  522. #define ATT_ERR_INSUFFICIENT_KEY_SIZE 0x0c //!< The Encryption Key Size used for encrypting this link is insufficient
  523. #define ATT_ERR_INVALID_VALUE_SIZE 0x0d //!< The attribute value length is invalid for the operation
  524. #define ATT_ERR_UNLIKELY 0x0e //!< The attribute request that was requested has encountered an error that was very unlikely, and therefore could not be completed as requested
  525. #define ATT_ERR_INSUFFICIENT_ENCRYPT 0x0f //!< The attribute requires encryption before it can be read or written
  526. #define ATT_ERR_UNSUPPORTED_GRP_TYPE 0x10 //!< The attribute type is not a supported grouping attribute as defined by a higher layer specification
  527. #define ATT_ERR_INSUFFICIENT_RESOURCES 0x11 //!< Insufficient Resources to complete the request
  528. #define ATT_ERR_INVALID_VALUE 0x80 //!< The attribute value is invalid for the operation
  529. /*********************************************************************
  530. * ATT Find By Type Value Response macros
  531. */
  532. // Attribute Handle and Group End Handle pair indexes
  533. #define ATT_ATTR_HANDLE_IDX( i ) ( (i) * (2 + 2) )
  534. #define ATT_GRP_END_HANDLE_IDX( i ) ( ATT_ATTR_HANDLE_IDX( (i) ) + 2 )
  535. #define ATT_ATTR_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_ATTR_HANDLE_IDX((i))], \
  536. (info)[ATT_ATTR_HANDLE_IDX((i))+1] ) )
  537. #define ATT_GRP_END_HANDLE( info, i ) ( BUILD_UINT16( (info)[ATT_GRP_END_HANDLE_IDX((i))], \
  538. (info)[ATT_GRP_END_HANDLE_IDX((i))+1] ) )
  539. /** @defgroup ATT_MSG_EVENT_DEFINES ATT Message Event IDs
  540. * @{
  541. */
  542. #define ATT_FLOW_CTRL_VIOLATED_EVENT 0x7E //!< Sent when ATT flow control is violated on a connection. This event is sent as an TMOS message defined as attFlowCtrlViolatedEvt_t.
  543. #define ATT_MTU_UPDATED_EVENT 0x7F //!< Sent when MTU is updated for a connection. This event is sent as an TMOS message defined as attMtuUpdatedEvt_t.
  544. /** @} End ATT_MSG_EVENT_DEFINES */
  545. /*** Opcode fields: bitmasks ***/
  546. // Size of 16-bit Bluetooth UUID
  547. #define ATT_BT_UUID_SIZE 2
  548. // Size of 128-bit UUID
  549. #define ATT_UUID_SIZE 16
  550. /******************************** GATT ***********************************/
  551. // GATT Attribute Access Permissions Bit Fields
  552. #define GATT_PERMIT_READ 0x01 //!< Attribute is Readable
  553. #define GATT_PERMIT_WRITE 0x02 //!< Attribute is Writable
  554. #define GATT_PERMIT_AUTHEN_READ 0x04 //!< Read requires Authentication
  555. #define GATT_PERMIT_AUTHEN_WRITE 0x08 //!< Write requires Authentication
  556. #define GATT_PERMIT_AUTHOR_READ 0x10 //!< Read requires Authorization
  557. #define GATT_PERMIT_AUTHOR_WRITE 0x20 //!< Write requires Authorization
  558. #define GATT_PERMIT_ENCRYPT_READ 0x40 //!< Read requires Encryption
  559. #define GATT_PERMIT_ENCRYPT_WRITE 0x80 //!< Write requires Encryption
  560. // GATT Characteristic Properties Bit Fields
  561. #define GATT_PROP_BCAST 0x01 //!< Permits broadcasts of the Characteristic Value
  562. #define GATT_PROP_READ 0x02 //!< Permits reads of the Characteristic Value
  563. #define GATT_PROP_WRITE_NO_RSP 0x04 //!< Permits writes of the Characteristic Value without response
  564. #define GATT_PROP_WRITE 0x08 //!< Permits writes of the Characteristic Value with response
  565. #define GATT_PROP_NOTIFY 0x10 //!< Permits notifications of a Characteristic Value without acknowledgement
  566. #define GATT_PROP_INDICATE 0x20 //!< Permits indications of a Characteristic Value with acknowledgement
  567. #define GATT_PROP_AUTHEN 0x40 //!< Permits signed writes to the Characteristic Value
  568. #define GATT_PROP_EXTENDED 0x80 //!< Additional characteristic properties are defined in the Characteristic Extended Properties Descriptor
  569. // GATT local read or write operation
  570. #define GATT_LOCAL_READ 0xFF
  571. #define GATT_LOCAL_WRITE 0xFE
  572. // GATT Encryption Key Size Limits
  573. #define GATT_MIN_ENCRYPT_KEY_SIZE 7 //!< GATT Minimum Encryption Key Size
  574. #define GATT_MAX_ENCRYPT_KEY_SIZE 16 //!< GATT Maximum Encryption Key Size
  575. // Attribute handle definitions
  576. #define GATT_INVALID_HANDLE 0x0000 // Invalid attribute handle
  577. #define GATT_MIN_HANDLE 0x0001 // Minimum attribute handle
  578. #define GATT_MAX_HANDLE 0xFFFF // Maximum attribute handle
  579. #define GATT_MAX_MTU 0xFFFF // Maximum MTU size
  580. // Attribute Access Permissions
  581. #define gattPermitRead( a ) ( (a) & GATT_PERMIT_READ )
  582. #define gattPermitWrite( a ) ( (a) & GATT_PERMIT_WRITE )
  583. #define gattPermitAuthenRead( a ) ( (a) & GATT_PERMIT_AUTHEN_READ )
  584. #define gattPermitAuthenWrite( a ) ( (a) & GATT_PERMIT_AUTHEN_WRITE )
  585. #define gattPermitAuthorRead( a ) ( (a) & GATT_PERMIT_AUTHOR_READ )
  586. #define gattPermitAuthorWrite( a ) ( (a) & GATT_PERMIT_AUTHOR_WRITE )
  587. #define gattPermitEncryptRead( a ) ( (a) & GATT_PERMIT_ENCRYPT_READ )
  588. #define gattPermitEncryptWrite( a ) ( (a) & GATT_PERMIT_ENCRYPT_WRITE )
  589. // Check for different UUID types
  590. #define gattPrimaryServiceType( t ) ( ATT_CompareUUID( primaryServiceUUID, ATT_BT_UUID_SIZE, (t).uuid, (t).len ) )
  591. #define gattSecondaryServiceType( t ) ( ATT_CompareUUID( secondaryServiceUUID, ATT_BT_UUID_SIZE, (t).uuid, (t).len ) )
  592. #define gattCharacterType( t ) ( ATT_CompareUUID( characterUUID, ATT_BT_UUID_SIZE, (t).uuid, (t).len ) )
  593. #define gattIncludeType( t ) ( ATT_CompareUUID( includeUUID, ATT_BT_UUID_SIZE, (t).uuid, (t).len ) )
  594. #define gattServiceType( t ) ( gattPrimaryServiceType( (t) ) || gattSecondaryServiceType( (t) ) )
  595. #define GATT_MAX_NUM_CONN (4)
  596. // GATT Client Characteristic Configuration Bit Fields
  597. #define GATT_CLIENT_CFG_NOTIFY 0x0001 //!< The Characteristic Value shall be notified
  598. #define GATT_CLIENT_CFG_INDICATE 0x0002 //!< The Characteristic Value shall be indicated
  599. #define GATT_CFG_NO_OPERATION 0x0000 // No operation
  600. // All profile services bit fields
  601. #define GATT_SERVICE_DEVICE_NAME (1<<0) //!< Device Name
  602. #define GATT_SERVICE_APPEARANCE (1<<1) //!< Appearance
  603. #define GATT_SERVICE_PRIVACY_FLAG (1<<2) //!< Peripheral Privacy Flag
  604. #define GATT_SERVICE_RECONN_ADDR (1<<3) //!< Reconnection Address
  605. #define GATT_SERVICE_PERI_CONN_PARAM (1<<4) //!< Peripheral Preferred Connection Parameters (PPCP)
  606. #define GATT_SERVICE_CENTRAL_ADDR_RL (1<<5) //!< Central Address Resolution
  607. #define GATT_SERVICE_PRIV_ADDR_ONLY (1<<6) //!< Resolvable Private Address Only
  608. #define GATT_SERVICE_ENCY_DATA_KEY (1<<7) //!< Encrypted Data Key Material
  609. #define GATT_SERVICE_LE_GATT_SECU (1<<8) //!< LE GATT Security Levels
  610. #define GATT_SERVICES_DEFS (GATT_SERVICE_DEVICE_NAME|GATT_SERVICE_APPEARANCE|GATT_SERVICE_PERI_CONN_PARAM|GATT_SERVICE_CENTRAL_ADDR_RL)
  611. #define GATT_ALL_SERVICES GATT_SERVICES_DEFS
  612. // The number of attribute records in a given attribute table
  613. #define GATT_NUM_ATTRS( attrs ) ( sizeof( attrs ) / sizeof( gattAttribute_t ) )
  614. // The handle of a service is the handle of the first attribute
  615. #define GATT_SERVICE_HANDLE( attrs ) ( (attrs)[0].handle )
  616. // The handle of the first included service (i = 1) is the value of the second attribute
  617. #define GATT_INCLUDED_HANDLE( attrs, i ) ( *((uint16_t *)((attrs)[(i)].pValue)) )
  618. // Client Characteristic Configuration table (from CCC attribute value pointer)
  619. #define GATT_CCC_TBL( pValue ) ( (gattCharCfg_t *)(*((PTR_TYPE)(&pValue))))
  620. /************************************ GAP *************************************/
  621. #define GAP_MSG_EVENT_DEFINES //!< GAP type of command
  622. #define GAP_DEVICE_INIT_DONE_EVENT 0x00 //!< Sent when the Device Initialization is complete. This event is sent as an tmos message defined as gapDeviceInitDoneEvent_t.
  623. #define GAP_DEVICE_DISCOVERY_EVENT 0x01 //!< Sent when the Device Discovery Process is complete. This event is sent as an tmos message defined as gapDevDiscEvent_t.
  624. #define GAP_ADV_DATA_UPDATE_DONE_EVENT 0x02 //!< Sent when the Advertising Data or SCAN_RSP Data has been updated. This event is sent as an tmos message defined as gapAdvDataUpdateEvent_t.
  625. #define GAP_MAKE_DISCOVERABLE_DONE_EVENT 0x03 //!< Sent when the Make Discoverable Request is complete. This event is sent as an tmos message defined as gapMakeDiscoverableRspEvent_t.
  626. #define GAP_END_DISCOVERABLE_DONE_EVENT 0x04 //!< Sent when the Advertising has ended. This event is sent as an tmos message defined as gapEndDiscoverableRspEvent_t.
  627. #define GAP_LINK_ESTABLISHED_EVENT 0x05 //!< Sent when the Establish Link Request is complete. This event is sent as an tmos message defined as gapEstLinkReqEvent_t.
  628. #define GAP_LINK_TERMINATED_EVENT 0x06 //!< Sent when a connection was terminated. This event is sent as an tmos message defined as gapTerminateLinkEvent_t.
  629. #define GAP_LINK_PARAM_UPDATE_EVENT 0x07 //!< Sent when an Update Parameters Event is received. This event is sent as an tmos message defined as gapLinkUpdateEvent_t.
  630. #define GAP_RANDOM_ADDR_CHANGED_EVENT 0x08 //!< Sent when a random address was changed. This event is sent as an tmos message defined as gapRandomAddrEvent_t.
  631. #define GAP_SIGNATURE_UPDATED_EVENT 0x09 //!< Sent when the device's signature counter is updated. This event is sent as an tmos message defined as gapSignUpdateEvent_t.
  632. #define GAP_AUTHENTICATION_COMPLETE_EVENT 0x0A //!< Sent when the Authentication (pairing) process is complete. This event is sent as an tmos message defined as gapAuthCompleteEvent_t.
  633. #define GAP_PASSKEY_NEEDED_EVENT 0x0B //!< Sent when a Passkey is needed. This is part of the pairing process. This event is sent as an tmos message defined as gapPasskeyNeededEvent_t.
  634. #define GAP_SLAVE_REQUESTED_SECURITY_EVENT 0x0C //!< Sent when a Slave Security Request is received. This event is sent as an tmos message defined as gapSlaveSecurityReqEvent_t.
  635. #define GAP_DEVICE_INFO_EVENT 0x0D //!< Sent during the Device Discovery Process when a device is discovered. This event is sent as an tmos message defined as gapDeviceInfoEvent_t.
  636. #define GAP_BOND_COMPLETE_EVENT 0x0E //!< Sent when the bonding process is complete. This event is sent as an tmos message defined as gapBondCompleteEvent_t.
  637. #define GAP_PAIRING_REQ_EVENT 0x0F //!< Sent when an unexpected Pairing Request is received. This event is sent as an tmos message defined as gapPairingReqEvent_t.
  638. #define GAP_DIRECT_DEVICE_INFO_EVENT 0x10 //!< Sent when a direct Advertising Data is received. This event is sent as an tmos message defined as gapDirectDeviceInfoEvent_t.
  639. #define GAP_PHY_UPDATE_EVENT 0x11 //!< Sent when a PHY Update Event is received. This event is sent as an tmos message defined as gapLinkUpdateEvent_t.
  640. #define GAP_EXT_ADV_DEVICE_INFO_EVENT 0x12 //!< Sent when a Extended Advertising Data is received. This event is sent as an tmos message defined as gapExtAdvDeviceInfoEvent_t.
  641. #define GAP_MAKE_PERIODIC_ADV_DONE_EVENT 0x13 //!< Sent when the Set Periodic Advertising enable is complete. This event is sent as an tmos message defined as gapMakePeriodicRspEvent_t.
  642. #define GAP_END_PERIODIC_ADV_DONE_EVENT 0x14 //!< Sent when the Set Periodic Advertising disable is complete. This event is sent as an tmos message defined as gapEndPeriodicRspEvent_t.
  643. #define GAP_SYNC_ESTABLISHED_EVENT 0x15 //!< Sent when a Periodic Advertising Sync Establish is complete. This event is sent as an tmos message defined as gapSyncEstablishedEvent_t.
  644. #define GAP_PERIODIC_ADV_DEVICE_INFO_EVENT 0x16 //!< Sent when a Periodic Advertising Data is received. This event is sent as an tmos message defined as gapPeriodicAdvDeviceInfoEvent_t.
  645. #define GAP_SYNC_LOST_EVENT 0x17 //!< Sent when a Periodic Advertising Sync was lost. This event is sent as an tmos message defined as gapSyncLostEvent_t.
  646. #define GAP_SCAN_REQUEST_EVENT 0x19 //!< Sent when a SCAN_REQ PDU or an AUX_SCAN_REQ PDU has been received by the advertiser. This event is sent as an tmos message defined as gapScanReqReseiveEvent_t.
  647. #define GAP_OOB_NEEDED_EVENT 0x1A //!< resv
  648. #define GAP_MAKE_CONNECTIONESS_CTE_DONE_EVENT 0x1B //!< Sent when the Set Connectionless CTE Transmit enable is complete. This event is sent as an tmos message defined as gapMakeConnectionlessCTERspEvent_t.
  649. #define GAP_END_CONNECTIONESS_CTE_DONE_EVENT 0x1C //!< Sent when the Set Connectionless CTE Transmit disable is complete. This event is sent as an tmos message defined as gapEndConnectionlessCTERspEvent_t.
  650. #define GAP_PERI_ADV_SYNC_TRAN_RECEIVED_EVENT 0x1D //!< Sent when the periodic advertising sync transfer received. This event is sent as an tmos message defined as gapPeriodicTranReceivec_t.
  651. #define GAP_PERI_ADV_SUBEVENT_DATA_REQ_EVENT 0x27 //!< Sent when the Controller
  652. #define GAP_PERI_ADV_RESPONSE_REPORT_EVENT 0x28 //!< Sent when one or more devices have responded to a periodic advertising subevent during a PAwR train. This event is sent as an tmos message defined as gapPeriodicAdvResponseEvent_t.
  653. // GAP_PROFILE_ROLE_DEFINES GAP Profile Roles
  654. #define GAP_PROFILE_BROADCASTER 0x01 //!< A device that sends advertising events only.
  655. #define GAP_PROFILE_OBSERVER 0x02 //!< A device that receives advertising events only.
  656. #define GAP_PROFILE_PERIPHERAL 0x04 //!< A device that accepts the establishment of an LE physical link using the connection establishment procedure
  657. #define GAP_PROFILE_CENTRAL 0x08 //!< A device that supports the Central role initiates the establishment of a physical connection
  658. // GAP Status Return Values - returned as bStatus_t
  659. #define bleGAPUserCanceled 0x30 //!< The user canceled the task
  660. #define bleGAPConnNotAcceptable 0x31 //!< The connection was not accepted
  661. #define bleGAPBondRejected 0x32 //!< The bond information was rejected.
  662. #define bleGAPExpiredCanceled 0x33 //!< The duration has expired
  663. #define GAP_DEVICE_NAME_LEN 21 //!< Excluding null-terminate char
  664. #define GAP_DEVICE_NAME_MAX_LEN 248 //!< maximum length of device name
  665. // option defined
  666. #define LISTEN_PERIODIC_ADVERTISING_MODE (1<<0) //!< used to determine whether the Periodic Advertiser List is used
  667. #define REPORTING_INITIALLY_DISABLED (1<<1) //!< 0: Reporting initially enabled 1: Reporting initially disabled
  668. #define DUPLICATE_FILTERING_INITIALLY_ENABLED (1<<2) //!< 0: Duplicate filtering initially disabled 1: Duplicate filtering initially enabled
  669. /*-------------------------------------------------------------------
  670. * CONSTANTS
  671. */
  672. /** @defgroup GAP_CONN_HANDLE_DEFINES GAP Special Connection Handles
  673. * Used by GAP_TerminateLinkReq()
  674. * @{
  675. */
  676. #define GAP_CONNHANDLE_INIT 0xFFFE //!< terminates a link create
  677. #define GAP_CONNHANDLE_ALL 0xFFFF //!< terminates all links for the matching task ID.
  678. /** @} End GAP_CONN_HANDLE_DEFINES */
  679. // Privacy Flag States
  680. #define GAP_PRIVACY_DISABLED 0x00
  681. #define GAP_PRIVACY_ENABLED 0x01
  682. // GAP GATT Server Parameters used with GGS Get/Set Parameter and Application's Callback functions
  683. #define GGS_DEVICE_NAME_ATT 0 //!< RW uint8_t[GAP_DEVICE_NAME_LEN]
  684. #define GGS_APPEARANCE_ATT 1 //!< RW uint16_t
  685. #define GGS_PERI_PRIVACY_FLAG_ATT 2 //!< RW uint8_t
  686. #define GGS_RECONNCT_ADDR_ATT 3 //!< RW uint8_t[B_ADDR_LEN]
  687. #define GGS_PERI_CONN_PARAM_ATT 4 //!< RW sizeof(gapPeriConnectParams_t)
  688. #define GGS_CENT_ADDR_RES_ATT 5 //!< RW uint8_t
  689. #define GGS_RL_PRIVATE_ADDR_ONLY 6 //!< RW uint8_t
  690. #define GGS_ENC_DATA_KEY_MATERIAL 7 //!< RW sizeof(gapEncDataKey_t)
  691. #define GGS_LE_GATT_SEC_LEVELS 8 //!< RW uint8_t
  692. #define GGS_PERI_PRIVACY_FLAG_PROPS 0X42 //!< RW uint8_t
  693. #define GGS_W_PERMIT_DEVICE_NAME_ATT 0x80 //!< W uint8_t
  694. #define GGS_W_PERMIT_APPEARANCE_ATT 0x81 //!< W uint8_t
  695. #define GGS_W_PERMIT_PRIVACY_FLAG_ATT 0x82 //!< W uint8_t
  696. // GAP_PARAMETER_ID_DEFINES GAP Parameter IDs
  697. // Timers
  698. #define TGAP_GEN_DISC_ADV_MIN 0 //!< Minimum time to remain advertising, when in Discoverable mode.Default 0-turns off the timeout. (n * 0.625 mSec).
  699. #define TGAP_LIM_ADV_TIMEOUT 1 //!< Maximum time to remain advertising, when in Limited Discoverable mode.Default 180 seconds. (n * 1 seconds)
  700. #define TGAP_DISC_SCAN 2 //!< Minimum time to perform scanning,Setting this parameter to 0 turns off the timeout.Default 10.24seconds. (n * 0.625 mSec)
  701. // when in General Discovery process
  702. #define TGAP_DISC_ADV_INT_MIN 3 //!< Minimum advertising interval.Default 160. (n * 0.625 mSec)
  703. #define TGAP_DISC_ADV_INT_MAX 4 //!< Maximum advertising interval.Default 160. (n * 0.625 mSec)
  704. #define TGAP_DISC_SCAN_INT 5 //!< Scan interval used during Link Layer Scanning state.Default 16. (n * 0.625 mSec)
  705. #define TGAP_DISC_SCAN_WIND 6 //!< Scan window used during Link Layer Scanning state.Default 16. (n * 0.625 mSec)
  706. // when in Connection Establishment process(1M PHY)
  707. #define TGAP_CONN_EST_INT_MIN 7 //!< Minimum Link Layer connection interval.Default 80. (n * 1.25 mSec)
  708. #define TGAP_CONN_EST_INT_MAX 8 //!< Maximum Link Layer connection interval.Default 80. (n * 1.25 mSec)
  709. #define TGAP_CONN_EST_SCAN_INT 9 //!< Scan interval used during Link Layer Initiating state.Default 16. (n * 0.625 mSec)
  710. #define TGAP_CONN_EST_SCAN_WIND 10 //!< Scan window used during Link Layer Initiating state.Default 16. (n * 0.625 mSec)
  711. #define TGAP_CONN_EST_HIGH_SCAN_INT 11 //!< Scan interval used during Link Layer Initiating state, high duty scan cycle scan parameters (n * 0.625 mSec)
  712. #define TGAP_CONN_EST_HIGH_SCAN_WIND 12 //!< Scan window used during Link Layer Initiating state, high duty scan cycle scan parameters (n * 0.625 mSec)
  713. #define TGAP_CONN_EST_SUPERV_TIMEOUT 13 //!< Link Layer connection supervision timeout.Default 2000. (n * 10 mSec)
  714. #define TGAP_CONN_EST_LATENCY 14 //!< Link Layer connection slave latency.Default 0. (in number of connection events)
  715. #define TGAP_CONN_EST_MIN_CE_LEN 15 //!< Local informational parameter about minimum length of connection needed.Default 0. (n * 0.625 mSec)
  716. #define TGAP_CONN_EST_MAX_CE_LEN 16 //!< Local informational parameter about maximum length of connection needed.Default 0. (n * 0.625 mSec)
  717. // Proprietary
  718. #define TGAP_PRIVATE_ADDR_INT 17 //!< Minimum Time Interval between private (resolvable) address changes.Default 900. (n * 1 seconds)
  719. #define TGAP_SM_TIMEOUT 18 //!< SM Message Timeout (milliseconds). Default 30 seconds.
  720. #define TGAP_SM_MIN_KEY_LEN 19 //!< SM Minimum Key Length supported. Default 7.
  721. #define TGAP_SM_MAX_KEY_LEN 20 //!< SM Maximum Key Length supported. Default 16.
  722. #define TGAP_FILTER_ADV_REPORTS 21 //!< Filter duplicate advertising reports. Default TRUE.
  723. #define TGAP_SCAN_RSSI_MIN 22 //!< Minimum RSSI required for scan advertising to be reported to the app. Default -127.
  724. #define TGAP_REJECT_CONN_PARAMS 23 //!< Whether or not to reject Connection Parameter Update Request received on Central device. Default FALSE.
  725. #define TGAP_AUTH_TASK_ID 24 //!< Task ID override for Task Authentication control (for stack internal use only)
  726. // v5.x
  727. #define TGAP_ADV_TX_POWER 25 //!< Indicates the maximum power level Range: -127 ≤ N ≤ +126 Units: dBm.Default 127(Host has no preference).
  728. #define TGAP_ADV_PRIMARY_PHY 26 //!< Indicates the PHY on which the advertising packets are transmitted on the primary advertising channel.LE 1M/LE Coded.Default GAP_PHY_VAL_LE_1M.
  729. #define TGAP_ADV_SECONDARY_PHY 27 //!< LE 1M/LE 2M/LE Coded. Default GAP_PHY_VAL_LE_1M.
  730. #define TGAP_ADV_SECONDARY_MAX_SKIP 28 //!< Maximum advertising events the Controller can skip before sending the AUX_ADV_IND packets on the secondary advertising channel. Default 0.
  731. #define TGAP_ADV_ADVERTISING_SID 29 //!< Value of the Advertising SID subfield in the ADI field of the PDU Range:0-15. Default 0.
  732. #define TGAP_ADV_SCAN_REQ_NOTIFY 30 //!< Scan request notifications enabled.Default 0-disabled.
  733. #define TGAP_ADV_ADVERTISING_DURATION 31 //!< Advertising duration Range: 0x0001 - 0xFFFF Time = N * 10ms. Default 0-No advertising duration.
  734. #define TGAP_ADV_MAX_EVENTS 32 //!< indicates the maximum number of extended advertising events.Range: 0x00 - 0xFF. Default 0(No maximum number of advertising events).
  735. // when in General Discovery process
  736. #define TGAP_DISC_SCAN_PHY 33 //!< LE 1M/LE Coded. Default GAP_PHY_BIT_LE_1M.
  737. #define TGAP_DISC_SCAN_CODED_INT 34 //!< Scan interval used during Link Layer coded Scanning state, when in General Discovery process (n * 0.625 mSec)
  738. #define TGAP_DISC_SCAN_CODED_WIND 35 //!< Scan window used during Link Layer coded Scanning state, when in General Discovery process (n * 0.625 mSec)
  739. #define TGAP_DISC_SCAN_DURATION 36 //!< Scan duration Range: 0x0001 - 0xFFFF Time = N * 10 ms. Default 0-Scan continuously until explicitly disable.
  740. #define TGAP_DISC_SCAN_PERIOD 37 //!< resv.
  741. // when in Connection Establishment process(2M PHY)
  742. #define TGAP_CONN_EST_INT_PHY 38 //!< LE 1M/LE Coded. Default GAP_PHY_BIT_LE_1M.
  743. #define TGAP_CONN_EST_2M_INT_MIN 39 //!< Minimum Link Layer connection interval.Default 80. (n * 1.25 mSec)
  744. #define TGAP_CONN_EST_2M_INT_MAX 40 //!< Maximum Link Layer connection interval.Default 80. (n * 1.25 mSec)
  745. #define TGAP_CONN_EST_2M_SUPERV_TIMEOUT 41 //!< Link Layer connection supervision timeout.Default 2000. (n * 10 mSec)
  746. #define TGAP_CONN_EST_2M_LATENCY 42 //!< Link Layer connection slave latency.Default 0. (in number of connection events)
  747. #define TGAP_CONN_EST_2M_MIN_CE_LEN 43 //!< Local informational parameter about minimum length of connection needed.Default 0. (n * 0.625 mSec)
  748. #define TGAP_CONN_EST_2M_MAX_CE_LEN 44 //!< Local informational parameter about maximum length of connection needed.Default 0. (n * 0.625 mSec)
  749. // when in Connection Establishment process(Coded PHY)
  750. #define TGAP_CONN_EST_CODED_INT_MIN 45 //!< Minimum Link Layer connection interval.Default 80. (n * 1.25 mSec)
  751. #define TGAP_CONN_EST_CODED_INT_MAX 46 //!< Maximum Link Layer connection interval.Default 80. (n * 1.25 mSec)
  752. #define TGAP_CONN_EST_CODED_SCAN_INT 47 //!< Scan interval used during Link Layer Initiating state.Default 16. (n * 0.625 mSec)
  753. #define TGAP_CONN_EST_CODED_SCAN_WIND 48 //!< Scan window used during Link Layer Initiating state.Default 16. (n * 0.625 mSec)
  754. #define TGAP_CONN_EST_CODED_HIGH_SCAN_INT 49 //!< Scan interval used during Link Layer Initiating state, high duty scan cycle scan parameters (n * 0.625 mSec)
  755. #define TGAP_CONN_EST_CODED_HIGH_SCAN_WIND 50 //!< Scan window used during Link Layer Initiating state, high duty scan cycle scan parameters (n * 0.625 mSec)
  756. #define TGAP_CONN_EST_CODED_SUPERV_TIMEOUT 51 //!< Link Layer connection supervision timeout.Default 2000. (n * 10 mSec)
  757. #define TGAP_CONN_EST_CODED_LATENCY 52 //!< Link Layer connection slave latency.Default 0. (in number of connection events)
  758. #define TGAP_CONN_EST_CODED_MIN_CE_LEN 53 //!< Local informational parameter about minimum length of connection needed.Default 0. (n * 0.625 mSec)
  759. #define TGAP_CONN_EST_CODED_MAX_CE_LEN 54 //!< Local informational parameter about maximum length of connection needed.Default 0. (n * 0.625 mSec)
  760. // periodic advertising
  761. #define TGAP_PERIODIC_ADV_INT_MIN 55 //!< Minimum periodic advertising interval.Range: 0x0006 to 0xFFFF.Default 160. (n * 1.25 mSec)
  762. #define TGAP_PERIODIC_ADV_INT_MAX 56 //!< Maximum periodic advertising interval.Range: 0x0006 to 0xFFFF.Default 160. (n * 1.25 mSec)
  763. #define TGAP_PERIODIC_ADV_PROPERTIES 57 //!< Include TxPower in the periodic advertising PDU.
  764. #define TGAP_SCAN_MAX_LENGTH 58 //!< Extended scan maximum data length.Default 460
  765. #define TGAP_AFH_CHANNEL_MDOE 59 //!< whether t he Controller's channel assessment scheme is enabled or disabled.Default disabled.
  766. // Constant Tone Extension Transmit
  767. #define TGAP_CTE_TYPE 60 //!< The type of Constant Tone Extension.Default GAP_CTE_TYPE_AOA.
  768. #define TGAP_CTE_LENGTH 61 //!< The type of Constant Tone Extension.Default 20.Range[2,20]
  769. #define TGAP_CTE_COUNT 62 //!< resv
  770. #define TGAP_LENGTH_OF_SWITCHING_PATTERN 63 //!< The number of Antenna IDs in the pattern,only used when transmitting an AoD Constant Tone Extension.Default 0.
  771. // Advertising Coding Selection
  772. #define TGAP_ADV_PRIMARY_PHY_OPTIONS 64 //!< Indicate the Host's preference or requirement concerning coding scheme.Default GAP_PHY_OPTIONS_NOPRE.
  773. #define TGAP_ADV_SECONDARY_PHY_OPTIONS 65 //!< indicate the Host's preference or requirement concerning coding scheme (including for periodic advertising).Default GAP_PHY_OPTIONS_NOPRE.
  774. #define TGAP_ADV_RSP_RSSI_MIN 66 //!< The minimum RSSI for advertising to send scanning response. Default -127.
  775. #define TGAP_PARAMID_MAX 67 //!< ID MAX-valid Parameter ID
  776. // GAP_DEVDISC_MODE_DEFINES GAP Device Discovery Modes
  777. #define DEVDISC_MODE_NONDISCOVERABLE 0x00 //!< No discoverable setting
  778. #define DEVDISC_MODE_GENERAL 0x01 //!< General Discoverable devices
  779. #define DEVDISC_MODE_LIMITED 0x02 //!< Limited Discoverable devices
  780. #define DEVDISC_MODE_ALL 0x03 //!< Not filtered
  781. // GAP_ADDR_TYPE_DEFINES GAP Address Types
  782. #define ADDRTYPE_PUBLIC 0x00 //!< Use the BD_ADDR
  783. #define ADDRTYPE_STATIC 0x01 //!< Static address
  784. #define ADDRTYPE_PRIVATE_NONRESOLVE 0x02 //!< Generate Non-Resolvable Private Address
  785. #define ADDRTYPE_PRIVATE_RESOLVE 0x03 //!< Generate Resolvable Private Address
  786. // GAP_ADVERTISEMENT_TYPE_DEFINES GAP Advertising Event Types
  787. #define GAP_ADTYPE_ADV_IND 0x00 //!< Connectable undirected event typet
  788. #define GAP_ADTYPE_ADV_HDC_DIRECT_IND 0x01 //!< Connectable high duty cycle directed event type
  789. #define GAP_ADTYPE_ADV_SCAN_IND 0x02 //!< Scannable undirected event type
  790. #define GAP_ADTYPE_ADV_NONCONN_IND 0x03 //!< Non-Connectable undirected event type
  791. #define GAP_ADTYPE_ADV_LDC_DIRECT_IND 0x04 //!< Connectable low duty cycle directed event type
  792. //v5.x
  793. #define GAP_ADTYPE_EXT_CONN_DIRECT 0x05 //!< extend Connectable directed event type
  794. #define GAP_ADTYPE_EXT_SCAN_UNDIRECT 0x06 //!< extend Scannable undirected event type
  795. #define GAP_ADTYPE_EXT_NONCONN_NONSCAN_UNDIRECT 0x07 //!< extend Non-Connectable and Non-Scannable undirected event type
  796. #define GAP_ADTYPE_EXT_CONN_UNDIRECT 0x08 //!< extend Connectable undirected event type
  797. #define GAP_ADTYPE_EXT_SCAN_DIRECT 0x09 //!< extend Scannable directed event type
  798. #define GAP_ADTYPE_EXT_NONCONN_NONSCAN_DIRECT 0x0A //!< extend Non-Connectable and Non-Scannable directed event type
  799. // GAP_ADVERTISEMENT_TYPE_DEFINES GAP Advertising PHY VAL TYPE(GAP_PHY_VAL_TYPE)
  800. #define GAP_PHY_VAL_TYPE
  801. #define GAP_PHY_VAL_LE_1M 0x01
  802. #define GAP_PHY_VAL_LE_2M 0x02
  803. #define GAP_PHY_VAL_LE_CODED 0x03
  804. // GAP_ADVERTISEMENT_TYPE_DEFINES GAP Scan PHY VAL TYPE(GAP_PHY_BIT_TYPE)
  805. #define GAP_PHY_BIT_TYPE
  806. #define GAP_PHY_BIT_LE_1M (1<<0)
  807. #define GAP_PHY_BIT_LE_2M (1<<1)
  808. #define GAP_PHY_BIT_LE_CODED (1<<2)
  809. #define GAP_PHY_BIT_ALL (GAP_PHY_BIT_LE_1M|GAP_PHY_BIT_LE_2M|GAP_PHY_BIT_LE_CODED)
  810. #define GAP_PHY_BIT_LE_CODED_S2 (1<<3)
  811. // PHY_OPTIONS preferred coding when transmitting on the LE Coded PHY
  812. #define GAP_PHY_OPTIONS_TYPE
  813. #define GAP_PHY_OPTIONS_NOPRE 0x00 //!< 0:no preferred
  814. #define GAP_PHY_OPTIONS_S2 0x01 //!< prefers that S=2 coding be used when transmitting on the LE Coded PHY
  815. #define GAP_PHY_OPTIONS_S8 0x02 //!< prefers that S=8 coding be used when transmitting on the LE Coded PHY
  816. #define GAP_PHY_OPTIONS_S2_REQUIRES 0x03 //!< requires that S=2 coding be used when transmitting on the LE Coded PHY
  817. #define GAP_PHY_OPTIONS_S8_REQUIRES 0x04 //!< requires that S=8 coding be used when transmitting on the LE Coded PHY
  818. // GAP_ADVERTISEMENT_TYPE_DEFINES GAP Periodic Advertising Properties
  819. #define GAP_PERI_PROPERTIES_INCLUDE_TXPOWER (1<<6)
  820. // GAP_ADVERTISEMENT_TYPE_DEFINES GAP Connectionless CTE Transmit CTE type
  821. #define GAP_CTE_TYPE_AOA 0x00 //!< AoA Constant Tone Extension
  822. #define GAP_CTE_TYPE_AOD_1US 0x01 //!< AoD Constant Tone Extension with 1us slots
  823. #define GAP_CTE_TYPE_AOD_2US 0x02 //!< AoD Constant Tone Extension with 2us slots
  824. // GAP Advertising Report Event Types
  825. #define GAP_ADVERTISEMENT_REPORT_TYPE_DEFINES
  826. // bit0 to 4 ADVERTISEMENT_TYPE:defined for gapExtAdvDeviceInfoEvent_t Advertisement data type
  827. #define GAP_ADRPT_ADV_IND 0x00 //!< Connectable undirected advertisement
  828. #define GAP_ADRPT_ADV_DIRECT_IND 0x01 //!< Connectable directed advertisement
  829. #define GAP_ADRPT_ADV_SCAN_IND 0x02 //!< Scannable undirected advertisement
  830. #define GAP_ADRPT_ADV_NONCONN_IND 0x03 //!< Non-Connectable undirected advertisement
  831. #define GAP_ADRPT_SCAN_RSP 0x04 //!< Scan Response
  832. #define GAP_ADRPT_EXT_CONN_DIRECT 0x05 //!< extend Connectable directed report type
  833. #define GAP_ADRPT_EXT_SCAN_UNDIRECT 0x06 //!< extend Scannable undirected report type
  834. #define GAP_ADRPT_EXT_NONCONN_NONSCAN_UNDIRECT 0x07 //!< extend Non-Connectable and Non-Scannable undirected report type
  835. #define GAP_ADRPT_EXT_CONN_UNDIRECT 0x08 //!< extend Connectable undirected report type
  836. #define GAP_ADRPT_EXT_SCAN_DIRECT 0x09 //!< extend Scannable directed report type
  837. #define GAP_ADRPT_EXT_NONCONN_NONSCAN_DIRECT 0x0A //!< extend Non-Connectable and Non-Scannable directed report type
  838. #define GAP_ADRPT_EXT_SCAN_RESPONSE 0x0B //!< extend Scan Response report type
  839. // bit5 to 6 Data status:defined for gapExtAdvDeviceInfoEvent_t Advertisement data type
  840. #define GAP_ADRPT_EXT_DATA_MASK (3<<5)
  841. #define GAP_ADRPT_EXT_DATA_COMPLETE (0<<5) //!< Complete
  842. #define GAP_ADRPT_EXT_DATA_INCOMPLETE (1<<5) //!< more data to come
  843. #define GAP_ADRPT_EXT_DATA_LAST (2<<5) //!< Incomplete, data truncated, no more to come
  844. // GAP_EXTEND_ADVERTISEMENT_REPORT_TYPE_DEFINES GAP Extend Advertising Report Event Types
  845. #define GAP_ADRPT_ADV_CONNECTABLE (1<<0)
  846. #define GAP_ADRPT_ADV_SCANNABLE (1<<1)
  847. #define GAP_ADRPT_ADV_DITECTED (1<<2)
  848. #define GAP_ADRPT_SCAN_RESPONSE (1<<3)
  849. // GAP_FILTER_POLICY_DEFINES GAP Advertiser Filter Scan Parameters
  850. #define GAP_FILTER_POLICY_ALL 0x00 //!< Allow Scan Request from Any, Allow Connect Request from Any (default).
  851. #define GAP_FILTER_POLICY_WHITE_SCAN 0x01 //!< Allow Scan Request from White List Only, Allow Connect from Any
  852. #define GAP_FILTER_POLICY_WHITE_CON 0x02 //!< Allow Scan Request from Any, Connect from White List Only
  853. #define GAP_FILTER_POLICY_WHITE 0x03 //!< Allow Scan Request and Connect from White List Only
  854. // Maximum Pairing Passcode/Passkey value. Range of a passkey can be 0 - 999,999.
  855. #define GAP_PASSCODE_MAX 999999
  856. /** Sign Counter Initialized - Sign counter hasn't been used yet. Used when setting up
  857. * a connection's signing information.
  858. */
  859. #define GAP_INIT_SIGN_COUNTER 0xFFFFFFFF
  860. // GAP_ADVCHAN_DEFINES GAP Advertisement Channel Map
  861. #define GAP_ADVCHAN_37 0x01 //!< Advertisement Channel 37
  862. #define GAP_ADVCHAN_38 0x02 //!< Advertisement Channel 38
  863. #define GAP_ADVCHAN_39 0x04 //!< Advertisement Channel 39
  864. #define GAP_ADVCHAN_ALL (GAP_ADVCHAN_37 | GAP_ADVCHAN_38 | GAP_ADVCHAN_39) //!< All Advertisement Channels Enabled
  865. // GAP_ADTYPE_DEFINES GAP Advertisement Data Types
  866. #define GAP_ADTYPE_FLAGS 0x01 //!< Discovery Mode: @ref GAP_ADTYPE_FLAGS_MODES
  867. #define GAP_ADTYPE_16BIT_MORE 0x02 //!< Service: More 16-bit UUIDs available
  868. #define GAP_ADTYPE_16BIT_COMPLETE 0x03 //!< Service: Complete list of 16-bit UUIDs
  869. #define GAP_ADTYPE_32BIT_MORE 0x04 //!< Service: More 32-bit UUIDs available
  870. #define GAP_ADTYPE_32BIT_COMPLETE 0x05 //!< Service: Complete list of 32-bit UUIDs
  871. #define GAP_ADTYPE_128BIT_MORE 0x06 //!< Service: More 128-bit UUIDs available
  872. #define GAP_ADTYPE_128BIT_COMPLETE 0x07 //!< Service: Complete list of 128-bit UUIDs
  873. #define GAP_ADTYPE_LOCAL_NAME_SHORT 0x08 //!< Shortened local name
  874. #define GAP_ADTYPE_LOCAL_NAME_COMPLETE 0x09 //!< Complete local name
  875. #define GAP_ADTYPE_POWER_LEVEL 0x0A //!< TX Power Level: -127 to +127 dBm
  876. #define GAP_ADTYPE_OOB_CLASS_OF_DEVICE 0x0D //!< Simple Pairing OOB Tag: Class of device (3 octets)
  877. #define GAP_ADTYPE_OOB_SIMPLE_PAIRING_HASHC 0x0E //!< Simple Pairing OOB Tag: Simple Pairing Hash C (16 octets)
  878. #define GAP_ADTYPE_OOB_SIMPLE_PAIRING_RANDR 0x0F //!< Simple Pairing OOB Tag: Simple Pairing Randomizer R (16 octets)
  879. #define GAP_ADTYPE_SM_TK 0x10 //!< Security Manager TK Value
  880. #define GAP_ADTYPE_SM_OOB_FLAG 0x11 //!< Security Manager OOB Flags
  881. #define GAP_ADTYPE_SLAVE_CONN_INTERVAL_RANGE 0x12 //!< Min and Max values of the connection interval (2 octets Min, 2 octets Max) (0xFFFF indicates no conn interval min or max)
  882. #define GAP_ADTYPE_SIGNED_DATA 0x13 //!< Signed Data field
  883. #define GAP_ADTYPE_SERVICES_LIST_16BIT 0x14 //!< Service Solicitation: list of 16-bit Service UUIDs
  884. #define GAP_ADTYPE_SERVICES_LIST_128BIT 0x15 //!< Service Solicitation: list of 128-bit Service UUIDs
  885. #define GAP_ADTYPE_SERVICE_DATA 0x16 //!< Service Data - 16-bit UUID
  886. #define GAP_ADTYPE_PUBLIC_TARGET_ADDR 0x17 //!< Public Target Address
  887. #define GAP_ADTYPE_RANDOM_TARGET_ADDR 0x18 //!< Random Target Address
  888. #define GAP_ADTYPE_APPEARANCE 0x19 //!< Appearance
  889. #define GAP_ADTYPE_ADV_INTERVAL 0x1A //!< Advertising Interval
  890. #define GAP_ADTYPE_LE_BD_ADDR 0x1B //!< LE Bluetooth Device Address
  891. #define GAP_ADTYPE_LE_ROLE 0x1C //!< LE Role
  892. #define GAP_ADTYPE_SIMPLE_PAIRING_HASHC_256 0x1D //!< Simple Pairing Hash C-256
  893. #define GAP_ADTYPE_SIMPLE_PAIRING_RANDR_256 0x1E //!< Simple Pairing Randomizer R-256
  894. #define GAP_ADTYPE_SERVICE_DATA_32BIT 0x20 //!< Service Data - 32-bit UUID
  895. #define GAP_ADTYPE_SERVICE_DATA_128BIT 0x21 //!< Service Data - 128-bit UUID
  896. #define GAP_ADTYPE_LE_SC_CONFIRMATION_VALUE 0x22 //!< LE Secure Connections Confirmation Value
  897. #define GAP_ADTYPE_LE_SC_RANDOM_VALUE 0x23 //!< LE Secure Connections Random Value
  898. #define GAP_ADTYPE_URI 0x24 //!< URI
  899. #define GAP_ADTYPE_INDOOR_POSITION 0x25 //!< Indoor Positioning Service v1.0 or later
  900. #define GAP_ADTYPE_TRAN_DISCOVERY_DATA 0x26 //!< Transport Discovery Service v1.0 or later
  901. #define GAP_ADTYPE_SUPPORTED_FEATURES 0x27 //!< LE Supported Features
  902. #define GAP_ADTYPE_CHANNEL_MAP_UPDATE 0x28 //!< Channel Map Update Indication
  903. #define GAP_ADTYPE_PB_ADV 0x29 //!< PB-ADV. Mesh Profile Specification Section 5.2.1
  904. #define GAP_ADTYPE_MESH_MESSAGE 0x2A //!< Mesh Message. Mesh Profile Specification Section 3.3.1
  905. #define GAP_ADTYPE_MESH_BEACON 0x2B //!< Mesh Beacon. Mesh Profile Specification Section 3.9
  906. #define GAP_ADTYPE_BIG_INFO 0x2C //!< BIGInfo
  907. #define GAP_ADTYPE_BROADCAST_CODE 0x2D //!< Broadcast_Code
  908. #define GAP_ADTYPE_RSL_SET_IDENT 0x2E //!< Resolvable Set Identifier.Coordinated Set Identification Profile 1.0
  909. #define GAP_ADTYPE_ADV_INTERVAL_LONG 0x2F //!< Advertising Interval - long
  910. #define GAP_ADTYPE_BROADCAST_NAME 0x30 //!< Public Broadcast Profile v1.0 or later
  911. #define GAP_ADTYPE_ENCRYPTED_ADV_DATA 0x31 //!< Core Specification Supplement, Part A, Section 1.23
  912. #define GAP_ADTYPE_PERI_ADV_RSP_TIMING_INFO 0x32 //!< Periodic Advertising Response Timing Information
  913. #define GAP_ADTYPE_ELECTRONIC_SHELF_LABEL 0x34 //!< ESL Profile
  914. #define GAP_ADTYPE_3D_INFO_DATA 0x3D //!< 3D Information Data
  915. #define GAP_ADTYPE_MANUFACTURER_SPECIFIC 0xFF //!< Manufacturer Specific Data: first 2 octets contain the Company Identifier Code followed by the additional manufacturer specific data
  916. // GAP_ADTYPE_FLAGS_MODES GAP ADTYPE Flags Discovery Modes
  917. #define GAP_ADTYPE_FLAGS_LIMITED 0x01 //!< Discovery Mode: LE Limited Discoverable Mode
  918. #define GAP_ADTYPE_FLAGS_GENERAL 0x02 //!< Discovery Mode: LE General Discoverable Mode
  919. #define GAP_ADTYPE_FLAGS_BREDR_NOT_SUPPORTED 0x04 //!< Discovery Mode: BR/EDR Not Supported
  920. // GAP_APPEARANCE_VALUES GAP Appearance Values
  921. #define GAP_APPEARE_UNKNOWN 0x0000 //!< Unknown
  922. #define GAP_APPEARE_GENERIC_PHONE 0x0040 //!< Generic Phone
  923. #define GAP_APPEARE_GENERIC_COMPUTER 0x0080 //!< Generic Computer
  924. #define GAP_APPEARE_GENERIC_WATCH 0x00C0 //!< Generic Watch
  925. #define GAP_APPEARE_WATCH_SPORTS 0x00C1 //!< Watch: Sports Watch
  926. #define GAP_APPEARE_GENERIC_CLOCK 0x0100 //!< Generic Clock
  927. #define GAP_APPEARE_GENERIC_DISPLAY 0x0140 //!< Generic Display
  928. #define GAP_APPEARE_GENERIC_RC 0x0180 //!< Generic Remote Control
  929. #define GAP_APPEARE_GENERIC_EYE_GALSSES 0x01C0 //!< Generic Eye-glasses
  930. #define GAP_APPEARE_GENERIC_TAG 0x0200 //!< Generic Tag
  931. #define GAP_APPEARE_GENERIC_KEYRING 0x0240 //!< Generic Keyring
  932. #define GAP_APPEARE_GENERIC_MEDIA_PLAYER 0x0280 //!< Generic Media Player
  933. #define GAP_APPEARE_GENERIC_BARCODE_SCANNER 0x02C0 //!< Generic Barcode Scanner
  934. #define GAP_APPEARE_GENERIC_THERMOMETER 0x0300 //!< Generic Thermometer
  935. #define GAP_APPEARE_GENERIC_THERMO_EAR 0x0301 //!< Thermometer: Ear
  936. #define GAP_APPEARE_GENERIC_HR_SENSOR 0x0340 //!< Generic Heart rate Sensor
  937. #define GAP_APPEARE_GENERIC_HRS_BELT 0x0341 //!< Heart Rate Sensor: Heart Rate Belt
  938. #define GAP_APPEARE_GENERIC_BLOOD_PRESSURE 0x0380 //!< Generic Blood Pressure
  939. #define GAP_APPEARE_GENERIC_BP_ARM 0x0381 //!< Blood Pressure: Arm
  940. #define GAP_APPEARE_GENERIC_BP_WRIST 0x0382 //!< Blood Pressure: Wrist
  941. #define GAP_APPEARE_GENERIC_HID 0x03C0 //!< Generic Human Interface Device (HID)
  942. #define GAP_APPEARE_HID_KEYBOARD 0x03C1 //!< HID Keyboard
  943. #define GAP_APPEARE_HID_MOUSE 0x03C2 //!< HID Mouse
  944. #define GAP_APPEARE_HID_JOYSTIC 0x03C3 //!< HID Joystick
  945. #define GAP_APPEARE_HID_GAMEPAD 0x03C4 //!< HID Gamepad
  946. #define GAP_APPEARE_HID_DIGITIZER_TYABLET 0x03C5 //!< HID Digitizer Tablet
  947. #define GAP_APPEARE_HID_DIGITAL_CARDREADER 0x03C6 //!< HID Card Reader
  948. #define GAP_APPEARE_HID_DIGITAL_PEN 0x03C7 //!< HID Digital Pen
  949. #define GAP_APPEARE_HID_BARCODE_SCANNER 0x03C8 //!< HID Barcode Scanner
  950. /************************************gapRole***********************************/
  951. // GAPROLE_PROFILE_PARAMETERS GAP Role Manager Parameters
  952. #define GAPROLE_PROFILEROLE 0x300 //!< Reading this parameter will return GAP Role type. Read Only. Size is uint8_t.
  953. #define GAPROLE_IRK 0x301 //!< Identity Resolving Key. Read/Write. Size is uint8_t[KEYLEN]. Default is all 0, which means that the IRK will be randomly generated.
  954. #define GAPROLE_SRK 0x302 //!< Signature Resolving Key. Read/Write. Size is uint8_t[KEYLEN]. Default is all 0, which means that the SRK will be randomly generated.
  955. #define GAPROLE_SIGNCOUNTER 0x303 //!< Sign Counter. Read/Write. Size is uint32_t. Default is 0.
  956. #define GAPROLE_BD_ADDR 0x304 //!< Device's Address. Read Only. Size is uint8_t[B_ADDR_LEN]. This item is read from the controller.
  957. #define GAPROLE_ADVERT_ENABLED 0x305 //!< Enable/Disable Advertising. Read/Write. Size is uint8_t. Default is TRUE=Enabled.
  958. #define GAPROLE_ADVERT_DATA 0x306 //!< Advertisement Data. Read/Write. Max size is B_MAX_ADV_EXT_LEN. Default to all 0.
  959. #define GAPROLE_SCAN_RSP_DATA 0x307 //!< Scan Response Data. Read/Write. Max size is B_MAX_ADV_EXT_LEN. Defaults to all 0.
  960. #define GAPROLE_ADV_EVENT_TYPE 0x308 //!< Advertisement Type. Read/Write. Size is uint8_t. Default is GAP_ADTYPE_ADV_IND.
  961. #define GAPROLE_ADV_DIRECT_TYPE 0x309 //!< Direct Advertisement Address Type. Read/Write. Size is uint8_t. Default is ADDRTYPE_PUBLIC.
  962. #define GAPROLE_ADV_DIRECT_ADDR 0x30A //!< Direct Advertisement Address. Read/Write. Size is uint8_t[B_ADDR_LEN]. Default is NULL.
  963. #define GAPROLE_ADV_CHANNEL_MAP 0x30B //!< Which channels to advertise on. Read/Write Size is uint8_t. Default is GAP_ADVCHAN_ALL
  964. #define GAPROLE_ADV_FILTER_POLICY 0x30C //!< Filter Policy. Ignored when directed advertising is used. Read/Write. Size is uint8_t. Default is GAP_FILTER_POLICY_ALL.
  965. #define GAPROLE_STATE 0x30D //!< Reading this parameter will return GAP Peripheral Role State. Read Only. Size is uint8_t.
  966. #define GAPROLE_MAX_SCAN_RES 0x30E //!< Maximum number of discover scan results to receive. Default is 0 = unlimited.
  967. #define GAPROLE_MIN_CONN_INTERVAL 0x311 //!< Minimum Connection Interval to allow (n * 1.25ms). Range: 7.5 msec to 4 seconds (0x0006 to 0x0C80). Read/Write. Size is uint16_t. Default is 7.5 milliseconds (0x0006).
  968. #define GAPROLE_MAX_CONN_INTERVAL 0x312 //!< Maximum Connection Interval to allow (n * 1.25ms). Range: 7.5 msec to 4 seconds (0x0006 to 0x0C80). Read/Write. Size is uint16_t. Default is 4 seconds (0x0C80).
  969. // v5.x
  970. #define GAPROLE_PHY_TX_SUPPORTED 0x313 //!< The transmitter PHYs that the Host prefers the Controller to use.Default is GAP_PHY_BIT_ALL
  971. #define GAPROLE_PHY_RX_SUPPORTED 0x314 //!< The receiver PHYs that the Host prefers the Controller to use.Default is GAP_PHY_BIT_ALL
  972. #define GAPROLE_PERIODIC_ADVERT_DATA 0x315 //!< Periodic advertisement Data. Read/Write. Max size is B_MAX_ADV_PERIODIC_LEN. Default to all 0.
  973. #define GAPROLE_PERIODIC_ADVERT_ENABLED 0x316 //!< bit0:Enable/Disable Periodic Advertising. Read/Write. Size is uint8_t. Default is FALSE=Disable.
  974. //!< bit1:Include the ADI field in AUX_SYNC_IND PDUs
  975. #define GAPROLE_CTE_CONNECTIONLESS_ENABLED 0x317 //!< Enable/Disable Connectionless CTE Transmit. Read/Write. Size is uint8_t. Default is FALSE=Disable.
  976. /************************************GAPBOND***********************************/
  977. // GAPBOND_PROFILE_PARAMETERS GAP Bond Manager Parameters
  978. #define GAPBOND_PERI_PAIRING_MODE 0x400 //!< Pairing Mode: @ref GAPBOND_PAIRING_MODE_DEFINES. Read/Write. Size is uint8_t. Default is GAPBOND_PAIRING_MODE_WAIT_FOR_REQ.
  979. #define GAPBOND_PERI_MITM_PROTECTION 0x401 //!< Man-In-The-Middle (MITM) basically turns on Passkey protection in the pairing algorithm. Read/Write. Size is uint8_t. Default is 0(disabled).
  980. #define GAPBOND_PERI_IO_CAPABILITIES 0x402 //!< I/O capabilities. Read/Write. Size is uint8_t. Default is GAPBOND_IO_CAP_DISPLAY_ONLY @ref GAPBOND_IO_CAP_DEFINES.
  981. #define GAPBOND_PERI_OOB_ENABLED 0x403 //!< OOB data available for pairing algorithm. Read/Write. Size is uint8_t. Default is 0(disabled).
  982. #define GAPBOND_PERI_OOB_DATA 0x404 //!< OOB Data. Read/Write. size uint8_t[16]. Default is all 0's.
  983. #define GAPBOND_PERI_BONDING_ENABLED 0x405 //!< Request Bonding during the pairing process if enabled. Read/Write. Size is uint8_t. Default is 0(disabled).
  984. #define GAPBOND_PERI_KEY_DIST_LIST 0x406 //!< The key distribution list for bonding. size is uint8_t. @ref GAPBOND_KEY_DIST_DEFINES. Default is 0x77.
  985. #define GAPBOND_PERI_DEFAULT_PASSCODE 0x407 //!< The default passcode for MITM protection. size is uint32_t. Range is 0 - 999,999. Default is 0.
  986. #define GAPBOND_CENT_PAIRING_MODE 0x408 //!< Pairing Mode: @ref GAPBOND_PAIRING_MODE_DEFINES. Read/Write. Size is uint8_t. Default is GAPBOND_PAIRING_MODE_WAIT_FOR_REQ.
  987. #define GAPBOND_CENT_MITM_PROTECTION 0x409 //!< Man-In-The-Middle (MITM) basically turns on Passkey protection in the pairing algorithm. Read/Write. Size is uint8_t. Default is 0(disabled).
  988. #define GAPBOND_CENT_IO_CAPABILITIES 0x40A //!< I/O capabilities. Read/Write. Size is uint8_t. Default is GAPBOND_IO_CAP_DISPLAY_ONLY @ref GAPBOND_IO_CAP_DEFINES.
  989. #define GAPBOND_CENT_OOB_ENABLED 0x40B //!< OOB data available for pairing algorithm. Read/Write. Size is uint8_t. Default is 0(disabled).
  990. #define GAPBOND_CENT_OOB_DATA 0x40C //!< OOB Data. Read/Write. size uint8_t[16]. Default is all 0's.
  991. #define GAPBOND_CENT_BONDING_ENABLED 0x40D //!< Request Bonding during the pairing process if enabled. Read/Write. Size is uint8_t. Default is 0(disabled).
  992. #define GAPBOND_CENT_KEY_DIST_LIST 0x40E //!< The key distribution list for bonding. size is uint8_t. @ref GAPBOND_KEY_DIST_DEFINES. Default is 0x77.
  993. #define GAPBOND_CENT_DEFAULT_PASSCODE 0x40F //!< The default passcode for MITM protection. size is uint32_t. Range is 0 - 999,999. Default is 0.
  994. #define GAPBOND_ERASE_ALLBONDS 0x410 //!< Erase all of the bonded devices. Write Only. No Size.
  995. #define GAPBOND_AUTO_FAIL_PAIRING 0x411 //!< TEST MODE (DO NOT USE) to automatically send a Pairing Fail when a Pairing Request is received. Read/Write. size is uint8_t. Default is 0 (disabled).
  996. #define GAPBOND_AUTO_FAIL_REASON 0x412 //!< TEST MODE (DO NOT USE) Pairing Fail reason when auto failing. Read/Write. size is uint8_t. Default is 0x05 (SMP_PAIRING_FAILED_NOT_SUPPORTED).
  997. #define GAPBOND_KEYSIZE 0x413 //!< Key Size used in pairing. Read/Write. size is uint8_t. Default is 16.
  998. #define GAPBOND_AUTO_SYNC_WL 0x414 //!< Clears the White List adds to it each unique address stored by bonds in NV. Read/Write. Size is uint8_t. Default is FALSE.
  999. #define GAPBOND_BOND_COUNT 0x415 //!< Gets the total number of bonds stored in NV. Read Only. Size is uint8_t. Default is 0 (no bonds).
  1000. #define GAPBOND_BOND_FAIL_ACTION 0x416 //!< Possible actions Central may take upon an unsuccessful bonding. Write Only. Size is uint8_t. Default is 0x02 (Terminate link upon unsuccessful bonding).
  1001. #define GAPBOND_ERASE_SINGLEBOND 0x417 //!< Erase a single bonded device. Write only. Must provide address type followed by device address.
  1002. #define GAPBOND_BOND_AUTO 0x418 //!< Auto save bonds into FLASH. Write Only. size is uint8_t. Default is 1(enabled).
  1003. #define GAPBOND_BOND_UPDATE 0x419 //!< Save current bonds into FLASH. Write Only. No Size.
  1004. #define GAPBOND_DISABLE_SINGLEBOND 0x41A //!< Disable a single bonded device. Write only. Must provide address type followed by device address.
  1005. #define GAPBOND_ENABLE_SINGLEBOND 0x41B //!< Ensable a single bonded device. Write only. Must provide address type followed by device address.
  1006. #define GAPBOND_DISABLE_ALLBONDS 0x41C //!< Disable all of the bonded devices. Write Only. No Size.
  1007. #define GAPBOND_ENABLE_ALLBONDS 0x41D //!< Ensable all of the bonded devices. Write Only. No Size.
  1008. #define GAPBOND_ERASE_AUTO 0x41E //!< Auto erase all of the bonded devices when the maximum number is reached.Size is uint8_t. Default is 1(enabled).
  1009. #define GAPBOND_AUTO_SYNC_RL 0x41F //!< Clears the Resolving List adds to it each unique address stored by bonds in NV. Read/Write. Size is uint8_t. Default is FALSE.
  1010. #define GAPBOND_SET_ENC_PARAMS 0x420 //!< Set bonding parameters.size is bondEncParams_t.
  1011. #define GAPBOND_PERI_SC_PROTECTION 0x421 //!< Set peripheral sc enable. Default is FALSE.
  1012. #define GAPBOND_CENT_SC_PROTECTION 0x422 //!< Set central sc enable. Default is FALSE.
  1013. // GAPBOND_PAIRING_MODE_DEFINES GAP Bond Manager Pairing Modes
  1014. #define GAPBOND_PAIRING_MODE_NO_PAIRING 0x00 //!< Pairing is not allowed
  1015. #define GAPBOND_PAIRING_MODE_WAIT_FOR_REQ 0x01 //!< Wait for a pairing request or slave security request
  1016. #define GAPBOND_PAIRING_MODE_INITIATE 0x02 //!< Don't wait, initiate a pairing request or slave security request
  1017. // GAPBOND_IO_CAP_DEFINES GAP Bond Manager I/O Capabilities
  1018. #define GAPBOND_IO_CAP_DISPLAY_ONLY 0x00 //!< Display Only Device
  1019. #define GAPBOND_IO_CAP_DISPLAY_YES_NO 0x01 //!< Display and Yes and No Capable
  1020. #define GAPBOND_IO_CAP_KEYBOARD_ONLY 0x02 //!< Keyboard Only
  1021. #define GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT 0x03 //!< No Display or Input Device
  1022. #define GAPBOND_IO_CAP_KEYBOARD_DISPLAY 0x04 //!< Both Keyboard and Display Capable
  1023. // GAPBOND_KEY_DIST_DEFINES GAP Bond Manager Key Distribution
  1024. #define GAPBOND_KEYDIST_SENCKEY 0x01 //!< Slave Encryption Key
  1025. #define GAPBOND_KEYDIST_SIDKEY 0x02 //!< Slave IRK and ID information
  1026. #define GAPBOND_KEYDIST_SSIGN 0x04 //!< Slave CSRK
  1027. #define GAPBOND_KEYDIST_SLINK 0x08 //!< Slave Link Key
  1028. #define GAPBOND_KEYDIST_MENCKEY 0x10 //!< Master Encrypton Key
  1029. #define GAPBOND_KEYDIST_MIDKEY 0x20 //!< Master IRK and ID information
  1030. #define GAPBOND_KEYDIST_MSIGN 0x40 //!< Master CSRK
  1031. #define GAPBOND_KEYDIST_MLINK 0x80 //!< Master Link Key
  1032. // GAPBOND_PAIRING_STATE_DEFINES GAP Bond Manager Pairing States
  1033. #define GAPBOND_PAIRING_STATE_STARTED 0x00 //!< Pairing started
  1034. #define GAPBOND_PAIRING_STATE_COMPLETE 0x01 //!< Pairing complete
  1035. #define GAPBOND_PAIRING_STATE_BONDED 0x02 //!< Devices bonded
  1036. #define GAPBOND_PAIRING_STATE_BOND_SAVED 0x03 //!< Bonding record saved in NV
  1037. // SMP_PAIRING_FAILED_DEFINES Pairing failure status values
  1038. #define SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED 0x01 //!< The user input of the passkey failed, for example, the user cancelled the operation.
  1039. #define SMP_PAIRING_FAILED_OOB_NOT_AVAIL 0x02 //!< The OOB data is not available
  1040. #define SMP_PAIRING_FAILED_AUTH_REQ 0x03 //!< The pairing procedure can't be performed as authentication requirements can't be met due to IO capabilities of one or both devices
  1041. #define SMP_PAIRING_FAILED_CONFIRM_VALUE 0x04 //!< The confirm value doesn't match the calculated compare value
  1042. #define SMP_PAIRING_FAILED_NOT_SUPPORTED 0x05 //!< Pairing isn't supported by the device
  1043. #define SMP_PAIRING_FAILED_ENC_KEY_SIZE 0x06 //!< The resultant encryption key size is insufficient for the security requirements of this device.
  1044. #define SMP_PAIRING_FAILED_CMD_NOT_SUPPORTED 0x07 //!< The SMP command received is not supported on this device.
  1045. #define SMP_PAIRING_FAILED_UNSPECIFIED 0x08 //!< Pairing failed due to an unspecified reason
  1046. #define SMP_PAIRING_FAILED_REPEATED_ATTEMPTS 0x09 //!< Pairing or authentication procedure is disallowed because too little time has elapsed since the last pairing request or security request.
  1047. #define SMP_PAIRING_FAILED_INVALID_PARAMERERS 0x0A //!< The Invalid Parameters error code indicates that the command length is invalid or that a parameter is outside of the specified range.
  1048. #define SMP_PAIRING_FAILED_DHKEY_CHECK_FAILED 0x0B //!< Indicates to the remote device that the DHKey Check value received doesn’t match the one calculated by the local device.
  1049. #define SMP_PAIRING_FAILED_NUMERIC_COMPARISON 0x0C //!< Indicates that the confirm values in the numeric comparison protocol do not match.
  1050. #define SMP_PAIRING_FAILED_KEY_REJECTED 0x0F //!< Indicates that the device chose not to accept a distributed key.
  1051. // GAPBOND_BONDING_FAILURE_DEFINES Bonding Failure Actions
  1052. #define GAPBOND_FAIL_NO_ACTION 0x00 //!< Take no action upon unsuccessful bonding
  1053. #define GAPBOND_FAIL_INITIATE_PAIRING 0x01 //!< Initiate pairing upon unsuccessful bonding
  1054. #define GAPBOND_FAIL_TERMINATE_LINK 0x02 //!< Terminate link upon unsuccessful bonding
  1055. #define GAPBOND_FAIL_TERMINATE_ERASE_BONDS 0x03 //!< Terminate link and erase all existing bonds on device upon unsuccessful bonding
  1056. // Device NV Items
  1057. #define BLE_NVID_IRK 0x0002 //!< The Device's IRK
  1058. #define BLE_NVID_CSRK 0x0003 //!< The Device's CSRK
  1059. #define BLE_NVID_SIGNCOUNTER 0x0004 //!< The Device's Sign Counter
  1060. //!< RF Mode BOND NV IDs
  1061. #define BLE_NVID_BOND_RF_START 0x0100 //!< Start of the RF BOND NV IDs
  1062. // Bonding NV Items - Range 0x0200 - 0x6FFF
  1063. #define BLE_NVID_GAP_BOND_START 0x0200 //!< Start of the GAP Bond Manager's NV IDs
  1064. // GAP BOND Items
  1065. #define GAP_BOND_REC_ID_OFFSET 0 //!< NV ID for the main bonding record
  1066. #define GAP_BOND_LOCAL_LTK_OFFSET 1 //!< NV ID for the bonding record's local LTK information
  1067. #define GAP_BOND_DEV_LTK_OFFSET 2 //!< NV ID for the bonding records' device LTK information
  1068. #define GAP_BOND_DEV_IRK_OFFSET 3 //!< NV ID for the bonding records' device IRK
  1069. #define GAP_BOND_DEV_CSRK_OFFSET 4 //!< NV ID for the bonding records' device CSRK
  1070. #define GAP_BOND_DEV_SIGN_COUNTER_OFFSET 5 //!< NV ID for the bonding records' device Sign Counter
  1071. #define GAP_BOND_REC_IDS 6
  1072. // Macros to calculate the index/offset in to NV space
  1073. #define calcNvID(Idx, offset) (((((Idx) * GAP_BOND_REC_IDS) + (offset))) + BLE_NVID_GAP_BOND_START)
  1074. #define mainRecordNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_REC_ID_OFFSET))
  1075. #define localLTKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_LOCAL_LTK_OFFSET))
  1076. #define devLTKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_LTK_OFFSET))
  1077. #define devIRKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_IRK_OFFSET))
  1078. #define devCSRKNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_CSRK_OFFSET))
  1079. #define devSignCounterNvID(bondIdx) (calcNvID((bondIdx), GAP_BOND_DEV_SIGN_COUNTER_OFFSET))
  1080. // GATT Configuration NV Items -Range 0x7000 - 0x7FFF
  1081. #define BLE_NVID_GATT_CFG_START 0x7000 //!< Start of the GATT Configuration NV IDs
  1082. // Macros to calculate the GATT index/offset in to NV space
  1083. // Six characteristic configuration can be saved in NV.
  1084. #define gattCfgNvID(Idx) ((Idx) + BLE_NVID_GATT_CFG_START)
  1085. #define BLE_NVID_MAX_VAL 0x7FFF
  1086. // Structure of NV data for the connected device's encryption information
  1087. typedef struct
  1088. {
  1089. uint8_t LTK[KEYLEN]; //!< Long Term Key (LTK)
  1090. uint16_t div; //!< LTK eDiv
  1091. uint8_t rand[B_RANDOM_NUM_SIZE]; //!< LTK random number
  1092. uint8_t keySize; //!< LTK key size
  1093. } gapBondLTK_t;
  1094. // Structure of NV data for the connected device's address information
  1095. typedef struct
  1096. {
  1097. uint8_t publicAddr[B_ADDR_LEN]; //!< Central's address
  1098. uint8_t reconnectAddr[B_ADDR_LEN]; //!< Privacy Reconnection Address
  1099. uint16_t stateFlags; //!< State flags: SM_AUTH_STATE_AUTHENTICATED & SM_AUTH_STATE_BONDING
  1100. uint8_t bondsToDelete;
  1101. uint8_t publicAddrType; //!< Central's address type
  1102. } gapBondRec_t;
  1103. // Structure of NV data for the connected device's characteristic configuration
  1104. typedef struct
  1105. {
  1106. uint16_t attrHandle; //!< attribute handle
  1107. uint8_t value; //!< attribute value for this device
  1108. } gapBondCharCfg_t;
  1109. /*********************************************************************
  1110. * TYPEDEFS
  1111. */
  1112. typedef struct
  1113. {
  1114. uint8_t srk[KEYLEN]; //!< Signature Resolving Key
  1115. uint32_t signCounter; //!< Sign Counter
  1116. } linkSec_t;
  1117. typedef struct
  1118. {
  1119. uint8_t ltk[KEYLEN]; //!< Long Term Key
  1120. uint16_t div; //!< Diversifier
  1121. uint8_t rand[B_RANDOM_NUM_SIZE]; //!< random number
  1122. uint8_t keySize; //!< LTK Key Size
  1123. uint8_t gapBondInvalid;
  1124. } encParams_t;
  1125. typedef struct
  1126. {
  1127. uint8_t connRole; //!< GAP Profile Roles @GAP_PROFILE_ROLE_DEFINES
  1128. uint8_t addrType; //!< Address type of connected device
  1129. uint8_t addr[B_ADDR_LEN]; //!< Other Device's address
  1130. encParams_t encParams;
  1131. } bondEncParams_t;
  1132. typedef struct
  1133. {
  1134. uint8_t taskID; //!< Application that controls the link
  1135. uint16_t connectionHandle; //!< Controller connection handle
  1136. uint8_t stateFlags; //!< LINK_CONNECTED, LINK_AUTHENTICATED...
  1137. uint8_t addrType; //!< Address type of connected device
  1138. uint8_t addr[B_ADDR_LEN]; //!< Other Device's address
  1139. uint8_t connRole; //!< Connection formed as central or peripheral
  1140. uint16_t connInterval; //!< The connection's interval (n * 1.25ms)
  1141. uint16_t connLatency;
  1142. uint16_t connTimeout;
  1143. uint16_t MTU; //!< The connection's MTU size
  1144. linkSec_t sec; //!< Connection Security related items
  1145. encParams_t *pEncParams; //!< pointer to LTK, ediv, rand. if needed.
  1146. uint16_t smEvtID;
  1147. void *pPairingParams;
  1148. void *pAuthLink;
  1149. } linkDBItem_t;
  1150. // function pointer used to register for a status callback
  1151. typedef void (*pfnLinkDBCB_t)( uint16_t connectionHandle, uint8_t changeType );
  1152. // function pointer used to perform specialized link database searches
  1153. typedef void (*pfnPerformFuncCB_t)( linkDBItem_t *pLinkItem );
  1154. /**
  1155. * Attribute Type format (2 or 16 octet UUID).
  1156. */
  1157. typedef struct
  1158. {
  1159. uint8_t len; //!< Length of UUID (2 or 16)
  1160. uint8_t uuid[ATT_UUID_SIZE]; //!< 16 or 128 bit UUID
  1161. } attAttrType_t;
  1162. /**
  1163. * Attribute Type format (2-octet Bluetooth UUID).
  1164. */
  1165. typedef struct
  1166. {
  1167. uint8_t len; //!< Length of UUID (2)
  1168. uint8_t uuid[ATT_BT_UUID_SIZE]; //!< 16 bit UUID
  1169. } attAttrBtType_t;
  1170. /**
  1171. * Error Response format.
  1172. */
  1173. typedef struct
  1174. {
  1175. uint8_t reqOpcode; //!< Request that generated this error response
  1176. uint16_t handle; //!< Attribute handle that generated error response
  1177. uint8_t errCode; //!< Reason why the request has generated error response
  1178. } attErrorRsp_t;
  1179. /**
  1180. * Exchange MTU Request format.
  1181. */
  1182. typedef struct
  1183. {
  1184. uint16_t clientRxMTU; //!< Client receive MTU size
  1185. } attExchangeMTUReq_t;
  1186. /**
  1187. * Exchange MTU Response format.
  1188. */
  1189. typedef struct
  1190. {
  1191. uint16_t serverRxMTU; //!< Server receive MTU size
  1192. } attExchangeMTURsp_t;
  1193. /**
  1194. * Find Information Request format.
  1195. */
  1196. typedef struct
  1197. {
  1198. uint16_t startHandle; //!< First requested handle number (must be first field)
  1199. uint16_t endHandle; //!< Last requested handle number
  1200. } attFindInfoReq_t;
  1201. /**
  1202. * Find Information Response format.
  1203. */
  1204. typedef struct
  1205. {
  1206. uint16_t numInfo; //!< Number of attribute handle-UUID pairs found
  1207. uint8_t format; //!< Format of information data
  1208. uint8_t *pInfo; //!< Information data whose format is determined by format field (4 to ATT_MTU_SIZE-2)
  1209. } attFindInfoRsp_t;
  1210. /**
  1211. * Find By Type Value Request format.
  1212. */
  1213. typedef struct
  1214. {
  1215. uint16_t startHandle; //!< First requested handle number (must be first field)
  1216. uint16_t endHandle; //!< Last requested handle number
  1217. attAttrBtType_t type; //!< 2-octet UUID to find
  1218. uint16_t len; //!< Length of value
  1219. uint8_t *pValue; //!< Attribute value to find (0 to ATT_MTU_SIZE-7)
  1220. } attFindByTypeValueReq_t;
  1221. /**
  1222. * Find By Type Value Response format.
  1223. */
  1224. typedef struct
  1225. {
  1226. uint16_t numInfo; //!< Number of handles information found
  1227. uint8_t *pHandlesInfo; //!< List of 1 or more handles information (4 to ATT_MTU_SIZE-1)
  1228. } attFindByTypeValueRsp_t;
  1229. /**
  1230. * Read By Type Request format.
  1231. */
  1232. typedef struct
  1233. {
  1234. uint16_t startHandle; //!< First requested handle number (must be first field)
  1235. uint16_t endHandle; //!< Last requested handle number
  1236. attAttrType_t type; //!< Requested type (2 or 16 octet UUID)
  1237. } attReadByTypeReq_t;
  1238. /**
  1239. * Read By Type Response format.
  1240. */
  1241. typedef struct
  1242. {
  1243. uint16_t numPairs; //!< Number of attribute handle-UUID pairs found
  1244. uint16_t len; //!< Size of each attribute handle-value pair
  1245. uint8_t *pDataList; //!< List of 1 or more attribute handle-value pairs (2 to ATT_MTU_SIZE-2)
  1246. } attReadByTypeRsp_t;
  1247. /**
  1248. * Read Request format.
  1249. */
  1250. typedef struct
  1251. {
  1252. uint16_t handle; //!< Handle of the attribute to be read (must be first field)
  1253. } attReadReq_t;
  1254. /**
  1255. * Read Response format.
  1256. */
  1257. typedef struct
  1258. {
  1259. uint16_t len; //!< Length of value
  1260. uint8_t *pValue; //!< Value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
  1261. } attReadRsp_t;
  1262. /**
  1263. * Read Blob Req format.
  1264. */
  1265. typedef struct
  1266. {
  1267. uint16_t handle; //!< Handle of the attribute to be read (must be first field)
  1268. uint16_t offset; //!< Offset of the first octet to be read
  1269. } attReadBlobReq_t;
  1270. /**
  1271. * Read Blob Response format.
  1272. */
  1273. typedef struct
  1274. {
  1275. uint16_t len; //!< Length of value
  1276. uint8_t *pValue; //!< Part of the value of the attribute with the handle given (0 to ATT_MTU_SIZE-1)
  1277. } attReadBlobRsp_t;
  1278. /**
  1279. * Read Multiple Request format.
  1280. */
  1281. typedef struct
  1282. {
  1283. uint8_t *pHandles; //!< Set of two or more attribute handles (4 to ATT_MTU_SIZE-1) - must be first field
  1284. uint16_t numHandles; //!< Number of attribute handles
  1285. } attReadMultiReq_t;
  1286. /**
  1287. * Read Multiple Response format.
  1288. */
  1289. typedef struct
  1290. {
  1291. uint16_t len; //!< Length of values
  1292. uint8_t *pValues; //!< Set of two or more values (0 to ATT_MTU_SIZE-1)
  1293. } attReadMultiRsp_t;
  1294. /**
  1295. * Read By Group Type Request format.
  1296. */
  1297. typedef struct
  1298. {
  1299. uint16_t startHandle; //!< First requested handle number (must be first field)
  1300. uint16_t endHandle; //!< Last requested handle number
  1301. attAttrType_t type; //!< Requested group type (2 or 16 octet UUID)
  1302. } attReadByGrpTypeReq_t;
  1303. /**
  1304. * Read By Group Type Response format.
  1305. */
  1306. typedef struct
  1307. {
  1308. uint16_t numGrps; //!< Number of attribute handle, end group handle and value sets found
  1309. uint16_t len; //!< Length of each attribute handle, end group handle and value set
  1310. uint8_t *pDataList; //!< List of 1 or more attribute handle, end group handle and value (4 to ATT_MTU_SIZE-2)
  1311. } attReadByGrpTypeRsp_t;
  1312. /**
  1313. * Write Request format.
  1314. */
  1315. typedef struct
  1316. {
  1317. uint16_t handle; //!< Handle of the attribute to be written (must be first field)
  1318. uint16_t len; //!< Length of value
  1319. uint8_t *pValue; //!< Value of the attribute to be written (0 to ATT_MTU_SIZE-3)
  1320. uint8_t sig; //!< Authentication Signature status (not included (0), valid (1), invalid (2))
  1321. uint8_t cmd; //!< Command Flag
  1322. } attWriteReq_t;
  1323. /**
  1324. * Prepare Write Request format.
  1325. */
  1326. typedef struct
  1327. {
  1328. uint16_t handle; //!< Handle of the attribute to be written (must be first field)
  1329. uint16_t offset; //!< Offset of the first octet to be written
  1330. uint16_t len; //!< Length of value
  1331. uint8_t *pValue; //!< Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5) - must be allocated
  1332. } attPrepareWriteReq_t;
  1333. /**
  1334. * Prepare Write Response format.
  1335. */
  1336. typedef struct
  1337. {
  1338. uint16_t handle; //!< Handle of the attribute that has been read
  1339. uint16_t offset; //!< Offset of the first octet to be written
  1340. uint16_t len; //!< Length of value
  1341. uint8_t *pValue; //!< Part of the value of the attribute to be written (0 to ATT_MTU_SIZE-5)
  1342. } attPrepareWriteRsp_t;
  1343. /**
  1344. * Execute Write Request format.
  1345. */
  1346. typedef struct
  1347. {
  1348. uint8_t flags; //!< 0x00 - cancel all prepared writes.
  1349. //!< 0x01 - immediately write all pending prepared values.
  1350. } attExecuteWriteReq_t;
  1351. /**
  1352. * Handle Value Notification format.
  1353. */
  1354. typedef struct
  1355. {
  1356. uint16_t handle; //!< Handle of the attribute that has been changed (must be first field)
  1357. uint16_t len; //!< Length of value
  1358. uint8_t *pValue; //!< Current value of the attribute (0 to ATT_MTU_SIZE-3)
  1359. } attHandleValueNoti_t;
  1360. /**
  1361. * Handle Value Indication format.
  1362. */
  1363. typedef struct
  1364. {
  1365. uint16_t handle; //!< Handle of the attribute that has been changed (must be first field)
  1366. uint16_t len; //!< Length of value
  1367. uint8_t *pValue; //!< Current value of the attribute (0 to ATT_MTU_SIZE-3)
  1368. } attHandleValueInd_t;
  1369. /**
  1370. * ATT Flow Control Violated Event message format. This message is sent to the
  1371. * app by the local ATT Server or Client when a sequential ATT Request-Response
  1372. * or Indication-Confirmation protocol flow control is violated for a connection.
  1373. * All subsequent ATT Requests and Indications received by the local ATT Server
  1374. * and Client respectively will be dropped.
  1375. *
  1376. * This message is to inform the app (that has registered with GAP by calling
  1377. * GAP_RegisterForMsgs()) in case it wants to drop the connection.
  1378. */
  1379. typedef struct
  1380. {
  1381. uint8_t opcode; //!< opcode of message that caused flow control violation
  1382. uint8_t pendingOpcode; //!< opcode of pending message
  1383. } attFlowCtrlViolatedEvt_t;
  1384. /**
  1385. * ATT MTU Updated Event message format. This message is sent to the app
  1386. * by the local ATT Server or Client when the ATT MTU size is updated for a
  1387. * connection. The default ATT MTU size is 23 octets.
  1388. *
  1389. * This message is to inform the app (that has registered with GAP by calling
  1390. * GAP_RegisterForMsgs()) about the new ATT MTU size negotiated for a connection.
  1391. */
  1392. typedef struct
  1393. {
  1394. uint16_t MTU; //!< new MTU size
  1395. } attMtuUpdatedEvt_t;
  1396. /**
  1397. * ATT Message format. It's a union of all attribute protocol messages and
  1398. * locally-generated events used between the attribute protocol and upper
  1399. * layer profile/application.
  1400. */
  1401. typedef union
  1402. {
  1403. // Request messages
  1404. attExchangeMTUReq_t exchangeMTUReq; //!< ATT Exchange MTU Request
  1405. attFindInfoReq_t findInfoReq; //!< ATT Find Information Request
  1406. attFindByTypeValueReq_t findByTypeValueReq; //!< ATT Find By Type Value Request
  1407. attReadByTypeReq_t readByTypeReq; //!< ATT Read By Type Request
  1408. attReadReq_t readReq; //!< ATT Read Request
  1409. attReadBlobReq_t readBlobReq; //!< ATT Read Blob Request
  1410. attReadMultiReq_t readMultiReq; //!< ATT Read Multiple Request
  1411. attReadByGrpTypeReq_t readByGrpTypeReq; //!< ATT Read By Group Type Request
  1412. attWriteReq_t writeReq; //!< ATT Write Request
  1413. attPrepareWriteReq_t prepareWriteReq; //!< ATT Prepare Write Request
  1414. attExecuteWriteReq_t executeWriteReq; //!< ATT Execute Write Request
  1415. // Response messages
  1416. attErrorRsp_t errorRsp; //!< ATT Error Response
  1417. attExchangeMTURsp_t exchangeMTURsp; //!< ATT Exchange MTU Response
  1418. attFindInfoRsp_t findInfoRsp; //!< ATT Find Information Response
  1419. attFindByTypeValueRsp_t findByTypeValueRsp; //!< ATT Find By Type Value Response
  1420. attReadByTypeRsp_t readByTypeRsp; //!< ATT Read By Type Response
  1421. attReadRsp_t readRsp; //!< ATT Read Response
  1422. attReadBlobRsp_t readBlobRsp; //!< ATT Read Blob Response
  1423. attReadMultiRsp_t readMultiRsp; //!< ATT Read Multiple Response
  1424. attReadByGrpTypeRsp_t readByGrpTypeRsp; //!< ATT Read By Group Type Response
  1425. attPrepareWriteRsp_t prepareWriteRsp; //!< ATT Prepare Write Response
  1426. // Indication and Notification messages
  1427. attHandleValueNoti_t handleValueNoti; //!< ATT Handle Value Notification
  1428. attHandleValueInd_t handleValueInd; //!< ATT Handle Value Indication
  1429. // Locally-generated event messages
  1430. attFlowCtrlViolatedEvt_t flowCtrlEvt; //!< ATT Flow Control Violated Event
  1431. attMtuUpdatedEvt_t mtuEvt; //!< ATT MTU Updated Event
  1432. } attMsg_t;
  1433. /**
  1434. * GATT Find By Type Value Request format.
  1435. */
  1436. typedef struct
  1437. {
  1438. uint16_t startHandle; //!< First requested handle number (must be first field)
  1439. uint16_t endHandle; //!< Last requested handle number
  1440. attAttrType_t value; //!< Primary service UUID value (2 or 16 octets)
  1441. } gattFindByTypeValueReq_t;
  1442. /**
  1443. * GATT Read By Type Request format.
  1444. */
  1445. typedef struct
  1446. {
  1447. uint8_t discCharsByUUID; //!< Whether this is a GATT Discover Characteristics by UUID sub-procedure
  1448. attReadByTypeReq_t req; //!< Read By Type Request
  1449. } gattReadByTypeReq_t;
  1450. /**
  1451. * GATT Write Long Request format. Do not change the order of the members.
  1452. */
  1453. typedef struct
  1454. {
  1455. uint8_t reliable; //!< Whether reliable writes requested (always FALSE for Write Long)
  1456. attPrepareWriteReq_t req; //!< ATT Prepare Write Request
  1457. uint16_t lastOffset; //!< Offset of last Prepare Write Request sent
  1458. } gattWriteLongReq_t;
  1459. /**
  1460. * GATT Reliable Writes Request format. Do not change the order of the members.
  1461. */
  1462. typedef struct
  1463. {
  1464. uint8_t reliable; //!< Whether reliable writes requested (always TRUE for Reliable Writes)
  1465. attPrepareWriteReq_t *pReqs; //!< Array of Prepare Write Requests (must be allocated)
  1466. uint8_t numReqs; //!< Number of Prepare Write Requests
  1467. uint8_t index; //!< Index of last Prepare Write Request sent
  1468. uint8_t flags; //!< 0x00 - cancel all prepared writes.
  1469. //!< 0x01 - immediately write all pending prepared values.
  1470. } gattReliableWritesReq_t;
  1471. /**
  1472. * GATT Message format. It's a union of all attribute protocol/profile messages
  1473. * and locally-generated events used between the attribute protocol/profile and
  1474. * upper layer application.
  1475. */
  1476. typedef union
  1477. {
  1478. // Request messages
  1479. attExchangeMTUReq_t exchangeMTUReq; //!< ATT Exchange MTU Request
  1480. attFindInfoReq_t findInfoReq; //!< ATT Find Information Request
  1481. attFindByTypeValueReq_t findByTypeValueReq; //!< ATT Find By Type Value Request
  1482. attReadByTypeReq_t readByTypeReq; //!< ATT Read By Type Request
  1483. attReadReq_t readReq; //!< ATT Read Request
  1484. attReadBlobReq_t readBlobReq; //!< ATT Read Blob Request
  1485. attReadMultiReq_t readMultiReq; //!< ATT Read Multiple Request
  1486. attReadByGrpTypeReq_t readByGrpTypeReq; //!< ATT Read By Group Type Request
  1487. attWriteReq_t writeReq; //!< ATT Write Request
  1488. attPrepareWriteReq_t prepareWriteReq; //!< ATT Prepare Write Request
  1489. attExecuteWriteReq_t executeWriteReq; //!< ATT Execute Write Request
  1490. gattFindByTypeValueReq_t gattFindByTypeValueReq;//!< GATT Find By Type Value Request
  1491. gattReadByTypeReq_t gattReadByTypeReq; //!< GATT Read By Type Request
  1492. gattWriteLongReq_t gattWriteLongReq; //!< GATT Long Write Request
  1493. gattReliableWritesReq_t gattReliableWritesReq; //!< GATT Reliable Writes Request
  1494. // Response messages
  1495. attErrorRsp_t errorRsp; //!< ATT Error Response
  1496. attExchangeMTURsp_t exchangeMTURsp; //!< ATT Exchange MTU Response
  1497. attFindInfoRsp_t findInfoRsp; //!< ATT Find Information Response
  1498. attFindByTypeValueRsp_t findByTypeValueRsp; //!< ATT Find By Type Value Response
  1499. attReadByTypeRsp_t readByTypeRsp; //!< ATT Read By Type Response
  1500. attReadRsp_t readRsp; //!< ATT Read Response
  1501. attReadBlobRsp_t readBlobRsp; //!< ATT Read Blob Response
  1502. attReadMultiRsp_t readMultiRsp; //!< ATT Read Multiple Response
  1503. attReadByGrpTypeRsp_t readByGrpTypeRsp; //!< ATT Read By Group Type Response
  1504. attPrepareWriteRsp_t prepareWriteRsp; //!< ATT Prepare Write Response
  1505. // Indication and Notification messages
  1506. attHandleValueNoti_t handleValueNoti; //!< ATT Handle Value Notification
  1507. attHandleValueInd_t handleValueInd; //!< ATT Handle Value Indication
  1508. // Locally-generated event messages
  1509. attFlowCtrlViolatedEvt_t flowCtrlEvt; //!< ATT Flow Control Violated Event
  1510. attMtuUpdatedEvt_t mtuEvt; //!< ATT MTU Updated Event
  1511. } gattMsg_t;
  1512. /**
  1513. * GATT tmos GATT_MSG_EVENT message format. This message is used to forward an
  1514. * incoming attribute protocol/profile message up to upper layer application.
  1515. */
  1516. typedef struct
  1517. {
  1518. tmos_event_hdr_t hdr; //!< GATT_MSG_EVENT and status
  1519. uint16_t connHandle; //!< Connection message was received on
  1520. uint8_t method; //!< Type of message
  1521. gattMsg_t msg; //!< Attribute protocol/profile message
  1522. } gattMsgEvent_t;
  1523. /**
  1524. * GATT Attribute Type format.
  1525. */
  1526. typedef struct
  1527. {
  1528. uint8_t len; //!< Length of UUID (2 or 16)
  1529. const uint8_t *uuid; //!< Pointer to UUID
  1530. } gattAttrType_t;
  1531. /**
  1532. * GATT Attribute format.
  1533. */
  1534. typedef struct attAttribute_t
  1535. {
  1536. gattAttrType_t type; //!< Attribute type (2 or 16 octet UUIDs)
  1537. uint8_t permissions; //!< Attribute permissions
  1538. uint16_t handle; //!< Attribute handle - assigned internally by attribute server
  1539. uint8_t *pValue; //!< Attribute value - encoding of the octet array is defined in
  1540. //!< the applicable profile. The maximum length of an attribute
  1541. //!< value shall be 512 octets.
  1542. } gattAttribute_t;
  1543. /**
  1544. * GATT Service format.
  1545. */
  1546. typedef struct
  1547. {
  1548. uint16_t numAttrs; //!< Number of attributes in attrs
  1549. uint8_t encKeySize; //!< Minimum encryption key size required by service (7-16 bytes)
  1550. /** Array of attribute records.
  1551. * note: The list must start with a Service attribute followed by
  1552. * all attributes associated with this Service attribute.
  1553. */
  1554. gattAttribute_t *attrs;
  1555. } gattService_t;
  1556. /**
  1557. * @brief Callback function prototype to read an attribute value.
  1558. *
  1559. * @note blePending can be returned ONLY for the following
  1560. * read operations:
  1561. * - Read Request: ATT_READ_REQ
  1562. * - Read Blob Request: ATT_READ_BLOB_REQ
  1563. *
  1564. * @note If blePending is returned then it's the responsibility of the application to respond to
  1565. * ATT_READ_REQ and ATT_READ_BLOB_REQ message with ATT_READ_RSP and ATT_READ_BLOB_RSP
  1566. * message respectively.
  1567. *
  1568. * @note Payload 'pValue' used with ATT_READ_RSP and ATT_READ_BLOB_RSP must be allocated using GATT_bm_alloc().
  1569. *
  1570. * @param connHandle - connection request was received on
  1571. * @param pAttr - pointer to attribute
  1572. * @param pValue - pointer to data to be read (to be returned)
  1573. * @param pLen - length of data (to be returned)
  1574. * @param offset - offset of the first octet to be read
  1575. * @param maxLen - maximum length of data to be read
  1576. * @param method - type of read message
  1577. *
  1578. * @return SUCCESS: Read was successfully.<BR>
  1579. * blePending: A response is pending for this client.<BR>
  1580. * Error, otherwise: ref ATT_ERR_CODE_DEFINES.<BR>
  1581. */
  1582. typedef uint8_t (*pfnGATTReadAttrCB_t)( uint16_t connHandle, gattAttribute_t *pAttr, uint8_t *pValue,
  1583. uint16_t *pLen, uint16_t offset, uint16_t maxLen, uint8_t method );
  1584. /**
  1585. * @brief Callback function prototype to write an attribute value.
  1586. *
  1587. * @note blePending can be returned ONLY for the following
  1588. * write operations:
  1589. * - Write Request: ATT_WRITE_REQ
  1590. * - Write Command: ATT_WRITE_CMD
  1591. * - Write Long: ATT_EXECUTE_WRITE_REQ
  1592. * - Reliable Writes: Multiple ATT_PREPARE_WRITE_REQ followed by one final ATT_EXECUTE_WRITE_REQ
  1593. *
  1594. * @note If blePending is returned then it's the responsibility of the application to 1) respond to
  1595. * ATT_WRITE_REQ and ATT_EXECUTE_WRITE_REQ message with ATT_WRITE_RSP and ATT_EXECUTE_WRITE_RSP
  1596. * message respectively, and 2) free each request payload 'pValue' using BM_free().
  1597. *
  1598. * @note Write Command (ATT_WRITE_CMD) does NOT require a response message.
  1599. *
  1600. * @param connHandle - connection request was received on
  1601. * @param pAttr - pointer to attribute
  1602. * @param pValue - pointer to data to be written
  1603. * @param pLen - length of data
  1604. * @param offset - offset of the first octet to be written
  1605. * @param method - type of write message
  1606. *
  1607. * @return SUCCESS: Write was successfully.<BR>
  1608. * blePending: A response is pending for this client.<BR>
  1609. * Error, otherwise: ref ATT_ERR_CODE_DEFINES.<BR>
  1610. */
  1611. typedef uint8_t (*pfnGATTWriteAttrCB_t)( uint16_t connHandle, gattAttribute_t *pAttr, uint8_t *pValue,
  1612. uint16_t len, uint16_t offset, uint8_t method );
  1613. /**
  1614. * @brief Callback function prototype to authorize a Read or Write operation
  1615. * on a given attribute.
  1616. *
  1617. * @param connHandle - connection request was received on
  1618. * @param pAttr - pointer to attribute
  1619. * @param opcode - request opcode (ATT_READ_REQ or ATT_WRITE_REQ)
  1620. *
  1621. * @return SUCCESS: Operation authorized.<BR>
  1622. * ATT_ERR_INSUFFICIENT_AUTHOR: Authorization required.<BR>
  1623. */
  1624. typedef bStatus_t (*pfnGATTAuthorizeAttrCB_t)( uint16_t connHandle, gattAttribute_t *pAttr,
  1625. uint8_t opcode );
  1626. /**
  1627. * GATT Structure for Client Characteristic Configuration.
  1628. */
  1629. typedef struct
  1630. {
  1631. uint16_t connHandle; //!< Client connection handle
  1632. uint8_t value; //!< Characteristic configuration value for this client
  1633. } gattCharCfg_t;
  1634. /**
  1635. * GATT Structure for service callback functions - must be setup by the application
  1636. * and used when GATTServApp_RegisterService() is called.
  1637. */
  1638. typedef struct
  1639. {
  1640. pfnGATTReadAttrCB_t pfnReadAttrCB; //!< Read callback function pointer
  1641. pfnGATTWriteAttrCB_t pfnWriteAttrCB; //!< Write callback function pointer
  1642. pfnGATTAuthorizeAttrCB_t pfnAuthorizeAttrCB; //!< Authorization callback function pointer
  1643. } gattServiceCBs_t;
  1644. /*************************************gap**************************************/
  1645. /**
  1646. * Connection parameters for the peripheral device. These numbers are used
  1647. * to compare against connection events and request connection parameter
  1648. * updates with the central.
  1649. */
  1650. typedef struct
  1651. {
  1652. uint16_t intervalMin; //!< Minimum value for the connection event (interval. 0x0006 - 0x0C80 * 1.25ms)
  1653. uint16_t intervalMax; //!< Maximum value for the connection event (interval. 0x0006 - 0x0C80 * 1.25ms)
  1654. uint16_t latency; //!< Number of LL latency connection events (0x0000 - 0x03e8)
  1655. uint16_t timeout; //!< Connection Timeout (0x000A - 0x0C80 * 10ms)
  1656. } gapPeriConnectParams_t;
  1657. typedef struct
  1658. {
  1659. uint8_t sessionKey[16]; //!< The shared session key.
  1660. uint8_t IV[8]; //!< The initialization vector.
  1661. } gapEncDataKey_t;
  1662. /**
  1663. * GAP event header format.
  1664. */
  1665. typedef struct
  1666. {
  1667. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1668. uint8_t opcode; //!< GAP type of command. Ref: @ref GAP_MSG_EVENT_DEFINES
  1669. } gapEventHdr_t;
  1670. /**
  1671. * GAP_DEVICE_INIT_DONE_EVENT message format. This message is sent to the
  1672. * app when the Device Initialization is done [initiated by calling
  1673. * GAP_DeviceInit()].
  1674. */
  1675. typedef struct
  1676. {
  1677. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1678. uint8_t opcode; //!< GAP_DEVICE_INIT_DONE_EVENT
  1679. uint8_t devAddr[B_ADDR_LEN]; //!< Device's BD_ADDR
  1680. uint16_t dataPktLen; //!< HC_LE_Data_Packet_Length
  1681. uint8_t numDataPkts; //!< HC_Total_Num_LE_Data_Packets
  1682. } gapDeviceInitDoneEvent_t;
  1683. /**
  1684. * GAP_SIGNATURE_UPDATED_EVENT message format. This message is sent to the
  1685. * app when the signature counter has changed. This message is to inform the
  1686. * application in case it wants to save it to be restored on reboot or reconnect.
  1687. * This message is sent to update a connection's signature counter and to update
  1688. * this device's signature counter. If devAddr == BD_ADDR, then this message pertains
  1689. * to this device.
  1690. */
  1691. typedef struct
  1692. {
  1693. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1694. uint8_t opcode; //!< GAP_SIGNATURE_UPDATED_EVENT
  1695. uint8_t addrType; //!< Device's address type for devAddr
  1696. uint8_t devAddr[B_ADDR_LEN]; //!< Device's BD_ADDR, could be own address
  1697. uint32_t signCounter; //!< new Signed Counter
  1698. } gapSignUpdateEvent_t;
  1699. /**
  1700. * GAP_DEVICE_INFO_EVENT message format. This message is sent to the
  1701. * app during a Device Discovery Request, when a new advertisement or scan
  1702. * response is received.
  1703. */
  1704. typedef struct
  1705. {
  1706. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1707. uint8_t opcode; //!< GAP_DEVICE_INFO_EVENT
  1708. uint8_t eventType; //!< Advertisement Type: @ref GAP_ADVERTISEMENT_REPORT_TYPE_DEFINES
  1709. uint8_t addrType; //!< address type: @ref GAP_ADDR_TYPE_DEFINES
  1710. uint8_t addr[B_ADDR_LEN]; //!< Address of the advertisement or SCAN_RSP
  1711. int8_t rssi; //!< Advertisement or SCAN_RSP RSSI
  1712. uint8_t dataLen; //!< Length (in bytes) of the data field (evtData)
  1713. uint8_t *pEvtData; //!< Data field of advertisement or SCAN_RSP
  1714. } gapDeviceInfoEvent_t;
  1715. /**
  1716. * GAP_DIRECT_DEVICE_INFO_EVENT message format. This message is sent to the
  1717. * app during a Device Discovery Request, when a new advertisement or scan
  1718. * response is received.
  1719. */
  1720. typedef struct
  1721. {
  1722. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1723. uint8_t opcode; //!< GAP_DIRECT_DEVICE_INFO_EVENT
  1724. uint8_t eventType; //!< Advertisement Type: @ref GAP_ADVERTISEMENT_REPORT_TYPE_DEFINES
  1725. uint8_t addrType; //!< address type: @ref GAP_ADDR_TYPE_DEFINES
  1726. uint8_t addr[B_ADDR_LEN]; //!< Address of the advertisement or SCAN_RSP
  1727. uint8_t directAddrType; //!< public or random address type
  1728. uint8_t directAddr[B_ADDR_LEN]; //!< device address
  1729. int8_t rssi; //!< Advertisement or SCAN_RSP RSSI
  1730. } gapDirectDeviceInfoEvent_t;
  1731. /**
  1732. * GAP_EXT_ADV_DEVICE_INFO_EVENT message format. This message is sent to the
  1733. * app during a Device Discovery Request, when a new advertisement or scan
  1734. * response is received.
  1735. */
  1736. typedef struct
  1737. {
  1738. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1739. uint8_t opcode; //!< GAP_EXT_ADV_DEVICE_INFO_EVENT
  1740. uint8_t eventType; //!< Advertisement Type: @ref GAP_ADVERTISEMENT_REPORT_TYPE_DEFINES
  1741. uint8_t addrType; //!< address type: @ref GAP_ADDR_TYPE_DEFINES
  1742. uint8_t addr[B_ADDR_LEN]; //!< Address of the advertisement or SCAN_RSP
  1743. uint8_t primaryPHY; //!< Advertiser PHY on the primary advertising channel
  1744. uint8_t secondaryPHY; //!< Advertiser PHY on the secondary advertising channel
  1745. uint8_t advertisingSID; //!< Value of the Advertising SID subfield in the ADI field of the PDU
  1746. int8_t txPower; //!< Advertisement or SCAN_RSP power
  1747. int8_t rssi; //!< Advertisement or SCAN_RSP RSSI
  1748. uint16_t periodicAdvInterval; //!< the interval of periodic advertising
  1749. uint8_t directAddressType; //!< public or random address type
  1750. uint8_t directAddress[B_ADDR_LEN]; //!< device address
  1751. uint8_t dataLen; //!< Length (in bytes) of the data field (evtData)
  1752. uint8_t *pEvtData; //!< Data field of advertisement or SCAN_RSP
  1753. } gapExtAdvDeviceInfoEvent_t;
  1754. /**
  1755. * Type of device discovery (Scan) to perform.
  1756. */
  1757. typedef struct
  1758. {
  1759. uint8_t taskID; //!< Requesting App's Task ID, used to return results
  1760. uint8_t mode; //!< Discovery Mode: @ref GAP_DEVDISC_MODE_DEFINES
  1761. uint8_t activeScan; //!< TRUE for active scanning
  1762. uint8_t whiteList; //!< TRUE to only allow advertisements from devices in the white list.
  1763. } gapDevDiscReq_t;
  1764. /**
  1765. * Type of device.
  1766. */
  1767. typedef struct
  1768. {
  1769. uint8_t eventType; //!< Indicates advertising event type used by the advertiser: @ref GAP_ADVERTISEMENT_REPORT_TYPE_DEFINES
  1770. uint8_t addrType; //!< Address Type: @ref GAP_ADDR_TYPE_DEFINES
  1771. uint8_t addr[B_ADDR_LEN]; //!< Device's Address
  1772. } gapDevRec_t;
  1773. /**
  1774. * GAP_DEVICE_DISCOVERY_EVENT message format. This message is sent to the
  1775. * Application after a scan is performed.
  1776. */
  1777. typedef struct
  1778. {
  1779. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1780. uint8_t opcode; //!< GAP_DEVICE_DISCOVERY_EVENT
  1781. uint8_t numDevs; //!< Number of devices found during scan
  1782. gapDevRec_t *pDevList; //!< array of device records
  1783. } gapDevDiscEvent_t;
  1784. /**
  1785. * GAP_MAKE_DISCOVERABLE_DONE_EVENT message format. This message is sent to the
  1786. * app when the Advertise config is complete.
  1787. */
  1788. typedef struct
  1789. {
  1790. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1791. uint8_t opcode; //!< GAP_MAKE_DISCOVERABLE_DONE_EVENT
  1792. } gapMakeDiscoverableRspEvent_t;
  1793. /**
  1794. * GAP_END_DISCOVERABLE_DONE_EVENT message format. This message is sent to the
  1795. * app when the Advertising has stopped.
  1796. */
  1797. typedef struct
  1798. {
  1799. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1800. uint8_t opcode; //!< GAP_END_DISCOVERABLE_DONE_EVENT
  1801. } gapEndDiscoverableRspEvent_t;
  1802. /**
  1803. * GAP_PERIODIC_ADVERTISING_DONE_EVENT message format. This message is sent to the
  1804. * app when the Periodic Advertising config is complete.
  1805. */
  1806. typedef struct
  1807. {
  1808. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1809. uint8_t opcode; //!< GAP_PERIODIC_ADVERTISING_DONE_EVENT
  1810. } gapMakePeriodicRspEvent_t;
  1811. /**
  1812. * GAP_END_PERIODIC_ADV_DONE_EVENT message format. This message is sent to the
  1813. * app when the Periodic Advertising disable is complete.
  1814. */
  1815. typedef struct
  1816. {
  1817. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1818. uint8_t opcode; //!< GAP_END_PERIODIC_ADV_DONE_EVENT
  1819. } gapEndPeriodicRspEvent_t;
  1820. /**
  1821. * GAP_SYNC_ESTABLISHED_EVENT message format. This message is sent to the
  1822. * app when the Periodic Advertising Sync Establish is complete.
  1823. */
  1824. typedef struct
  1825. {
  1826. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1827. uint8_t opcode; //!< GAP_SYNC_ESTABLISHED_EVENT
  1828. uint8_t status; //!< Periodic advertising sync status
  1829. uint16_t syncHandle; //!< Identifying the periodic advertising train
  1830. uint8_t advertisingSID; //!< Value of the Advertising SID subfield in the ADI field of the PDU
  1831. uint8_t devAddrType; //!< Device address type: @ref GAP_ADDR_TYPE_DEFINES
  1832. uint8_t devAddr[B_ADDR_LEN]; //!< Device address of sync
  1833. uint8_t advertisingPHY; //!< Advertiser PHY
  1834. uint16_t periodicInterval; //!< Periodic advertising interval
  1835. uint8_t clockAccuracy; //!< Clock Accuracy
  1836. uint8_t numSubevents; //!< Number of subevents.0x00-No subevents
  1837. uint8_t subInterval; //!< Subevent interval.0x00-No subevents
  1838. uint8_t rspSlotDelay; //!< Response slot delay.0x00-No response slots
  1839. uint8_t rspSlotSpacing; //!< Response slot spacing.0x00-No response slots
  1840. } gapSyncEstablishedEvent_t;
  1841. /**
  1842. * GAP_PERIODIC_ADV_DEVICE_INFO_EVENT message format. This message is sent to the
  1843. * app during Periodic Advertising Sync, when received a Periodic Advertising packet
  1844. */
  1845. typedef struct
  1846. {
  1847. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1848. uint8_t opcode; //!< GAP_PERIODIC_ADV_DEVICE_INFO_EVENT
  1849. uint16_t syncHandle; //!< Identifying the periodic advertising train
  1850. int8_t txPower; //!< Periodic advertising tx power,Units: dBm
  1851. int8_t rssi; //!< Periodic advertising rssi,Units: dBm
  1852. uint8_t unUsed;
  1853. uint16_t eventCounter; //!< The value of paEventCounter for the reported periodic advertising packet
  1854. uint8_t subevent; //!< The subevent number. 0xFF: No subevents
  1855. uint8_t dataStatus; //!< Data complete
  1856. uint8_t dataLength; //!< Length (in bytes) of the data field (evtData)
  1857. uint8_t *pEvtData; //!< Data field of periodic advertising data
  1858. } gapPeriodicAdvDeviceInfoEvent_t;
  1859. /**
  1860. * GAP_SYNC_LOST_EVENT message format. This message is sent to the
  1861. * app when the Periodic Advertising Sync timeout period.
  1862. */
  1863. typedef struct
  1864. {
  1865. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1866. uint8_t opcode; //!< GAP_SYNC_LOST_EVENT
  1867. uint16_t syncHandle; //!< Identifying the periodic advertising train
  1868. } gapSyncLostEvent_t;
  1869. #define PKT_TRANSMITTED 0x00
  1870. #define PKT_NOT_TRANSMITTED 0x01
  1871. typedef struct
  1872. {
  1873. uint8_t taskID; //!< set periodic advertising task ID
  1874. uint8_t enable; //!< bit0 Enable periodic advertising
  1875. //!< bit1 Include the ADI field in AUX_SYNC_IND PDUs
  1876. uint8_t advHandle; //!< Used to identify a periodic advertising train
  1877. uint16_t advIntervalMin; //!< Minimum advertising interval for periodic advertising.Time = N × 1.25ms.Time Range: 7.5ms to 81.91875s
  1878. uint16_t advIntervalMax; //!< Maximum advertising interval for periodic advertising.Time = N × 1.25ms.Time Range: 7.5ms to 81.91875s
  1879. uint16_t advProperties; //!< bit6 Include TxPower in the advertising PDU
  1880. uint8_t numSubevents; //!< Number of subevents.
  1881. uint8_t subInterval; //!< Interval between subevents.Time = N × 1.25ms.Time Range: 7.5 ms to 318.75 ms
  1882. uint8_t rspSlotDelay; //!< Time between the advertising packet in a subevent and the first response slot.Time = N × 1.25 ms.Time Range: 1.25ms to 317.5ms
  1883. uint8_t rspSlotSpacing; //!< Time between response slots.Time = N × 0.125ms.Time Range: 0.25ms to 31.875ms
  1884. uint8_t numRspSlots; //!< Number of subevent response slots.Range: 0x01 to 0xFF
  1885. }gapPawrSetParam_t;
  1886. typedef struct
  1887. {
  1888. uint8_t subevent; //!< The subevent index of the data contained in this command.
  1889. uint8_t rspSlotStart; //!< The first response slots to be used in this subevent.
  1890. uint8_t rspSlotCount; //!< The number of response slots to be used.
  1891. uint8_t dataLength; //!< The number of octets in the Subevent_Data parameter.
  1892. uint16_t rspMaxLength; //!<
  1893. uint8_t *pData; //!< Advertising data
  1894. }gapPawrSetData_t;
  1895. typedef struct
  1896. {
  1897. uint16_t syncHandle; //!< identifying the PAwR train
  1898. uint16_t reqEvent; //!< The value of paEventCounter the periodic advertising packet that the Host is responding to
  1899. uint8_t reqSubevent; //!< The subevent for the periodic advertising packet that the Host is responding to
  1900. uint8_t rspSubevent; //!< Used to identify the subevent of the PAwR train.
  1901. uint8_t rspSlot; //!< Used to identify the response slot of the PAwR train.
  1902. uint8_t rspDataLength;//!< The number of octets in the Response_Data parameter.
  1903. uint8_t *pRspData; //!< Response data
  1904. } gapPawrSetResponseData_t;
  1905. typedef struct
  1906. {
  1907. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1908. uint8_t opcode; //!< GAP_PERI_ADV_SUBEVENT_DATA_REQ_EVENT
  1909. uint8_t advHandle;
  1910. uint8_t subeventStart;
  1911. uint8_t subeventDataCount;
  1912. } gapPawrDataRequestEvent_t;
  1913. typedef struct
  1914. {
  1915. uint8_t txPower;
  1916. int8_t rssi;
  1917. uint8_t cteType;
  1918. uint8_t rspSlot;
  1919. uint8_t dataStatus;
  1920. uint8_t dataLength;
  1921. uint8_t *pData;
  1922. }pawrResponseInfo_t;
  1923. typedef struct
  1924. {
  1925. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1926. uint8_t opcode; //!< GAP_PERI_ADV_RESPONSE_REPORT_EVENT
  1927. uint8_t advHandle;
  1928. uint8_t subevent;
  1929. uint8_t txStatus; //!< 0x00 packet was transmitted. 0x01 packet was not transmitted.
  1930. uint8_t numResponses;
  1931. pawrResponseInfo_t *pList;
  1932. } gapPawrResponseEvent_t;
  1933. typedef struct
  1934. {
  1935. uint8_t advHandle; //!< Used to identify a periodic advertising train
  1936. uint8_t subevent; //!< Subevent where the connection request is to be sent.
  1937. uint8_t ownAddrType;
  1938. uint8_t peerAddrType;
  1939. uint8_t peerAddr[6];
  1940. uint16_t connIntervalMin;
  1941. uint16_t connIntervalMax;
  1942. uint16_t maxLatency;
  1943. uint16_t supervisionTimeout;
  1944. } gapPawrCreateConnection_t;
  1945. /**
  1946. * GAP_SCAN_REQUEST_EVENT message format. This message is sent to the
  1947. * app when the advertiser receives a SCAN_REQ PDU or an AUX_SCAN_REQ PDU
  1948. */
  1949. typedef struct
  1950. {
  1951. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1952. uint8_t opcode; //!< GAP_SCAN_REQUEST_EVENT
  1953. uint8_t advHandle; //!< identifying the periodic advertising train
  1954. uint8_t scannerAddrType; //!< the type of the address
  1955. uint8_t scannerAddr[B_ADDR_LEN];//!< the address of scanner device
  1956. } gapScanReqReseiveEvent_t;
  1957. /**
  1958. * GAP_CONNECTIONESS_CTE_DONE_EVENT message format. This message is sent to the
  1959. * app when the Connectionless CTE Transmit config is complete.
  1960. */
  1961. typedef struct
  1962. {
  1963. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1964. uint8_t opcode; //!< GAP_CONNECTIONESS_CTE_DONE_EVENT
  1965. } gapMakeConnectionlessCTERspEvent_t;
  1966. /**
  1967. * GAP_END_PERIODIC_ADV_DONE_EVENT message format. This message is sent to the
  1968. * app when the Periodic Advertising disable is complete.
  1969. */
  1970. typedef struct
  1971. {
  1972. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1973. uint8_t opcode; //!< GAP_END_CONNECTIONESS_CTE_DONE_EVENT
  1974. } gapEndConnectionlessCTERspEvent_t;
  1975. /**
  1976. * GAP_ADV_DATA_UPDATE_DONE_EVENT message format. This message is sent to the
  1977. * app when Advertising Data Update is complete.
  1978. */
  1979. typedef struct
  1980. {
  1981. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1982. uint8_t opcode; //!< GAP_ADV_DATA_UPDATE_DONE_EVENT
  1983. uint8_t adType; //!< TRUE if advertising data, FALSE if SCAN_RSP
  1984. } gapAdvDataUpdateEvent_t;
  1985. /**
  1986. * GAP_LINK_ESTABLISHED_EVENT message format. This message is sent to the app
  1987. * when the link request is complete.<BR>
  1988. * <BR>
  1989. * For an Observer, this message is sent to complete the Establish Link Request.<BR>
  1990. * For a Peripheral, this message is sent to indicate that a link has been created.
  1991. */
  1992. typedef struct
  1993. {
  1994. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  1995. uint8_t opcode; //!< GAP_LINK_ESTABLISHED_EVENT
  1996. uint8_t devAddrType; //!< Device address type: @ref GAP_ADDR_TYPE_DEFINES
  1997. uint8_t devAddr[B_ADDR_LEN]; //!< Device address of link
  1998. uint16_t connectionHandle; //!< Connection Handle from controller used to ref the device
  1999. uint8_t connRole; //!< Connection formed as Central or Peripheral
  2000. uint16_t connInterval; //!< Connection Interval
  2001. uint16_t connLatency; //!< Connection Latency
  2002. uint16_t connTimeout; //!< Connection Timeout
  2003. uint8_t clockAccuracy; //!< Clock Accuracy
  2004. uint8_t advHandle; //!< Used to identify an advertising set
  2005. uint16_t syncHandle; //!< Identifying the periodic advertising train
  2006. } gapEstLinkReqEvent_t;
  2007. /**
  2008. * GAP_LINK_PARAM_UPDATE_EVENT message format. This message is sent to the app
  2009. * when the connection parameters update request is complete.
  2010. */
  2011. typedef struct
  2012. {
  2013. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  2014. uint8_t opcode; //!< GAP_LINK_PARAM_UPDATE_EVENT
  2015. uint8_t status; //!< bStatus_t
  2016. uint16_t connectionHandle; //!< Connection handle of the update
  2017. uint16_t connInterval; //!< Requested connection interval
  2018. uint16_t connLatency; //!< Requested connection latency
  2019. uint16_t connTimeout; //!< Requested connection timeout
  2020. } gapLinkUpdateEvent_t;
  2021. /**
  2022. * GAP_LINK_TERMINATED_EVENT message format. This message is sent to the
  2023. * app when a link to a device is terminated.
  2024. */
  2025. typedef struct
  2026. {
  2027. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  2028. uint8_t opcode; //!< GAP_LINK_TERMINATED_EVENT
  2029. uint16_t connectionHandle; //!< connection Handle
  2030. uint8_t reason; //!< termination reason from LL
  2031. uint8_t connRole;
  2032. } gapTerminateLinkEvent_t;
  2033. /**
  2034. * GAP_PHY_UPDATE_EVENT message format. This message is sent to the app(GAP_MSG_EVENT)
  2035. * when the PHY update request is complete.
  2036. */
  2037. typedef struct
  2038. {
  2039. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  2040. uint8_t opcode; //!< GAP_PHY_UPDATE_EVENT
  2041. uint8_t status; //!< bStatus_t
  2042. uint16_t connectionHandle; //!< Connection handle of the update
  2043. uint8_t connTxPHYS; //!< tx phy(GAP_PHY_VAL_TYPE)
  2044. uint8_t connRxPHYS; //!< rx phy(GAP_PHY_VAL_TYPE)
  2045. } gapPhyUpdateEvent_t;
  2046. /**
  2047. * GAP_PERI_ADV_SYNC_TRAN_RECEIVED_EVENT message format. This message is sent to the app(GAP_MSG_EVENT)
  2048. * when the periodic advertising sync transfer received.
  2049. */
  2050. typedef struct
  2051. {
  2052. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  2053. uint8_t opcode; //!< GAP_PERI_ADV_SYNC_TRAN_RECEIVED_EVENT
  2054. uint8_t status; //!< bStatus_t
  2055. uint16_t connectionHandle; //!< Connection handle of the update
  2056. uint16_t serviceData; //!< A value provided by the peer device
  2057. uint16_t syncHandle; //!< Identifying the periodic advertising train
  2058. uint8_t advertisingSID; //!< Value of the Advertising SID used to advertise the periodic advertising
  2059. uint8_t devAddrType; //!< Device address type: @ref GAP_ADDR_TYPE_DEFINES
  2060. uint8_t devAddr[B_ADDR_LEN]; //!< Device address of periodic advertising
  2061. uint8_t advertisingPHY; //!< the PHY used for the periodic advertising
  2062. uint16_t periodicInterval; //!< Periodic advertising interval
  2063. uint8_t clockAccuracy; //!< Clock Accuracy
  2064. uint8_t numSubevents; //!< Number of subevents
  2065. uint8_t subInterval; //!< Subevent interval
  2066. uint8_t rspSlotDelay; //!< Response slot delay
  2067. uint8_t rspSlotSpacing; //!< Response slot spacing
  2068. } gapPeriodicTranReceivec_t;
  2069. /**
  2070. * GAP_PASSKEY_NEEDED_EVENT message format. This message is sent to the
  2071. * app when a Passkey is needed from the app's user interface.
  2072. */
  2073. typedef struct
  2074. {
  2075. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  2076. uint8_t opcode; //!< GAP_PASSKEY_NEEDED_EVENT
  2077. uint8_t deviceAddr[B_ADDR_LEN]; //!< address of device to pair with, and could be either public or random.
  2078. uint16_t connectionHandle; //!< Connection handle
  2079. uint8_t uiInputs; //!< Pairing User Interface Inputs - Ask user to input passcode
  2080. uint8_t uiOutputs; //!< Pairing User Interface Outputs - Display passcode
  2081. } gapPasskeyNeededEvent_t;
  2082. /**
  2083. * Passcode Callback Function
  2084. */
  2085. typedef void (*pfnPasscodeCB_t)( uint8_t *deviceAddr, //!< address of device to pair with, and could be either public or random.
  2086. uint16_t connectionHandle, //!< Connection handle
  2087. uint8_t uiInputs, //!< Pairing User Interface Inputs - Ask user to input passcode
  2088. uint8_t uiOutputs //!< Pairing User Interface Outputs - Display passcode
  2089. );
  2090. /**
  2091. * Pairing State Callback Function
  2092. */
  2093. typedef void (*pfnPairStateCB_t)( uint16_t connectionHandle, //!< Connection handle
  2094. uint8_t state, //!< Pairing state @ref GAPBOND_PAIRING_STATE_DEFINES
  2095. uint8_t status //!< Pairing status
  2096. );
  2097. typedef struct
  2098. {
  2099. tmos_event_hdr_t hdr; //!< GAP_MSG_EVENT and status
  2100. uint8_t opcode; //!< GAP_O0B_NEEDED_EVENT
  2101. uint8_t deviceAddr[B_ADDR_LEN]; //!< address of device to pair with, and could be either public or random.
  2102. uint16_t connectionHandle; //!< Connection handle
  2103. uint8_t r_local[16];
  2104. uint8_t c_local[16];
  2105. } gapOobNeededEvent_t;
  2106. /**
  2107. * OOB Callback Function
  2108. */
  2109. typedef void (*pfnOobCB_t)( uint8_t *deviceAddr, //!< address of device to pair with, and could be either public or random.
  2110. uint16_t connectionHandle, //!< Connection handle
  2111. uint8_t* r_local, //!< local rand
  2112. uint8_t *c_local //!< local confirm
  2113. );
  2114. /**
  2115. * Callback Registration Structure
  2116. */
  2117. typedef struct
  2118. {
  2119. pfnPasscodeCB_t passcodeCB; //!< Passcode callback
  2120. pfnPairStateCB_t pairStateCB; //!< Pairing state callback
  2121. pfnOobCB_t oobCB; //!< oob callback
  2122. } gapBondCBs_t;
  2123. typedef int (*pfnEcc_key_t)( uint8_t *pub, uint8_t *priv);
  2124. typedef int (*pfnEcc_dhkey_t)( uint8_t *peer_pub_key_x, uint8_t *peer_pub_key_y,
  2125. uint8_t *our_priv_key, uint8_t *out_dhkey );
  2126. typedef int (*pfnEcc_alg_f4_t)( uint8_t *u, uint8_t *v, uint8_t *x, uint8_t z,
  2127. uint8_t *out_enc_data );
  2128. typedef int (*pfnEcc_alg_g2_t)( uint8_t *u, uint8_t *v, uint8_t *x, uint8_t *y,
  2129. uint32_t *passkey );
  2130. typedef int (*pfnEcc_alg_f5_t)( uint8_t *w, uint8_t *n1, uint8_t *n2,
  2131. uint8_t a1t, uint8_t *a1, uint8_t a2t, uint8_t *a2, uint8_t *mackey, uint8_t *ltk );
  2132. typedef int (*pfnEcc_alg_f6_t)( uint8_t *w, uint8_t *n1, uint8_t *n2, uint8_t *r,
  2133. uint8_t *iocap, uint8_t a1t, uint8_t *a1, uint8_t a2t, uint8_t *a2, uint8_t *check );
  2134. /**
  2135. * Callback Registration Structure
  2136. */
  2137. typedef struct
  2138. {
  2139. pfnEcc_key_t gen_key_pair;
  2140. pfnEcc_dhkey_t gen_dhkey;
  2141. pfnEcc_alg_f4_t alg_f4; //!< LE Secure Connections confirm value generation function f4
  2142. pfnEcc_alg_g2_t alg_g2; //!< LE Secure Connections numeric comparison value generation function g2
  2143. pfnEcc_alg_f5_t alg_f5; //!< LE Secure Connect ions key generation function f5
  2144. pfnEcc_alg_f6_t alg_f6; //!< LE Secure Connections check value generation function f6
  2145. } gapEccCBs_t;
  2146. /**
  2147. * gapRole_States_t defined
  2148. */
  2149. typedef uint32_t gapRole_States_t;
  2150. // gapRole_States_t @ 4b'[3-0]-advertising states
  2151. #define GAPROLE_STATE_ADV_MASK (0xF) //!< advertising states mask
  2152. #define GAPROLE_STATE_ADV_SHIFT (0x0) //!< advertising states shift
  2153. #define GAPROLE_INIT 0 //!< Waiting to be started
  2154. #define GAPROLE_STARTED 1 //!< Started but not advertising
  2155. #define GAPROLE_ADVERTISING 2 //!< Currently Advertising
  2156. #define GAPROLE_WAITING 3 //!< Device is started but not advertising, is in waiting period before advertising again
  2157. #define GAPROLE_CONNECTED 4 //!< In a connection
  2158. #define GAPROLE_CONNECTED_ADV 5 //!< In a connection + advertising
  2159. #define GAPROLE_ERROR 6 //!< Error occurred - invalid state
  2160. // gapRole_States_t @ 4b'[7-4]-Periodic advertising states
  2161. // Periodic advertising Enable,only effective when GAP_ADTYPE_EXT_NONCONN_NONSCAN_UNDIRECT advertising event enable
  2162. #define GAPROLE_STATE_PERIODIC_MASK (0xF0) //!< Periodic advertising states mask
  2163. #define GAPROLE_STATE_PERIODIC_SHIFT (4) //!< Periodic advertising states shift
  2164. #define GAPROLE_PERIODIC_INVALID (0<<4) //!< Periodic advertising Waiting to be started
  2165. #define GAPROLE_PERIODIC_ENABLE (1<<4) //!< Periodic advertising Enable
  2166. #define GAPROLE_PERIODIC_WAIT (2<<4) //!< Periodic advertising is started but disable
  2167. #define GAPROLE_PERIODIC_ERROR (3<<4) //!< Periodic advertising error occurred
  2168. // gapRole_States_t @ 4b'[11-8]-Connectionless CTE Transmit states
  2169. // Connectionless CTE Transmit Enable,only effective when Periodic advertising valid
  2170. #define GAPROLE_STATE_CTE_MASK (0xF00) //!< gapRole_States_t Connectionless CTE defined
  2171. #define GAPROLE_STATE_CTE_SHIFT (8) //!< Connectionless CTE Transmit states shift
  2172. #define GAPROLE_CONNECTIONLESS_CTE_INVALID (0<<8) //!< Connectionless CTE Transmit Waiting to be started
  2173. #define GAPROLE_CONNECTIONLESS_CTE_ENABLE (1<<8) //!< Connectionless CTE Transmit Enable
  2174. #define GAPROLE_CONNECTIONLESS_CTE_WAIT (2<<8) //!< Connectionless CTE Transmit is started but disable
  2175. #define GAPROLE_CONNECTIONLESS_CTE_ERROR (3<<8) //!< Connectionless CTE Transmit error occurred
  2176. // gapRole_States_t @ 12b'[23-12]- Reserved for future use
  2177. // gapRole_States_t @ 8b'[31-24] - indicates which fields change
  2178. #define GAPROLE_PERIODIC_STATE_VALID (1<<24) //!< indicates periodic advertising states change
  2179. #define GAPROLE_CTE_T_STATE_VALID (1<<25) //!< indicates Connectionless CTE Transmit states change
  2180. typedef union {
  2181. struct {
  2182. uint32_t advState : 4;
  2183. uint32_t periState : 4;
  2184. uint32_t cteState : 4;
  2185. uint32_t Reserved0 : 12;
  2186. uint32_t periValid : 1;
  2187. uint32_t cteValid : 1;
  2188. uint32_t Reserved1 : 6;
  2189. };
  2190. uint32_t gapRoleStates;
  2191. } gapRoleStates_t;
  2192. /**
  2193. * gapRole Event Structure
  2194. */
  2195. typedef union
  2196. {
  2197. gapEventHdr_t gap; //!< GAP_MSG_EVENT and status.
  2198. gapDeviceInitDoneEvent_t initDone; //!< GAP initialization done.
  2199. gapDeviceInfoEvent_t deviceInfo; //!< Discovery device information event structure.
  2200. gapDirectDeviceInfoEvent_t deviceDirectInfo; //!< Discovery direct device information event structure.
  2201. gapAdvDataUpdateEvent_t dataUpdate; //!< Advertising Data Update is complete.
  2202. gapPeriodicAdvDeviceInfoEvent_t devicePeriodicInfo; //!< Discovery periodic device information event structure.
  2203. gapExtAdvDeviceInfoEvent_t deviceExtAdvInfo; //!< Discovery extend advertising device information event structure.
  2204. gapDevDiscEvent_t discCmpl; //!< Discovery complete event structure.
  2205. gapSyncEstablishedEvent_t syncEstEvt; //!< sync established event structure.
  2206. gapSyncLostEvent_t syncLostEvt; //!< sync lost event structure.
  2207. gapScanReqReseiveEvent_t scanReqEvt; //!< Scan_Request_Received event structure.
  2208. gapEstLinkReqEvent_t linkCmpl; //!< Link complete event structure.
  2209. gapLinkUpdateEvent_t linkUpdate; //!< Link update event structure.
  2210. gapTerminateLinkEvent_t linkTerminate; //!< Link terminated event structure.
  2211. gapPhyUpdateEvent_t linkPhyUpdate; //!< Link phy update event structure.
  2212. gapPeriodicTranReceivec_t syncTran;
  2213. } gapRoleEvent_t;
  2214. /**
  2215. * Type of device.
  2216. */
  2217. typedef struct
  2218. {
  2219. uint8_t eventType; //!< Indicates advertising event type used by the advertiser: @ref GAP_ADVERTISEMENT_REPORT_TYPE_DEFINES
  2220. uint8_t addrType; //!< Scan Address Type:0x00-Public Device Address or Public Identity Address 0x01-Random Device Address or Random (static) Identity Address
  2221. uint8_t addr[B_ADDR_LEN]; //!< Device's Address
  2222. int8_t rssi;
  2223. } gapScanRec_t;
  2224. /**
  2225. * Type of GAPRole_CreateSync command parameters.
  2226. */
  2227. typedef struct
  2228. {
  2229. uint8_t options;
  2230. /*
  2231. bit0: used to determine whether the Periodic Advertiser List is used
  2232. 0: Use the Advertising_SID, Advertisier_Address_Type, and Advertiser_Address parameters to determine which advertiser to listen to.
  2233. 1: Use the Periodic Advertiser List to determine which advertiser to listen to.
  2234. bit1: whether GAP_PERIODIC_ADV_DEVICE_INFO_EVENT events for this periodic advertising train are initially enabled or disabled.
  2235. 0: Reporting initially enabled
  2236. 1: Reporting initially disabled
  2237. bit2:
  2238. 0: Duplicate filtering initially disabled
  2239. 1: Duplicate filtering initially enabled */
  2240. uint8_t advertising_SID; //!< if used, specifies the value that must match the Advertising SID
  2241. uint8_t addrType; //!< Scan Address Type: @ref GAP_ADDR_TYPE_DEFINES
  2242. uint8_t addr[B_ADDR_LEN]; //!< Device's Address
  2243. uint16_t skip; //!< the maximum number of consecutive periodic advertising events that the receiver may skip after
  2244. //!< successfully receiving a periodic advertising packet.Range: 0x0000 to 0x01F3
  2245. uint16_t syncTimeout; //!< the maximum permitted time between successful receives. If this time is exceeded, synchronization is lost.
  2246. //!< Time = N*10 ms.Range: 0x000A to 0x4000
  2247. uint8_t syncCTEType; //!< specifies whether to only synchronize to periodic advertising with certain types of Constant Tone Extension
  2248. //!< (a value of 0 indicates that the presence or absence of a Constant Tone Extension is irrelevant).
  2249. } gapCreateSync_t;
  2250. /**
  2251. * Type of GAPRole_SyncTransferParameters command parameters.
  2252. */
  2253. typedef struct
  2254. {
  2255. uint16_t connHandle; //!< Used to identify the Connection handle
  2256. uint8_t mode; //!< specifies the action to be taken when periodic advertising synchronization information is received
  2257. #define MODE_0 0 //!< No attempt is made to synchronize to the periodic advertising and no
  2258. //!< gapPeriodicTranReceivec_t event is sent to the APP.
  2259. #define MODE_1 1 //!< An gapPeriodicTranReceivec_t event is sent to the APP.
  2260. //!< gapPeriodicAdvDeviceInfoEvent_t events will be disabled.
  2261. #define MODE_2 2 //!< An gapPeriodicTranReceivec_t event is sent to the APP.
  2262. //!< gapPeriodicAdvDeviceInfoEvent_t events will be enabled with duplicate filtering disabled.
  2263. #define MODE_3 3 //!< An gapPeriodicTranReceivec_t event is sent to the APP.
  2264. //!< gapPeriodicAdvDeviceInfoEvent_t events will be enabled with duplicate filtering enabled.
  2265. uint16_t skip; //!< resv(The number of periodic advertising packets that can be skipped after a successful receive).
  2266. uint16_t syncTimeout; //!< Synchronization timeout for the periodic advertising train.Time = N*10 ms.Range: 0x000A to 0x4000
  2267. uint8_t cteType; //!< Reserved for future use.
  2268. } gapSyncTransferParam_t;
  2269. /**
  2270. * Type of GAPRole_SyncTransferSync command parameters.
  2271. */
  2272. typedef struct
  2273. {
  2274. uint16_t connHandle; //!< Used to identify the Connection handle
  2275. uint16_t serviceData; //!< A value provided by the Host for use by the Host of the peer device.
  2276. uint16_t syncHandle; //!< Identifier of the periodic advertising train to a connected device.
  2277. } gapSyncTransferSync_t;
  2278. /**
  2279. * Type of GAPRole_SyncTransferAdvertising command parameters.
  2280. */
  2281. typedef struct
  2282. {
  2283. uint16_t connHandle; //!< Used to identify the Connection handle
  2284. uint16_t serviceData; //!< A value provided by the Host for use by the Host of the peer device.
  2285. uint8_t advHandle; //!< Identifier of the periodic advertising in an advertising set to a connected device.
  2286. } gapSyncTransferAdvertising_t;
  2287. /**
  2288. * Type of GAPRole_SetPathLossReporting command parameters.
  2289. */
  2290. typedef struct
  2291. {
  2292. uint16_t connHandle; //!< Used to identify the Connection handle
  2293. int8_t highThreshold; //!< High threshold for the path loss.Units: dB
  2294. int8_t highHysteresis; //!< Hysteresis value for the high threshold.Units: dB
  2295. int8_t lowThreshold; //!< High threshold for the path loss.Units: dB
  2296. int8_t lowHysteresis; //!< Hysteresis value for the high threshold.Units: dB
  2297. uint16_t minTimeSpent; //!< Minimum time in number of connection events to be observed
  2298. //!< once the path crosses the threshold before an event is generated.
  2299. uint8_t enable; //!< 0x00:Reporting disabled 0x01:Reporting enabled
  2300. } gapRoleSetPathLossReporting_t;
  2301. typedef struct
  2302. {
  2303. uint16_t connHandle; //!< Used to identify the Connection handle
  2304. int8_t lowRxThreshold; //!< High threshold for the peer power levels.Units: dB
  2305. int8_t highRxThreshold; //!< High threshold for the peer power levels.Units: dB
  2306. int8_t minTxPower; //!< Minimum transmit power level.Units: dB
  2307. int8_t maxTxPower; //!< Maximum transmit power level.Units: dB
  2308. } gapRolePowerlevelManagement_t;
  2309. /**
  2310. * Callback when the device has been started. Callback event to
  2311. * the Notify of a state change.
  2312. */
  2313. typedef void (*gapRolesBroadcasterStateNotify_t)( gapRole_States_t newState );
  2314. typedef void (*gapRolesScanReqRecv_t)( gapScanRec_t * pEvent );
  2315. typedef struct
  2316. {
  2317. gapRolesBroadcasterStateNotify_t pfnStateChange; //!< Whenever the device changes state
  2318. gapRolesScanReqRecv_t pfnScanRecv;
  2319. } gapRolesBroadcasterCBs_t;
  2320. /**
  2321. * Observer Event Callback Function
  2322. */
  2323. typedef void (*pfnGapObserverRoleEventCB_t)( gapRoleEvent_t *pEvent //!< Pointer to event structure.
  2324. );
  2325. /**
  2326. * Observer Callback Structure
  2327. */
  2328. typedef struct
  2329. {
  2330. pfnGapObserverRoleEventCB_t eventCB; //!< Event callback.
  2331. } gapRoleObserverCB_t;
  2332. /**
  2333. * Callback when the device has read an new RSSI value during a connection.
  2334. */
  2335. typedef void (*gapRolesRssiRead_t)( uint16_t connHandle, int8_t newRSSI );
  2336. /**
  2337. * Callback when the device has been started. Callback event to
  2338. * the Notify of a state change.
  2339. */
  2340. typedef void (*gapRolesStateNotify_t)( gapRole_States_t newState, gapRoleEvent_t * pEvent );
  2341. /**
  2342. * Callback when the connection parameteres are updated.
  2343. */
  2344. typedef void (*gapRolesParamUpdateCB_t)( uint16_t connHandle, uint16_t connInterval,
  2345. uint16_t connSlaveLatency, uint16_t connTimeout );
  2346. /**
  2347. * Callback structure - must be setup by the application and used when gapRoles_StartDevice() is called.
  2348. */
  2349. typedef struct
  2350. {
  2351. gapRolesStateNotify_t pfnStateChange; //!< Whenever the device changes state
  2352. gapRolesRssiRead_t pfnRssiRead; //!< When a valid RSSI is read from controller
  2353. gapRolesParamUpdateCB_t pfnParamUpdate; //!< When the connection parameteres are updated
  2354. } gapRolesCBs_t;
  2355. /**
  2356. * Central Event Callback Function
  2357. */
  2358. typedef void (*pfnGapCentralRoleEventCB_t)( gapRoleEvent_t *pEvent ); //!< Pointer to event structure.
  2359. /**
  2360. * HCI Data Length Change Event Callback Function
  2361. */
  2362. typedef void (*pfnHciDataLenChangeEvCB_t)( uint16_t connHandle, uint16_t maxTxOctets,
  2363. uint16_t maxRxOctets );
  2364. /**
  2365. * Central Callback Structure
  2366. */
  2367. typedef struct
  2368. {
  2369. gapRolesRssiRead_t rssiCB; //!< RSSI callback.
  2370. pfnGapCentralRoleEventCB_t eventCB; //!< Event callback.
  2371. pfnHciDataLenChangeEvCB_t ChangCB; //!< Length Change Event Callback .
  2372. } gapCentralRoleCB_t; // gapCentralRoleCB_t
  2373. /* RF-PHY define */
  2374. /*
  2375. * RF_ROLE_STATUS_TYPE pfnRFStatusCB_t state defined
  2376. */
  2377. // TX_MODE call RF_Tx
  2378. #define TX_MODE_TX_FINISH 0x01 //!< basic or auto tx mode sends data successfully
  2379. //!< if it is in basic mode,it will enter idle state;
  2380. //!< if it is in auto mode,it will wait for receiving
  2381. #define TX_MODE_TX_FAIL 0x11 //!< basic or auto tx mode fail to send data and enter idle state
  2382. #define TX_MODE_TX_TIMEOUT TX_MODE_TX_FAIL //!< time of data transmission
  2383. #define TX_MODE_RX_DATA 0x02 //!< auto tx mode receive data(ack) and enter idle state
  2384. #define TX_MODE_RX_TIMEOUT 0x12 //!< auto tx mode receive timeout and enter idle state
  2385. #define TX_MODE_HOP_SHUT 0x22
  2386. // RX_MODE call RF_Rx
  2387. #define RX_MODE_RX_DATA 0x03 //!< basic or auto rx mode receive data
  2388. //!< if it is in basic mode,it will enter idle state;
  2389. //!< if it is in auto mode,it will judge whether the type matches;
  2390. //!< if it matches,it will send data(ack),otherwise(rsr=2), it will restart receiving
  2391. #define RX_MODE_TX_FINISH 0x04 //!< auto rx mode sends data(ack) successfully and enters idle state
  2392. #define RX_MODE_TX_FAIL 0x14 //!< auto rx mode fail to send data and enter idle state
  2393. #define RX_MODE_TX_TIMEOUT RX_MODE_TX_FAIL //!< time of data transmission
  2394. #define RX_MODE_HOP_SHUT 0x24
  2395. // LLE_MODE_TYPE
  2396. #define LLE_MODE_BASIC (0) //!< basic mode, enter idle state after sending or receive
  2397. #define LLE_MODE_AUTO (1) //!< auto mode, auto swtich to the receiving status after sending and the sending status after receiving
  2398. // LLE_WHITENING_TYPE
  2399. #define LLE_WHITENING_ON (0<<1)
  2400. #define LLE_WHITENING_OFF (1<<1)
  2401. // LLE_PHY_TYPE
  2402. #define LLE_MODE_PHY_MODE_MASK (0x30)
  2403. #define LLE_MODE_PHY_1M (0<<4)
  2404. #define LLE_MODE_PHY_2M (1<<4)
  2405. #define LLE_MODE_PHY_CODED_S8 (2<<4)
  2406. #define LLE_MODE_PHY_CODED_S2 (3<<4)
  2407. #define LLE_MODE_EX_CHANNEL (1<<6)
  2408. #define LLE_MODE_NON_RSSI (1<<7)
  2409. /**
  2410. * RFRole Event Callback Function
  2411. */
  2412. typedef void (*pfnRFStatusCB_t)( uint8_t sta, uint8_t rsr, uint8_t *rxBuf );
  2413. // sta - current status@ref RF_ROLE_STATUS_TYPE
  2414. // rsr - receive status: bit0- crc check result,bit1- type matching result
  2415. // rxBuf - receive data buffer
  2416. typedef struct tag_rf_config
  2417. {
  2418. uint8_t LLEMode; //!< BIT0 0=basic, 1=auto def@LLE_MODE_TYPE
  2419. //!< BIT1 0=whitening on, 1=whitening off def@LLE_WHITENING_TYPE
  2420. //!< BIT4-5 00-1M 01-2M 10-coded(S8) 11-coded(S2) def@LLE_PHY_TYPE
  2421. //!< BIT6 0=data channel(0-39)
  2422. //!< 1=rf frequency (2400000kHz-2483500kHz)
  2423. //!< BIT7 0=the first byte of the receive buffer is rssi
  2424. //!< 1=the first byte of the receive buffer is package type
  2425. uint8_t Channel; //!< rf channel(0-39)
  2426. uint32_t Frequency; //!< rf frequency (2400000kHz-2483500kHz)
  2427. uint32_t accessAddress; //!< access address,32bit PHY address
  2428. uint32_t CRCInit; //!< crc initial value
  2429. pfnRFStatusCB_t rfStatusCB; //!< status call back
  2430. uint32_t ChannelMap; //!< indicating Used and Unused data channels.Every channel is represented with a
  2431. //!< bit positioned as per the data channel index,The LSB represents data channel index 0
  2432. uint8_t Resv;
  2433. uint8_t HeartPeriod; //!< The heart package interval shall be an integer multiple of 100ms
  2434. uint8_t HopPeriod; //!< hop period( T=32n*RTC clock ),default is 8
  2435. uint8_t HopIndex; //!< indicate the hopIncrement used in the data channel selection algorithm,default is 17
  2436. uint8_t RxMaxlen; //!< Maximum data length received in rf-mode(default 251)
  2437. uint8_t TxMaxlen; //!< Maximum data length transmit in rf-mode(default 251)
  2438. } rfConfig_t;
  2439. /* end define@RF-PHY */
  2440. /*******************************************************************************
  2441. * UUID defined
  2442. */
  2443. /**
  2444. * GATT Services
  2445. */
  2446. extern const uint8_t gapServiceUUID[];
  2447. extern const uint8_t gattServiceUUID[];
  2448. /**
  2449. * GATT Attribute Types
  2450. */
  2451. extern const uint8_t primaryServiceUUID[];
  2452. extern const uint8_t secondaryServiceUUID[];
  2453. extern const uint8_t includeUUID[];
  2454. extern const uint8_t characterUUID[];
  2455. /**
  2456. * GATT Characteristic Descriptors
  2457. */
  2458. extern const uint8_t charExtPropsUUID[];
  2459. extern const uint8_t charUserDescUUID[];
  2460. extern const uint8_t clientCharCfgUUID[];
  2461. extern const uint8_t servCharCfgUUID[];
  2462. extern const uint8_t charFormatUUID[];
  2463. extern const uint8_t charAggFormatUUID[];
  2464. extern const uint8_t validRangeUUID[];
  2465. extern const uint8_t extReportRefUUID[];
  2466. extern const uint8_t reportRefUUID[];
  2467. /**
  2468. * GATT Characteristic Types
  2469. */
  2470. extern const uint8_t deviceNameUUID[];
  2471. extern const uint8_t appearanceUUID[];
  2472. extern const uint8_t periPrivacyFlagUUID[];
  2473. extern const uint8_t reconnectAddrUUID[];
  2474. extern const uint8_t periConnParamUUID[];
  2475. extern const uint8_t serviceChangedUUID[];
  2476. extern const uint8_t centAddrResUUID[];
  2477. /*******************************************************************************
  2478. * PUBLIC FUNCTIONS
  2479. */
  2480. extern uint32_t tmos_rand( void ); // pseudo-random number
  2481. extern BOOL tmos_memcmp( const void *src1, const void *src2, uint32_t len ); // TRUE - same, FALSE - different
  2482. extern BOOL tmos_isbufset( uint8_t *buf, uint8_t val, uint32_t len ); // TRUE if all "val",FALSE otherwise
  2483. extern uint32_t tmos_strlen( char *pString );
  2484. extern void tmos_memset( void * pDst, uint8_t Value, uint32_t len );
  2485. extern void tmos_memcpy( void *dst, const void *src, uint32_t len ); // Generic memory copy.
  2486. /**
  2487. * @brief start a event immediately
  2488. *
  2489. * @param taskID - task ID of event
  2490. * @param event - event value
  2491. *
  2492. * @return 0 - SUCCESS.
  2493. */
  2494. extern bStatus_t tmos_set_event( tmosTaskID taskID, tmosEvents event );
  2495. /**
  2496. * @brief clear a event already timeout, cannot be used in it own event function.
  2497. *
  2498. * @param taskID - task ID of event
  2499. * @param event - event value
  2500. *
  2501. * @return 0 - SUCCESS.
  2502. */
  2503. extern bStatus_t tmos_clear_event( tmosTaskID taskID, tmosEvents event );
  2504. /**
  2505. * @brief start a event after period of time
  2506. *
  2507. * @param taskID - task ID to set event for
  2508. * @param event - event to be notified with
  2509. * @param time - timeout value
  2510. *
  2511. * @return TRUE,FALSE.
  2512. */
  2513. extern BOOL tmos_start_task( tmosTaskID taskID, tmosEvents event, tmosTimer time );
  2514. /**
  2515. * @brief This function is called to start a timer to expire in n system clock time.
  2516. * When the timer expires, the calling task will get the specified event
  2517. * and the timer will be reloaded with the timeout value.
  2518. *
  2519. * @param taskID - task ID to set timer for
  2520. * @param event - event to be notified with
  2521. * @param time - timeout value
  2522. *
  2523. * @return SUCCESS, or NO_TIMER_AVAIL.
  2524. */
  2525. extern bStatus_t tmos_start_reload_task( tmosTaskID taskID, tmosEvents event, tmosTimer time );
  2526. /**
  2527. * @brief stop a event
  2528. *
  2529. * @param taskID - task ID of event
  2530. * @param event - event value
  2531. *
  2532. * @param None.
  2533. *
  2534. * @return SUCCESS.
  2535. */
  2536. extern bStatus_t tmos_stop_task( tmosTaskID taskID, tmosEvents event );
  2537. /**
  2538. * @brief get last period of time for this event
  2539. *
  2540. * @param taskID - task ID of event
  2541. * @param event - event value
  2542. *
  2543. * @return the timer's tick count if found, zero otherwise.
  2544. */
  2545. extern tmosTimer tmos_get_task_timer( tmosTaskID taskID, tmosEvents event );
  2546. /**
  2547. * @brief send msg to a task,callback events&SYS_EVENT_MSG
  2548. *
  2549. * @param taskID - task ID of task need to send msg
  2550. * @param *msg_ptr - point of msg
  2551. *
  2552. * @return SUCCESS, INVALID_TASK, INVALID_MSG_POINTER
  2553. */
  2554. extern bStatus_t tmos_msg_send( tmosTaskID taskID, uint8_t *msg_ptr );
  2555. /**
  2556. * @brief delete a msg
  2557. *
  2558. * @param *msg_ptr - point of msg
  2559. *
  2560. * @return SUCCESS.
  2561. */
  2562. extern bStatus_t tmos_msg_deallocate( uint8_t *msg_ptr );
  2563. /**
  2564. * @brief receive a msg
  2565. *
  2566. * @param taskID - task ID of task need to receive msg
  2567. *
  2568. * @return *uint8_t - message information or NULL if no message
  2569. */
  2570. extern uint8_t *tmos_msg_receive( tmosTaskID taskID );
  2571. /**
  2572. * @brief allocate buffer for msg when need to send msg
  2573. *
  2574. * @param len - length of msg
  2575. *
  2576. * @return pointer to allocated buffer or NULL if allocation failed.
  2577. */
  2578. extern uint8_t *tmos_msg_allocate( uint16_t len );
  2579. /**
  2580. * @brief read a data item to NV.
  2581. *
  2582. * @param id - Valid NV item Id.
  2583. * @param len - Length of data to read.
  2584. * @param *pBuf - Data to read.
  2585. *
  2586. * @return SUCCESS if successful, NV_OPER_FAILED if failed.
  2587. */
  2588. extern bStatus_t tmos_snv_read( tmosSnvId_t id, tmosSnvLen_t len, void *pBuf );
  2589. /**
  2590. * @brief tmos system timer initialization
  2591. *
  2592. * @note must initialization before call tmos task
  2593. *
  2594. * @param fnGetClock - system clock select extend input,if NULL select HSE as the clock source
  2595. *
  2596. * @return SUCCESS if successful, FAILURE if failed.
  2597. */
  2598. extern bStatus_t TMOS_TimerInit( bleClockConfig_t *pClockConfig );
  2599. /**
  2600. * @brief interrupt handler.
  2601. *
  2602. * @param None
  2603. *
  2604. * @return None
  2605. */
  2606. extern bStatus_t TMOS_TimerIRQHandler( uint32_t *time );
  2607. /**
  2608. * @brief Process system
  2609. *
  2610. * @param None.
  2611. *
  2612. * @return None.
  2613. */
  2614. extern void TMOS_SystemProcess( void );
  2615. /**
  2616. * @brief Get current system clock
  2617. *
  2618. * @param None.
  2619. *
  2620. * @return current system clock (in 0.625ms)
  2621. */
  2622. extern uint32_t TMOS_GetSystemClock( void );
  2623. /**
  2624. * @brief register process event callback function
  2625. *
  2626. * @param eventCb-events callback function
  2627. *
  2628. * @return 0xFF - error,others-task id
  2629. */
  2630. extern tmosTaskID TMOS_ProcessEventRegister( pTaskEventHandlerFn eventCb );
  2631. /**
  2632. * @brief Add a device address into white list ( support SNVNum MAX )
  2633. *
  2634. * @param addrType - Type of device address
  2635. * @param devAddr - first address of device address
  2636. *
  2637. * @return Command Status.
  2638. */
  2639. extern bStatus_t LL_AddWhiteListDevice( uint8_t addrType, uint8_t *devAddr );
  2640. /**
  2641. * @brief Remove a device address from white list
  2642. *
  2643. * @param addrType - Type of device address
  2644. * @param devAddr - first address of device address
  2645. *
  2646. * @return Command Status.
  2647. */
  2648. extern bStatus_t LL_RemoveWhiteListDevice( uint8_t addrType, uint8_t *devAddr );
  2649. /**
  2650. * @brief Clear white list
  2651. *
  2652. * @param None
  2653. *
  2654. * @return Command Status.
  2655. */
  2656. extern bStatus_t LL_ClearWhiteList( void );
  2657. /**
  2658. * @brief Encrypt data
  2659. *
  2660. * @param key - key
  2661. * @param plaintextData - original data
  2662. * @param encryptData - encrypted data
  2663. *
  2664. * @return Command Status.
  2665. */
  2666. extern bStatus_t LL_Encrypt( uint8_t *key, uint8_t *plaintextData, uint8_t *encryptData );
  2667. /**
  2668. * @brief Decrypt data
  2669. *
  2670. * @param key - key
  2671. * @param plaintextData - original data
  2672. * @param decryptData - decrypted data
  2673. *
  2674. * @return Command Status.
  2675. */
  2676. extern bStatus_t LL_Decrypt( uint8_t *key, uint8_t *plaintextData, uint8_t *decryptData );
  2677. /**
  2678. * @brief get number of unAck packet in current connect buffer
  2679. *
  2680. * @param handle - connect handle
  2681. *
  2682. * @return 0xFFFFFFFF-handle error,number of packets not receiving ack
  2683. */
  2684. extern uint32_t LL_GetNumberOfUnAckPacket( uint16_t handle );
  2685. /**
  2686. * @brief Register a callback function will be called after each connect event.
  2687. * Only effect in single connection
  2688. *
  2689. * @param connEventCB - callback function
  2690. *
  2691. * @return None.
  2692. */
  2693. extern void LL_ConnectEventRegister( pfnEventCB connEventCB );
  2694. /**
  2695. * @brief Register a callback function will be called after each advertise event.
  2696. *
  2697. * @param advEventCB - callback function
  2698. *
  2699. * @return None.
  2700. */
  2701. extern void LL_AdvertiseEventRegister( pfnEventCB advEventCB );
  2702. /**
  2703. * @brief set tx power level
  2704. *
  2705. * @param power - tx power level
  2706. *
  2707. * @return Command Status.
  2708. */
  2709. extern bStatus_t LL_SetTxPowerLevel( uint8_t power );
  2710. /**
  2711. * @brief read rssi
  2712. *
  2713. * @param None.
  2714. *
  2715. * @return the value of rssi.
  2716. */
  2717. extern int8_t BLE_ReadRssi( void );
  2718. /**
  2719. * @brief read cfo
  2720. *
  2721. * @param None.
  2722. *
  2723. * @return the value of cfo.
  2724. */
  2725. extern int16_t BLE_ReadCfo( void );
  2726. /**
  2727. * @brief pa control init
  2728. *
  2729. * @note Can't be called until role Init
  2730. *
  2731. * @param paControl - pa control parameters(global variable)
  2732. *
  2733. * @return Command Status.
  2734. */
  2735. extern void BLE_PAControlInit( blePaControlConfig_t *paControl );
  2736. /**
  2737. * @brief ble register reset and rf calibration
  2738. *
  2739. * @param None
  2740. *
  2741. * @return None
  2742. */
  2743. extern void BLE_RegInit( void );
  2744. /**
  2745. * @brief Init BLE lib. RTC will be occupied at the same time.
  2746. *
  2747. * @param pCfg - config of BLE lib
  2748. *
  2749. * @return 0-success. error defined @ ERR_LIB_INIT
  2750. */
  2751. extern bStatus_t BLE_LibInit( bleConfig_t* pCfg );
  2752. /**
  2753. * @brief interrupt handler.
  2754. *
  2755. * @param None
  2756. *
  2757. * @return None
  2758. */
  2759. extern void BB_IRQLibHandler( void );
  2760. /**
  2761. * @brief interrupt handler.
  2762. *
  2763. * @param None
  2764. *
  2765. * @return None
  2766. */
  2767. extern void LLE_IRQLibHandler( void );
  2768. /**
  2769. * @brief generate a valid access address
  2770. *
  2771. * @param None.
  2772. *
  2773. * @return access address
  2774. * the Access Address meets the following requirements:
  2775. * It shall have no more than six consecutive zeros or ones.
  2776. * It shall not be t he advertising channel packets’ Access Address.
  2777. * It shall not be a sequence that differ s from the advertising channel packets' Access Address by only one bit.
  2778. * It shall not have all four octets equal.
  2779. * It shall have no more than 24 transitions.
  2780. * It shall have a minimum of two transitions in the most significant six bits.
  2781. */
  2782. extern uint32_t BLE_AccessAddressGenerate( void );
  2783. /*
  2784. * linkDB_Register - Register with this function to receive a callback when
  2785. * status changes on a connection.
  2786. */
  2787. extern uint8_t linkDB_Register( pfnLinkDBCB_t pFunc );
  2788. /*
  2789. * linkDB_State - Check to see if a physical link is in a specific state.
  2790. *
  2791. * returns TRUE is the link is in state. FALSE, otherwise.
  2792. */
  2793. extern uint8_t linkDB_State( uint16_t connectionHandle, uint8_t state );
  2794. /*
  2795. * linkDB_PerformFunc - Perform a function of each connection in the link database.
  2796. */
  2797. extern void linkDB_PerformFunc( pfnPerformFuncCB_t cb );
  2798. /*
  2799. * linkDB_Up - Check to see if a physical link is up (connected).
  2800. * Use like: uint8_t linkDB_Up( uint16_t connectionHandle );
  2801. * connectionHandle - controller link connection handle.
  2802. * returns TRUE if the link is up. FALSE, otherwise.
  2803. */
  2804. #define linkDB_Up( connectionHandle ) linkDB_State( (connectionHandle), LINK_CONNECTED )
  2805. /**
  2806. * @brief This function is used to get the MTU size of a connection.
  2807. *
  2808. * @param connHandle - connection handle.
  2809. *
  2810. * @return connection MTU size.<BR>
  2811. */
  2812. extern uint16_t ATT_GetMTU( uint16_t connHandle );
  2813. /**
  2814. * @brief Send Handle Value Confirmation.
  2815. *
  2816. * @param connHandle - connection to use
  2817. *
  2818. * @return SUCCESS: Confirmation was sent successfully.<BR>
  2819. * INVALIDPARAMETER: Invalid confirmation field.<BR>
  2820. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  2821. * bleNotConnected: Connection is down.<BR>
  2822. * bleMemAllocError: Memory allocation error occurred.<BR>
  2823. */
  2824. extern bStatus_t ATT_HandleValueCfm( uint16_t connHandle );
  2825. /*
  2826. * Compare two UUIDs. The UUIDs are converted if necessary.
  2827. */
  2828. extern uint8_t ATT_CompareUUID( const uint8_t *pUUID1, uint16_t len1, const uint8_t *pUUID2, uint16_t len2 );
  2829. /**
  2830. * @brief Initialize the Generic Attribute Profile Client.
  2831. *
  2832. * @return SUCCESS: Client initialized successfully.<BR>
  2833. * bleMemAllocError: Memory allocation error occurred.<BR>
  2834. */
  2835. extern bStatus_t GATT_InitClient( void );
  2836. /**
  2837. * @brief Register to receive incoming ATT Indications or Notifications
  2838. * of attribute values.
  2839. *
  2840. * @param taskId ?task to forward indications or notifications to
  2841. *
  2842. * @return void
  2843. */
  2844. extern void GATT_RegisterForInd( uint8_t taskId );
  2845. /**
  2846. * @brief Find the attribute record for a given handle
  2847. *
  2848. * @param handle - handle to look for
  2849. * @param pHandle - handle of owner of attribute (to be returned)
  2850. *
  2851. * @return Pointer to attribute record. NULL, otherwise.
  2852. */
  2853. extern gattAttribute_t *GATT_FindHandle( uint16_t handle, uint16_t *pHandle );
  2854. /**
  2855. * @brief This sub-procedure is used when a server is configured to
  2856. * indicate a characteristic value to a client and expects an
  2857. * attribute protocol layer acknowledgement that the indication
  2858. * was successfully received.
  2859. *
  2860. * The ATT Handle Value Indication is used in this sub-procedure.
  2861. *
  2862. * If the return status from this function is SUCCESS, the calling
  2863. * application task will receive an tmos GATT_MSG_EVENT message.
  2864. * The type of the message will be ATT_HANDLE_VALUE_CFM.
  2865. *
  2866. * @note This sub-procedure is complete when ATT_HANDLE_VALUE_CFM
  2867. * (with SUCCESS or bleTimeoutstatus) is received by the calling application task.
  2868. *
  2869. * @param connHandle - connection to use
  2870. * @param pInd - pointer to indication to be sent
  2871. * @param authenticated - whether an authenticated link is required
  2872. * @param taskId - task to be notified of response
  2873. *
  2874. * @return SUCCESS: Indication was sent successfully.<BR>
  2875. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  2876. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  2877. * bleNotConnected: Connection is down.<BR>
  2878. * blePending: A confirmation is pending with this client.<BR>
  2879. * bleMemAllocError: Memory allocation error occurred.<BR>
  2880. * bleTimeout: Previous transaction timed out.<BR>
  2881. */
  2882. extern bStatus_t GATT_Indication( uint16_t connHandle, attHandleValueInd_t *pInd, uint8_t authenticated, uint8_t taskId );
  2883. /**
  2884. * @brief This sub-procedure is used when a server is configured to
  2885. * notify a characteristic value to a client without expecting
  2886. * any attribute protocol layer acknowledgement that the
  2887. * notification was successfully received.
  2888. *
  2889. * The ATT Handle Value Notification is used in this sub-procedure.
  2890. *
  2891. * @note A notification may be sent at any time and does not invoke a confirmation.
  2892. * No confirmation will be sent to the calling application task for
  2893. * this sub-procedure.
  2894. *
  2895. * @param connHandle - connection to use
  2896. * @param pNoti - pointer to notification to be sent
  2897. * @param authenticated - whether an authenticated link is required
  2898. *
  2899. * @return SUCCESS: Notification was sent successfully.<BR>
  2900. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  2901. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  2902. * bleNotConnected: Connection is down.<BR>
  2903. * bleMemAllocError: Memory allocation error occurred.<BR>
  2904. * bleTimeout: Previous transaction timed out.<BR>
  2905. */
  2906. extern bStatus_t GATT_Notification( uint16_t connHandle, attHandleValueNoti_t *pNoti, uint8_t authenticated );
  2907. /**
  2908. * @brief This sub-procedure is used by the client to set the ATT_MTU
  2909. * to the maximum possible value that can be supported by both
  2910. * devices when the client supports a value greater than the
  2911. * default ATT_MTU for the Attribute Protocol. This sub-procedure
  2912. * shall only be initiated once during a connection.
  2913. *
  2914. * The ATT Exchange MTU Request is used by this sub-procedure.
  2915. *
  2916. * If the return status from this function is SUCCESS, the calling
  2917. * application task will receive an tmos GATT_MSG_EVENT message.
  2918. * The type of the message will be either ATT_EXCHANGE_MTU_RSP or
  2919. * ATT_ERROR_RSP (if an error occurred on the server).
  2920. *
  2921. * @note This sub-procedure is complete when either ATT_EXCHANGE_MTU_RSP
  2922. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP
  2923. * (with SUCCESS status) is received by the calling application task.
  2924. *
  2925. * @param connHandle - connection to use
  2926. * @param pReq - pointer to request to be sent
  2927. * @param taskId - task to be notified of response
  2928. *
  2929. * @return SUCCESS: Request was sent successfully.<BR>
  2930. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  2931. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  2932. * bleNotConnected: Connection is down.<BR>
  2933. * blePending: A response is pending with this server.<BR>
  2934. * bleMemAllocError: Memory allocation error occurred.<BR>
  2935. * bleTimeout: Previous transaction timed out.<BR>
  2936. */
  2937. extern bStatus_t GATT_ExchangeMTU( uint16_t connHandle, attExchangeMTUReq_t *pReq, uint8_t taskId );
  2938. /**
  2939. * @brief This sub-procedure is used by a client to discover all
  2940. * the primary services on a server.
  2941. *
  2942. * The ATT Read By Group Type Request is used with the Attribute
  2943. * Type parameter set to the UUID for "Primary Service". The
  2944. * Starting Handle is set to 0x0001 and the Ending Handle is
  2945. * set to 0xFFFF.
  2946. *
  2947. * If the return status from this function is SUCCESS, the calling
  2948. * application task will receive multiple tmos GATT_MSG_EVENT messages.
  2949. * The type of the messages will be either ATT_READ_BY_GRP_TYPE_RSP
  2950. * or ATT_ERROR_RSP (if an error occurred on the server).
  2951. *
  2952. * @note This sub-procedure is complete when either ATT_READ_BY_GRP_TYPE_RSP
  2953. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  2954. * (with SUCCESS status) is received by the calling application task.
  2955. *
  2956. * @param connHandle - connection to use
  2957. * @param taskId - task to be notified of response
  2958. *
  2959. * @return SUCCESS: Request was sent successfully.<BR>
  2960. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  2961. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  2962. * bleNotConnected: Connection is down.<BR>
  2963. * blePending: A response is pending with this server.<BR>
  2964. * bleMemAllocError: Memory allocation error occurred.<BR>
  2965. * bleTimeout: Previous transaction timed out.<BR>
  2966. */
  2967. extern bStatus_t GATT_DiscAllPrimaryServices( uint16_t connHandle, uint8_t taskId );
  2968. /**
  2969. * @brief This sub-procedure is used by a client to discover a specific
  2970. * primary service on a server when only the Service UUID is
  2971. * known. The primary specific service may exist multiple times
  2972. * on a server. The primary service being discovered is identified
  2973. * by the service UUID.
  2974. *
  2975. * The ATT Find By Type Value Request is used with the Attribute
  2976. * Type parameter set to the UUID for "Primary Service" and the
  2977. * Attribute Value set to the 16-bit Bluetooth UUID or 128-bit
  2978. * UUID for the specific primary service. The Starting Handle shall
  2979. * be set to 0x0001 and the Ending Handle shall be set to 0xFFFF.
  2980. *
  2981. * If the return status from this function is SUCCESS, the calling
  2982. * application task will receive multiple tmos GATT_MSG_EVENT messages.
  2983. * The type of the messages will be either ATT_FIND_BY_TYPE_VALUE_RSP
  2984. * or ATT_ERROR_RSP (if an error occurred on the server).
  2985. *
  2986. * @note This sub-procedure is complete when either ATT_FIND_BY_TYPE_VALUE_RSP
  2987. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  2988. * (with SUCCESS status) is received by the calling application task.
  2989. *
  2990. * @param connHandle - connection to use
  2991. * @param pUUID - pointer to service UUID to look for
  2992. * @param len - length of value
  2993. * @param taskId - task to be notified of response
  2994. *
  2995. * @return SUCCESS: Request was sent successfully.<BR>
  2996. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  2997. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  2998. * bleNotConnected: Connection is down.<BR>
  2999. * blePending: A response is pending with this server.<BR>
  3000. * bleMemAllocError: Memory allocation error occurred.<BR>
  3001. * bleTimeout: Previous transaction timed out.<BR>
  3002. */
  3003. extern bStatus_t GATT_DiscPrimaryServiceByUUID( uint16_t connHandle, uint8_t *pUUID, uint8_t len, uint8_t taskId );
  3004. /**
  3005. * @brief This sub-procedure is used by a client to find include
  3006. * service declarations within a service definition on a
  3007. * server. The service specified is identified by the service
  3008. * handle range.
  3009. *
  3010. * The ATT Read By Type Request is used with the Attribute
  3011. * Type parameter set to the UUID for "Included Service". The
  3012. * Starting Handle is set to starting handle of the specified
  3013. * service and the Ending Handle is set to the ending handle
  3014. * of the specified service.
  3015. *
  3016. * If the return status from this function is SUCCESS, the calling
  3017. * application task will receive multiple tmos GATT_MSG_EVENT messages.
  3018. * The type of the messages will be either ATT_READ_BY_TYPE_RSP
  3019. * or ATT_ERROR_RSP (if an error occurred on the server).
  3020. *
  3021. * @note This sub-procedure is complete when either ATT_READ_BY_TYPE_RSP
  3022. * (with bleProcedureCompleteor bleTimeout status)or ATT_ERROR_RSP
  3023. * (with SUCCESS status) is received by the calling application task.
  3024. *
  3025. * @param connHandle - connection to use
  3026. * @param startHandle - starting handle
  3027. * @param endHandle - end handle
  3028. * @param taskId - task to be notified of response
  3029. *
  3030. * @return SUCCESS: Request was sent successfully.<BR>
  3031. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3032. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3033. * bleNotConnected: Connection is down.<BR>
  3034. * blePending: A response is pending with this server.<BR>
  3035. * bleMemAllocError: Memory allocation error occurred.<BR>
  3036. * bleTimeout: Previous transaction timed out.<BR>
  3037. */
  3038. extern bStatus_t GATT_FindIncludedServices( uint16_t connHandle, uint16_t startHandle, uint16_t endHandle, uint8_t taskId );
  3039. /**
  3040. * @brief This sub-procedure is used by a client to find all the
  3041. * characteristic declarations within a service definition on
  3042. * a server when only the service handle range is known. The
  3043. * service specified is identified by the service handle range.
  3044. *
  3045. * The ATT Read By Type Request is used with the Attribute Type
  3046. * parameter set to the UUID for "Characteristic". The Starting
  3047. * Handle is set to starting handle of the specified service and
  3048. * the Ending Handle is set to the ending handle of the specified
  3049. * service.
  3050. *
  3051. * If the return status from this function is SUCCESS, the calling
  3052. * application task will receive multiple tmos GATT_MSG_EVENT messages.
  3053. * The type of the messages will be either ATT_READ_BY_TYPE_RSP
  3054. * or ATT_ERROR_RSP (if an error occurred on the server).
  3055. *
  3056. * @note This sub-procedure is complete when either ATT_READ_BY_TYPE_RSP
  3057. * (with bleProcedureComplete or bleTimeout status)or ATT_ERROR_RSP
  3058. * (with SUCCESS status) is received by the calling application task.
  3059. *
  3060. * @param connHandle - connection to use
  3061. * @param startHandle - starting handle
  3062. * @param endHandle - end handle
  3063. * @param taskId - task to be notified of response
  3064. *
  3065. * @return SUCCESS: Request was sent successfully.<BR>
  3066. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3067. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3068. * bleNotConnected: Connection is down.<BR>
  3069. * blePending: A response is pending with this server.<BR>
  3070. * bleMemAllocError: Memory allocation error occurred.<BR>
  3071. * bleTimeout: Previous transaction timed out.<BR>
  3072. */
  3073. extern bStatus_t GATT_DiscAllChars( uint16_t connHandle, uint16_t startHandle, uint16_t endHandle, uint8_t taskId );
  3074. /**
  3075. * @brief This sub-procedure is used by a client to discover service
  3076. * characteristics on a server when only the service handle
  3077. * ranges are known and the characteristic UUID is known.
  3078. * The specific service may exist multiple times on a server.
  3079. * The characteristic being discovered is identified by the
  3080. * characteristic UUID.
  3081. *
  3082. * The ATT Read By Type Request is used with the Attribute Type
  3083. * is set to the UUID for "Characteristic" and the Starting
  3084. * Handle and Ending Handle parameters is set to the service
  3085. * handle range.
  3086. *
  3087. * If the return status from this function is SUCCESS, the calling
  3088. * application task will receive multiple tmos GATT_MSG_EVENT messages.
  3089. * The type of the messages will be either ATT_READ_BY_TYPE_RSP
  3090. * or ATT_ERROR_RSP (if an error occurred on the server).
  3091. *
  3092. * @note This sub-procedure is complete when either ATT_READ_BY_TYPE_RSP
  3093. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  3094. * (with SUCCESS status) is received by the calling application task.
  3095. *
  3096. * @param connHandle - connection to use
  3097. * @param pReq - pointer to request to be sent
  3098. * @param taskId - task to be notified of response
  3099. *
  3100. * @return SUCCESS: Request was sent successfully.<BR>
  3101. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3102. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3103. * bleNotConnected: Connection is down.<BR>
  3104. * blePending: A response is pending with this server.<BR>
  3105. * bleMemAllocError: Memory allocation error occurred.<BR>
  3106. * bleTimeout: Previous transaction timed out.<BR>
  3107. */
  3108. extern bStatus_t GATT_DiscCharsByUUID( uint16_t connHandle, attReadByTypeReq_t *pReq, uint8_t taskId );
  3109. /**
  3110. * @brief This sub-procedure is used by a client to find all the
  3111. * characteristic descriptors Attribute Handles and Attribute
  3112. * Types within a characteristic definition when only the
  3113. * characteristic handle range is known. The characteristic
  3114. * specified is identified by the characteristic handle range.
  3115. *
  3116. * The ATT Find Information Request is used with the Starting
  3117. * Handle set to starting handle of the specified characteristic
  3118. * and the Ending Handle set to the ending handle of the specified
  3119. * characteristic. The UUID Filter parameter is NULL (zero length).
  3120. *
  3121. * If the return status from this function is SUCCESS, the calling
  3122. * application task will receive multiple tmos GATT_MSG_EVENT messages.
  3123. * The type of the messages will be either ATT_FIND_INFO_RSP or
  3124. * ATT_ERROR_RSP (if an error occurred on the server).
  3125. *
  3126. * @note This sub-procedure is complete when either ATT_FIND_INFO_RSP
  3127. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  3128. * (with SUCCESS status) is received by the calling application task.
  3129. *
  3130. * @param connHandle - connection to use
  3131. * @param startHandle - starting handle
  3132. * @param endHandle - end handle
  3133. * @param taskId - task to be notified of response
  3134. *
  3135. * @return SUCCESS: Request was sent successfully.<BR>
  3136. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3137. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3138. * bleNotConnected: Connection is down.<BR>
  3139. * blePending: A response is pending with this server.<BR>
  3140. * bleMemAllocError: Memory allocation error occurred.<BR>
  3141. * bleTimeout: Previous transaction timed out.<BR>
  3142. */
  3143. extern bStatus_t GATT_DiscAllCharDescs( uint16_t connHandle, uint16_t startHandle, uint16_t endHandle, uint8_t taskId );
  3144. /**
  3145. * @brief This sub-procedure is used to read a Characteristic Value
  3146. * from a server when the client knows the Characteristic Value
  3147. * Handle. The ATT Read Request is used with the Attribute Handle
  3148. * parameter set to the Characteristic Value Handle. The Read
  3149. * Response returns the Characteristic Value in the Attribute
  3150. * Value parameter.
  3151. *
  3152. * The Read Response only contains a Characteristic Value that
  3153. * is less than or equal to (ATT_MTU ?1) octets in length. If
  3154. * the Characteristic Value is greater than (ATT_MTU - 1) octets
  3155. * in length, the Read Long Characteristic Value procedure may
  3156. * be used if the rest of the Characteristic Value is required.
  3157. *
  3158. * If the return status from this function is SUCCESS, the calling
  3159. * application task will receive an tmos GATT_MSG_EVENT message.
  3160. * The type of the message will be either ATT_READ_RSP or
  3161. * ATT_ERROR_RSP (if an error occurred on the server).
  3162. *
  3163. * @note This sub-procedure is complete when either ATT_READ_RSP
  3164. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP
  3165. * (with SUCCESS status) is received by the calling application task.
  3166. *
  3167. * @param connHandle - connection to use
  3168. * @param pReq - pointer to request to be sent
  3169. * @param taskId - task to be notified of response
  3170. *
  3171. * @return SUCCESS: Request was sent successfully.<BR>
  3172. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3173. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3174. * bleNotConnected: Connection is down.<BR>
  3175. * blePending: A response is pending with this server.<BR>
  3176. * bleMemAllocError: Memory allocation error occurred.<BR>
  3177. * bleTimeout: Previous transaction timed out.<BR>
  3178. */
  3179. extern bStatus_t GATT_ReadCharValue( uint16_t connHandle, attReadReq_t *pReq, uint8_t taskId );
  3180. /**
  3181. * @brief This sub-procedure is used to read a Characteristic Value
  3182. * from a server when the client only knows the characteristic
  3183. * UUID and does not know the handle of the characteristic.
  3184. *
  3185. * The ATT Read By Type Request is used to perform the sub-procedure.
  3186. * The Attribute Type is set to the known characteristic UUID and
  3187. * the Starting Handle and Ending Handle parameters shall be set
  3188. * to the range over which this read is to be performed. This is
  3189. * typically the handle range for the service in which the
  3190. * characteristic belongs.
  3191. *
  3192. * If the return status from this function is SUCCESS, the calling
  3193. * application task will receive an tmos GATT_MSG_EVENT messages.
  3194. * The type of the message will be either ATT_READ_BY_TYPE_RSP
  3195. * or ATT_ERROR_RSP (if an error occurred on the server).
  3196. *
  3197. * @note This sub-procedure is complete when either ATT_READ_BY_TYPE_RSP
  3198. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP
  3199. * (with SUCCESS status) is received by the calling application task.
  3200. *
  3201. * @param connHandle - connection to use
  3202. * @param pReq - pointer to request to be sent
  3203. * @param taskId - task to be notified of response
  3204. *
  3205. * @return SUCCESS: Request was sent successfully.<BR>
  3206. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3207. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3208. * bleNotConnected: Connection is down.<BR>
  3209. * blePending: A response is pending with this server.<BR>
  3210. * bleMemAllocError: Memory allocation error occurred.<BR>
  3211. * bleTimeout: Previous transaction timed out.<BR>
  3212. */
  3213. extern bStatus_t GATT_ReadUsingCharUUID( uint16_t connHandle, attReadByTypeReq_t *pReq, uint8_t taskId );
  3214. /**
  3215. * @brief This sub-procedure is used to read a Characteristic Value from
  3216. * a server when the client knows the Characteristic Value Handle
  3217. * and the length of the Characteristic Value is longer than can
  3218. * be sent in a single Read Response Attribute Protocol message.
  3219. *
  3220. * The ATT Read Blob Request is used in this sub-procedure.
  3221. *
  3222. * If the return status from this function is SUCCESS, the calling
  3223. * application task will receive multiple tmos GATT_MSG_EVENT messages.
  3224. * The type of the messages will be either ATT_READ_BLOB_RSP or
  3225. * ATT_ERROR_RSP (if an error occurred on the server).
  3226. *
  3227. * @note This sub-procedure is complete when either ATT_READ_BLOB_RSP
  3228. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  3229. * (with SUCCESS status) is received by the calling application task.
  3230. *
  3231. * @param connHandle - connection to use
  3232. * @param pReq - pointer to request to be sent
  3233. * @param taskId - task to be notified of response
  3234. *
  3235. * @return SUCCESS: Request was sent successfully.<BR>
  3236. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3237. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3238. * bleNotConnected: Connection is down.<BR>
  3239. * blePending: A response is pending with this server.<BR>
  3240. * bleMemAllocError: Memory allocation error occurred.<BR>
  3241. * bleTimeout: Previous transaction timed out.<BR>
  3242. */
  3243. extern bStatus_t GATT_ReadLongCharValue( uint16_t connHandle, attReadBlobReq_t *pReq, uint8_t taskId );
  3244. /**
  3245. * @brief This sub-procedure is used to read multiple Characteristic Values
  3246. * from a server when the client knows the Characteristic Value
  3247. * Handles. The Attribute Protocol Read Multiple Requests is used
  3248. * with the Set Of Handles parameter set to the Characteristic Value
  3249. * Handles. The Read Multiple Response returns the Characteristic
  3250. * Values in the Set Of Values parameter.
  3251. *
  3252. * The ATT Read Multiple Request is used in this sub-procedure.
  3253. *
  3254. * If the return status from this function is SUCCESS, the calling
  3255. * application task will receive an tmos GATT_MSG_EVENT message.
  3256. * The type of the message will be either ATT_READ_MULTI_RSP
  3257. * or ATT_ERROR_RSP (if an error occurred on the server).
  3258. *
  3259. * @note This sub-procedure is complete when either ATT_READ_MULTI_RSP
  3260. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP
  3261. * (with SUCCESS status) is received by the calling application task.
  3262. *
  3263. * @param connHandle - connection to use
  3264. * @param pReq - pointer to request to be sent
  3265. * @param taskId - task to be notified of response
  3266. *
  3267. * @return SUCCESS: Request was sent successfully.<BR>
  3268. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3269. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3270. * bleNotConnected: Connection is down.<BR>
  3271. * blePending: A response is pending with this server.<BR>
  3272. * bleMemAllocError: Memory allocation error occurred.<BR>
  3273. * bleTimeout: Previous transaction timed out.<BR>
  3274. */
  3275. extern bStatus_t GATT_ReadMultiCharValues( uint16_t connHandle, attReadMultiReq_t *pReq, uint8_t taskId );
  3276. /**
  3277. * @brief This sub-procedure is used to write a Characteristic Value
  3278. * to a server when the client knows the Characteristic Value
  3279. * Handle and the client does not need an acknowledgement that
  3280. * the write was successfully performed. This sub-procedure
  3281. * only writes the first (ATT_MTU ?3) octets of a Characteristic
  3282. * Value. This sub-procedure can not be used to write a long
  3283. * characteristic; instead the Write Long Characteristic Values
  3284. * sub-procedure should be used.
  3285. *
  3286. * The ATT Write Command is used for this sub-procedure. The
  3287. * Attribute Handle parameter shall be set to the Characteristic
  3288. * Value Handle. The Attribute Value parameter shall be set to
  3289. * the new Characteristic Value.
  3290. *
  3291. * No response will be sent to the calling application task for this
  3292. * sub-procedure. If the Characteristic Value write request is the
  3293. * wrong size, or has an invalid value as defined by the profile,
  3294. * then the write will not succeed and no error will be generated
  3295. * by the server.
  3296. *
  3297. * @param connHandle - connection to use
  3298. * @param pReq - pointer to command to be sent
  3299. *
  3300. * @return SUCCESS: Request was sent successfully.<BR>
  3301. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3302. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3303. * bleNotConnected: Connection is down.<BR>
  3304. * bleMemAllocError: Memory allocation error occurred.<BR>
  3305. * bleTimeout: Previous transaction timed out.<BR>
  3306. */
  3307. extern bStatus_t GATT_WriteNoRsp( uint16_t connHandle, attWriteReq_t *pReq );
  3308. /**
  3309. * @brief This sub-procedure is used to write a Characteristic Value
  3310. * to a server when the client knows the Characteristic Value
  3311. * Handle and the ATT Bearer is not encrypted. This sub-procedure
  3312. * shall only be used if the Characteristic Properties authenticated
  3313. * bit is enabled and the client and server device share a bond as
  3314. * defined in the GAP.
  3315. *
  3316. * This sub-procedure only writes the first (ATT_MTU ?15) octets
  3317. * of an Attribute Value. This sub-procedure cannot be used to
  3318. * write a long Attribute.
  3319. *
  3320. * The ATT Write Command is used for this sub-procedure. The
  3321. * Attribute Handle parameter shall be set to the Characteristic
  3322. * Value Handle. The Attribute Value parameter shall be set to
  3323. * the new Characteristic Value authenticated by signing the
  3324. * value, as defined in the Security Manager.
  3325. *
  3326. * No response will be sent to the calling application task for this
  3327. * sub-procedure. If the authenticated Characteristic Value that is
  3328. * written is the wrong size, or has an invalid value as defined by
  3329. * the profile, or the signed value does not authenticate the client,
  3330. * then the write will not succeed and no error will be generated by
  3331. * the server.
  3332. *
  3333. * @param connHandle - connection to use
  3334. * @param pReq - pointer to command to be sent
  3335. *
  3336. * @return SUCCESS: Request was sent successfully.<BR>
  3337. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3338. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3339. * bleNotConnected: Connection is down.<BR>
  3340. * bleMemAllocError: Memory allocation error occurred.<BR>
  3341. * bleLinkEncrypted: Connection is already encrypted.<BR>
  3342. * bleTimeout: Previous transaction timed out.<BR>
  3343. */
  3344. extern bStatus_t GATT_SignedWriteNoRsp( uint16_t connHandle, attWriteReq_t *pReq );
  3345. /**
  3346. * @brief This sub-procedure is used to write a characteristic value
  3347. * to a server when the client knows the characteristic value
  3348. * handle. This sub-procedure only writes the first (ATT_MTU-3)
  3349. * octets of a characteristic value. This sub-procedure can not
  3350. * be used to write a long attribute; instead the Write Long
  3351. * Characteristic Values sub-procedure should be used.
  3352. *
  3353. * The ATT Write Request is used in this sub-procedure. The
  3354. * Attribute Handle parameter shall be set to the Characteristic
  3355. * Value Handle. The Attribute Value parameter shall be set to
  3356. * the new characteristic.
  3357. *
  3358. * If the return status from this function is SUCCESS, the calling
  3359. * application task will receive an tmos GATT_MSG_EVENT message.
  3360. * The type of the message will be either ATT_WRITE_RSP
  3361. * or ATT_ERROR_RSP (if an error occurred on the server).
  3362. *
  3363. * @note This sub-procedure is complete when either ATT_WRITE_RSP
  3364. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP
  3365. * (with SUCCESS status) is received by the calling application task.
  3366. *
  3367. * @param connHandle - connection to use
  3368. * @param pReq - pointer to request to be sent
  3369. * @param taskId - task to be notified of response
  3370. *
  3371. * @return SUCCESS: Request was sent successfully.<BR>
  3372. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3373. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3374. * bleNotConnected: Connection is down.<BR>
  3375. * blePending: A response is pending with this server.<BR>
  3376. * bleMemAllocError: Memory allocation error occurred.<BR>
  3377. * bleTimeout: Previous transaction timed out.<BR>
  3378. */
  3379. extern bStatus_t GATT_WriteCharValue( uint16_t connHandle, attWriteReq_t *pReq, uint8_t taskId );
  3380. /**
  3381. * @brief This sub-procedure is used to write a Characteristic Value to
  3382. * a server when the client knows the Characteristic Value Handle
  3383. * but the length of the Characteristic Value is longer than can
  3384. * be sent in a single Write Request Attribute Protocol message.
  3385. *
  3386. * The ATT Prepare Write Request and Execute Write Request are
  3387. * used to perform this sub-procedure.
  3388. *
  3389. * If the return status from this function is SUCCESS, the calling
  3390. * application task will receive multiple tmos GATT_MSG_EVENT messages.
  3391. * The type of the messages will be either ATT_PREPARE_WRITE_RSP,
  3392. * ATT_EXECUTE_WRITE_RSP or ATT_ERROR_RSP (if an error occurred on
  3393. * the server).
  3394. *
  3395. * @note This sub-procedure is complete when either ATT_PREPARE_WRITE_RSP
  3396. * (with bleTimeout status), ATT_EXECUTE_WRITE_RSP
  3397. * (with SUCCESS or bleTimeout status), or ATT_ERROR_RSP
  3398. * (with SUCCESS status) is received by the calling application task.
  3399. *
  3400. * @note The 'pReq->pValue' pointer will be freed when the sub-procedure is complete.
  3401. *
  3402. * @param connHandle - connection to use
  3403. * @param pReq - pointer to request to be sent
  3404. * @param taskId - task to be notified of response
  3405. *
  3406. * @return SUCCESS: Request was sent successfully.<BR>
  3407. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3408. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3409. * bleNotConnected: Connection is down.<BR>
  3410. * blePending: A response is pending with this server.<BR>
  3411. * bleMemAllocError: Memory allocation error occurred.<BR>
  3412. * bleTimeout: Previous transaction timed out.<BR>
  3413. */
  3414. extern bStatus_t GATT_WriteLongCharValue( uint16_t connHandle, attPrepareWriteReq_t *pReq, uint8_t taskId );
  3415. /**
  3416. * @brief This sub-procedure is used to write a Characteristic Value to
  3417. * a server when the client knows the Characteristic Value Handle,
  3418. * and assurance is required that the correct Characteristic Value
  3419. * is going to be written by transferring the Characteristic Value
  3420. * to be written in both directions before the write is performed.
  3421. * This sub-procedure can also be used when multiple values must
  3422. * be written, in order, in a single operation.
  3423. *
  3424. * The sub-procedure has two phases, the first phase prepares the
  3425. * characteristic values to be written. Once this is complete,
  3426. * the second phase performs the execution of all of the prepared
  3427. * characteristic value writes on the server from this client.
  3428. *
  3429. * In the first phase, the ATT Prepare Write Request is used.
  3430. * In the second phase, the attribute protocol Execute Write
  3431. * Request is used.
  3432. *
  3433. * If the return status from this function is SUCCESS, the calling
  3434. * application task will receive multiple tmos GATT_MSG_EVENT messages.
  3435. * The type of the messages will be either ATT_PREPARE_WRITE_RSP,
  3436. * ATT_EXECUTE_WRITE_RSP or ATT_ERROR_RSP (if an error occurred on
  3437. * the server).
  3438. *
  3439. * @note This sub-procedure is complete when either ATT_PREPARE_WRITE_RSP
  3440. * (with bleTimeout status), ATT_EXECUTE_WRITE_RSP
  3441. * (with SUCCESS or bleTimeout status), or ATT_ERROR_RSP
  3442. * (with SUCCESS status) is received by the calling application task.
  3443. *
  3444. * @note The 'pReqs' pointer will be freed when the sub-procedure is complete.
  3445. *
  3446. * @param connHandle - connection to use
  3447. * @param pReqs - pointer to requests to be sent
  3448. * @param numReqs - number of requests in pReq
  3449. * @param flags - execute write request flags
  3450. * @param taskId - task to be notified of response
  3451. *
  3452. * @return SUCCESS: Request was sent successfully.<BR>
  3453. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3454. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3455. * bleNotConnected: Connection is down.<BR>
  3456. * blePending: A response is pending with this server.<BR>
  3457. * bleMemAllocError: Memory allocation error occurred.<BR>
  3458. * bleTimeout: Previous transaction timed out.<BR>
  3459. */
  3460. extern bStatus_t GATT_ReliableWrites( uint16_t connHandle, attPrepareWriteReq_t *pReqs, uint8_t numReqs,
  3461. uint8_t flags, uint8_t taskId );
  3462. /**
  3463. * @brief This sub-procedure is used to read a characteristic descriptor
  3464. * from a server when the client knows the characteristic descriptor
  3465. * declaration's Attribute handle.
  3466. *
  3467. * The ATT Read Request is used for this sub-procedure. The Read
  3468. * Request is used with the Attribute Handle parameter set to the
  3469. * characteristic descriptor handle. The Read Response returns the
  3470. * characteristic descriptor value in the Attribute Value parameter.
  3471. *
  3472. * If the return status from this function is SUCCESS, the calling
  3473. * application task will receive an tmos GATT_MSG_EVENT message.
  3474. * The type of the message will be either ATT_READ_RSP or
  3475. * ATT_ERROR_RSP (if an error occurred on the server).
  3476. *
  3477. * @note This sub-procedure is complete when either ATT_READ_RSP
  3478. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP
  3479. * (with SUCCESS status) is received by the calling application task.
  3480. *
  3481. * @param connHandle - connection to use
  3482. * @param pReq - pointer to request to be sent
  3483. * @param taskId - task to be notified of response
  3484. *
  3485. * @return SUCCESS: Request was sent successfully.<BR>
  3486. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3487. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3488. * bleNotConnected: Connection is down.<BR>
  3489. * blePending: A response is pending with this server.<BR>
  3490. * bleMemAllocError: Memory allocation error occurred.<BR>
  3491. * bleTimeout: Previous transaction timed out.<BR>
  3492. */
  3493. extern bStatus_t GATT_ReadCharDesc( uint16_t connHandle, attReadReq_t *pReq, uint8_t taskId );
  3494. /**
  3495. * @brief This sub-procedure is used to read a characteristic descriptor
  3496. * from a server when the client knows the characteristic descriptor
  3497. * declaration's Attribute handle and the length of the characteristic
  3498. * descriptor declaration is longer than can be sent in a single Read
  3499. * Response attribute protocol message.
  3500. *
  3501. * The ATT Read Blob Request is used to perform this sub-procedure.
  3502. * The Attribute Handle parameter shall be set to the characteristic
  3503. * descriptor handle. The Value Offset parameter shall be the offset
  3504. * within the characteristic descriptor to be read.
  3505. *
  3506. * If the return status from this function is SUCCESS, the calling
  3507. * application task will receive multiple tmos GATT_MSG_EVENT messages.
  3508. * The type of the messages will be either ATT_READ_BLOB_RSP or
  3509. * ATT_ERROR_RSP (if an error occurred on the server).
  3510. *
  3511. * @note This sub-procedure is complete when either ATT_READ_BLOB_RSP
  3512. * (with bleProcedureComplete or bleTimeout status) or ATT_ERROR_RSP
  3513. * (with SUCCESS status) is received by the calling application task.
  3514. *
  3515. * @param connHandle - connection to use
  3516. * @param pReq - pointer to request to be sent
  3517. * @param taskId - task to be notified of response
  3518. *
  3519. * @return SUCCESS: Request was sent successfully.<BR>
  3520. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3521. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3522. * bleNotConnected: Connection is down.<BR>
  3523. * blePending: A response is pending with this server.<BR>
  3524. * bleMemAllocError: Memory allocation error occurred.<BR>
  3525. * bleTimeout: Previous transaction timed out.<BR>
  3526. */
  3527. extern bStatus_t GATT_ReadLongCharDesc( uint16_t connHandle, attReadBlobReq_t *pReq, uint8_t taskId );
  3528. /**
  3529. * @brief This sub-procedure is used to write a characteristic
  3530. * descriptor value to a server when the client knows the
  3531. * characteristic descriptor handle.
  3532. *
  3533. * The ATT Write Request is used for this sub-procedure. The
  3534. * Attribute Handle parameter shall be set to the characteristic
  3535. * descriptor handle. The Attribute Value parameter shall be
  3536. * set to the new characteristic descriptor value.
  3537. *
  3538. * If the return status from this function is SUCCESS, the calling
  3539. * application task will receive an tmos GATT_MSG_EVENT message.
  3540. * The type of the message will be either ATT_WRITE_RSP
  3541. * or ATT_ERROR_RSP (if an error occurred on the server).
  3542. *
  3543. * @note This sub-procedure is complete when either ATT_WRITE_RSP
  3544. * (with SUCCESS or bleTimeout status) or ATT_ERROR_RSP
  3545. * (with SUCCESS status) is received by the calling application task.
  3546. *
  3547. * @param connHandle - connection to use
  3548. * @param pReq - pointer to request to be sent
  3549. * @param taskId - task to be notified of response
  3550. *
  3551. * @return SUCCESS: Request was sent successfully.<BR>
  3552. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3553. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3554. * bleNotConnected: Connection is down.<BR>
  3555. * blePending: A response is pending with this server.<BR>
  3556. * bleMemAllocError: Memory allocation error occurred.<BR>
  3557. * bleTimeout: Previous transaction timed out.<BR>
  3558. */
  3559. extern bStatus_t GATT_WriteCharDesc( uint16_t connHandle, attWriteReq_t *pReq, uint8_t taskId );
  3560. /**
  3561. * @brief This sub-procedure is used to write a Characteristic Value to
  3562. * a server when the client knows the Characteristic Value Handle
  3563. * but the length of the Characteristic Value is longer than can
  3564. * be sent in a single Write Request Attribute Protocol message.
  3565. *
  3566. * The ATT Prepare Write Request and Execute Write Request are
  3567. * used to perform this sub-procedure.
  3568. *
  3569. * If the return status from this function is SUCCESS, the calling
  3570. * application task will receive multiple tmos GATT_MSG_EVENT messages.
  3571. * The type of the messages will be either ATT_PREPARE_WRITE_RSP,
  3572. * ATT_EXECUTE_WRITE_RSP or ATT_ERROR_RSP (if an error occurred on
  3573. * the server).
  3574. *
  3575. * @note This sub-procedure is complete when either ATT_PREPARE_WRITE_RSP
  3576. * (with bleTimeout status), ATT_EXECUTE_WRITE_RSP
  3577. * (with SUCCESS or bleTimeout status), or ATT_ERROR_RSP
  3578. * (with SUCCESS status) is received by the calling application task.
  3579. *
  3580. * @note The 'pReq->pValue' pointer will be freed when the sub-procedure is complete.
  3581. *
  3582. * @param connHandle - connection to use
  3583. * @param pReq - pointer to request to be sent
  3584. * @param taskId - task to be notified of response
  3585. *
  3586. * @return SUCCESS: Request was sent successfully.<BR>
  3587. * INVALIDPARAMETER: Invalid connection handle or request field.v
  3588. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3589. * bleNotConnected: Connection is down.<BR>
  3590. * blePending: A response is pending with this server.<BR>
  3591. * bleMemAllocError: Memory allocation error occurred.<BR>
  3592. * bleTimeout: Previous transaction timed out.<BR>
  3593. */
  3594. extern bStatus_t GATT_WriteLongCharDesc( uint16_t connHandle, attPrepareWriteReq_t *pReq, uint8_t taskId );
  3595. /**
  3596. * @brief GATT implementation of the allocator functionality.
  3597. *
  3598. * @note This function should only be called by GATT and the upper layer protocol/application.
  3599. *
  3600. * @param connHandle - connection that message is to be sent on.
  3601. * @param opcode - opcode of message that buffer to be allocated for.
  3602. * @param size - number of bytes to allocate from the heap.
  3603. * @param pSizeAlloc - number of bytes allocated for the caller from the heap.
  3604. * @param flag - .
  3605. *
  3606. * @return pointer to the heap allocation; NULL if error or failure.
  3607. */
  3608. extern void *GATT_bm_alloc( uint16_t connHandle, uint8_t opcode, uint16_t size, uint16_t *pSizeAlloc, uint8_t flag );
  3609. /**
  3610. * @brief GATT implementation of the de-allocator functionality.
  3611. *
  3612. * @param pMsg - pointer to GATT message containing the memory to free.
  3613. * @param opcode - opcode of the message
  3614. *
  3615. * @return none
  3616. */
  3617. extern void GATT_bm_free( gattMsg_t *pMsg, uint8_t opcode );
  3618. /**
  3619. * @brief Register a service's attribute list and callback functions with
  3620. * the GATT Server Application.
  3621. *
  3622. * @param pAttrs - Array of attribute records to be registered
  3623. * @param numAttrs - Number of attributes in array
  3624. * @param encKeySize - Minimum encryption key size required by service (7-16 bytes)
  3625. * @param pServiceCBs - Service callback function pointers
  3626. *
  3627. * @return SUCCESS: Service registered successfully.<BR>
  3628. * INVALIDPARAMETER: Invalid service fields.<BR>
  3629. * FAILURE: Not enough attribute handles available.<BR>
  3630. * bleMemAllocError: Memory allocation error occurred.<BR>
  3631. * bleInvalidRange: Encryption key size's out of range.<BR>
  3632. */
  3633. extern bStatus_t GATTServApp_RegisterService( gattAttribute_t *pAttrs, uint16_t numAttrs,
  3634. uint8_t encKeySize, gattServiceCBs_t *pServiceCBs );
  3635. /**
  3636. * @brief Add function for the GATT Service.
  3637. *
  3638. * @param services - services to add. This is a bit map and can
  3639. * contain more than one service.
  3640. *
  3641. * @return SUCCESS: Service added successfully.<BR>
  3642. * INVALIDPARAMETER: Invalid service field.<BR>
  3643. * FAILURE: Not enough attribute handles available.<BR>
  3644. * bleMemAllocError: Memory allocation error occurred.<BR>
  3645. */
  3646. extern bStatus_t GATTServApp_AddService( uint32_t services );
  3647. /**
  3648. * @brief Deregister a service's attribute list and callback functions from
  3649. * the GATT Server Application.
  3650. *
  3651. * @note It's the caller's responsibility to free the service attribute
  3652. * list returned from this API.
  3653. *
  3654. * @param handle - handle of service to be deregistered
  3655. * @param p2pAttrs - pointer to array of attribute records (to be returned)
  3656. *
  3657. * @return SUCCESS: Service deregistered successfully.<BR>
  3658. * FAILURE: Service not found.<BR>
  3659. */
  3660. extern bStatus_t GATTServApp_DeregisterService( uint16_t handle, gattAttribute_t **p2pAttrs );
  3661. /**
  3662. * @brief Initialize the client characteristic configuration table.
  3663. *
  3664. * @note Each client has its own instantiation of the ClientCharacteristic Configuration.
  3665. * Reads/Writes of the Client Characteristic Configuration only only affect the
  3666. * configuration of that client.
  3667. *
  3668. * @param connHandle - connection handle (0xFFFF for all connections).
  3669. * @param charCfgTbl - client characteristic configuration table.
  3670. *
  3671. * @return none
  3672. */
  3673. extern void GATTServApp_InitCharCfg( uint16_t connHandle, gattCharCfg_t *charCfgTbl );
  3674. /**
  3675. * @brief Send out a Service Changed Indication.
  3676. *
  3677. * @param connHandle - connection to use
  3678. * @param taskId - task to be notified of confirmation
  3679. *
  3680. * @return SUCCESS: Indication was sent successfully.<BR>
  3681. * FAILURE: Service Changed attribute not found.<BR>
  3682. * INVALIDPARAMETER: Invalid connection handle or request field.<BR>
  3683. * MSG_BUFFER_NOT_AVAIL: No HCI buffer is available.<BR>
  3684. * bleNotConnected: Connection is down.<BR>
  3685. * blePending: A confirmation is pending with this client.<BR>
  3686. */
  3687. extern bStatus_t GATTServApp_SendServiceChangedInd( uint16_t connHandle, uint8_t taskId );
  3688. /**
  3689. * @brief Read the client characteristic configuration for a given client.
  3690. *
  3691. * @note Each client has its own instantiation of the Client Characteristic Configuration.
  3692. * Reads of the Client Characteristic Configuration only shows the configuration
  3693. * for that client.
  3694. *
  3695. * @param connHandle - connection handle.
  3696. * @param charCfgTbl - client characteristic configuration table.
  3697. *
  3698. * @return attribute value
  3699. */
  3700. extern uint16_t GATTServApp_ReadCharCfg( uint16_t connHandle, gattCharCfg_t *charCfgTbl );
  3701. /**
  3702. * @brief Write the client characteristic configuration for a given client.
  3703. *
  3704. * @note Each client has its own instantiation of the Client Characteristic Configuration.
  3705. * Writes of the Client Characteristic Configuration only only affect the
  3706. * configuration of that client.
  3707. *
  3708. * @param connHandle - connection handle.
  3709. * @param charCfgTbl - client characteristic configuration table.
  3710. * @param value - attribute new value.
  3711. *
  3712. * @return Success or Failure
  3713. */
  3714. extern uint8_t GATTServApp_WriteCharCfg( uint16_t connHandle, gattCharCfg_t *charCfgTbl, uint16_t value );
  3715. /**
  3716. * @brief Process the client characteristic configuration
  3717. * write request for a given client.
  3718. *
  3719. * @param connHandle - connection message was received on.
  3720. * @param pAttr - pointer to attribute.
  3721. * @param pValue - pointer to data to be written.
  3722. * @param len - length of data.
  3723. * @param offset - offset of the first octet to be written.
  3724. * @param validCfg - valid configuration.
  3725. *
  3726. * @return Success or Failure
  3727. */
  3728. extern bStatus_t GATTServApp_ProcessCCCWriteReq( uint16_t connHandle, gattAttribute_t *pAttr,
  3729. uint8_t *pValue, uint16_t len, uint16_t offset, uint16_t validCfg );
  3730. /**
  3731. * @brief Set a GAP GATT Server parameter.
  3732. *
  3733. * @param param - Profile parameter ID<BR>
  3734. * @param len - length of data to right
  3735. * @param value - pointer to data to write. This is dependent on
  3736. * the parameter ID and WILL be cast to the appropriate
  3737. * data type (example: data type of uint16_t will be cast to
  3738. * uint16_t pointer).<BR>
  3739. *
  3740. * @return bStatus_t
  3741. */
  3742. extern bStatus_t GGS_SetParameter( uint8_t param, uint8_t len, void *value );
  3743. /**
  3744. * @brief Get a GAP GATT Server parameter.
  3745. *
  3746. * @param param - Profile parameter ID<BR>
  3747. * @param value - pointer to data to put. This is dependent on
  3748. * the parameter ID and WILL be cast to the appropriate
  3749. * data type (example: data type of uint16_t will be cast to
  3750. * uint16_t pointer).<BR>
  3751. *
  3752. * @return bStatus_t
  3753. */
  3754. extern bStatus_t GGS_GetParameter( uint8_t param, void *value );
  3755. /**
  3756. * @brief Add function for the GAP GATT Service.
  3757. *
  3758. * @param services - services to add. This is a bit map and can
  3759. * contain more than one service.
  3760. *
  3761. * @return SUCCESS: Service added successfully.<BR>
  3762. * INVALIDPARAMETER: Invalid service field.<BR>
  3763. * FAILURE: Not enough attribute handles available.<BR>
  3764. * bleMemAllocError: Memory allocation error occurred.<BR>
  3765. */
  3766. extern bStatus_t GGS_AddService( uint32_t services );
  3767. /*-------------------------------------------------------------------
  3768. * FUNCTIONS - Initialization and Configuration
  3769. */
  3770. /**
  3771. * @brief Set a GAP Parameter value. Use this function to change the default GAP parameter values.
  3772. *
  3773. * @param paramID - parameter ID: @ref GAP_PARAMETER_ID_DEFINES
  3774. * @param paramValue - new param value
  3775. *
  3776. * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
  3777. */
  3778. extern bStatus_t GAP_SetParamValue( uint16_t paramID, uint16_t paramValue );
  3779. /**
  3780. * @brief Get a GAP Parameter value.
  3781. *
  3782. * @note This function is the same as GAP_PasskeyUpdate(), except that
  3783. * the passkey is passed in as a non-string format.
  3784. *
  3785. * @param paramID - parameter ID: @ref GAP_PARAMETER_ID_DEFINES
  3786. *
  3787. * @return GAP Parameter value or 0xFFFF if invalid
  3788. */
  3789. extern uint16_t GAP_GetParamValue( uint16_t paramID );
  3790. /**
  3791. * @brief Setup the device's address type. If ADDRTYPE_PRIVATE_RESOLVE is selected,
  3792. * the address will change periodically.
  3793. *
  3794. * @param addrType - @ref GAP_ADDR_TYPE_DEFINES
  3795. * @param pStaticAddr - Only used with ADDRTYPE_STATIC or ADDRTYPE_PRIVATE_NONRESOLVE type
  3796. * NULL to auto generate otherwise the application can specify the address value
  3797. *
  3798. * @return SUCCESS: address type updated,<BR>
  3799. * bleNotReady: Can't be called until GAP_DeviceInit() is called
  3800. * and the init process is completed
  3801. * bleIncorrectMode: can't change with an active connection,or INVALIDPARAMETER
  3802. * If return value isn't SUCCESS, the address type remains the same as before this call.
  3803. */
  3804. extern bStatus_t GAP_ConfigDeviceAddr( uint8_t addrType, uint8_t *pStaticAddr );
  3805. /**
  3806. * @brief Resolves a private address against an IRK.
  3807. *
  3808. * @param(in) pIRK - pointer to the IRK
  3809. * @param(in) pAddr - pointer to the Resolvable Private address
  3810. *
  3811. * @param(out) pIRK
  3812. * @param(out) pAddr
  3813. *
  3814. * @return SUCCESS: match,<BR>
  3815. * FAILURE: don't match,<BR>
  3816. * INVALIDPARAMETER: parameters invalid<BR>
  3817. */
  3818. extern bStatus_t GAP_ResolvePrivateAddr( uint8_t *pIRK, uint8_t *pAddr );
  3819. /**
  3820. * @brief Setup or change advertising and scan response data.
  3821. *
  3822. * @note if the return status from this function is SUCCESS,the task isn't complete
  3823. * until the GAP_ADV_DATA_UPDATE_DONE_EVENT is sent to the calling application task.
  3824. *
  3825. * @param taskID - task ID of the app requesting the change
  3826. * @param adType - TRUE - advertisement data, FALSE - scan response data
  3827. * @param dataLen - Octet length of advertData
  3828. * @param pAdvertData - advertising or scan response data
  3829. *
  3830. * @return SUCCESS: data accepted
  3831. * bleIncorrectMode: invalid profile role
  3832. */
  3833. extern bStatus_t GAP_UpdateAdvertisingData( uint8_t taskID, uint8_t adType, uint16_t dataLen, uint8_t *pAdvertData );
  3834. /*-------------------------------------------------------------------
  3835. * FUNCTIONS - GAP Bond API
  3836. */
  3837. /**
  3838. * @brief Set a GAP Bond Manager parameter.
  3839. *
  3840. * @note You can call this function with a GAP Parameter ID and it will set the GAP Parameter.
  3841. *
  3842. * @param param - Profile parameter ID: @ref GAPBOND_PROFILE_PARAMETERS
  3843. * @param len - length of data to write
  3844. * @param pValue - pointer to data to write. This is dependent on
  3845. * the parameter ID and WILL be cast to the appropriate
  3846. * data type (example: data type of uint16_t will be cast to
  3847. * uint16_t pointer).
  3848. *
  3849. * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
  3850. */
  3851. extern bStatus_t GAPBondMgr_SetParameter( uint16_t param, uint8_t len, void *pValue );
  3852. /**
  3853. * @brief Get a GAP Bond Manager parameter.
  3854. *
  3855. * @note You can call this function with a GAP Parameter ID and it will get a GAP Parameter.
  3856. *
  3857. * @param param - Profile parameter ID: @ref GAPBOND_PROFILE_PARAMETERS
  3858. * @param pValue - pointer to location to get the value. This is dependent on
  3859. * the parameter ID and WILL be cast to the appropriate data type.
  3860. * (example: data type of uint16_t will be cast to uint16_t pointer)
  3861. *
  3862. * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
  3863. */
  3864. extern bStatus_t GAPBondMgr_GetParameter( uint16_t param, void *pValue );
  3865. /**
  3866. * @brief Respond to a passcode request.
  3867. *
  3868. * @param connectionHandle - connection handle of the connected device or 0xFFFF if all devices in database.
  3869. * @param status - SUCCESS if passcode is available, otherwise see @ref SMP_PAIRING_FAILED_DEFINES.
  3870. * @param passcode - integer value containing the passcode.
  3871. *
  3872. * @return SUCCESS - bond record found and changed
  3873. * bleIncorrectMode - Link not found.
  3874. */
  3875. extern bStatus_t GAPBondMgr_PasscodeRsp( uint16_t connectionHandle, uint8_t status, uint32_t passcode );
  3876. /**
  3877. * @brief Respond to a passcode request.
  3878. *
  3879. * @param connHandle - connection handle of the connected device or 0xFFFF if all devices in database.
  3880. * @param status - SUCCESS if oob data is available, otherwise see @ref SMP_PAIRING_FAILED_DEFINES.
  3881. * @param oob - containing the oob data.
  3882. * @param c_peer - containing the peer confirm.
  3883. *
  3884. * @return SUCCESS - bond record found and changed
  3885. * bleIncorrectMode - Link not found.
  3886. */
  3887. extern bStatus_t GAPBondMgr_OobRsp( uint16_t connHandle, uint8_t status, uint8_t *oob, uint8_t * c_peer );
  3888. /**
  3889. * @brief Initialization function for the ecc-function callback.
  3890. *
  3891. * @param pEcc - callback registration Structure @ref gapEccCBs_t.
  3892. *
  3893. * @return null.
  3894. */
  3895. extern void GAPBondMgr_EccInit( gapEccCBs_t *pEcc );
  3896. /**
  3897. * @brief Send a security request
  3898. *
  3899. * @param connHandle - connection handle
  3900. *
  3901. * @return SUCCESS: will send
  3902. * bleNotConnected: Link not found
  3903. * bleIncorrectMode: wrong GAP role, must be a Peripheral Role
  3904. */
  3905. extern bStatus_t GAPBondMgr_PeriSecurityReq( uint16_t connHandle );
  3906. /*-------------------------------------------------------------------
  3907. * FUNCTIONS - GAPRole API
  3908. */
  3909. /**
  3910. * @brief Set a GAP Role parameter.
  3911. *
  3912. * @note You can call this function with a GAP Parameter ID and it will set a GAP Parameter.
  3913. *
  3914. * @param param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
  3915. * @param len - length of data to write
  3916. * @param pValue - pointer to data to write. This is dependent on the parameter ID and
  3917. * WILL be cast to the appropriate data type (example: data type of uint16_t
  3918. * will be cast to uint16_t pointer).
  3919. *
  3920. * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
  3921. */
  3922. extern bStatus_t GAPRole_SetParameter( uint16_t param, uint16_t len, void *pValue );
  3923. /**
  3924. * @brief Get a GAP Role parameter.
  3925. *
  3926. * @note You can call this function with a GAP Parameter ID and it will get a GAP Parameter.
  3927. *
  3928. * @param param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
  3929. * @param pValue - pointer to location to get the value. This is dependent on
  3930. * the parameter ID and WILL be cast to the appropriate
  3931. * data type (example: data type of uint16_t will be cast to
  3932. * uint16_t pointer).
  3933. *
  3934. * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
  3935. */
  3936. extern bStatus_t GAPRole_GetParameter( uint16_t param, void *pValue );
  3937. /**
  3938. * @brief Terminates the existing connection.
  3939. *
  3940. * @return SUCCESS or bleIncorrectMode
  3941. */
  3942. extern bStatus_t GAPRole_TerminateLink( uint16_t connHandle );
  3943. /**
  3944. * @brief Read Rssi Cmd.
  3945. *
  3946. * @param connHandle - connection handle
  3947. *
  3948. * @return bStatus_t: HCI Error Code.<BR>
  3949. *
  3950. */
  3951. extern bStatus_t GAPRole_ReadRssiCmd( uint16_t connHandle );
  3952. /**
  3953. * @brief used to synchronize with a periodic advertising train from an advertiser and
  3954. * begin receiving periodic advertising packets.
  3955. *
  3956. * @param pSync - sync parameters@ gapCreateSync_t
  3957. *
  3958. * @return bStatus_t: HCI Error Code.<BR>
  3959. *
  3960. */
  3961. extern bStatus_t GAPRole_CreateSync( gapCreateSync_t *pSync );
  3962. /**
  3963. * @brief used to cancel the HCI_LE_Periodic_Advertising_Create_Sync command while
  3964. * it is pending.
  3965. *
  3966. * @param None.
  3967. *
  3968. * @return bStatus_t: HCI Error Code.<BR>
  3969. *
  3970. */
  3971. extern bStatus_t GAPRole_CancelSync( void );
  3972. /**
  3973. * @brief used to stop reception of the periodic advertising train identified
  3974. * by the Sync_Handle parameter.
  3975. *
  3976. * @param syncHandle-identifying the periodic advertising train
  3977. *
  3978. * @return bStatus_t: HCI Error Code.<BR>
  3979. *
  3980. */
  3981. extern bStatus_t GAPRole_TerminateSync( uint16_t syncHandle );
  3982. /**
  3983. * @brief used to instruct the Controller to send synchronization information about the periodic
  3984. * advertising in an advertising set to a connected device.
  3985. *
  3986. * @param pSync - sync parameters@ gapSyncTransferParam_t
  3987. *
  3988. * @return bStatus_t: HCI Error Code.<BR>
  3989. *
  3990. */
  3991. extern bStatus_t GAPRole_SyncTransferParameters( gapSyncTransferParam_t *pSync );
  3992. /**
  3993. * @brief used to instruct the Controller to send synchronization information about the periodic
  3994. * advertising train identified by the Sync_Handle parameter to a connected device.
  3995. *
  3996. * @param pSync - sync parameters@ gapSyncTransferSync_t
  3997. *
  3998. * @return bStatus_t: HCI Error Code.<BR>
  3999. *
  4000. */
  4001. extern bStatus_t GAPRole_SyncTransferSync( gapSyncTransferSync_t *pSync );
  4002. /**
  4003. * @brief used to instruct the Controller to send synchronization information about the periodic
  4004. * advertising in an advertising set to a connected device.
  4005. *
  4006. * @param pSync - sync parameters@ gapSyncTransferAdvertising_t
  4007. *
  4008. * @return bStatus_t: HCI Error Code.<BR>
  4009. *
  4010. */
  4011. extern bStatus_t GAPRole_SyncTransferAdvertising( gapSyncTransferAdvertising_t *pSync );
  4012. /**
  4013. * @brief Update the link connection parameters.
  4014. *
  4015. * @param connHandle - connection handle
  4016. * @param connIntervalMin - minimum connection interval in 1.25ms units
  4017. * @param connIntervalMax - maximum connection interval in 1.25ms units
  4018. * @param connLatency - number of LL latency connection events
  4019. * @param connTimeout - connection timeout in 10ms units
  4020. *
  4021. * @return SUCCESS: Connection update started started.<BR>
  4022. * bleIncorrectMode: No connection to update.<BR>
  4023. */
  4024. extern bStatus_t GAPRole_UpdateLink( uint16_t connHandle, uint16_t connIntervalMin,
  4025. uint16_t connIntervalMax, uint16_t connLatency, uint16_t connTimeout );
  4026. /**
  4027. * @brief Update the connection phy.
  4028. *
  4029. * @param connHandle - connection handle
  4030. * @param all_phys - a bit field that allows the Host to specify, for each direction
  4031. * set BIT0:The Host has no preference among the transmitter PHYs supported by the Controller
  4032. * set BIT1:The Host has no preference among the receiver PHYs supported by the Controller
  4033. * @param tx_phys - a bit field that indicates the transmitter PHYs.(GAP_PHY_BIT_TYPE)
  4034. * @param rx_phys - a bit field that indicates the receiver PHYs.(GAP_PHY_BIT_TYPE)
  4035. * @param phy_options - preferred coding when transmitting on the LE Coded PHY(GAP_PHY_OPTIONS_TYPE)
  4036. *
  4037. * @return SUCCESS: PHY update started started .<BR>
  4038. * bleIncorrectMode: No connection to update.<BR>
  4039. */
  4040. extern bStatus_t GAPRole_UpdatePHY( uint16_t connHandle, uint8_t all_phys, uint8_t tx_phys,\
  4041. uint8_t rx_phys, uint16_t phy_options );
  4042. /**
  4043. * @brief used to allow the Host to specify the privacy mode to be used for a given entry on the resolving list.
  4044. *
  4045. * @note This command shall not be used when address resolution is enabled in the Controller and:
  4046. * Advertising (other than periodic advertising) is enabled,
  4047. * Scanning is enabled, or
  4048. * an GAPRole_CentralEstablishLink, or GAPRole_CreateSync command is pending.
  4049. *
  4050. * @param addrTypePeer - 0x00:Public Identity Address 0x01:Random (static) Identity Address
  4051. * @param peerAddr - Public Identity Address or Random (static) Identity Address of the advertiser
  4052. * @param privacyMode - 0x00:Use Network Privacy Mode for this peer device (default)
  4053. * 0x01:Use Device Privacy Mode for this peer device
  4054. *
  4055. * @return Command Status.
  4056. *
  4057. */
  4058. extern bStatus_t GAPRole_SetPrivacyMode( uint8_t addrTypePeer, uint8_t *peerAddr, uint8_t privacyMode );
  4059. /**
  4060. * @brief used to set the path loss threshold reporting parameters.
  4061. *
  4062. * @param pParm - set path loss parameters@ gapRoleSetPathLossReporting_t
  4063. *
  4064. * @return Command Status.
  4065. *
  4066. */
  4067. extern bStatus_t GAPRole_SetPathLossReporting( gapRoleSetPathLossReporting_t *pParm );
  4068. /**
  4069. * @brief used to set power level management.
  4070. *
  4071. * @param pParm - set power level parameters@ gapRolePowerlevelManagement_t
  4072. *
  4073. * @return Command Status.
  4074. *
  4075. */
  4076. extern bStatus_t GAPRole_SetPowerlevel( gapRolePowerlevelManagement_t *pParm );
  4077. /**
  4078. * @brief used to set the parameters for pawr advertising..
  4079. *
  4080. * @param pParm - set pawr parameters@ gapPawrSetParam_t
  4081. *
  4082. * @return Command Status.
  4083. *
  4084. */
  4085. extern bStatus_t GAPPawr_SetParameters( gapPawrSetParam_t *pParm );
  4086. /**
  4087. * @brief used to set the data for one or more subevents of PAwR in reply to an
  4088. * HCI_LE_Periodic_Advertising_Subevent_Data_Request event.
  4089. *
  4090. * @param advHandle - advertising handle
  4091. * @param numSubevents - the number of subevent data contained in the parameter arrays.
  4092. * @param pParm - The arrayed parameter @ gapPawrSetResponseData_t
  4093. *
  4094. * @return Command Status.
  4095. *
  4096. */
  4097. extern bStatus_t GAPPawr_SetSubeventData( uint8_t advHandle, uint8_t numSubevents, gapPawrSetData_t *pParm );
  4098. /**
  4099. * @brief used by the Host to set the data for a response slot in a specific subevent
  4100. * of the PAwR identified by the Sync_Handle.
  4101. *
  4102. * @param pParm - The parameter @ gapPawrSetResponseData_t
  4103. *
  4104. * @return Command Status.
  4105. *
  4106. */
  4107. extern bStatus_t GAPPawr_SetResponseData( gapPawrSetResponseData_t *pParm );
  4108. /**
  4109. * @brief used to create an ACL connection between a periodic advertiser and a synchronized device.
  4110. *
  4111. * @param pParm - The parameter @ gapPawrCreateConnection_t
  4112. *
  4113. * @return Command Status.
  4114. *
  4115. */
  4116. extern bStatus_t GAPPawr_CreatConnection( gapPawrCreateConnection_t *pParm );
  4117. /*-------------------------------------------------------------------
  4118. * FUNCTIONS - BROADCASTER_PROFILE_API Broadcaster Profile API
  4119. */
  4120. /**
  4121. *
  4122. * @brief Initialization function for the GAP Role Task.
  4123. *
  4124. * @param None.
  4125. *
  4126. * @return SUCCESS,bleInvalidRange
  4127. */
  4128. extern bStatus_t GAPRole_BroadcasterInit( void );
  4129. /**
  4130. * @brief Does the device initialization. Only call this function once.
  4131. *
  4132. * @param pAppCallbacks - pointer to application callbacks.
  4133. *
  4134. * @return SUCCESS or bleAlreadyInRequestedMode
  4135. */
  4136. extern bStatus_t GAPRole_BroadcasterStartDevice( gapRolesBroadcasterCBs_t *pAppCallbacks );
  4137. /**
  4138. * @brief Does the Broadcaster receive scan request call initialization.
  4139. *
  4140. * @param pAppCallbacks - pointer to application callbacks.
  4141. *
  4142. * @return None
  4143. */
  4144. extern void GAPRole_BroadcasterSetCB( gapRolesBroadcasterCBs_t *pAppCallbacks );
  4145. /*-------------------------------------------------------------------
  4146. * FUNCTIONS - OBSERVER_PROFILE_API Observer Profile API
  4147. */
  4148. /**
  4149. * @internal
  4150. *
  4151. * @brief Observer Profile Task initialization function.
  4152. *
  4153. * @param None.
  4154. *
  4155. * @return SUCCESS,bleInvalidRange
  4156. */
  4157. extern bStatus_t GAPRole_ObserverInit( void );
  4158. /**
  4159. * @brief Start the device in Observer role. This function is typically
  4160. * called once during system startup.
  4161. *
  4162. * @param pAppCallbacks - pointer to application callbacks
  4163. *
  4164. * @return SUCCESS: Operation successful.<BR>
  4165. * bleAlreadyInRequestedMode: Device already started.<BR>
  4166. */
  4167. extern bStatus_t GAPRole_ObserverStartDevice( gapRoleObserverCB_t *pAppCallbacks );
  4168. /**
  4169. * @brief Start a device discovery scan.
  4170. *
  4171. * @param mode - discovery mode: @ref GAP_DEVDISC_MODE_DEFINES
  4172. * @param activeScan - TRUE to perform active scan
  4173. * @param whiteList - TRUE to only scan for devices in the white list
  4174. *
  4175. * @return SUCCESS: Discovery scan started.<BR>
  4176. * bleIncorrectMode: Invalid profile role.<BR>
  4177. * bleAlreadyInRequestedMode: Not available.<BR>
  4178. */
  4179. extern bStatus_t GAPRole_ObserverStartDiscovery( uint8_t mode, uint8_t activeScan, uint8_t whiteList );
  4180. /**
  4181. * @brief Cancel a device discovery scan.
  4182. *
  4183. * @return SUCCESS: Cancel started.<BR>
  4184. * bleInvalidTaskID: Not the task that started discovery.<BR>
  4185. * bleIncorrectMode: Not in discovery mode.<BR>
  4186. */
  4187. extern bStatus_t GAPRole_ObserverCancelDiscovery( void );
  4188. /*-------------------------------------------------------------------
  4189. * FUNCTIONS - PERIPHERAL_PROFILE_API Peripheral Profile API
  4190. */
  4191. /**
  4192. * @internal
  4193. *
  4194. * @brief Initialization function for the GAP Role Task.
  4195. * This is called during initialization and should contain
  4196. * any application specific initialization (ie. hardware
  4197. * initialization/setup, table initialization, power up
  4198. * notificaiton ... ).
  4199. *
  4200. * @param None.
  4201. *
  4202. * @return SUCCESS,bleInvalidRange
  4203. */
  4204. extern bStatus_t GAPRole_PeripheralInit( void );
  4205. /**
  4206. * @brief Does the device initialization. Only call this function once.
  4207. *
  4208. * @param pAppCallbacks - pointer to application callbacks.
  4209. *
  4210. * @return SUCCESS or bleAlreadyInRequestedMode
  4211. */
  4212. extern bStatus_t GAPRole_PeripheralStartDevice( uint8_t taskid, gapBondCBs_t *pCB, gapRolesCBs_t *pAppCallbacks );
  4213. /**
  4214. * @brief Update the parameters of an existing connection
  4215. *
  4216. * @param connHandle - the connection Handle
  4217. * @param connIntervalMin - minimum connection interval in 1.25ms units
  4218. * @param connIntervalMax - maximum connection interval in 1.25ms units
  4219. * @param latency - the new slave latency
  4220. * @param connTimeout - the new timeout value
  4221. * @param taskId - taskID will recv L2CAP_SIGNAL_EVENT message
  4222. *
  4223. * @return SUCCESS, bleNotConnected or bleInvalidRange
  4224. */
  4225. extern bStatus_t GAPRole_PeripheralConnParamUpdateReq( uint16_t connHandle, uint16_t connIntervalMin,
  4226. uint16_t connIntervalMax, uint16_t latency, uint16_t connTimeout, uint8_t taskId );
  4227. /*-------------------------------------------------------------------
  4228. * FUNCTIONS - CENTRAL_PROFILE_API Central Profile API
  4229. */
  4230. /**
  4231. * @internal
  4232. *
  4233. * @brief Central Profile Task initialization function.
  4234. *
  4235. * @param None.
  4236. *
  4237. * @return SUCCESS,bleInvalidRange
  4238. */
  4239. extern bStatus_t GAPRole_CentralInit( void );
  4240. /**
  4241. * @brief Start the device in Central role. This function is typically
  4242. * called once during system startup.
  4243. *
  4244. * @param pAppCallbacks - pointer to application callbacks
  4245. *
  4246. * @return SUCCESS: Operation successful.<BR>
  4247. * bleAlreadyInRequestedMode: Device already started.<BR>
  4248. */
  4249. extern bStatus_t GAPRole_CentralStartDevice( uint8_t taskid, gapBondCBs_t *pCB, gapCentralRoleCB_t *pAppCallbacks );
  4250. /**
  4251. * @brief Start a device discovery scan.
  4252. *
  4253. * @param mode - discovery mode: @ref GAP_DEVDISC_MODE_DEFINES
  4254. * @param activeScan - TRUE to perform active scan
  4255. * @param whiteList - TRUE to only scan for devices in the white list
  4256. *
  4257. * @return SUCCESS: Discovery scan started.<BR>
  4258. * bleIncorrectMode: Invalid profile role.<BR>
  4259. * bleAlreadyInRequestedMode: Not available.<BR>
  4260. */
  4261. extern bStatus_t GAPRole_CentralStartDiscovery( uint8_t mode, uint8_t activeScan, uint8_t whiteList );
  4262. /**
  4263. * @brief Cancel a device discovery scan.
  4264. *
  4265. * @return SUCCESS: Cancel started.<BR>
  4266. * bleInvalidTaskID: Not the task that started discovery.<BR>
  4267. * bleIncorrectMode: Not in discovery mode.<BR>
  4268. */
  4269. extern bStatus_t GAPRole_CentralCancelDiscovery( void );
  4270. /**
  4271. * @brief This API is called by the Central to update the Host data channels
  4272. * initiating an Update Data Channel control procedure.
  4273. *
  4274. * @note While it isn't specified,it is assumed that the Host expects an
  4275. * update channel map on all active connections and periodic advertise.
  4276. *
  4277. * input parameters
  4278. *
  4279. * @param chanMap - A five byte array containing one bit per data channel
  4280. * where a 1 means the channel is "used".
  4281. *
  4282. * @return SUCCESS
  4283. */
  4284. extern void GAPRole_SetHostChanClassification( uint8_t *chanMap );
  4285. /**
  4286. * @brief Establish a link to a peer device.
  4287. *
  4288. * @param highDutyCycle - TRUE to high duty cycle scan, FALSE if not
  4289. * @param whiteList - determines use of the white list: TRUE-enable
  4290. * @param addrTypePeer - address type of the peer device: @ref GAP_ADDR_TYPE_DEFINES
  4291. * @param peerAddr - peer device address
  4292. *
  4293. * @return SUCCESS: started establish link process.<BR>
  4294. * bleIncorrectMode: invalid profile role.<BR>
  4295. * bleNotReady: a scan is in progress.<BR>
  4296. * bleAlreadyInRequestedMode: can't process now.<BR>
  4297. * bleNoResources: too many links.<BR>
  4298. */
  4299. extern bStatus_t GAPRole_CentralEstablishLink( uint8_t highDutyCycle, uint8_t whiteList, uint8_t addrTypePeer, uint8_t *peerAddr );
  4300. /*-------------------------------------------------------------------
  4301. * FUNCTIONS - RF_PHY Profile API
  4302. */
  4303. /**
  4304. * @brief RF_PHY Profile Task initialization function.
  4305. *
  4306. * @param None.
  4307. *
  4308. * @return 0 - success.
  4309. */
  4310. extern bStatus_t RF_RoleInit( void );
  4311. /**
  4312. * @brief rf config.
  4313. *
  4314. * @param pConfig - rf config parameters
  4315. *
  4316. * @return 0 - success.
  4317. */
  4318. extern bStatus_t RF_Config( rfConfig_t *pConfig );
  4319. /**
  4320. * @brief rx mode.
  4321. *
  4322. * @param txBuf - rx mode tx data
  4323. * @param txLen - rx mode tx length(0-251)
  4324. * @param pktRxType - rx mode rx package type
  4325. * broadcast type(0xFF):receive all matching types,
  4326. * others:receive match type or broadcast type
  4327. * @param pktTxType - rx mode tx package type(auto mode)
  4328. * broadcast type(0xFF):received by all matching types;
  4329. * others:only received by matching type
  4330. *
  4331. * @return 0 - success. 1-access address error 2-busy
  4332. */
  4333. extern bStatus_t RF_Rx( uint8_t *txBuf, uint8_t txLen, uint8_t pktRxType, uint8_t pktTxType );
  4334. /**
  4335. * @brief tx mode.
  4336. *
  4337. * @param txBuf - tx mode tx data
  4338. * @param txLen - tx mode tx length(0-251)
  4339. * @param pktTxType - tx mode tx package type
  4340. * broadcast type(0xFF):received by all matching types;
  4341. * others:only received by matching type
  4342. * @param pktRxType - tx mode rx package type(auto mode)
  4343. * broadcast type(0xFF):receive all matching types,
  4344. * others:receive match type or broadcast type
  4345. *
  4346. * @return 0 - success. 1-access address error 2-busy
  4347. */
  4348. extern bStatus_t RF_Tx( uint8_t *txBuf, uint8_t txLen, uint8_t pktTxType, uint8_t pktRxType );
  4349. /**
  4350. * @brief shut down,stop tx/rx mode.
  4351. *
  4352. * @param None.
  4353. *
  4354. * @return 0 - success.
  4355. */
  4356. extern bStatus_t RF_Shut( void );
  4357. /**
  4358. * @brief rf mode set radio channel/frequency.
  4359. *
  4360. * @param channel.
  4361. *
  4362. * @return 0 - success.
  4363. */
  4364. extern void RF_SetChannel( uint32_t channel );
  4365. /**
  4366. * @brief rf mode set radio frequency and whitening channel index
  4367. * note: LLEMode bit6 set 1
  4368. *
  4369. * @param frequency -
  4370. * @param ch - the whitening channel index
  4371. *
  4372. * @return 0 - success.
  4373. */
  4374. extern bStatus_t RF_SetFrequency( uint32_t frequency, uint8_t ch );
  4375. /**
  4376. * @brief shut down rf frequency hopping
  4377. *
  4378. * @param None.
  4379. *
  4380. * @return None.
  4381. */
  4382. extern void RF_FrequencyHoppingShut( void );
  4383. /**
  4384. * @brief
  4385. *
  4386. * @param resendCount - Maximum count of sending HOP_TX pdu,0 = unlimited.
  4387. *
  4388. * @return 0 - success.
  4389. */
  4390. extern uint8_t RF_FrequencyHoppingTx( uint8_t resendCount );
  4391. /**
  4392. * @brief
  4393. *
  4394. * @param timeoutMS - Maximum time to wait for receiving HOP_TX pdu(Time = n * 1mSec),0 = unlimited.
  4395. *
  4396. * @return 0 - success.1-fail.2-LLEMode error(shall AUTO)
  4397. */
  4398. extern uint8_t RF_FrequencyHoppingRx( uint32_t timeoutMS );
  4399. /**
  4400. * @brief Erase FH bonded device
  4401. *
  4402. * @param None.
  4403. *
  4404. * @return None.
  4405. */
  4406. extern void RF_BondingErase( void );
  4407. /**
  4408. * @brief single channel mode.
  4409. *
  4410. * @param ch - rf channel,f=2402+ch*2 MHz, ch=0,...,39
  4411. *
  4412. * @return 0 - success.
  4413. */
  4414. extern bStatus_t LL_SingleChannel( uint8_t ch );
  4415. /**
  4416. * @brief used to stop any test which is in progress.
  4417. *
  4418. * @param(in) pPktNum - null
  4419. *
  4420. * @param(out) the number of received packets.
  4421. *
  4422. * @return 0 - success.
  4423. */
  4424. extern bStatus_t LL_TestEnd( uint8_t *pPktNum );
  4425. /**
  4426. * @brief used to start a test where the DUT receives test reference packets at a fixed interval
  4427. *
  4428. * input parameters
  4429. *
  4430. * @param opcode = 0x201D
  4431. * pParm0 - RX_Channel
  4432. *
  4433. * opcode = 0x2033
  4434. * pParm0 - RX_Channel
  4435. * pParm1 - PHY
  4436. * pParm2 - Modulation_Index
  4437. *
  4438. * @return 0 - success.
  4439. */
  4440. extern bStatus_t API_LE_ReceiverTestCmd( uint8_t *pParm, uint16_t opcode );
  4441. /**
  4442. * @brief used to start a test where the DUT generates test reference packets at a fixed interval
  4443. *
  4444. * @param opcode = 0x201E
  4445. * pParm 0 - TX_Channel
  4446. * pParm 1 - Test_Data_Length
  4447. * pParm 2 - Packet_Payload
  4448. *
  4449. * opcode = 0x2034
  4450. * pParm 0 - TX_Channel
  4451. * pParm 1 - Test_Data_Length
  4452. * pParm 2 - Packet_Payload
  4453. * pParm 3 - PHY
  4454. *
  4455. * @return 0 - success.
  4456. */
  4457. extern bStatus_t API_LE_TransmitterTestCmd( uint8_t *pParm, uint16_t opcode );
  4458. /**
  4459. * @brief used to stop any test which is in progress
  4460. *
  4461. * @param None
  4462. *
  4463. * @return 0 - success.
  4464. */
  4465. extern bStatus_t API_LE_TestEndCmd( void );
  4466. /**
  4467. * @brief used to set sensitivity level
  4468. *
  4469. * @param None
  4470. *
  4471. * @return None.
  4472. */
  4473. extern void RFEND_SetSensitivity( void );
  4474. /**
  4475. * @brief used to set rf TxCtune value
  4476. *
  4477. * @param pParm(in) - Must provide length of parameter followed by 6 bytes parameter
  4478. *
  4479. * @return Command Status.
  4480. */
  4481. extern bStatus_t RFEND_TXCtuneSet( uint8_t *pParm );
  4482. /**
  4483. * @brief used to get rf TxCtune value
  4484. *
  4485. * @param pParm(out) - length of parameter(6) followed by 6 bytes parameter
  4486. *
  4487. * @return Command Status.
  4488. */
  4489. extern bStatus_t RFEND_TXCtuneGet( uint8_t *pParm );
  4490. /*
  4491. * END @ Profile API
  4492. */
  4493. /******************************************************************************/
  4494. #ifdef __cplusplus
  4495. }
  4496. #endif
  4497. #endif