2
0

ant.cpp 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171
  1. /*
  2. This software is subject to the license described in the License.txt file
  3. included with this software distribution. You may not use this file except
  4. in compliance with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2016
  6. All rights reserved.
  7. */
  8. /*
  9. **************************************************************************
  10. *
  11. * DESCRIPTION:
  12. *
  13. * This module is an example wrapper for the ANT communications library
  14. * It sets up and maintains the link, and provides a simplified API to the
  15. * application.
  16. *
  17. **************************************************************************
  18. */
  19. #include <string.h> // memcpy
  20. #include <stdio.h>
  21. #include <assert.h>
  22. #include "ant.h"
  23. #include "version.h"
  24. #include "types.h"
  25. #include "defines.h"
  26. #include "antdefines.h"
  27. #include "usb_device_handle.hpp"
  28. #include "dsi_serial_generic.hpp"
  29. #if defined(DSI_TYPES_WINDOWS)
  30. #include "dsi_serial_vcp.hpp"
  31. #endif
  32. #include "dsi_framer_ant.hpp"
  33. #include "dsi_thread.h"
  34. #if defined(DEBUG_FILE)
  35. #include "dsi_debug.hpp"
  36. #endif
  37. #define MAX_CHANNELS ((UCHAR) 8)
  38. #define MESG_CHANNEL_OFFSET 0
  39. #define MESG_EVENT_ID_OFFSET 1
  40. #define MESG_EVENT_CODE_OFFSET 2
  41. // Struct to define channel event callback functions
  42. // and recieve buffer.
  43. typedef struct
  44. {
  45. CHANNEL_EVENT_FUNC pfLinkEvent;
  46. UCHAR *pucRxBuffer;
  47. } CHANNEL_LINK;
  48. // Local variables.
  49. static DSISerial* pclSerialObject = NULL;
  50. static DSIFramerANT* pclMessageObject = NULL;
  51. static DSI_THREAD_ID uiDSIThread;
  52. static DSI_CONDITION_VAR condTestDone;
  53. static DSI_MUTEX mutexTestDone;
  54. // Local Data
  55. static RESPONSE_FUNC pfResponseFunc = NULL; //pointer to main response callback function
  56. static UCHAR *pucResponseBuffer = NULL; //pointer to buffer used to hold data from the response message
  57. static CHANNEL_LINK sLink[MAX_CHANNELS]; //array of pointer for each channel
  58. static BOOL bInitialized = FALSE;
  59. static UCHAR ucAutoTransferChannel = 0xFF;
  60. static USHORT usNumDataPackets = 0;
  61. static BOOL bGoThread = FALSE;
  62. static DSI_THREAD_IDNUM eTheThread;
  63. // Local funcs
  64. static DSI_THREAD_RETURN MessageThread(void *pvParameter_);
  65. static void SerialHaveMessage(ANT_MESSAGE& stMessage_, USHORT usSize_);
  66. static void MemoryCleanup(); //Deletes internal objects from memory
  67. extern "C" EXPORT
  68. BOOL ANT_Init(UCHAR ucUSBDeviceNum, ULONG ulBaudrate)
  69. {
  70. return ANT_InitExt(ucUSBDeviceNum, ulBaudrate, PORT_TYPE_USB, FRAMER_TYPE_BASIC);
  71. }
  72. //Initializes and opens USB connection to the module
  73. extern "C" EXPORT
  74. BOOL ANT_InitExt(UCHAR ucUSBDeviceNum, ULONG ulBaudrate, UCHAR ucPortType_, UCHAR ucSerialFrameType_)
  75. {
  76. DSI_THREAD_IDNUM eThread = DSIThread_GetCurrentThreadIDNum();
  77. assert(eTheThread != eThread); // CANNOT CALL THIS FUNCTION FROM DLL THREAD (INSIDE DLL CALLBACK ROUTINES).
  78. assert(!bInitialized); // IF ANT WAS ALREADY INITIALIZED, DO NOT CALL THIS FUNCTION BEFORE CALLING ANT_Close();
  79. #if defined(DEBUG_FILE)
  80. DSIDebug::Init();
  81. DSIDebug::SetDebug(TRUE);
  82. #endif
  83. //Create Serial object.
  84. pclSerialObject = NULL;
  85. switch(ucPortType_)
  86. {
  87. case PORT_TYPE_USB:
  88. pclSerialObject = new DSISerialGeneric();
  89. break;
  90. #if defined(DSI_TYPES_WINDOWS)
  91. case PORT_TYPE_COM:
  92. pclSerialObject = new DSISerialVCP();
  93. break;
  94. #endif
  95. default: //Invalid port type selection
  96. return(FALSE);
  97. }
  98. if(!pclSerialObject)
  99. return(FALSE);
  100. //Initialize Serial object.
  101. //NOTE: Will fail if the module is not available.
  102. if(!pclSerialObject->Init(ulBaudrate, ucUSBDeviceNum))
  103. {
  104. MemoryCleanup();
  105. return(FALSE);
  106. }
  107. //Create Framer object.
  108. pclMessageObject = NULL;
  109. switch(ucSerialFrameType_)
  110. {
  111. case FRAMER_TYPE_BASIC:
  112. pclMessageObject = new DSIFramerANT(pclSerialObject);
  113. break;
  114. default:
  115. MemoryCleanup();
  116. return(FALSE);
  117. }
  118. if(!pclMessageObject)
  119. {
  120. MemoryCleanup();
  121. return(FALSE);
  122. }
  123. //Initialize Framer object.
  124. if(!pclMessageObject->Init())
  125. {
  126. MemoryCleanup();
  127. return(FALSE);
  128. }
  129. //Let Serial know about Framer.
  130. pclSerialObject->SetCallback(pclMessageObject);
  131. //Open Serial.
  132. if(!pclSerialObject->Open())
  133. {
  134. MemoryCleanup();
  135. return(FALSE);
  136. }
  137. //Create message thread.
  138. UCHAR ucCondInit= DSIThread_CondInit(&condTestDone);
  139. assert(ucCondInit == DSI_THREAD_ENONE);
  140. UCHAR ucMutexInit = DSIThread_MutexInit(&mutexTestDone);
  141. assert(ucMutexInit == DSI_THREAD_ENONE);
  142. bGoThread = TRUE;
  143. uiDSIThread = DSIThread_CreateThread(MessageThread, NULL);
  144. if(!uiDSIThread)
  145. {
  146. MemoryCleanup();
  147. bGoThread = FALSE;
  148. return(FALSE);
  149. }
  150. bInitialized = TRUE;
  151. return(TRUE);
  152. }
  153. ///////////////////////////////////////////////////////////////////////
  154. // Called by the application to close the usb connection
  155. // MUST NOT BE CALLED IN THE CONTEXT OF THE MessageThread. That is,
  156. // At the application level it must not be called within the
  157. // callback functions into this library.
  158. ///////////////////////////////////////////////////////////////////////
  159. extern "C" EXPORT
  160. void ANT_Close(void)
  161. {
  162. DSI_THREAD_IDNUM eThread = DSIThread_GetCurrentThreadIDNum();
  163. assert(eTheThread != eThread); // CANNOT CALL THIS FUNCTION FROM DLL THREAD (INSIDE DLL CALLBACK ROUTINES).
  164. if (!bInitialized)
  165. return;
  166. bInitialized = FALSE;
  167. DSIThread_MutexLock(&mutexTestDone);
  168. bGoThread = FALSE;
  169. UCHAR ucWaitResult = DSIThread_CondTimedWait(&condTestDone, &mutexTestDone, DSI_THREAD_INFINITE);
  170. assert(ucWaitResult == DSI_THREAD_ENONE);
  171. DSIThread_MutexUnlock(&mutexTestDone);
  172. //Destroy mutex and condition var
  173. DSIThread_MutexDestroy(&mutexTestDone);
  174. DSIThread_CondDestroy(&condTestDone);
  175. MemoryCleanup();
  176. #if defined(DEBUG_FILE)
  177. DSIDebug::Close();
  178. #endif
  179. }
  180. ///////////////////////////////////////////////////////////////////////
  181. // Priority: Any
  182. //
  183. // Called by the application to initialize the main callback funcation,
  184. // the main callback funcation must be initialized before the application
  185. // can receive any reponse messages.
  186. ///////////////////////////////////////////////////////////////////////
  187. extern "C" EXPORT
  188. void ANT_AssignResponseFunction(RESPONSE_FUNC pfResponse_, UCHAR* pucResponseBuffer_)
  189. {
  190. pfResponseFunc = pfResponse_;
  191. pucResponseBuffer = pucResponseBuffer_;
  192. }
  193. ///////////////////////////////////////////////////////////////////////
  194. // Priority: Any
  195. //
  196. // Called by the application to initialize the callback funcation and
  197. // data buffers for a particular channel. This must be done in order
  198. // for a channel to function properly.
  199. ///////////////////////////////////////////////////////////////////////
  200. extern "C" EXPORT
  201. void ANT_AssignChannelEventFunction(UCHAR ucLink, CHANNEL_EVENT_FUNC pfLinkEvent, UCHAR *pucRxBuffer)
  202. {
  203. if(ucLink < MAX_CHANNELS)
  204. {
  205. sLink[ucLink].pfLinkEvent = pfLinkEvent;
  206. sLink[ucLink].pucRxBuffer = pucRxBuffer;
  207. }
  208. }
  209. ///////////////////////////////////////////////////////////////////////
  210. // Priority: Any
  211. //
  212. // Unassigns response function. Important for memory management of
  213. // higher layer applications to avoid this library calling invalid pointers
  214. ///////////////////////////////////////////////////////////////////////
  215. extern "C" EXPORT
  216. void ANT_UnassignAllResponseFunctions()
  217. {
  218. pfResponseFunc = NULL;
  219. pucResponseBuffer = NULL;
  220. for(int i=0; i< MAX_CHANNELS; ++i)
  221. {
  222. sLink[i].pfLinkEvent = NULL;
  223. sLink[i].pucRxBuffer = NULL;
  224. }
  225. }
  226. ///////////////////////////////////////////////////////////////////////
  227. // Priority: Any
  228. //
  229. // Returns a pointer to a string constant containing the core library
  230. // version.
  231. ///////////////////////////////////////////////////////////////////////
  232. extern "C" EXPORT
  233. const char* ANT_LibVersion(void)
  234. {
  235. return(SW_VER);
  236. }
  237. ///////////////////////////////////////////////////////////////////////
  238. // Priority: Any
  239. //
  240. // Called by the application to restart ANT on the module
  241. ///////////////////////////////////////////////////////////////////////
  242. extern "C" EXPORT
  243. BOOL ANT_ResetSystem(void)
  244. {
  245. if(pclMessageObject)
  246. return(pclMessageObject->ResetSystem());
  247. return(FALSE);
  248. }
  249. ///////////////////////////////////////////////////////////////////////
  250. // Priority: Any
  251. //
  252. // Called by the application to set the network address for a given
  253. // module channel
  254. //!! This is (should be) a private network function
  255. ///////////////////////////////////////////////////////////////////////
  256. extern "C" EXPORT
  257. BOOL ANT_SetNetworkKey(UCHAR ucNetNumber, UCHAR *pucKey)
  258. {
  259. return ANT_SetNetworkKey_RTO(ucNetNumber, pucKey, 0);
  260. }
  261. ///////////////////////////////////////////////////////////////////////
  262. // Response TimeOut Version
  263. ///////////////////////////////////////////////////////////////////////
  264. extern "C" EXPORT
  265. BOOL ANT_SetNetworkKey_RTO(UCHAR ucNetNumber, UCHAR *pucKey, ULONG ulResponseTime_)
  266. {
  267. if(pclMessageObject)
  268. {
  269. return(pclMessageObject->SetNetworkKey(ucNetNumber, pucKey, ulResponseTime_));
  270. }
  271. return(FALSE);
  272. }
  273. ///////////////////////////////////////////////////////////////////////
  274. // Priority: Any
  275. //
  276. // Called by the application to assign a channel
  277. ///////////////////////////////////////////////////////////////////////
  278. extern "C" EXPORT
  279. BOOL ANT_AssignChannel(UCHAR ucANTChannel, UCHAR ucChannelType_, UCHAR ucNetNumber)
  280. {
  281. return ANT_AssignChannel_RTO(ucANTChannel, ucChannelType_, ucNetNumber, 0);
  282. }
  283. ///////////////////////////////////////////////////////////////////////
  284. // Response TimeOut Version
  285. ///////////////////////////////////////////////////////////////////////
  286. extern "C" EXPORT
  287. BOOL ANT_AssignChannel_RTO(UCHAR ucANTChannel, UCHAR ucChannelType_, UCHAR ucNetNumber, ULONG ulResponseTime_)
  288. {
  289. if(pclMessageObject)
  290. {
  291. return(pclMessageObject->AssignChannel(ucANTChannel, ucChannelType_, ucNetNumber, ulResponseTime_));
  292. }
  293. return(FALSE);
  294. }
  295. ///////////////////////////////////////////////////////////////////////
  296. // Priority: Any
  297. //
  298. // Called by the application to assign a channel using extended assignment
  299. ///////////////////////////////////////////////////////////////////////
  300. extern "C" EXPORT
  301. BOOL ANT_AssignChannelExt(UCHAR ucANTChannel, UCHAR ucChannelType_, UCHAR ucNetNumber, UCHAR ucExtFlags_)
  302. {
  303. return ANT_AssignChannelExt_RTO(ucANTChannel, ucChannelType_, ucNetNumber, ucExtFlags_, 0);
  304. }
  305. ///////////////////////////////////////////////////////////////////////
  306. // Response TimeOut Version
  307. ///////////////////////////////////////////////////////////////////////
  308. extern "C" EXPORT
  309. BOOL ANT_AssignChannelExt_RTO(UCHAR ucANTChannel, UCHAR ucChannelType_, UCHAR ucNetNumber, UCHAR ucExtFlags_, ULONG ulResponseTime_)
  310. {
  311. if(pclMessageObject)
  312. {
  313. UCHAR aucChannelType[] = {ucChannelType_, ucExtFlags_}; // Channel Type + Extended Assignment Byte
  314. return(pclMessageObject->AssignChannelExt(ucANTChannel, aucChannelType, 2, ucNetNumber, ulResponseTime_));
  315. }
  316. return(FALSE);
  317. }
  318. ///////////////////////////////////////////////////////////////////////
  319. // Priority: Any
  320. //
  321. // Called by the application to unassign a channel
  322. ///////////////////////////////////////////////////////////////////////
  323. extern "C" EXPORT
  324. BOOL ANT_UnAssignChannel(UCHAR ucANTChannel)
  325. {
  326. return ANT_UnAssignChannel_RTO(ucANTChannel, 0);
  327. }
  328. ///////////////////////////////////////////////////////////////////////
  329. // Response TimeOut Version
  330. ///////////////////////////////////////////////////////////////////////
  331. extern "C" EXPORT
  332. BOOL ANT_UnAssignChannel_RTO(UCHAR ucANTChannel, ULONG ulResponseTime_)
  333. {
  334. if(pclMessageObject)
  335. {
  336. return(pclMessageObject->UnAssignChannel(ucANTChannel, ulResponseTime_));
  337. }
  338. return(FALSE);
  339. }
  340. ///////////////////////////////////////////////////////////////////////
  341. // Priority: Any
  342. //
  343. // Called by the application to set the channel ID
  344. ///////////////////////////////////////////////////////////////////////
  345. extern "C" EXPORT
  346. BOOL ANT_SetChannelId(UCHAR ucANTChannel_, USHORT usDeviceNumber_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_)
  347. {
  348. return ANT_SetChannelId_RTO(ucANTChannel_, usDeviceNumber_, ucDeviceType_, ucTransmissionType_, 0);
  349. }
  350. ///////////////////////////////////////////////////////////////////////
  351. // Response TimeOut Version
  352. ///////////////////////////////////////////////////////////////////////
  353. extern "C" EXPORT
  354. BOOL ANT_SetChannelId_RTO(UCHAR ucANTChannel_, USHORT usDeviceNumber_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_, ULONG ulResponseTime_)
  355. {
  356. if(pclMessageObject)
  357. {
  358. return(pclMessageObject->SetChannelID(ucANTChannel_, usDeviceNumber_, ucDeviceType_, ucTransmissionType_, ulResponseTime_));
  359. }
  360. return(FALSE);
  361. }
  362. ///////////////////////////////////////////////////////////////////////
  363. // Priority: Any
  364. //
  365. // Called by the application to set the messaging period
  366. ///////////////////////////////////////////////////////////////////////
  367. extern "C" EXPORT
  368. BOOL ANT_SetChannelPeriod(UCHAR ucANTChannel_, USHORT usMesgPeriod_)
  369. {
  370. return ANT_SetChannelPeriod_RTO(ucANTChannel_, usMesgPeriod_, 0);
  371. }
  372. ///////////////////////////////////////////////////////////////////////
  373. // Response TimeOut Version
  374. ///////////////////////////////////////////////////////////////////////
  375. extern "C" EXPORT
  376. BOOL ANT_SetChannelPeriod_RTO(UCHAR ucANTChannel_, USHORT usMesgPeriod_, ULONG ulResponseTime_)
  377. {
  378. if(pclMessageObject)
  379. {
  380. return(pclMessageObject->SetChannelPeriod(ucANTChannel_, usMesgPeriod_, ulResponseTime_));
  381. }
  382. return(FALSE);
  383. }
  384. ///////////////////////////////////////////////////////////////////////
  385. // Priority: Any
  386. //
  387. // Called by the application to set the messaging period
  388. ///////////////////////////////////////////////////////////////////////
  389. extern "C" EXPORT
  390. BOOL ANT_RSSI_SetSearchThreshold(UCHAR ucANTChannel_, UCHAR ucThreshold_)
  391. {
  392. return ANT_RSSI_SetSearchThreshold_RTO(ucANTChannel_, ucThreshold_, 0);
  393. }
  394. ///////////////////////////////////////////////////////////////////////
  395. // Response TimeOut Version
  396. ///////////////////////////////////////////////////////////////////////
  397. extern "C" EXPORT
  398. BOOL ANT_RSSI_SetSearchThreshold_RTO(UCHAR ucANTChannel_, UCHAR ucThreshold_, ULONG ulResponseTime_)
  399. {
  400. if(pclMessageObject)
  401. {
  402. return(pclMessageObject->SetRSSISearchThreshold(ucANTChannel_, ucThreshold_, ulResponseTime_));
  403. }
  404. return(FALSE);
  405. }
  406. ///////////////////////////////////////////////////////////////////////
  407. // Priority: Any
  408. //
  409. // Used to set Low Priority Search Timeout. Not available on AP1
  410. ///////////////////////////////////////////////////////////////////////
  411. extern "C" EXPORT
  412. BOOL ANT_SetLowPriorityChannelSearchTimeout(UCHAR ucANTChannel_, UCHAR ucSearchTimeout_)
  413. {
  414. return ANT_SetLowPriorityChannelSearchTimeout_RTO(ucANTChannel_, ucSearchTimeout_, 0);
  415. }
  416. ///////////////////////////////////////////////////////////////////////
  417. // Response TimeOut Version
  418. ///////////////////////////////////////////////////////////////////////
  419. extern "C" EXPORT
  420. BOOL ANT_SetLowPriorityChannelSearchTimeout_RTO(UCHAR ucANTChannel_, UCHAR ucSearchTimeout_, ULONG ulResponseTime_)
  421. {
  422. if(pclMessageObject)
  423. {
  424. return(pclMessageObject->SetLowPriorityChannelSearchTimeout(ucANTChannel_, ucSearchTimeout_, ulResponseTime_));
  425. }
  426. return(FALSE);
  427. }
  428. ///////////////////////////////////////////////////////////////////////
  429. // Priority: Any
  430. //
  431. // Called by the application to set the search timeout for a particular
  432. // channel on the module
  433. ///////////////////////////////////////////////////////////////////////
  434. extern "C" EXPORT
  435. BOOL ANT_SetChannelSearchTimeout(UCHAR ucANTChannel_, UCHAR ucSearchTimeout_)
  436. {
  437. return ANT_SetChannelSearchTimeout_RTO(ucANTChannel_, ucSearchTimeout_, 0);
  438. }
  439. ///////////////////////////////////////////////////////////////////////
  440. // Response TimeOut Version
  441. ///////////////////////////////////////////////////////////////////////
  442. extern "C" EXPORT
  443. BOOL ANT_SetChannelSearchTimeout_RTO(UCHAR ucANTChannel_, UCHAR ucSearchTimeout_, ULONG ulResponseTime_)
  444. {
  445. if(pclMessageObject)
  446. {
  447. return(pclMessageObject->SetChannelSearchTimeout(ucANTChannel_, ucSearchTimeout_, ulResponseTime_));
  448. }
  449. return(FALSE);
  450. }
  451. ///////////////////////////////////////////////////////////////////////
  452. // Priority: Any
  453. //
  454. // Called by the application to set the RF frequency for a given channel
  455. //!! This is (should be) a private network function
  456. ///////////////////////////////////////////////////////////////////////
  457. extern "C" EXPORT
  458. BOOL ANT_SetChannelRFFreq(UCHAR ucANTChannel_, UCHAR ucRFFreq_)
  459. {
  460. return ANT_SetChannelRFFreq_RTO(ucANTChannel_, ucRFFreq_, 0);
  461. }
  462. ///////////////////////////////////////////////////////////////////////
  463. // Response TimeOut Version
  464. ///////////////////////////////////////////////////////////////////////
  465. extern "C" EXPORT
  466. BOOL ANT_SetChannelRFFreq_RTO(UCHAR ucANTChannel_, UCHAR ucRFFreq_, ULONG ulResponseTime_)
  467. {
  468. if(pclMessageObject)
  469. {
  470. return(pclMessageObject->SetChannelRFFrequency(ucANTChannel_, ucRFFreq_, ulResponseTime_));
  471. }
  472. return(FALSE);
  473. }
  474. ///////////////////////////////////////////////////////////////////////
  475. // Priority: Any
  476. //
  477. // Called by the application to set the transmit power for the module
  478. ///////////////////////////////////////////////////////////////////////
  479. extern "C" EXPORT
  480. BOOL ANT_SetTransmitPower(UCHAR ucTransmitPower_)
  481. {
  482. return ANT_SetTransmitPower_RTO(ucTransmitPower_, 0);
  483. }
  484. ///////////////////////////////////////////////////////////////////////
  485. // Response TimeOut Version
  486. ///////////////////////////////////////////////////////////////////////
  487. extern "C" EXPORT
  488. BOOL ANT_SetTransmitPower_RTO(UCHAR ucTransmitPower_, ULONG ulResponseTime_)
  489. {
  490. if(pclMessageObject)
  491. {
  492. return(pclMessageObject->SetAllChannelsTransmitPower(ucTransmitPower_, ulResponseTime_));
  493. }
  494. return(FALSE);
  495. }
  496. ///////////////////////////////////////////////////////////////////////
  497. // Priority: Any
  498. //
  499. // Called by the application to configure advanced bursting
  500. ///////////////////////////////////////////////////////////////////////
  501. extern "C" EXPORT
  502. BOOL ANT_ConfigureAdvancedBurst(BOOL bEnable_, UCHAR ucMaxPacketLength_, ULONG ulRequiredFields_, ULONG ulOptionalFields_)
  503. {
  504. return ANT_ConfigureAdvancedBurst_RTO(bEnable_, ucMaxPacketLength_, ulRequiredFields_, ulOptionalFields_, 0);
  505. }
  506. ///////////////////////////////////////////////////////////////////////
  507. // Response TimeOut Version
  508. ///////////////////////////////////////////////////////////////////////
  509. extern "C" EXPORT
  510. BOOL ANT_ConfigureAdvancedBurst_RTO(BOOL bEnable_, UCHAR ucMaxPacketLength_, ULONG ulRequiredFields_, ULONG ulOptionalFields_, ULONG ulResponseTime_)
  511. {
  512. if(pclMessageObject)
  513. {
  514. return(pclMessageObject->ConfigAdvancedBurst(bEnable_, ucMaxPacketLength_, ulRequiredFields_, ulOptionalFields_, ulResponseTime_));
  515. }
  516. return(FALSE);
  517. }
  518. ///////////////////////////////////////////////////////////////////////
  519. // Stall count version
  520. ///////////////////////////////////////////////////////////////////////
  521. extern "C" EXPORT
  522. BOOL ANT_ConfigureAdvancedBurst_ext(BOOL bEnable_, UCHAR ucMaxPacketLength_, ULONG ulRequiredFields_, ULONG ulOptionalFields_, USHORT usStallCount_, UCHAR ucRetryCount_)
  523. {
  524. return ANT_ConfigureAdvancedBurst_ext_RTO(bEnable_, ucMaxPacketLength_, ulRequiredFields_, ulOptionalFields_, usStallCount_, ucRetryCount_, 0);
  525. }
  526. ///////////////////////////////////////////////////////////////////////
  527. // Stall count version with response timeout
  528. ///////////////////////////////////////////////////////////////////////
  529. extern "C" EXPORT
  530. BOOL ANT_ConfigureAdvancedBurst_ext_RTO(BOOL bEnable_, UCHAR ucMaxPacketLength_, ULONG ulRequiredFields_, ULONG ulOptionalFields_, USHORT usStallCount_, UCHAR ucRetryCount_, ULONG ulResponseTime_)
  531. {
  532. if(pclMessageObject)
  533. {
  534. return(pclMessageObject->ConfigAdvancedBurst_ext(bEnable_, ucMaxPacketLength_, ulRequiredFields_, ulOptionalFields_, usStallCount_, ucRetryCount_, ulResponseTime_));
  535. }
  536. return(FALSE);
  537. }
  538. ///////////////////////////////////////////////////////////////////////
  539. // Priority: Any
  540. //
  541. // Called by the application to set the transmit power for the module
  542. ///////////////////////////////////////////////////////////////////////
  543. extern "C" EXPORT
  544. BOOL ANT_SetChannelTxPower(UCHAR ucANTChannel_, UCHAR ucTransmitPower_)
  545. {
  546. return ANT_SetChannelTxPower_RTO(ucANTChannel_, ucTransmitPower_, 0);
  547. }
  548. ///////////////////////////////////////////////////////////////////////
  549. // Response TimeOut Version
  550. ///////////////////////////////////////////////////////////////////////
  551. extern "C" EXPORT
  552. BOOL ANT_SetChannelTxPower_RTO(UCHAR ucANTChannel_, UCHAR ucTransmitPower_, ULONG ulResponseTime_)
  553. {
  554. if(pclMessageObject)
  555. {
  556. return(pclMessageObject->SetChannelTransmitPower(ucANTChannel_, ucTransmitPower_, ulResponseTime_));
  557. }
  558. return(FALSE);
  559. }
  560. ///////////////////////////////////////////////////////////////////////
  561. // Priority: Any
  562. //
  563. // Called by the application to request a generic message
  564. ///////////////////////////////////////////////////////////////////////
  565. extern "C" EXPORT
  566. BOOL ANT_RequestMessage(UCHAR ucANTChannel_, UCHAR ucMessageID_)
  567. {
  568. if(pclMessageObject){
  569. ANT_MESSAGE_ITEM stResponse;
  570. return pclMessageObject->SendRequest(ucMessageID_, ucANTChannel_, &stResponse, 0);
  571. }
  572. return FALSE;
  573. }
  574. ///////////////////////////////////////////////////////////////////////
  575. // Priority: Any
  576. //
  577. // Called by the application to send a generic message
  578. ///////////////////////////////////////////////////////////////////////
  579. extern "C" EXPORT
  580. BOOL ANT_WriteMessage(UCHAR ucMessageID, UCHAR* aucData, USHORT usMessageSize)
  581. {
  582. if(pclMessageObject){
  583. ANT_MESSAGE pstTempANTMessage;
  584. pstTempANTMessage.ucMessageID = ucMessageID;
  585. memcpy(pstTempANTMessage.aucData, aucData, MIN(usMessageSize, MESG_MAX_SIZE_VALUE));
  586. return pclMessageObject->WriteMessage(&pstTempANTMessage, usMessageSize);
  587. }
  588. return FALSE;
  589. }
  590. ///////////////////////////////////////////////////////////////////////
  591. // Priority: Any
  592. //
  593. // Called by the application to open an assigned channel
  594. ///////////////////////////////////////////////////////////////////////
  595. extern "C" EXPORT
  596. BOOL ANT_OpenChannel(UCHAR ucANTChannel_)
  597. {
  598. return ANT_OpenChannel_RTO(ucANTChannel_, 0);
  599. }
  600. ///////////////////////////////////////////////////////////////////////
  601. // Response TimeOut Version
  602. ///////////////////////////////////////////////////////////////////////
  603. extern "C" EXPORT
  604. BOOL ANT_OpenChannel_RTO(UCHAR ucANTChannel_, ULONG ulResponseTime_)
  605. {
  606. if(pclMessageObject)
  607. {
  608. return(pclMessageObject->OpenChannel(ucANTChannel_, ulResponseTime_));
  609. }
  610. return(FALSE);
  611. }
  612. ///////////////////////////////////////////////////////////////////////
  613. // Priority: Any
  614. //
  615. // Called by the application to close an opend channel
  616. ///////////////////////////////////////////////////////////////////////
  617. extern "C" EXPORT
  618. BOOL ANT_CloseChannel(UCHAR ucANTChannel_)
  619. {
  620. return ANT_CloseChannel_RTO(ucANTChannel_, 0);
  621. }
  622. ///////////////////////////////////////////////////////////////////////
  623. // Response TimeOut Version
  624. ///////////////////////////////////////////////////////////////////////
  625. extern "C" EXPORT
  626. BOOL ANT_CloseChannel_RTO(UCHAR ucANTChannel_, ULONG ulResponseTime_)
  627. {
  628. if(pclMessageObject)
  629. {
  630. return(pclMessageObject->CloseChannel(ucANTChannel_, ulResponseTime_));
  631. }
  632. return(FALSE);
  633. }
  634. ///////////////////////////////////////////////////////////////////////
  635. // Priority: Any
  636. //
  637. // Called by the application to construct and send a broadcast data message.
  638. // This message will be broadcast on the next synchronous channel period.
  639. ///////////////////////////////////////////////////////////////////////
  640. extern "C" EXPORT
  641. BOOL ANT_SendBroadcastData(UCHAR ucANTChannel_, UCHAR *pucData_)
  642. {
  643. if(pclMessageObject)
  644. {
  645. return(pclMessageObject->SendBroadcastData(ucANTChannel_, pucData_));
  646. }
  647. return(FALSE);
  648. }
  649. ///////////////////////////////////////////////////////////////////////
  650. // Priority: Any
  651. //
  652. // Called by the application to construct and send an acknowledged data
  653. // mesg. This message will be transmitted on the next synchronous channel
  654. // period.
  655. ///////////////////////////////////////////////////////////////////////
  656. extern "C" EXPORT
  657. BOOL ANT_SendAcknowledgedData(UCHAR ucANTChannel_, UCHAR *pucData_)
  658. {
  659. return ANT_SendAcknowledgedData_RTO(ucANTChannel_, pucData_, 0);
  660. }
  661. ///////////////////////////////////////////////////////////////////////
  662. // Response TimeOut Version
  663. ///////////////////////////////////////////////////////////////////////
  664. extern "C" EXPORT
  665. BOOL ANT_SendAcknowledgedData_RTO(UCHAR ucANTChannel_, UCHAR *pucData_, ULONG ulResponseTime_)
  666. {
  667. if(pclMessageObject)
  668. {
  669. return(pclMessageObject->SendAcknowledgedData( ucANTChannel_, pucData_, ulResponseTime_));
  670. }
  671. return(FALSE);
  672. }
  673. ///////////////////////////////////////////////////////////////////////
  674. // Used to send burst data using a block of data. Proper sequence number
  675. // of packet is maintained by the function. Useful for testing purposes.
  676. ///////////////////////////////////////////////////////////////////////
  677. extern "C" EXPORT
  678. BOOL ANT_SendBurstTransfer(UCHAR ucANTChannel_, UCHAR *pucData_, USHORT usNumDataPackets_)
  679. {
  680. return ANT_SendBurstTransfer_RTO(ucANTChannel_, pucData_, usNumDataPackets_, 0);
  681. }
  682. ///////////////////////////////////////////////////////////////////////
  683. // Response TimeOut Version
  684. ///////////////////////////////////////////////////////////////////////
  685. extern "C" EXPORT
  686. BOOL ANT_SendBurstTransfer_RTO(UCHAR ucANTChannel_, UCHAR *pucData_, USHORT usNumDataPackets_, ULONG ulResponseTime_)
  687. {
  688. ULONG ulSize = usNumDataPackets_*8; // Pass the number of bytes.
  689. ANTFRAMER_RETURN eStatus;
  690. if(pclMessageObject)
  691. {
  692. eStatus = pclMessageObject->SendTransfer( ucANTChannel_, pucData_, ulSize, ulResponseTime_);
  693. if( eStatus == ANTFRAMER_PASS )
  694. return(TRUE);
  695. }
  696. return(FALSE);
  697. }
  698. //////////////////////////////////////////////////////////////////////
  699. // Priority: Any
  700. //
  701. // Called by the application to configure and start CW test mode.
  702. // There is no way to turn off CW mode other than to do a reset on the module.
  703. /////////////////////////////////////////////////////////////////////
  704. extern "C" EXPORT
  705. BOOL ANT_InitCWTestMode(void)
  706. {
  707. return ANT_InitCWTestMode_RTO(0);
  708. }
  709. ///////////////////////////////////////////////////////////////////////
  710. // Response TimeOut Version
  711. ///////////////////////////////////////////////////////////////////////
  712. extern "C" EXPORT
  713. BOOL ANT_InitCWTestMode_RTO(ULONG ulResponseTime_)
  714. {
  715. if(pclMessageObject)
  716. {
  717. return(pclMessageObject->InitCWTestMode(ulResponseTime_));
  718. }
  719. return(FALSE);
  720. }
  721. //////////////////////////////////////////////////////////////////////
  722. // Priority: Any
  723. //
  724. // Called by the application to configure and start CW test mode.
  725. // There is no way to turn off CW mode other than to do a reset on the module.
  726. /////////////////////////////////////////////////////////////////////
  727. extern "C" EXPORT
  728. BOOL ANT_SetCWTestMode(UCHAR ucTransmitPower_, UCHAR ucRFChannel_)
  729. {
  730. return ANT_SetCWTestMode_RTO(ucTransmitPower_, ucRFChannel_, 0);
  731. }
  732. ///////////////////////////////////////////////////////////////////////
  733. // Response TimeOut Version
  734. ///////////////////////////////////////////////////////////////////////
  735. extern "C" EXPORT
  736. BOOL ANT_SetCWTestMode_RTO(UCHAR ucTransmitPower_, UCHAR ucRFChannel_, ULONG ulResponseTime_)
  737. {
  738. if(pclMessageObject)
  739. {
  740. return(pclMessageObject->SetCWTestMode(ucTransmitPower_, ucRFChannel_, ulResponseTime_));
  741. }
  742. return(FALSE);
  743. }
  744. ///////////////////////////////////////////////////////////////////////
  745. // Priority: Any
  746. //
  747. // Add a channel ID to a channel's include/exclude ID list
  748. ///////////////////////////////////////////////////////////////////////
  749. extern "C" EXPORT
  750. BOOL ANT_AddChannelID(UCHAR ucANTChannel_, USHORT usDeviceNumber_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_, UCHAR ucListIndex_)
  751. {
  752. return ANT_AddChannelID_RTO(ucANTChannel_, usDeviceNumber_, ucDeviceType_, ucTransmissionType_, ucListIndex_, 0);
  753. }
  754. ///////////////////////////////////////////////////////////////////////
  755. // Response TimeOut Version
  756. ///////////////////////////////////////////////////////////////////////
  757. extern "C" EXPORT
  758. BOOL ANT_AddChannelID_RTO(UCHAR ucANTChannel_, USHORT usDeviceNumber_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_, UCHAR ucListIndex_, ULONG ulResponseTime_)
  759. {
  760. if(pclMessageObject)
  761. {
  762. return(pclMessageObject->AddChannelID(ucANTChannel_, usDeviceNumber_, ucDeviceType_, ucTransmissionType_, ucListIndex_, ulResponseTime_));
  763. }
  764. return(FALSE);
  765. }
  766. ///////////////////////////////////////////////////////////////////////
  767. // Priority: Any
  768. //
  769. // Configure the size and type of a channel's include/exclude ID list
  770. ///////////////////////////////////////////////////////////////////////
  771. extern "C" EXPORT
  772. BOOL ANT_ConfigList(UCHAR ucANTChannel_, UCHAR ucListSize_, UCHAR ucExclude_)
  773. {
  774. return ANT_ConfigList_RTO(ucANTChannel_, ucListSize_, ucExclude_, 0);
  775. }
  776. ///////////////////////////////////////////////////////////////////////
  777. // Response TimeOut Version
  778. ///////////////////////////////////////////////////////////////////////
  779. extern "C" EXPORT
  780. BOOL ANT_ConfigList_RTO(UCHAR ucANTChannel_, UCHAR ucListSize_, UCHAR ucExclude_, ULONG ulResponseTime_)
  781. {
  782. if(pclMessageObject)
  783. {
  784. return(pclMessageObject->ConfigList(ucANTChannel_, ucListSize_, ucExclude_, ulResponseTime_));
  785. }
  786. return(FALSE);
  787. }
  788. ///////////////////////////////////////////////////////////////////////
  789. // Priority: Any
  790. //
  791. // Open Scan Mode
  792. ///////////////////////////////////////////////////////////////////////
  793. extern "C" EXPORT
  794. BOOL ANT_OpenRxScanMode()
  795. {
  796. return ANT_OpenRxScanMode_RTO(0);
  797. }
  798. ///////////////////////////////////////////////////////////////////////
  799. // Response TimeOut Version
  800. ///////////////////////////////////////////////////////////////////////
  801. extern "C" EXPORT
  802. BOOL ANT_OpenRxScanMode_RTO(ULONG ulResponseTime_)
  803. {
  804. if(pclMessageObject)
  805. {
  806. return(pclMessageObject->OpenRxScanMode(ulResponseTime_));
  807. }
  808. return(FALSE);
  809. }
  810. ///////////////////////////////////////////////////////////////////////
  811. // Priority: Any
  812. //
  813. // Configure ANT Frequency Agility Functionality (not on AP1 or AT3)
  814. ///////////////////////////////////////////////////////////////////////
  815. extern "C" EXPORT
  816. BOOL ANT_ConfigFrequencyAgility(UCHAR ucANTChannel_, UCHAR ucFreq1_, UCHAR ucFreq2_, UCHAR ucFreq3_)
  817. {
  818. return(ANT_ConfigFrequencyAgility_RTO(ucANTChannel_, ucFreq1_, ucFreq2_, ucFreq3_, 0));
  819. }
  820. ///////////////////////////////////////////////////////////////////////
  821. // Response TimeOut Version
  822. ///////////////////////////////////////////////////////////////////////
  823. extern "C" EXPORT
  824. BOOL ANT_ConfigFrequencyAgility_RTO(UCHAR ucANTChannel_, UCHAR ucFreq1_, UCHAR ucFreq2_, UCHAR ucFreq3_, ULONG ulResponseTime_)
  825. {
  826. if(pclMessageObject)
  827. {
  828. return(pclMessageObject->ConfigFrequencyAgility(ucANTChannel_, ucFreq1_, ucFreq2_, ucFreq3_, ulResponseTime_));
  829. }
  830. return(FALSE);
  831. }
  832. ///////////////////////////////////////////////////////////////////////
  833. // Priority: Any
  834. //
  835. // Configure proximity search (not on AP1 or AT3)
  836. ///////////////////////////////////////////////////////////////////////
  837. extern "C" EXPORT
  838. BOOL ANT_SetProximitySearch(UCHAR ucANTChannel_, UCHAR ucSearchThreshold_)
  839. {
  840. return(ANT_SetProximitySearch_RTO(ucANTChannel_, ucSearchThreshold_, 0));
  841. }
  842. ///////////////////////////////////////////////////////////////////////
  843. // Response TimeOut Version
  844. ///////////////////////////////////////////////////////////////////////
  845. extern "C" EXPORT
  846. BOOL ANT_SetProximitySearch_RTO(UCHAR ucANTChannel_, UCHAR ucSearchThreshold_, ULONG ulResponseTime_)
  847. {
  848. if(pclMessageObject)
  849. {
  850. return(pclMessageObject->SetProximitySearch(ucANTChannel_, ucSearchThreshold_, ulResponseTime_));
  851. }
  852. return(FALSE);
  853. }
  854. ///////////////////////////////////////////////////////////////////////
  855. // Priority: Any
  856. //
  857. // Configure Event Filter (USBm and nRF5 only)
  858. ///////////////////////////////////////////////////////////////////////
  859. extern "C" EXPORT
  860. BOOL ANT_ConfigEventFilter(USHORT usEventFilter_)
  861. {
  862. return(ANT_ConfigEventFilter_RTO(usEventFilter_, 0));
  863. }
  864. ///////////////////////////////////////////////////////////////////////
  865. // Response TimeOut Version
  866. ///////////////////////////////////////////////////////////////////////
  867. extern "C" EXPORT
  868. BOOL ANT_ConfigEventFilter_RTO(USHORT usEventFilter_, ULONG ulResponseTime_)
  869. {
  870. if(pclMessageObject)
  871. {
  872. return(pclMessageObject->ConfigEventFilter(usEventFilter_, ulResponseTime_));
  873. }
  874. return(FALSE);
  875. }
  876. ///////////////////////////////////////////////////////////////////////
  877. // Priority: Any
  878. //
  879. // Configure Event Buffer (USBm only)
  880. ///////////////////////////////////////////////////////////////////////
  881. extern "C" EXPORT
  882. BOOL ANT_ConfigEventBuffer(UCHAR ucConfig_, USHORT usSize_, USHORT usTime_)
  883. {
  884. return(ANT_ConfigEventBuffer_RTO(ucConfig_, usSize_, usTime_, 0));
  885. }
  886. ///////////////////////////////////////////////////////////////////////
  887. // Response TimeOut Version
  888. ///////////////////////////////////////////////////////////////////////
  889. extern "C" EXPORT
  890. BOOL ANT_ConfigEventBuffer_RTO(UCHAR ucConfig_, USHORT usSize_, USHORT usTime_, ULONG ulResponseTime_)
  891. {
  892. if(pclMessageObject)
  893. {
  894. return(pclMessageObject->ConfigEventBuffer(ucConfig_, usSize_, usTime_, ulResponseTime_));
  895. }
  896. return(FALSE);
  897. }
  898. ///////////////////////////////////////////////////////////////////////
  899. // Priority: Any
  900. //
  901. // Configure High Duty Search (USBm only)
  902. ///////////////////////////////////////////////////////////////////////
  903. extern "C" EXPORT
  904. BOOL ANT_ConfigHighDutySearch(UCHAR ucEnable_, UCHAR ucSuppressionCycles_)
  905. {
  906. return(ANT_ConfigHighDutySearch_RTO(ucEnable_, ucSuppressionCycles_, 0));
  907. }
  908. ///////////////////////////////////////////////////////////////////////
  909. // Response TimeOut Version
  910. ///////////////////////////////////////////////////////////////////////
  911. extern "C" EXPORT
  912. BOOL ANT_ConfigHighDutySearch_RTO(UCHAR ucEnable_, UCHAR ucSuppressionCycles_, ULONG ulResponseTime_)
  913. {
  914. if(pclMessageObject)
  915. {
  916. return(pclMessageObject->ConfigHighDutySearch(ucEnable_, ucSuppressionCycles_, ulResponseTime_));
  917. }
  918. return(FALSE);
  919. }
  920. ///////////////////////////////////////////////////////////////////////
  921. // Priority: Any
  922. //
  923. // Configure Selective Data Update (USBm only)
  924. ///////////////////////////////////////////////////////////////////////
  925. extern "C" EXPORT
  926. BOOL ANT_ConfigSelectiveDataUpdate(UCHAR ucChannel_, UCHAR ucSduConfig_)
  927. {
  928. return(ANT_ConfigSelectiveDataUpdate_RTO(ucChannel_, ucSduConfig_, 0));
  929. }
  930. ///////////////////////////////////////////////////////////////////////
  931. // Response TimeOut Version
  932. ///////////////////////////////////////////////////////////////////////
  933. extern "C" EXPORT
  934. BOOL ANT_ConfigSelectiveDataUpdate_RTO(UCHAR ucChannel_, UCHAR ucSduConfig_, ULONG ulResponseTime_)
  935. {
  936. if(pclMessageObject)
  937. {
  938. return(pclMessageObject->ConfigSelectiveDataUpdate(ucChannel_, ucSduConfig_, ulResponseTime_));
  939. }
  940. return(FALSE);
  941. }
  942. ///////////////////////////////////////////////////////////////////////
  943. // Priority: Any
  944. //
  945. // Set Selective Data Update Mask (USBm only)
  946. ///////////////////////////////////////////////////////////////////////
  947. extern "C" EXPORT
  948. BOOL ANT_SetSelectiveDataUpdateMask(UCHAR ucMaskNumber_, UCHAR* pucSduMask_)
  949. {
  950. return(ANT_SetSelectiveDataUpdateMask_RTO(ucMaskNumber_, pucSduMask_, 0));
  951. }
  952. ///////////////////////////////////////////////////////////////////////
  953. // Response TimeOut Version
  954. ///////////////////////////////////////////////////////////////////////
  955. extern "C" EXPORT
  956. BOOL ANT_SetSelectiveDataUpdateMask_RTO(UCHAR ucMaskNumber_, UCHAR* pucSduMask_, ULONG ulResponseTime_)
  957. {
  958. if(pclMessageObject)
  959. {
  960. return(pclMessageObject->SetSelectiveDataUpdateMask(ucMaskNumber_, pucSduMask_, ulResponseTime_));
  961. }
  962. return(FALSE);
  963. }
  964. ///////////////////////////////////////////////////////////////////////
  965. // Priority: Any
  966. //
  967. // Configure User NVM (USBm only)
  968. ///////////////////////////////////////////////////////////////////////
  969. extern "C" EXPORT
  970. BOOL ANT_ConfigUserNVM(USHORT usAddress_, UCHAR* pucData_, UCHAR ucSize_)
  971. {
  972. return(ANT_ConfigUserNVM_RTO(usAddress_, pucData_, ucSize_, 0));
  973. }
  974. ///////////////////////////////////////////////////////////////////////
  975. // Response TimeOut Version
  976. ///////////////////////////////////////////////////////////////////////
  977. extern "C" EXPORT
  978. BOOL ANT_ConfigUserNVM_RTO(USHORT usAddress_, UCHAR* pucData_, UCHAR ucSize_, ULONG ulResponseTime_)
  979. {
  980. if(pclMessageObject)
  981. {
  982. return(pclMessageObject->ConfigUserNVM(usAddress_, pucData_, ucSize_, ulResponseTime_));
  983. }
  984. return(FALSE);
  985. }
  986. ///////////////////////////////////////////////////////////////////////
  987. // Priority: Any
  988. //
  989. // Message to put into DEEP SLEEP (not on AP1 or AT3)
  990. ///////////////////////////////////////////////////////////////////////
  991. extern "C" EXPORT
  992. BOOL ANT_SleepMessage()
  993. {
  994. return(ANT_SleepMessage_RTO(0));
  995. }
  996. ///////////////////////////////////////////////////////////////////////
  997. // Response TimeOut Version
  998. ///////////////////////////////////////////////////////////////////////
  999. extern "C" EXPORT
  1000. BOOL ANT_SleepMessage_RTO(ULONG ulResponseTime_)
  1001. {
  1002. if(pclMessageObject)
  1003. {
  1004. return(pclMessageObject->SleepMessage(ulResponseTime_));
  1005. }
  1006. return(FALSE);
  1007. }
  1008. ///////////////////////////////////////////////////////////////////////
  1009. // Priority: Any
  1010. //
  1011. // Message to put into DEEP SLEEP (not on AP1 or AT3)
  1012. ///////////////////////////////////////////////////////////////////////
  1013. extern "C" EXPORT
  1014. BOOL ANT_CrystalEnable()
  1015. {
  1016. return(ANT_CrystalEnable_RTO(0));
  1017. }
  1018. ///////////////////////////////////////////////////////////////////////
  1019. // Response TimeOut Version
  1020. ///////////////////////////////////////////////////////////////////////
  1021. extern "C" EXPORT
  1022. BOOL ANT_CrystalEnable_RTO(ULONG ulResponseTime_)
  1023. {
  1024. if(pclMessageObject)
  1025. {
  1026. return(pclMessageObject->CrystalEnable(ulResponseTime_));
  1027. }
  1028. return(FALSE);
  1029. }
  1030. ///////////////////////////////////////////////////////////////////////
  1031. // Priority: Any
  1032. //
  1033. // Called by the application to write NVM data
  1034. ///////////////////////////////////////////////////////////////////////
  1035. extern "C" EXPORT
  1036. BOOL ANT_NVM_Write(UCHAR ucSize_, UCHAR *pucData_)
  1037. {
  1038. return ANT_NVM_Write_RTO(ucSize_, pucData_ , 0);
  1039. }
  1040. ///////////////////////////////////////////////////////////////////////
  1041. // Response TimeOut Version
  1042. ///////////////////////////////////////////////////////////////////////
  1043. extern "C" EXPORT
  1044. BOOL ANT_NVM_Write_RTO(UCHAR ucSize_, UCHAR *pucData_, ULONG ulResponseTime_)
  1045. {
  1046. if(pclMessageObject)
  1047. {
  1048. return(pclMessageObject->ScriptWrite(ucSize_,pucData_, ulResponseTime_ ));
  1049. }
  1050. return(FALSE);
  1051. }
  1052. ///////////////////////////////////////////////////////////////////////
  1053. // Priority: Any
  1054. //
  1055. // Called by the application to clear NVM data
  1056. ///////////////////////////////////////////////////////////////////////
  1057. extern "C" EXPORT
  1058. BOOL ANT_NVM_Clear(UCHAR ucSectNumber_)
  1059. {
  1060. return ANT_NVM_Clear_RTO(ucSectNumber_, 0);
  1061. }
  1062. ///////////////////////////////////////////////////////////////////////
  1063. // Response TimeOut Version
  1064. ///////////////////////////////////////////////////////////////////////
  1065. extern "C" EXPORT
  1066. BOOL ANT_NVM_Clear_RTO(UCHAR ucSectNumber_, ULONG ulResponseTime_)
  1067. //Sector number is useless here, but is still here for backwards compatibility
  1068. {
  1069. if(pclMessageObject)
  1070. {
  1071. return(pclMessageObject->ScriptClear(ulResponseTime_));
  1072. }
  1073. return(FALSE);
  1074. }
  1075. ///////////////////////////////////////////////////////////////////////
  1076. // Priority: Any
  1077. //
  1078. // Called by the application to set default NVM sector
  1079. ///////////////////////////////////////////////////////////////////////
  1080. extern "C" EXPORT
  1081. BOOL ANT_NVM_SetDefaultSector(UCHAR ucSectNumber_)
  1082. {
  1083. return ANT_NVM_SetDefaultSector_RTO(ucSectNumber_, 0);
  1084. }
  1085. ///////////////////////////////////////////////////////////////////////
  1086. // Response TimeOut Version
  1087. ///////////////////////////////////////////////////////////////////////
  1088. extern "C" EXPORT
  1089. BOOL ANT_NVM_SetDefaultSector_RTO(UCHAR ucSectNumber_, ULONG ulResponseTime_)
  1090. {
  1091. if(pclMessageObject)
  1092. {
  1093. return(pclMessageObject->ScriptSetDefaultSector(ucSectNumber_, ulResponseTime_));
  1094. }
  1095. return(FALSE);
  1096. }
  1097. ///////////////////////////////////////////////////////////////////////
  1098. // Priority: Any
  1099. //
  1100. // Called by the application to end NVM sector
  1101. ///////////////////////////////////////////////////////////////////////
  1102. extern "C" EXPORT
  1103. BOOL ANT_NVM_EndSector()
  1104. {
  1105. return ANT_NVM_EndSector_RTO(0);
  1106. }
  1107. ///////////////////////////////////////////////////////////////////////
  1108. // Response TimeOut Version
  1109. ///////////////////////////////////////////////////////////////////////
  1110. extern "C" EXPORT
  1111. BOOL ANT_NVM_EndSector_RTO(ULONG ulResponseTime_)
  1112. {
  1113. if(pclMessageObject)
  1114. {
  1115. return(pclMessageObject->ScriptEndSector(ulResponseTime_));
  1116. }
  1117. return(FALSE);
  1118. }
  1119. ///////////////////////////////////////////////////////////////////////
  1120. // Priority: Any
  1121. //
  1122. // Called by the application to dump the contents of the NVM
  1123. ///////////////////////////////////////////////////////////////////////
  1124. extern "C" EXPORT
  1125. BOOL ANT_NVM_Dump()
  1126. {
  1127. return ANT_NVM_Dump_RTO(0);
  1128. }
  1129. ///////////////////////////////////////////////////////////////////////
  1130. // Response TimeOut Version
  1131. ///////////////////////////////////////////////////////////////////////
  1132. extern "C" EXPORT
  1133. BOOL ANT_NVM_Dump_RTO(ULONG ulResponseTime_)
  1134. //Response time is useless here, but is kept for backwards compatibility
  1135. {
  1136. if(pclMessageObject)
  1137. {
  1138. pclMessageObject->ScriptDump();
  1139. return TRUE;
  1140. }
  1141. return(FALSE);
  1142. }
  1143. ///////////////////////////////////////////////////////////////////////
  1144. // Priority: Any
  1145. //
  1146. // Called by the application to lock the contents of the NVM
  1147. ///////////////////////////////////////////////////////////////////////
  1148. extern "C" EXPORT
  1149. BOOL ANT_NVM_Lock()
  1150. {
  1151. return ANT_NVM_Lock_RTO(0);
  1152. }
  1153. ///////////////////////////////////////////////////////////////////////
  1154. // Response TimeOut Version
  1155. ///////////////////////////////////////////////////////////////////////
  1156. extern "C" EXPORT
  1157. BOOL ANT_NVM_Lock_RTO(ULONG ulResponseTimeout_)
  1158. {
  1159. if(pclMessageObject)
  1160. {
  1161. return(pclMessageObject->ScriptLock(ulResponseTimeout_));
  1162. }
  1163. return(FALSE);
  1164. }
  1165. ///////////////////////////////////////////////////////////////////////
  1166. // Priority: Any
  1167. //
  1168. // Called by the application to set the state of the FE (FIT1e)
  1169. ///////////////////////////////////////////////////////////////////////
  1170. extern "C" EXPORT
  1171. BOOL FIT_SetFEState(UCHAR ucFEState_)
  1172. {
  1173. return FIT_SetFEState_RTO(ucFEState_, 0);
  1174. }
  1175. ///////////////////////////////////////////////////////////////////////
  1176. // Response TimeOut Version
  1177. ///////////////////////////////////////////////////////////////////////
  1178. extern "C" EXPORT
  1179. BOOL FIT_SetFEState_RTO(UCHAR ucFEState_, ULONG ulResponseTime_)
  1180. {
  1181. if(pclMessageObject)
  1182. {
  1183. return(pclMessageObject->FITSetFEState(ucFEState_, ulResponseTime_));
  1184. }
  1185. return(FALSE);
  1186. }
  1187. ///////////////////////////////////////////////////////////////////////
  1188. // Priority: Any
  1189. //
  1190. // Called by the application to set the pairing distance (FIT1e)
  1191. ///////////////////////////////////////////////////////////////////////
  1192. extern "C" EXPORT
  1193. BOOL FIT_AdjustPairingSettings(UCHAR ucSearchLv_, UCHAR ucPairLv_, UCHAR ucTrackLv_)
  1194. {
  1195. return FIT_AdjustPairingSettings_RTO(ucSearchLv_, ucPairLv_, ucTrackLv_, 0);
  1196. }
  1197. ///////////////////////////////////////////////////////////////////////
  1198. // Response TimeOut Version
  1199. ///////////////////////////////////////////////////////////////////////
  1200. extern "C" EXPORT
  1201. BOOL FIT_AdjustPairingSettings_RTO(UCHAR ucSearchLv_, UCHAR ucPairLv_, UCHAR ucTrackLv_, ULONG ulResponseTime_)
  1202. {
  1203. if(pclMessageObject)
  1204. {
  1205. return(pclMessageObject->FITAdjustPairingSettings(ucSearchLv_, ucPairLv_, ucTrackLv_, ulResponseTime_));
  1206. }
  1207. return(FALSE);
  1208. }
  1209. ///////////////////////////////////////////////////////////////////////
  1210. // Priority: Any
  1211. //
  1212. // Called by the application to construct and send an extended broadcast data message.
  1213. // This message will be broadcast on the next synchronous channel period.
  1214. ///////////////////////////////////////////////////////////////////////
  1215. extern "C" EXPORT
  1216. BOOL ANT_SendExtBroadcastData(UCHAR ucANTChannel_, UCHAR *pucData_)
  1217. {
  1218. if(!pclMessageObject)
  1219. return FALSE;
  1220. return pclMessageObject->SendExtBroadcastData(ucANTChannel_, pucData_);
  1221. }
  1222. ///////////////////////////////////////////////////////////////////////
  1223. // Priority: Any
  1224. //
  1225. // Called by the application to construct and send an extended acknowledged data
  1226. // mesg. This message will be transmitted on the next synchronous channel
  1227. // period.
  1228. ///////////////////////////////////////////////////////////////////////
  1229. extern "C" EXPORT
  1230. BOOL ANT_SendExtAcknowledgedData(UCHAR ucANTChannel_, UCHAR *pucData_)
  1231. {
  1232. return ANT_SendExtAcknowledgedData_RTO(ucANTChannel_, pucData_, 0);
  1233. }
  1234. ///////////////////////////////////////////////////////////////////////
  1235. // Response TimeOut Version
  1236. ///////////////////////////////////////////////////////////////////////
  1237. extern "C" EXPORT
  1238. BOOL ANT_SendExtAcknowledgedData_RTO(UCHAR ucANTChannel_, UCHAR *pucData_, ULONG ulResponseTime_)
  1239. {
  1240. if(!pclMessageObject)
  1241. return FALSE;
  1242. return (ANTFRAMER_PASS == pclMessageObject->SendExtAcknowledgedData(ucANTChannel_, pucData_, ulResponseTime_));
  1243. }
  1244. ///////////////////////////////////////////////////////////////////////
  1245. // Priority: Any
  1246. //
  1247. // Called by the application to construct and send extended burst data
  1248. // mesg.
  1249. ///////////////////////////////////////////////////////////////////////
  1250. ///////////////////////////////////////////////////////////////////////
  1251. // Priority: Any
  1252. //
  1253. // Used to send extended burst data with individual packets. Proper sequence number
  1254. // of packet is maintained by the application.
  1255. ///////////////////////////////////////////////////////////////////////
  1256. extern "C" EXPORT
  1257. BOOL ANT_SendExtBurstTransferPacket(UCHAR ucANTChannelSeq_, UCHAR *pucData_)
  1258. {
  1259. if(pclMessageObject)
  1260. {
  1261. ANT_MESSAGE stMessage;
  1262. stMessage.ucMessageID = MESG_EXT_BURST_DATA_ID;
  1263. stMessage.aucData[0] = ucANTChannelSeq_;
  1264. memcpy(&stMessage.aucData[1],pucData_, MESG_EXT_DATA_SIZE-1);
  1265. return pclMessageObject->WriteMessage(&stMessage, MESG_EXT_DATA_SIZE);
  1266. }
  1267. return(FALSE);
  1268. }
  1269. ///////////////////////////////////////////////////////////////////////
  1270. // Priority: Any
  1271. //
  1272. // Used to send extended burst data using a block of data. Proper sequence number
  1273. // of packet is maintained by the function. Useful for testing purposes.
  1274. ///////////////////////////////////////////////////////////////////////
  1275. extern "C" EXPORT
  1276. USHORT ANT_SendExtBurstTransfer(UCHAR ucANTChannel_, UCHAR *pucData_, USHORT usDataPackets_)
  1277. {
  1278. return ANT_SendExtBurstTransfer_RTO(ucANTChannel_, pucData_, usDataPackets_, 0);
  1279. }
  1280. ///////////////////////////////////////////////////////////////////////
  1281. // Response TimeOut Version
  1282. ///////////////////////////////////////////////////////////////////////
  1283. extern "C" EXPORT
  1284. USHORT ANT_SendExtBurstTransfer_RTO(UCHAR ucANTChannel_, UCHAR *pucData_, USHORT usDataPackets_, ULONG ulResponseTime_)
  1285. {
  1286. if(!pclMessageObject)
  1287. return FALSE;
  1288. return (ANTFRAMER_PASS == pclMessageObject->SendExtBurstTransfer(ucANTChannel_, pucData_, usDataPackets_*8, ulResponseTime_));
  1289. }
  1290. ///////////////////////////////////////////////////////////////////////
  1291. // Priority: Any
  1292. //
  1293. // Used to force the module to use extended rx messages all the time
  1294. ///////////////////////////////////////////////////////////////////////
  1295. extern "C" EXPORT
  1296. BOOL ANT_RxExtMesgsEnable(UCHAR ucEnable_)
  1297. {
  1298. return ANT_RxExtMesgsEnable_RTO(ucEnable_, 0);
  1299. }
  1300. ///////////////////////////////////////////////////////////////////////
  1301. // Response TimeOut Version
  1302. ///////////////////////////////////////////////////////////////////////
  1303. extern "C" EXPORT
  1304. BOOL ANT_RxExtMesgsEnable_RTO(UCHAR ucEnable_, ULONG ulResponseTimeout_)
  1305. {
  1306. if(pclMessageObject)
  1307. {
  1308. return(pclMessageObject->RxExtMesgsEnable(ucEnable_, ulResponseTimeout_));
  1309. }
  1310. return(FALSE);
  1311. }
  1312. ///////////////////////////////////////////////////////////////////////
  1313. // Priority: Any
  1314. //
  1315. // Used to set a channel device ID to the module serial number
  1316. ///////////////////////////////////////////////////////////////////////
  1317. extern "C" EXPORT
  1318. BOOL ANT_SetSerialNumChannelId(UCHAR ucANTChannel_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_)
  1319. {
  1320. return ANT_SetSerialNumChannelId_RTO(ucANTChannel_, ucDeviceType_, ucTransmissionType_, 0);
  1321. }
  1322. ///////////////////////////////////////////////////////////////////////
  1323. // Response TimeOut Version
  1324. ///////////////////////////////////////////////////////////////////////
  1325. extern "C" EXPORT
  1326. BOOL ANT_SetSerialNumChannelId_RTO(UCHAR ucANTChannel_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_, ULONG ulResponseTime_)
  1327. {
  1328. if(pclMessageObject)
  1329. {
  1330. return(pclMessageObject->SetSerialNumChannelId(ucANTChannel_, ucDeviceType_, ucTransmissionType_, ulResponseTime_));
  1331. }
  1332. return(FALSE);
  1333. }
  1334. ///////////////////////////////////////////////////////////////////////
  1335. // Priority: Any
  1336. //
  1337. // Enables the module LED to flash on RF activity
  1338. ///////////////////////////////////////////////////////////////////////
  1339. extern "C" EXPORT
  1340. BOOL ANT_EnableLED(UCHAR ucEnable_)
  1341. {
  1342. return ANT_EnableLED_RTO(ucEnable_, 0);
  1343. }
  1344. ///////////////////////////////////////////////////////////////////////
  1345. // Response TimeOut Version
  1346. ///////////////////////////////////////////////////////////////////////
  1347. extern "C" EXPORT
  1348. BOOL ANT_EnableLED_RTO(UCHAR ucEnable_, ULONG ulResponseTime_)
  1349. {
  1350. if(pclMessageObject)
  1351. {
  1352. return(pclMessageObject->EnableLED(ucEnable_, ulResponseTime_));
  1353. }
  1354. return(FALSE);
  1355. }
  1356. ///////////////////////////////////////////////////////////////////////
  1357. // Called by the application to get the product string and serial number string (four bytes) of a particular device
  1358. ///////////////////////////////////////////////////////////////////////
  1359. extern "C" EXPORT
  1360. BOOL ANT_GetDeviceUSBInfo(UCHAR ucDeviceNum, UCHAR* pucProductString, UCHAR* pucSerialString)
  1361. {
  1362. if(pclMessageObject)
  1363. {
  1364. return(pclMessageObject->GetDeviceUSBInfo(ucDeviceNum, pucProductString, pucSerialString, USB_MAX_STRLEN));
  1365. }
  1366. return(FALSE);
  1367. }
  1368. ///////////////////////////////////////////////////////////////////////
  1369. // Called by the application to get the USB PID
  1370. ///////////////////////////////////////////////////////////////////////
  1371. extern "C" EXPORT
  1372. BOOL ANT_GetDeviceUSBPID(USHORT* pusPID_)
  1373. {
  1374. if(pclMessageObject)
  1375. {
  1376. return(pclMessageObject->GetDeviceUSBPID(*pusPID_));
  1377. }
  1378. return (FALSE);
  1379. }
  1380. ///////////////////////////////////////////////////////////////////////
  1381. // Called by the application to get the USB VID
  1382. ///////////////////////////////////////////////////////////////////////
  1383. extern "C" EXPORT
  1384. BOOL ANT_GetDeviceUSBVID(USHORT* pusVID_)
  1385. {
  1386. if(pclMessageObject)
  1387. {
  1388. return(pclMessageObject->GetDeviceUSBVID(*pusVID_));
  1389. }
  1390. return (FALSE);
  1391. }
  1392. ////////////////////////////////////////////////////////////////////////////////////////
  1393. ////////////////////////////////////////////////////////////////////////////////////////
  1394. // The following are the Integrated ANTFS_Client functions
  1395. ////////////////////////////////////////////////////////////////////////////////////////
  1396. ////////////////////////////////////////////////////////////////////////////////////////
  1397. //Memory Device Commands/////////////
  1398. extern "C" EXPORT
  1399. BOOL ANTFS_InitEEPROMDevice(USHORT usPageSize_, UCHAR ucAddressConfig_)
  1400. {
  1401. return (pclMessageObject->InitEEPROMDevice(usPageSize_, ucAddressConfig_, 3000));
  1402. }
  1403. //File System Commands//////////////
  1404. extern "C" EXPORT
  1405. BOOL ANTFS_InitFSMemory()
  1406. {
  1407. return (pclMessageObject->InitFSMemory(3000));
  1408. }
  1409. extern "C" EXPORT
  1410. BOOL ANTFS_FormatFSMemory(USHORT usNumberOfSectors_, USHORT usPagesPerSector_)
  1411. {
  1412. return (pclMessageObject->FormatFSMemory(usNumberOfSectors_, usPagesPerSector_, 3000));
  1413. }
  1414. extern "C" EXPORT
  1415. BOOL ANTFS_SaveDirectory()
  1416. {
  1417. return (pclMessageObject->SaveDirectory(3000));
  1418. }
  1419. extern "C" EXPORT
  1420. BOOL ANTFS_DirectoryRebuild()
  1421. {
  1422. return (pclMessageObject->DirectoryRebuild(3000));
  1423. }
  1424. extern "C" EXPORT
  1425. BOOL ANTFS_FileDelete(UCHAR ucFileHandle_)
  1426. {
  1427. return (pclMessageObject->FileDelete(ucFileHandle_, 3000));
  1428. }
  1429. extern "C" EXPORT
  1430. BOOL ANTFS_FileClose(UCHAR ucFileHandle_)
  1431. {
  1432. return (pclMessageObject->FileClose(ucFileHandle_, 3000));
  1433. }
  1434. extern "C" EXPORT
  1435. BOOL ANTFS_SetFileSpecificFlags(UCHAR ucFileHandle_, UCHAR ucFlags_)
  1436. {
  1437. return (pclMessageObject->SetFileSpecificFlags(ucFileHandle_, ucFlags_, 3000));
  1438. }
  1439. extern "C" EXPORT
  1440. UCHAR ANTFS_DirectoryReadLock(BOOL bLock_)
  1441. {
  1442. return (pclMessageObject->DirectoryReadLock(bLock_, 3000));
  1443. }
  1444. extern "C" EXPORT
  1445. BOOL ANTFS_SetSystemTime(ULONG ulTime_)
  1446. {
  1447. return (pclMessageObject->SetSystemTime(ulTime_, 3000));
  1448. }
  1449. //File System Requests////////////
  1450. extern "C" EXPORT
  1451. ULONG ANTFS_GetUsedSpace()
  1452. {
  1453. return (pclMessageObject->GetUsedSpace(3000));
  1454. }
  1455. extern "C" EXPORT
  1456. ULONG ANTFS_GetFreeSpace()
  1457. {
  1458. return (pclMessageObject->GetFreeFSSpace(3000));
  1459. }
  1460. extern "C" EXPORT
  1461. USHORT ANTFS_FindFileIndex(UCHAR ucFileDataType_, UCHAR ucFileSubType_, USHORT usFileNumber_)
  1462. {
  1463. return (pclMessageObject->FindFileIndex(ucFileDataType_, ucFileSubType_, usFileNumber_, 3000));
  1464. }
  1465. extern "C" EXPORT
  1466. UCHAR ANTFS_ReadDirectoryAbsolute(ULONG ulOffset_, UCHAR ucSize_, UCHAR* pucBuffer_)
  1467. {
  1468. return (pclMessageObject->ReadDirectoryAbsolute(ulOffset_, ucSize_, pucBuffer_,3000));
  1469. }
  1470. extern "C" EXPORT
  1471. UCHAR ANTFS_DirectoryReadEntry (USHORT usFileIndex_, UCHAR* ucFileDirectoryBuffer_)
  1472. {
  1473. return (pclMessageObject->DirectoryReadEntry (usFileIndex_, ucFileDirectoryBuffer_, 3000));
  1474. }
  1475. extern "C" EXPORT
  1476. ULONG ANTFS_DirectoryGetSize()
  1477. {
  1478. return (pclMessageObject->DirectoryGetSize(3000));
  1479. }
  1480. extern "C" EXPORT
  1481. USHORT ANTFS_FileCreate(USHORT usFileIndex_, UCHAR ucFileDataType_, ULONG ulFileIdentifier_, UCHAR ucFileDataTypeSpecificFlags_, UCHAR ucGeneralFlags)
  1482. {
  1483. return (pclMessageObject->FileCreate(usFileIndex_, ucFileDataType_, ulFileIdentifier_, ucFileDataTypeSpecificFlags_, ucGeneralFlags, 3000));
  1484. }
  1485. extern "C" EXPORT
  1486. UCHAR ANTFS_FileOpen(USHORT usFileIndex_, UCHAR ucOpenFlags_)
  1487. {
  1488. return (pclMessageObject->FileOpen(usFileIndex_, ucOpenFlags_, 3000));
  1489. }
  1490. extern "C" EXPORT
  1491. UCHAR ANTFS_FileReadAbsolute(UCHAR ucFileHandle_, ULONG ulOffset_, UCHAR ucReadSize_, UCHAR* pucReadBuffer_)
  1492. {
  1493. return (pclMessageObject->FileReadAbsolute(ucFileHandle_, ulOffset_, ucReadSize_, pucReadBuffer_, 3000));
  1494. }
  1495. extern "C" EXPORT
  1496. UCHAR ANTFS_FileReadRelative(UCHAR ucFileHandle_, UCHAR ucReadSize_, UCHAR* pucReadBuffer_)
  1497. {
  1498. return (pclMessageObject->FileReadRelative(ucFileHandle_, ucReadSize_, pucReadBuffer_, 3000));
  1499. }
  1500. extern "C" EXPORT
  1501. UCHAR ANTFS_FileWriteAbsolute(UCHAR ucFileHandle_, ULONG ulFileOffset_, UCHAR ucWriteSize_, const UCHAR* pucWriteBuffer_, UCHAR* ucBytesWritten_)
  1502. {
  1503. return (pclMessageObject->FileWriteAbsolute(ucFileHandle_, ulFileOffset_, ucWriteSize_, pucWriteBuffer_, ucBytesWritten_, 3000));
  1504. }
  1505. extern "C" EXPORT
  1506. UCHAR ANTFS_FileWriteRelative(UCHAR ucFileHandle_, UCHAR ucWriteSize_, const UCHAR* pucWriteBuffer_, UCHAR* ucBytesWritten_)
  1507. {
  1508. return (pclMessageObject->FileWriteRelative(ucFileHandle_, ucWriteSize_, pucWriteBuffer_, ucBytesWritten_, 3000));
  1509. }
  1510. extern "C" EXPORT
  1511. ULONG ANTFS_FileGetSize(UCHAR ucFileHandle_)
  1512. {
  1513. return (pclMessageObject->FileGetSize(ucFileHandle_, 3000));
  1514. }
  1515. extern "C" EXPORT
  1516. ULONG ANTFS_FileGetSizeInMem(UCHAR ucFileHandle_)
  1517. {
  1518. return (pclMessageObject->FileGetSizeInMem(ucFileHandle_, 3000));
  1519. }
  1520. extern "C" EXPORT
  1521. UCHAR ANTFS_FileGetSpecificFlags(UCHAR ucFileHandle_)
  1522. {
  1523. return (pclMessageObject->FileGetSpecificFlags(ucFileHandle_, 3000));
  1524. }
  1525. extern "C" EXPORT
  1526. ULONG ANTFS_FileGetSystemTime()
  1527. {
  1528. return (pclMessageObject->FileGetSystemTime(3000));
  1529. }
  1530. //FS-Crypto Commands/////////////
  1531. extern "C" EXPORT
  1532. UCHAR ANTFS_CryptoAddUserKeyIndex(UCHAR ucIndex_, UCHAR* pucKey_)
  1533. {
  1534. return (pclMessageObject->CryptoAddUserKeyIndex(ucIndex_, pucKey_, 3000));
  1535. }
  1536. extern "C" EXPORT
  1537. UCHAR ANTFS_CryptoSetUserKeyIndex(UCHAR ucIndex_)
  1538. {
  1539. return (pclMessageObject->CryptoSetUserKeyIndex(ucIndex_, 3000));
  1540. }
  1541. extern "C" EXPORT
  1542. UCHAR ANTFS_CryptoSetUserKeyVal(UCHAR* pucKey_)
  1543. {
  1544. return (pclMessageObject->CryptoSetUserKeyVal(pucKey_, 3000));
  1545. }
  1546. //FIT Commands///////////////////////
  1547. extern "C" EXPORT
  1548. UCHAR ANTFS_FitFileIntegrityCheck(UCHAR ucFileHandle_)
  1549. {
  1550. return (pclMessageObject->FitFileIntegrityCheck(ucFileHandle_, 3000));
  1551. }
  1552. //ANT-FS Commands////////////////////
  1553. extern "C" EXPORT
  1554. UCHAR ANTFS_OpenBeacon()
  1555. {
  1556. return (pclMessageObject->OpenBeacon(3000));
  1557. }
  1558. extern "C" EXPORT
  1559. UCHAR ANTFS_CloseBeacon()
  1560. {
  1561. return (pclMessageObject->CloseBeacon(3000));
  1562. }
  1563. extern "C" EXPORT
  1564. UCHAR ANTFS_ConfigBeacon(USHORT usDeviceType_, USHORT usManufacturer_, UCHAR ucAuthType_, UCHAR ucBeaconStatus_)
  1565. {
  1566. return (pclMessageObject->ConfigBeacon(usDeviceType_, usManufacturer_, ucAuthType_, ucBeaconStatus_, 3000));
  1567. }
  1568. extern "C" EXPORT
  1569. UCHAR ANTFS_SetFriendlyName(UCHAR ucLength_, const UCHAR* pucString_)
  1570. {
  1571. return (pclMessageObject->SetFriendlyName(ucLength_, pucString_, 3000));
  1572. }
  1573. extern "C" EXPORT
  1574. UCHAR ANTFS_SetPasskey(UCHAR ucLength_, const UCHAR* pucString_)
  1575. {
  1576. return (pclMessageObject->SetPasskey(ucLength_, pucString_, 3000));
  1577. }
  1578. extern "C" EXPORT
  1579. UCHAR ANTFS_SetBeaconState(UCHAR ucBeaconStatus_)
  1580. {
  1581. return (pclMessageObject->SetBeaconState(ucBeaconStatus_, 3000));
  1582. }
  1583. extern "C" EXPORT
  1584. UCHAR ANTFS_PairResponse(BOOL bAccept_)
  1585. {
  1586. return (pclMessageObject->PairResponse(bAccept_, 3000));
  1587. }
  1588. extern "C" EXPORT
  1589. UCHAR ANTFS_SetLinkFrequency(UCHAR ucChannelNumber_, UCHAR ucFrequency_)
  1590. {
  1591. return (pclMessageObject->SetLinkFrequency(ucChannelNumber_, ucFrequency_, 3000));
  1592. }
  1593. extern "C" EXPORT
  1594. UCHAR ANTFS_SetBeaconTimeout(UCHAR ucTimeout_)
  1595. {
  1596. return (pclMessageObject->SetBeaconTimeout(ucTimeout_, 3000));
  1597. }
  1598. extern "C" EXPORT
  1599. UCHAR ANTFS_SetPairingTimeout(UCHAR ucTimeout_)
  1600. {
  1601. return (pclMessageObject->SetPairingTimeout(ucTimeout_, 3000));
  1602. }
  1603. extern "C" EXPORT
  1604. UCHAR ANTFS_EnableRemoteFileCreate(BOOL bEnable_)
  1605. {
  1606. return (pclMessageObject->EnableRemoteFileCreate(bEnable_, 3000));
  1607. }
  1608. //ANT-FS Responses////////////////////
  1609. extern "C" EXPORT
  1610. UCHAR ANTFS_GetCmdPipe(UCHAR ucOffset_, UCHAR ucReadSize_, UCHAR* pucReadBuffer_)
  1611. {
  1612. return (pclMessageObject->GetCmdPipe(ucOffset_, ucReadSize_, pucReadBuffer_, 3000));
  1613. }
  1614. extern "C" EXPORT
  1615. UCHAR ANTFS_SetCmdPipe(UCHAR ucOffset_, UCHAR ucWriteSize_, const UCHAR* pucWriteBuffer_)
  1616. {
  1617. return (pclMessageObject->SetCmdPipe(ucOffset_, ucWriteSize_, pucWriteBuffer_, 3000));
  1618. }
  1619. //GetFSResponse/////////////////////////
  1620. extern "C" EXPORT
  1621. UCHAR ANTFS_GetLastError()
  1622. {
  1623. return (pclMessageObject->GetLastError());
  1624. }
  1625. ///////////////////////////////////////////////////////////////////////
  1626. // Set the directory the log files are saved to
  1627. ///////////////////////////////////////////////////////////////////////
  1628. extern "C" EXPORT
  1629. BOOL ANT_SetDebugLogDirectory(char* pcDirectory)
  1630. {
  1631. #if defined(DEBUG_FILE)
  1632. return DSIDebug::SetDirectory(pcDirectory);
  1633. #else
  1634. return false;
  1635. #endif
  1636. }
  1637. ///////////////////////////////////////////////////////////////////////
  1638. // Put current thread to sleep for the specified number of milliseconds
  1639. ///////////////////////////////////////////////////////////////////////
  1640. extern "C" EXPORT
  1641. void ANT_Nap(ULONG ulMilliseconds_)
  1642. {
  1643. DSIThread_Sleep(ulMilliseconds_);
  1644. }
  1645. // Local functions ****************************************************//
  1646. static DSI_THREAD_RETURN MessageThread(void *pvParameter_)
  1647. {
  1648. ANT_MESSAGE stMessage;
  1649. USHORT usSize;
  1650. eTheThread = DSIThread_GetCurrentThreadIDNum();
  1651. while(bGoThread)
  1652. {
  1653. if(pclMessageObject->WaitForMessage(1000/*DSI_THREAD_INFINITE*/))
  1654. {
  1655. usSize = pclMessageObject->GetMessage(&stMessage);
  1656. if(usSize == DSI_FRAMER_ERROR)
  1657. {
  1658. // Get the message to clear the error
  1659. usSize = pclMessageObject->GetMessage(&stMessage, MESG_MAX_SIZE_VALUE);
  1660. continue;
  1661. }
  1662. if(usSize != 0 && usSize != DSI_FRAMER_ERROR && usSize != DSI_FRAMER_TIMEDOUT)
  1663. {
  1664. SerialHaveMessage(stMessage, usSize);
  1665. }
  1666. }
  1667. }
  1668. DSIThread_MutexLock(&mutexTestDone);
  1669. UCHAR ucCondResult = DSIThread_CondSignal(&condTestDone);
  1670. assert(ucCondResult == DSI_THREAD_ENONE);
  1671. DSIThread_MutexUnlock(&mutexTestDone);
  1672. return(NULL);
  1673. }
  1674. //Called internally to delete objects from memory
  1675. static void MemoryCleanup(void)
  1676. {
  1677. if(pclSerialObject)
  1678. {
  1679. //Close all stuff
  1680. pclSerialObject->Close();
  1681. delete pclSerialObject;
  1682. pclSerialObject = NULL;
  1683. }
  1684. if(pclMessageObject)
  1685. {
  1686. delete pclMessageObject;
  1687. pclMessageObject = NULL;
  1688. }
  1689. }
  1690. ///////////////////////////////////////////////////////////////////////
  1691. //
  1692. // Processes a received serial message. This function is intended to be
  1693. // called by the serial message driver code, to be defined by the user,
  1694. // when a serial message is received from the ANT module.
  1695. ///////////////////////////////////////////////////////////////////////
  1696. static void SerialHaveMessage(ANT_MESSAGE& stMessage_, USHORT usSize_)
  1697. {
  1698. UCHAR ucANTChannel;
  1699. //If no response function has been assigned, ignore the message and unlock
  1700. //the receive buffer
  1701. if (pfResponseFunc == NULL)
  1702. return;
  1703. ucANTChannel = stMessage_.aucData[MESG_CHANNEL_OFFSET] & CHANNEL_NUMBER_MASK;
  1704. //Process the message to determine whether it is a response event or one
  1705. //of the channel events and call the appropriate event function.
  1706. switch (stMessage_.ucMessageID)
  1707. {
  1708. case MESG_RESPONSE_EVENT_ID:
  1709. {
  1710. if (stMessage_.aucData[MESG_EVENT_ID_OFFSET] != MESG_EVENT_ID) // this is a response
  1711. {
  1712. if (pucResponseBuffer)
  1713. {
  1714. memcpy(pucResponseBuffer, stMessage_.aucData, MESG_RESPONSE_EVENT_SIZE);
  1715. pfResponseFunc(ucANTChannel, MESG_RESPONSE_EVENT_ID);
  1716. }
  1717. }
  1718. else // this is an event
  1719. {
  1720. // If we are in auto transfer mode, stop sending packets
  1721. if ((stMessage_.aucData[MESG_EVENT_CODE_OFFSET] == EVENT_TRANSFER_TX_FAILED) && (ucAutoTransferChannel == ucANTChannel))
  1722. usNumDataPackets = 0;
  1723. if (sLink[ucANTChannel].pfLinkEvent == NULL)
  1724. break;
  1725. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, usSize_);
  1726. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, stMessage_.aucData[MESG_EVENT_CODE_OFFSET]); // pass through any events not handled here
  1727. }
  1728. break;
  1729. }
  1730. case MESG_BROADCAST_DATA_ID:
  1731. {
  1732. if ( sLink[ucANTChannel].pfLinkEvent == NULL ||
  1733. sLink[ucANTChannel].pucRxBuffer == NULL)
  1734. {
  1735. break;
  1736. }
  1737. // If size is greater than the standard data message size, then assume
  1738. // that this is a data message with a flag at the end. Set the event accordingly.
  1739. if(usSize_ > MESG_DATA_SIZE)
  1740. {
  1741. //Call channel event function with Broadcast message code
  1742. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, usSize_);
  1743. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_FLAG_BROADCAST); // process the event
  1744. }
  1745. else
  1746. {
  1747. //Call channel event function with Broadcast message code
  1748. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, ANT_STANDARD_DATA_PAYLOAD_SIZE + MESG_CHANNEL_NUM_SIZE);
  1749. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_BROADCAST); // process the event
  1750. }
  1751. break;
  1752. }
  1753. case MESG_ACKNOWLEDGED_DATA_ID:
  1754. {
  1755. if (sLink[ucANTChannel].pfLinkEvent == NULL)
  1756. break;
  1757. if(usSize_ > MESG_DATA_SIZE)
  1758. {
  1759. //Call channel event function with Broadcast message code
  1760. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, usSize_);
  1761. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_FLAG_ACKNOWLEDGED); // process the event
  1762. }
  1763. else
  1764. {
  1765. //Call channel event function with Acknowledged message code
  1766. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, ANT_STANDARD_DATA_PAYLOAD_SIZE + MESG_CHANNEL_NUM_SIZE);
  1767. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_ACKNOWLEDGED); // process the message
  1768. }
  1769. break;
  1770. }
  1771. case MESG_BURST_DATA_ID:
  1772. {
  1773. if (sLink[ucANTChannel].pfLinkEvent == NULL)
  1774. break;
  1775. if(usSize_ > MESG_DATA_SIZE)
  1776. {
  1777. //Call channel event function with Broadcast message code
  1778. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, usSize_);
  1779. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_FLAG_BURST_PACKET); // process the event
  1780. }
  1781. else
  1782. {
  1783. //Call channel event function with Burst message code
  1784. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, ANT_STANDARD_DATA_PAYLOAD_SIZE + MESG_CHANNEL_NUM_SIZE);
  1785. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_BURST_PACKET); // process the message
  1786. }
  1787. break;
  1788. }
  1789. case MESG_EXT_BROADCAST_DATA_ID:
  1790. {
  1791. if (sLink[ucANTChannel].pfLinkEvent == NULL)
  1792. break;
  1793. //Call channel event function with Broadcast message code
  1794. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, MESG_EXT_DATA_SIZE);
  1795. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_EXT_BROADCAST); // process the event
  1796. break;
  1797. }
  1798. case MESG_EXT_ACKNOWLEDGED_DATA_ID:
  1799. {
  1800. if (sLink[ucANTChannel].pfLinkEvent == NULL)
  1801. break;
  1802. //Call channel event function with Acknowledged message code
  1803. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, MESG_EXT_DATA_SIZE);
  1804. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_EXT_ACKNOWLEDGED); // process the message
  1805. break;
  1806. }
  1807. case MESG_EXT_BURST_DATA_ID:
  1808. {
  1809. if (sLink[ucANTChannel].pfLinkEvent == NULL)
  1810. break;
  1811. //Call channel event function with Burst message code
  1812. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, MESG_EXT_DATA_SIZE);
  1813. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_EXT_BURST_PACKET); // process the message
  1814. break;
  1815. }
  1816. case MESG_RSSI_BROADCAST_DATA_ID:
  1817. {
  1818. if (sLink[ucANTChannel].pfLinkEvent == NULL)
  1819. break;
  1820. //Call channel event function with Broadcast message code
  1821. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, MESG_RSSI_DATA_SIZE);
  1822. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_RSSI_BROADCAST); // process the event
  1823. break;
  1824. }
  1825. case MESG_RSSI_ACKNOWLEDGED_DATA_ID:
  1826. {
  1827. if (sLink[ucANTChannel].pfLinkEvent == NULL)
  1828. break;
  1829. //Call channel event function with Acknowledged message code
  1830. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, MESG_RSSI_DATA_SIZE);
  1831. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_RSSI_ACKNOWLEDGED); // process the message
  1832. break;
  1833. }
  1834. case MESG_RSSI_BURST_DATA_ID:
  1835. {
  1836. if (sLink[ucANTChannel].pfLinkEvent == NULL)
  1837. break;
  1838. //Call channel event function with Burst message code
  1839. memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, MESG_RSSI_DATA_SIZE);
  1840. sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_RSSI_BURST_PACKET); // process the message
  1841. break;
  1842. }
  1843. case MESG_SCRIPT_DATA_ID:
  1844. {
  1845. if (pucResponseBuffer)
  1846. {
  1847. memcpy(pucResponseBuffer, stMessage_.aucData, usSize_);
  1848. pucResponseBuffer[10] = (UCHAR)usSize_;
  1849. pfResponseFunc(ucANTChannel, MESG_SCRIPT_DATA_ID);
  1850. }
  1851. break;
  1852. }
  1853. case MESG_SCRIPT_CMD_ID:
  1854. {
  1855. if (pucResponseBuffer)
  1856. {
  1857. memcpy(pucResponseBuffer, stMessage_.aucData, MESG_SCRIPT_CMD_SIZE);
  1858. pfResponseFunc(ucANTChannel, MESG_SCRIPT_CMD_ID);
  1859. }
  1860. break;
  1861. }
  1862. default:
  1863. {
  1864. if (pucResponseBuffer) // can we process this link
  1865. {
  1866. memcpy(pucResponseBuffer, stMessage_.aucData, usSize_);
  1867. pfResponseFunc(ucANTChannel, stMessage_.ucMessageID );
  1868. }
  1869. break;
  1870. }
  1871. }
  1872. return;
  1873. }