wchble_rom.h 243 KB

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