12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171 |
- /*
- This software is subject to the license described in the License.txt file
- included with this software distribution. You may not use this file except
- in compliance with this license.
- Copyright (c) Dynastream Innovations Inc. 2016
- All rights reserved.
- */
- /*
- **************************************************************************
- *
- * DESCRIPTION:
- *
- * This module is an example wrapper for the ANT communications library
- * It sets up and maintains the link, and provides a simplified API to the
- * application.
- *
- **************************************************************************
- */
- #include <string.h> // memcpy
- #include <stdio.h>
- #include <assert.h>
- #include "ant.h"
- #include "version.h"
- #include "types.h"
- #include "defines.h"
- #include "antdefines.h"
- #include "usb_device_handle.hpp"
- #include "dsi_serial_generic.hpp"
- #if defined(DSI_TYPES_WINDOWS)
- #include "dsi_serial_vcp.hpp"
- #endif
- #include "dsi_framer_ant.hpp"
- #include "dsi_thread.h"
- #if defined(DEBUG_FILE)
- #include "dsi_debug.hpp"
- #endif
- #define MAX_CHANNELS ((UCHAR) 8)
- #define MESG_CHANNEL_OFFSET 0
- #define MESG_EVENT_ID_OFFSET 1
- #define MESG_EVENT_CODE_OFFSET 2
- // Struct to define channel event callback functions
- // and recieve buffer.
- typedef struct
- {
- CHANNEL_EVENT_FUNC pfLinkEvent;
- UCHAR *pucRxBuffer;
- } CHANNEL_LINK;
- // Local variables.
- static DSISerial* pclSerialObject = NULL;
- static DSIFramerANT* pclMessageObject = NULL;
- static DSI_THREAD_ID uiDSIThread;
- static DSI_CONDITION_VAR condTestDone;
- static DSI_MUTEX mutexTestDone;
- // Local Data
- static RESPONSE_FUNC pfResponseFunc = NULL; //pointer to main response callback function
- static UCHAR *pucResponseBuffer = NULL; //pointer to buffer used to hold data from the response message
- static CHANNEL_LINK sLink[MAX_CHANNELS]; //array of pointer for each channel
- static BOOL bInitialized = FALSE;
- static UCHAR ucAutoTransferChannel = 0xFF;
- static USHORT usNumDataPackets = 0;
- static BOOL bGoThread = FALSE;
- static DSI_THREAD_IDNUM eTheThread;
- // Local funcs
- static DSI_THREAD_RETURN MessageThread(void *pvParameter_);
- static void SerialHaveMessage(ANT_MESSAGE& stMessage_, USHORT usSize_);
- static void MemoryCleanup(); //Deletes internal objects from memory
- extern "C" EXPORT
- BOOL ANT_Init(UCHAR ucUSBDeviceNum, ULONG ulBaudrate)
- {
- return ANT_InitExt(ucUSBDeviceNum, ulBaudrate, PORT_TYPE_USB, FRAMER_TYPE_BASIC);
- }
- //Initializes and opens USB connection to the module
- extern "C" EXPORT
- BOOL ANT_InitExt(UCHAR ucUSBDeviceNum, ULONG ulBaudrate, UCHAR ucPortType_, UCHAR ucSerialFrameType_)
- {
- DSI_THREAD_IDNUM eThread = DSIThread_GetCurrentThreadIDNum();
- assert(eTheThread != eThread); // CANNOT CALL THIS FUNCTION FROM DLL THREAD (INSIDE DLL CALLBACK ROUTINES).
- assert(!bInitialized); // IF ANT WAS ALREADY INITIALIZED, DO NOT CALL THIS FUNCTION BEFORE CALLING ANT_Close();
- #if defined(DEBUG_FILE)
- DSIDebug::Init();
- DSIDebug::SetDebug(TRUE);
- #endif
- //Create Serial object.
- pclSerialObject = NULL;
- switch(ucPortType_)
- {
- case PORT_TYPE_USB:
- pclSerialObject = new DSISerialGeneric();
- break;
- #if defined(DSI_TYPES_WINDOWS)
- case PORT_TYPE_COM:
- pclSerialObject = new DSISerialVCP();
- break;
- #endif
- default: //Invalid port type selection
- return(FALSE);
- }
- if(!pclSerialObject)
- return(FALSE);
- //Initialize Serial object.
- //NOTE: Will fail if the module is not available.
- if(!pclSerialObject->Init(ulBaudrate, ucUSBDeviceNum))
- {
- MemoryCleanup();
- return(FALSE);
- }
- //Create Framer object.
- pclMessageObject = NULL;
- switch(ucSerialFrameType_)
- {
- case FRAMER_TYPE_BASIC:
- pclMessageObject = new DSIFramerANT(pclSerialObject);
- break;
- default:
- MemoryCleanup();
- return(FALSE);
- }
- if(!pclMessageObject)
- {
- MemoryCleanup();
- return(FALSE);
- }
- //Initialize Framer object.
- if(!pclMessageObject->Init())
- {
- MemoryCleanup();
- return(FALSE);
- }
- //Let Serial know about Framer.
- pclSerialObject->SetCallback(pclMessageObject);
- //Open Serial.
- if(!pclSerialObject->Open())
- {
- MemoryCleanup();
- return(FALSE);
- }
- //Create message thread.
- UCHAR ucCondInit= DSIThread_CondInit(&condTestDone);
- assert(ucCondInit == DSI_THREAD_ENONE);
- UCHAR ucMutexInit = DSIThread_MutexInit(&mutexTestDone);
- assert(ucMutexInit == DSI_THREAD_ENONE);
- bGoThread = TRUE;
- uiDSIThread = DSIThread_CreateThread(MessageThread, NULL);
- if(!uiDSIThread)
- {
- MemoryCleanup();
- bGoThread = FALSE;
- return(FALSE);
- }
- bInitialized = TRUE;
- return(TRUE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Called by the application to close the usb connection
- // MUST NOT BE CALLED IN THE CONTEXT OF THE MessageThread. That is,
- // At the application level it must not be called within the
- // callback functions into this library.
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- void ANT_Close(void)
- {
- DSI_THREAD_IDNUM eThread = DSIThread_GetCurrentThreadIDNum();
- assert(eTheThread != eThread); // CANNOT CALL THIS FUNCTION FROM DLL THREAD (INSIDE DLL CALLBACK ROUTINES).
- if (!bInitialized)
- return;
- bInitialized = FALSE;
- DSIThread_MutexLock(&mutexTestDone);
- bGoThread = FALSE;
- UCHAR ucWaitResult = DSIThread_CondTimedWait(&condTestDone, &mutexTestDone, DSI_THREAD_INFINITE);
- assert(ucWaitResult == DSI_THREAD_ENONE);
- DSIThread_MutexUnlock(&mutexTestDone);
- //Destroy mutex and condition var
- DSIThread_MutexDestroy(&mutexTestDone);
- DSIThread_CondDestroy(&condTestDone);
- MemoryCleanup();
- #if defined(DEBUG_FILE)
- DSIDebug::Close();
- #endif
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to initialize the main callback funcation,
- // the main callback funcation must be initialized before the application
- // can receive any reponse messages.
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- void ANT_AssignResponseFunction(RESPONSE_FUNC pfResponse_, UCHAR* pucResponseBuffer_)
- {
- pfResponseFunc = pfResponse_;
- pucResponseBuffer = pucResponseBuffer_;
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to initialize the callback funcation and
- // data buffers for a particular channel. This must be done in order
- // for a channel to function properly.
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- void ANT_AssignChannelEventFunction(UCHAR ucLink, CHANNEL_EVENT_FUNC pfLinkEvent, UCHAR *pucRxBuffer)
- {
- if(ucLink < MAX_CHANNELS)
- {
- sLink[ucLink].pfLinkEvent = pfLinkEvent;
- sLink[ucLink].pucRxBuffer = pucRxBuffer;
- }
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Unassigns response function. Important for memory management of
- // higher layer applications to avoid this library calling invalid pointers
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- void ANT_UnassignAllResponseFunctions()
- {
- pfResponseFunc = NULL;
- pucResponseBuffer = NULL;
- for(int i=0; i< MAX_CHANNELS; ++i)
- {
- sLink[i].pfLinkEvent = NULL;
- sLink[i].pucRxBuffer = NULL;
- }
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Returns a pointer to a string constant containing the core library
- // version.
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- const char* ANT_LibVersion(void)
- {
- return(SW_VER);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to restart ANT on the module
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ResetSystem(void)
- {
- if(pclMessageObject)
- return(pclMessageObject->ResetSystem());
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to set the network address for a given
- // module channel
- //!! This is (should be) a private network function
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetNetworkKey(UCHAR ucNetNumber, UCHAR *pucKey)
- {
- return ANT_SetNetworkKey_RTO(ucNetNumber, pucKey, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetNetworkKey_RTO(UCHAR ucNetNumber, UCHAR *pucKey, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetNetworkKey(ucNetNumber, pucKey, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to assign a channel
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_AssignChannel(UCHAR ucANTChannel, UCHAR ucChannelType_, UCHAR ucNetNumber)
- {
- return ANT_AssignChannel_RTO(ucANTChannel, ucChannelType_, ucNetNumber, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_AssignChannel_RTO(UCHAR ucANTChannel, UCHAR ucChannelType_, UCHAR ucNetNumber, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->AssignChannel(ucANTChannel, ucChannelType_, ucNetNumber, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to assign a channel using extended assignment
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_AssignChannelExt(UCHAR ucANTChannel, UCHAR ucChannelType_, UCHAR ucNetNumber, UCHAR ucExtFlags_)
- {
- return ANT_AssignChannelExt_RTO(ucANTChannel, ucChannelType_, ucNetNumber, ucExtFlags_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_AssignChannelExt_RTO(UCHAR ucANTChannel, UCHAR ucChannelType_, UCHAR ucNetNumber, UCHAR ucExtFlags_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- UCHAR aucChannelType[] = {ucChannelType_, ucExtFlags_}; // Channel Type + Extended Assignment Byte
- return(pclMessageObject->AssignChannelExt(ucANTChannel, aucChannelType, 2, ucNetNumber, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to unassign a channel
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_UnAssignChannel(UCHAR ucANTChannel)
- {
- return ANT_UnAssignChannel_RTO(ucANTChannel, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_UnAssignChannel_RTO(UCHAR ucANTChannel, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->UnAssignChannel(ucANTChannel, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to set the channel ID
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetChannelId(UCHAR ucANTChannel_, USHORT usDeviceNumber_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_)
- {
- return ANT_SetChannelId_RTO(ucANTChannel_, usDeviceNumber_, ucDeviceType_, ucTransmissionType_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetChannelId_RTO(UCHAR ucANTChannel_, USHORT usDeviceNumber_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetChannelID(ucANTChannel_, usDeviceNumber_, ucDeviceType_, ucTransmissionType_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to set the messaging period
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetChannelPeriod(UCHAR ucANTChannel_, USHORT usMesgPeriod_)
- {
- return ANT_SetChannelPeriod_RTO(ucANTChannel_, usMesgPeriod_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetChannelPeriod_RTO(UCHAR ucANTChannel_, USHORT usMesgPeriod_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetChannelPeriod(ucANTChannel_, usMesgPeriod_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to set the messaging period
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_RSSI_SetSearchThreshold(UCHAR ucANTChannel_, UCHAR ucThreshold_)
- {
- return ANT_RSSI_SetSearchThreshold_RTO(ucANTChannel_, ucThreshold_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_RSSI_SetSearchThreshold_RTO(UCHAR ucANTChannel_, UCHAR ucThreshold_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetRSSISearchThreshold(ucANTChannel_, ucThreshold_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Used to set Low Priority Search Timeout. Not available on AP1
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetLowPriorityChannelSearchTimeout(UCHAR ucANTChannel_, UCHAR ucSearchTimeout_)
- {
- return ANT_SetLowPriorityChannelSearchTimeout_RTO(ucANTChannel_, ucSearchTimeout_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetLowPriorityChannelSearchTimeout_RTO(UCHAR ucANTChannel_, UCHAR ucSearchTimeout_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetLowPriorityChannelSearchTimeout(ucANTChannel_, ucSearchTimeout_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to set the search timeout for a particular
- // channel on the module
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetChannelSearchTimeout(UCHAR ucANTChannel_, UCHAR ucSearchTimeout_)
- {
- return ANT_SetChannelSearchTimeout_RTO(ucANTChannel_, ucSearchTimeout_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetChannelSearchTimeout_RTO(UCHAR ucANTChannel_, UCHAR ucSearchTimeout_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetChannelSearchTimeout(ucANTChannel_, ucSearchTimeout_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to set the RF frequency for a given channel
- //!! This is (should be) a private network function
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetChannelRFFreq(UCHAR ucANTChannel_, UCHAR ucRFFreq_)
- {
- return ANT_SetChannelRFFreq_RTO(ucANTChannel_, ucRFFreq_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetChannelRFFreq_RTO(UCHAR ucANTChannel_, UCHAR ucRFFreq_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetChannelRFFrequency(ucANTChannel_, ucRFFreq_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to set the transmit power for the module
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetTransmitPower(UCHAR ucTransmitPower_)
- {
- return ANT_SetTransmitPower_RTO(ucTransmitPower_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetTransmitPower_RTO(UCHAR ucTransmitPower_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetAllChannelsTransmitPower(ucTransmitPower_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to configure advanced bursting
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigureAdvancedBurst(BOOL bEnable_, UCHAR ucMaxPacketLength_, ULONG ulRequiredFields_, ULONG ulOptionalFields_)
- {
- return ANT_ConfigureAdvancedBurst_RTO(bEnable_, ucMaxPacketLength_, ulRequiredFields_, ulOptionalFields_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigureAdvancedBurst_RTO(BOOL bEnable_, UCHAR ucMaxPacketLength_, ULONG ulRequiredFields_, ULONG ulOptionalFields_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ConfigAdvancedBurst(bEnable_, ucMaxPacketLength_, ulRequiredFields_, ulOptionalFields_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Stall count version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigureAdvancedBurst_ext(BOOL bEnable_, UCHAR ucMaxPacketLength_, ULONG ulRequiredFields_, ULONG ulOptionalFields_, USHORT usStallCount_, UCHAR ucRetryCount_)
- {
- return ANT_ConfigureAdvancedBurst_ext_RTO(bEnable_, ucMaxPacketLength_, ulRequiredFields_, ulOptionalFields_, usStallCount_, ucRetryCount_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Stall count version with response timeout
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigureAdvancedBurst_ext_RTO(BOOL bEnable_, UCHAR ucMaxPacketLength_, ULONG ulRequiredFields_, ULONG ulOptionalFields_, USHORT usStallCount_, UCHAR ucRetryCount_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ConfigAdvancedBurst_ext(bEnable_, ucMaxPacketLength_, ulRequiredFields_, ulOptionalFields_, usStallCount_, ucRetryCount_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to set the transmit power for the module
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetChannelTxPower(UCHAR ucANTChannel_, UCHAR ucTransmitPower_)
- {
- return ANT_SetChannelTxPower_RTO(ucANTChannel_, ucTransmitPower_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetChannelTxPower_RTO(UCHAR ucANTChannel_, UCHAR ucTransmitPower_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetChannelTransmitPower(ucANTChannel_, ucTransmitPower_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to request a generic message
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_RequestMessage(UCHAR ucANTChannel_, UCHAR ucMessageID_)
- {
- if(pclMessageObject){
- ANT_MESSAGE_ITEM stResponse;
- return pclMessageObject->SendRequest(ucMessageID_, ucANTChannel_, &stResponse, 0);
- }
- return FALSE;
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to send a generic message
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_WriteMessage(UCHAR ucMessageID, UCHAR* aucData, USHORT usMessageSize)
- {
- if(pclMessageObject){
- ANT_MESSAGE pstTempANTMessage;
- pstTempANTMessage.ucMessageID = ucMessageID;
- memcpy(pstTempANTMessage.aucData, aucData, MIN(usMessageSize, MESG_MAX_SIZE_VALUE));
- return pclMessageObject->WriteMessage(&pstTempANTMessage, usMessageSize);
- }
- return FALSE;
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to open an assigned channel
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_OpenChannel(UCHAR ucANTChannel_)
- {
- return ANT_OpenChannel_RTO(ucANTChannel_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_OpenChannel_RTO(UCHAR ucANTChannel_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->OpenChannel(ucANTChannel_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to close an opend channel
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_CloseChannel(UCHAR ucANTChannel_)
- {
- return ANT_CloseChannel_RTO(ucANTChannel_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_CloseChannel_RTO(UCHAR ucANTChannel_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->CloseChannel(ucANTChannel_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to construct and send a broadcast data message.
- // This message will be broadcast on the next synchronous channel period.
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SendBroadcastData(UCHAR ucANTChannel_, UCHAR *pucData_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SendBroadcastData(ucANTChannel_, pucData_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to construct and send an acknowledged data
- // mesg. This message will be transmitted on the next synchronous channel
- // period.
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SendAcknowledgedData(UCHAR ucANTChannel_, UCHAR *pucData_)
- {
- return ANT_SendAcknowledgedData_RTO(ucANTChannel_, pucData_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SendAcknowledgedData_RTO(UCHAR ucANTChannel_, UCHAR *pucData_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SendAcknowledgedData( ucANTChannel_, pucData_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Used to send burst data using a block of data. Proper sequence number
- // of packet is maintained by the function. Useful for testing purposes.
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SendBurstTransfer(UCHAR ucANTChannel_, UCHAR *pucData_, USHORT usNumDataPackets_)
- {
- return ANT_SendBurstTransfer_RTO(ucANTChannel_, pucData_, usNumDataPackets_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SendBurstTransfer_RTO(UCHAR ucANTChannel_, UCHAR *pucData_, USHORT usNumDataPackets_, ULONG ulResponseTime_)
- {
- ULONG ulSize = usNumDataPackets_*8; // Pass the number of bytes.
- ANTFRAMER_RETURN eStatus;
- if(pclMessageObject)
- {
- eStatus = pclMessageObject->SendTransfer( ucANTChannel_, pucData_, ulSize, ulResponseTime_);
- if( eStatus == ANTFRAMER_PASS )
- return(TRUE);
- }
- return(FALSE);
- }
- //////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to configure and start CW test mode.
- // There is no way to turn off CW mode other than to do a reset on the module.
- /////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_InitCWTestMode(void)
- {
- return ANT_InitCWTestMode_RTO(0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_InitCWTestMode_RTO(ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->InitCWTestMode(ulResponseTime_));
- }
- return(FALSE);
- }
- //////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to configure and start CW test mode.
- // There is no way to turn off CW mode other than to do a reset on the module.
- /////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetCWTestMode(UCHAR ucTransmitPower_, UCHAR ucRFChannel_)
- {
- return ANT_SetCWTestMode_RTO(ucTransmitPower_, ucRFChannel_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetCWTestMode_RTO(UCHAR ucTransmitPower_, UCHAR ucRFChannel_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetCWTestMode(ucTransmitPower_, ucRFChannel_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Add a channel ID to a channel's include/exclude ID list
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_AddChannelID(UCHAR ucANTChannel_, USHORT usDeviceNumber_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_, UCHAR ucListIndex_)
- {
- return ANT_AddChannelID_RTO(ucANTChannel_, usDeviceNumber_, ucDeviceType_, ucTransmissionType_, ucListIndex_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_AddChannelID_RTO(UCHAR ucANTChannel_, USHORT usDeviceNumber_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_, UCHAR ucListIndex_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->AddChannelID(ucANTChannel_, usDeviceNumber_, ucDeviceType_, ucTransmissionType_, ucListIndex_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Configure the size and type of a channel's include/exclude ID list
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigList(UCHAR ucANTChannel_, UCHAR ucListSize_, UCHAR ucExclude_)
- {
- return ANT_ConfigList_RTO(ucANTChannel_, ucListSize_, ucExclude_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigList_RTO(UCHAR ucANTChannel_, UCHAR ucListSize_, UCHAR ucExclude_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ConfigList(ucANTChannel_, ucListSize_, ucExclude_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Open Scan Mode
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_OpenRxScanMode()
- {
- return ANT_OpenRxScanMode_RTO(0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_OpenRxScanMode_RTO(ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->OpenRxScanMode(ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Configure ANT Frequency Agility Functionality (not on AP1 or AT3)
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigFrequencyAgility(UCHAR ucANTChannel_, UCHAR ucFreq1_, UCHAR ucFreq2_, UCHAR ucFreq3_)
- {
- return(ANT_ConfigFrequencyAgility_RTO(ucANTChannel_, ucFreq1_, ucFreq2_, ucFreq3_, 0));
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigFrequencyAgility_RTO(UCHAR ucANTChannel_, UCHAR ucFreq1_, UCHAR ucFreq2_, UCHAR ucFreq3_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ConfigFrequencyAgility(ucANTChannel_, ucFreq1_, ucFreq2_, ucFreq3_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Configure proximity search (not on AP1 or AT3)
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetProximitySearch(UCHAR ucANTChannel_, UCHAR ucSearchThreshold_)
- {
- return(ANT_SetProximitySearch_RTO(ucANTChannel_, ucSearchThreshold_, 0));
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetProximitySearch_RTO(UCHAR ucANTChannel_, UCHAR ucSearchThreshold_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetProximitySearch(ucANTChannel_, ucSearchThreshold_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Configure Event Filter (USBm and nRF5 only)
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigEventFilter(USHORT usEventFilter_)
- {
- return(ANT_ConfigEventFilter_RTO(usEventFilter_, 0));
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigEventFilter_RTO(USHORT usEventFilter_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ConfigEventFilter(usEventFilter_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Configure Event Buffer (USBm only)
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigEventBuffer(UCHAR ucConfig_, USHORT usSize_, USHORT usTime_)
- {
- return(ANT_ConfigEventBuffer_RTO(ucConfig_, usSize_, usTime_, 0));
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigEventBuffer_RTO(UCHAR ucConfig_, USHORT usSize_, USHORT usTime_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ConfigEventBuffer(ucConfig_, usSize_, usTime_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Configure High Duty Search (USBm only)
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigHighDutySearch(UCHAR ucEnable_, UCHAR ucSuppressionCycles_)
- {
- return(ANT_ConfigHighDutySearch_RTO(ucEnable_, ucSuppressionCycles_, 0));
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigHighDutySearch_RTO(UCHAR ucEnable_, UCHAR ucSuppressionCycles_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ConfigHighDutySearch(ucEnable_, ucSuppressionCycles_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Configure Selective Data Update (USBm only)
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigSelectiveDataUpdate(UCHAR ucChannel_, UCHAR ucSduConfig_)
- {
- return(ANT_ConfigSelectiveDataUpdate_RTO(ucChannel_, ucSduConfig_, 0));
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigSelectiveDataUpdate_RTO(UCHAR ucChannel_, UCHAR ucSduConfig_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ConfigSelectiveDataUpdate(ucChannel_, ucSduConfig_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Set Selective Data Update Mask (USBm only)
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetSelectiveDataUpdateMask(UCHAR ucMaskNumber_, UCHAR* pucSduMask_)
- {
- return(ANT_SetSelectiveDataUpdateMask_RTO(ucMaskNumber_, pucSduMask_, 0));
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetSelectiveDataUpdateMask_RTO(UCHAR ucMaskNumber_, UCHAR* pucSduMask_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetSelectiveDataUpdateMask(ucMaskNumber_, pucSduMask_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Configure User NVM (USBm only)
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigUserNVM(USHORT usAddress_, UCHAR* pucData_, UCHAR ucSize_)
- {
- return(ANT_ConfigUserNVM_RTO(usAddress_, pucData_, ucSize_, 0));
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_ConfigUserNVM_RTO(USHORT usAddress_, UCHAR* pucData_, UCHAR ucSize_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ConfigUserNVM(usAddress_, pucData_, ucSize_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Message to put into DEEP SLEEP (not on AP1 or AT3)
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SleepMessage()
- {
- return(ANT_SleepMessage_RTO(0));
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SleepMessage_RTO(ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SleepMessage(ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Message to put into DEEP SLEEP (not on AP1 or AT3)
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_CrystalEnable()
- {
- return(ANT_CrystalEnable_RTO(0));
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_CrystalEnable_RTO(ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->CrystalEnable(ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to write NVM data
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_NVM_Write(UCHAR ucSize_, UCHAR *pucData_)
- {
- return ANT_NVM_Write_RTO(ucSize_, pucData_ , 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_NVM_Write_RTO(UCHAR ucSize_, UCHAR *pucData_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ScriptWrite(ucSize_,pucData_, ulResponseTime_ ));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to clear NVM data
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_NVM_Clear(UCHAR ucSectNumber_)
- {
- return ANT_NVM_Clear_RTO(ucSectNumber_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_NVM_Clear_RTO(UCHAR ucSectNumber_, ULONG ulResponseTime_)
- //Sector number is useless here, but is still here for backwards compatibility
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ScriptClear(ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to set default NVM sector
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_NVM_SetDefaultSector(UCHAR ucSectNumber_)
- {
- return ANT_NVM_SetDefaultSector_RTO(ucSectNumber_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_NVM_SetDefaultSector_RTO(UCHAR ucSectNumber_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ScriptSetDefaultSector(ucSectNumber_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to end NVM sector
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_NVM_EndSector()
- {
- return ANT_NVM_EndSector_RTO(0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_NVM_EndSector_RTO(ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ScriptEndSector(ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to dump the contents of the NVM
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_NVM_Dump()
- {
- return ANT_NVM_Dump_RTO(0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_NVM_Dump_RTO(ULONG ulResponseTime_)
- //Response time is useless here, but is kept for backwards compatibility
- {
- if(pclMessageObject)
- {
- pclMessageObject->ScriptDump();
- return TRUE;
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to lock the contents of the NVM
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_NVM_Lock()
- {
- return ANT_NVM_Lock_RTO(0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_NVM_Lock_RTO(ULONG ulResponseTimeout_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->ScriptLock(ulResponseTimeout_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to set the state of the FE (FIT1e)
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL FIT_SetFEState(UCHAR ucFEState_)
- {
- return FIT_SetFEState_RTO(ucFEState_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL FIT_SetFEState_RTO(UCHAR ucFEState_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->FITSetFEState(ucFEState_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to set the pairing distance (FIT1e)
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL FIT_AdjustPairingSettings(UCHAR ucSearchLv_, UCHAR ucPairLv_, UCHAR ucTrackLv_)
- {
- return FIT_AdjustPairingSettings_RTO(ucSearchLv_, ucPairLv_, ucTrackLv_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL FIT_AdjustPairingSettings_RTO(UCHAR ucSearchLv_, UCHAR ucPairLv_, UCHAR ucTrackLv_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->FITAdjustPairingSettings(ucSearchLv_, ucPairLv_, ucTrackLv_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to construct and send an extended broadcast data message.
- // This message will be broadcast on the next synchronous channel period.
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SendExtBroadcastData(UCHAR ucANTChannel_, UCHAR *pucData_)
- {
- if(!pclMessageObject)
- return FALSE;
- return pclMessageObject->SendExtBroadcastData(ucANTChannel_, pucData_);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to construct and send an extended acknowledged data
- // mesg. This message will be transmitted on the next synchronous channel
- // period.
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SendExtAcknowledgedData(UCHAR ucANTChannel_, UCHAR *pucData_)
- {
- return ANT_SendExtAcknowledgedData_RTO(ucANTChannel_, pucData_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SendExtAcknowledgedData_RTO(UCHAR ucANTChannel_, UCHAR *pucData_, ULONG ulResponseTime_)
- {
- if(!pclMessageObject)
- return FALSE;
- return (ANTFRAMER_PASS == pclMessageObject->SendExtAcknowledgedData(ucANTChannel_, pucData_, ulResponseTime_));
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Called by the application to construct and send extended burst data
- // mesg.
- ///////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Used to send extended burst data with individual packets. Proper sequence number
- // of packet is maintained by the application.
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SendExtBurstTransferPacket(UCHAR ucANTChannelSeq_, UCHAR *pucData_)
- {
- if(pclMessageObject)
- {
- ANT_MESSAGE stMessage;
- stMessage.ucMessageID = MESG_EXT_BURST_DATA_ID;
- stMessage.aucData[0] = ucANTChannelSeq_;
- memcpy(&stMessage.aucData[1],pucData_, MESG_EXT_DATA_SIZE-1);
- return pclMessageObject->WriteMessage(&stMessage, MESG_EXT_DATA_SIZE);
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Used to send extended burst data using a block of data. Proper sequence number
- // of packet is maintained by the function. Useful for testing purposes.
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- USHORT ANT_SendExtBurstTransfer(UCHAR ucANTChannel_, UCHAR *pucData_, USHORT usDataPackets_)
- {
- return ANT_SendExtBurstTransfer_RTO(ucANTChannel_, pucData_, usDataPackets_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- USHORT ANT_SendExtBurstTransfer_RTO(UCHAR ucANTChannel_, UCHAR *pucData_, USHORT usDataPackets_, ULONG ulResponseTime_)
- {
- if(!pclMessageObject)
- return FALSE;
- return (ANTFRAMER_PASS == pclMessageObject->SendExtBurstTransfer(ucANTChannel_, pucData_, usDataPackets_*8, ulResponseTime_));
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Used to force the module to use extended rx messages all the time
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_RxExtMesgsEnable(UCHAR ucEnable_)
- {
- return ANT_RxExtMesgsEnable_RTO(ucEnable_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_RxExtMesgsEnable_RTO(UCHAR ucEnable_, ULONG ulResponseTimeout_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->RxExtMesgsEnable(ucEnable_, ulResponseTimeout_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Used to set a channel device ID to the module serial number
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetSerialNumChannelId(UCHAR ucANTChannel_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_)
- {
- return ANT_SetSerialNumChannelId_RTO(ucANTChannel_, ucDeviceType_, ucTransmissionType_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetSerialNumChannelId_RTO(UCHAR ucANTChannel_, UCHAR ucDeviceType_, UCHAR ucTransmissionType_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->SetSerialNumChannelId(ucANTChannel_, ucDeviceType_, ucTransmissionType_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Priority: Any
- //
- // Enables the module LED to flash on RF activity
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_EnableLED(UCHAR ucEnable_)
- {
- return ANT_EnableLED_RTO(ucEnable_, 0);
- }
- ///////////////////////////////////////////////////////////////////////
- // Response TimeOut Version
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_EnableLED_RTO(UCHAR ucEnable_, ULONG ulResponseTime_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->EnableLED(ucEnable_, ulResponseTime_));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Called by the application to get the product string and serial number string (four bytes) of a particular device
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_GetDeviceUSBInfo(UCHAR ucDeviceNum, UCHAR* pucProductString, UCHAR* pucSerialString)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->GetDeviceUSBInfo(ucDeviceNum, pucProductString, pucSerialString, USB_MAX_STRLEN));
- }
- return(FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Called by the application to get the USB PID
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_GetDeviceUSBPID(USHORT* pusPID_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->GetDeviceUSBPID(*pusPID_));
- }
- return (FALSE);
- }
- ///////////////////////////////////////////////////////////////////////
- // Called by the application to get the USB VID
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_GetDeviceUSBVID(USHORT* pusVID_)
- {
- if(pclMessageObject)
- {
- return(pclMessageObject->GetDeviceUSBVID(*pusVID_));
- }
- return (FALSE);
- }
- ////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////
- // The following are the Integrated ANTFS_Client functions
- ////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////
- //Memory Device Commands/////////////
- extern "C" EXPORT
- BOOL ANTFS_InitEEPROMDevice(USHORT usPageSize_, UCHAR ucAddressConfig_)
- {
- return (pclMessageObject->InitEEPROMDevice(usPageSize_, ucAddressConfig_, 3000));
- }
- //File System Commands//////////////
- extern "C" EXPORT
- BOOL ANTFS_InitFSMemory()
- {
- return (pclMessageObject->InitFSMemory(3000));
- }
- extern "C" EXPORT
- BOOL ANTFS_FormatFSMemory(USHORT usNumberOfSectors_, USHORT usPagesPerSector_)
- {
- return (pclMessageObject->FormatFSMemory(usNumberOfSectors_, usPagesPerSector_, 3000));
- }
- extern "C" EXPORT
- BOOL ANTFS_SaveDirectory()
- {
- return (pclMessageObject->SaveDirectory(3000));
- }
- extern "C" EXPORT
- BOOL ANTFS_DirectoryRebuild()
- {
- return (pclMessageObject->DirectoryRebuild(3000));
- }
- extern "C" EXPORT
- BOOL ANTFS_FileDelete(UCHAR ucFileHandle_)
- {
- return (pclMessageObject->FileDelete(ucFileHandle_, 3000));
- }
- extern "C" EXPORT
- BOOL ANTFS_FileClose(UCHAR ucFileHandle_)
- {
- return (pclMessageObject->FileClose(ucFileHandle_, 3000));
- }
- extern "C" EXPORT
- BOOL ANTFS_SetFileSpecificFlags(UCHAR ucFileHandle_, UCHAR ucFlags_)
- {
- return (pclMessageObject->SetFileSpecificFlags(ucFileHandle_, ucFlags_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_DirectoryReadLock(BOOL bLock_)
- {
- return (pclMessageObject->DirectoryReadLock(bLock_, 3000));
- }
- extern "C" EXPORT
- BOOL ANTFS_SetSystemTime(ULONG ulTime_)
- {
- return (pclMessageObject->SetSystemTime(ulTime_, 3000));
- }
- //File System Requests////////////
- extern "C" EXPORT
- ULONG ANTFS_GetUsedSpace()
- {
- return (pclMessageObject->GetUsedSpace(3000));
- }
- extern "C" EXPORT
- ULONG ANTFS_GetFreeSpace()
- {
- return (pclMessageObject->GetFreeFSSpace(3000));
- }
- extern "C" EXPORT
- USHORT ANTFS_FindFileIndex(UCHAR ucFileDataType_, UCHAR ucFileSubType_, USHORT usFileNumber_)
- {
- return (pclMessageObject->FindFileIndex(ucFileDataType_, ucFileSubType_, usFileNumber_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_ReadDirectoryAbsolute(ULONG ulOffset_, UCHAR ucSize_, UCHAR* pucBuffer_)
- {
- return (pclMessageObject->ReadDirectoryAbsolute(ulOffset_, ucSize_, pucBuffer_,3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_DirectoryReadEntry (USHORT usFileIndex_, UCHAR* ucFileDirectoryBuffer_)
- {
- return (pclMessageObject->DirectoryReadEntry (usFileIndex_, ucFileDirectoryBuffer_, 3000));
- }
- extern "C" EXPORT
- ULONG ANTFS_DirectoryGetSize()
- {
- return (pclMessageObject->DirectoryGetSize(3000));
- }
- extern "C" EXPORT
- USHORT ANTFS_FileCreate(USHORT usFileIndex_, UCHAR ucFileDataType_, ULONG ulFileIdentifier_, UCHAR ucFileDataTypeSpecificFlags_, UCHAR ucGeneralFlags)
- {
- return (pclMessageObject->FileCreate(usFileIndex_, ucFileDataType_, ulFileIdentifier_, ucFileDataTypeSpecificFlags_, ucGeneralFlags, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_FileOpen(USHORT usFileIndex_, UCHAR ucOpenFlags_)
- {
- return (pclMessageObject->FileOpen(usFileIndex_, ucOpenFlags_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_FileReadAbsolute(UCHAR ucFileHandle_, ULONG ulOffset_, UCHAR ucReadSize_, UCHAR* pucReadBuffer_)
- {
- return (pclMessageObject->FileReadAbsolute(ucFileHandle_, ulOffset_, ucReadSize_, pucReadBuffer_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_FileReadRelative(UCHAR ucFileHandle_, UCHAR ucReadSize_, UCHAR* pucReadBuffer_)
- {
- return (pclMessageObject->FileReadRelative(ucFileHandle_, ucReadSize_, pucReadBuffer_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_FileWriteAbsolute(UCHAR ucFileHandle_, ULONG ulFileOffset_, UCHAR ucWriteSize_, const UCHAR* pucWriteBuffer_, UCHAR* ucBytesWritten_)
- {
- return (pclMessageObject->FileWriteAbsolute(ucFileHandle_, ulFileOffset_, ucWriteSize_, pucWriteBuffer_, ucBytesWritten_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_FileWriteRelative(UCHAR ucFileHandle_, UCHAR ucWriteSize_, const UCHAR* pucWriteBuffer_, UCHAR* ucBytesWritten_)
- {
- return (pclMessageObject->FileWriteRelative(ucFileHandle_, ucWriteSize_, pucWriteBuffer_, ucBytesWritten_, 3000));
- }
- extern "C" EXPORT
- ULONG ANTFS_FileGetSize(UCHAR ucFileHandle_)
- {
- return (pclMessageObject->FileGetSize(ucFileHandle_, 3000));
- }
- extern "C" EXPORT
- ULONG ANTFS_FileGetSizeInMem(UCHAR ucFileHandle_)
- {
- return (pclMessageObject->FileGetSizeInMem(ucFileHandle_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_FileGetSpecificFlags(UCHAR ucFileHandle_)
- {
- return (pclMessageObject->FileGetSpecificFlags(ucFileHandle_, 3000));
- }
- extern "C" EXPORT
- ULONG ANTFS_FileGetSystemTime()
- {
- return (pclMessageObject->FileGetSystemTime(3000));
- }
- //FS-Crypto Commands/////////////
- extern "C" EXPORT
- UCHAR ANTFS_CryptoAddUserKeyIndex(UCHAR ucIndex_, UCHAR* pucKey_)
- {
- return (pclMessageObject->CryptoAddUserKeyIndex(ucIndex_, pucKey_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_CryptoSetUserKeyIndex(UCHAR ucIndex_)
- {
- return (pclMessageObject->CryptoSetUserKeyIndex(ucIndex_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_CryptoSetUserKeyVal(UCHAR* pucKey_)
- {
- return (pclMessageObject->CryptoSetUserKeyVal(pucKey_, 3000));
- }
- //FIT Commands///////////////////////
- extern "C" EXPORT
- UCHAR ANTFS_FitFileIntegrityCheck(UCHAR ucFileHandle_)
- {
- return (pclMessageObject->FitFileIntegrityCheck(ucFileHandle_, 3000));
- }
- //ANT-FS Commands////////////////////
- extern "C" EXPORT
- UCHAR ANTFS_OpenBeacon()
- {
- return (pclMessageObject->OpenBeacon(3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_CloseBeacon()
- {
- return (pclMessageObject->CloseBeacon(3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_ConfigBeacon(USHORT usDeviceType_, USHORT usManufacturer_, UCHAR ucAuthType_, UCHAR ucBeaconStatus_)
- {
- return (pclMessageObject->ConfigBeacon(usDeviceType_, usManufacturer_, ucAuthType_, ucBeaconStatus_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_SetFriendlyName(UCHAR ucLength_, const UCHAR* pucString_)
- {
- return (pclMessageObject->SetFriendlyName(ucLength_, pucString_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_SetPasskey(UCHAR ucLength_, const UCHAR* pucString_)
- {
- return (pclMessageObject->SetPasskey(ucLength_, pucString_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_SetBeaconState(UCHAR ucBeaconStatus_)
- {
- return (pclMessageObject->SetBeaconState(ucBeaconStatus_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_PairResponse(BOOL bAccept_)
- {
- return (pclMessageObject->PairResponse(bAccept_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_SetLinkFrequency(UCHAR ucChannelNumber_, UCHAR ucFrequency_)
- {
- return (pclMessageObject->SetLinkFrequency(ucChannelNumber_, ucFrequency_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_SetBeaconTimeout(UCHAR ucTimeout_)
- {
- return (pclMessageObject->SetBeaconTimeout(ucTimeout_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_SetPairingTimeout(UCHAR ucTimeout_)
- {
- return (pclMessageObject->SetPairingTimeout(ucTimeout_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_EnableRemoteFileCreate(BOOL bEnable_)
- {
- return (pclMessageObject->EnableRemoteFileCreate(bEnable_, 3000));
- }
- //ANT-FS Responses////////////////////
- extern "C" EXPORT
- UCHAR ANTFS_GetCmdPipe(UCHAR ucOffset_, UCHAR ucReadSize_, UCHAR* pucReadBuffer_)
- {
- return (pclMessageObject->GetCmdPipe(ucOffset_, ucReadSize_, pucReadBuffer_, 3000));
- }
- extern "C" EXPORT
- UCHAR ANTFS_SetCmdPipe(UCHAR ucOffset_, UCHAR ucWriteSize_, const UCHAR* pucWriteBuffer_)
- {
- return (pclMessageObject->SetCmdPipe(ucOffset_, ucWriteSize_, pucWriteBuffer_, 3000));
- }
- //GetFSResponse/////////////////////////
- extern "C" EXPORT
- UCHAR ANTFS_GetLastError()
- {
- return (pclMessageObject->GetLastError());
- }
- ///////////////////////////////////////////////////////////////////////
- // Set the directory the log files are saved to
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- BOOL ANT_SetDebugLogDirectory(char* pcDirectory)
- {
- #if defined(DEBUG_FILE)
- return DSIDebug::SetDirectory(pcDirectory);
- #else
- return false;
- #endif
- }
- ///////////////////////////////////////////////////////////////////////
- // Put current thread to sleep for the specified number of milliseconds
- ///////////////////////////////////////////////////////////////////////
- extern "C" EXPORT
- void ANT_Nap(ULONG ulMilliseconds_)
- {
- DSIThread_Sleep(ulMilliseconds_);
- }
- // Local functions ****************************************************//
- static DSI_THREAD_RETURN MessageThread(void *pvParameter_)
- {
- ANT_MESSAGE stMessage;
- USHORT usSize;
- eTheThread = DSIThread_GetCurrentThreadIDNum();
- while(bGoThread)
- {
- if(pclMessageObject->WaitForMessage(1000/*DSI_THREAD_INFINITE*/))
- {
- usSize = pclMessageObject->GetMessage(&stMessage);
- if(usSize == DSI_FRAMER_ERROR)
- {
- // Get the message to clear the error
- usSize = pclMessageObject->GetMessage(&stMessage, MESG_MAX_SIZE_VALUE);
- continue;
- }
- if(usSize != 0 && usSize != DSI_FRAMER_ERROR && usSize != DSI_FRAMER_TIMEDOUT)
- {
- SerialHaveMessage(stMessage, usSize);
- }
- }
- }
- DSIThread_MutexLock(&mutexTestDone);
- UCHAR ucCondResult = DSIThread_CondSignal(&condTestDone);
- assert(ucCondResult == DSI_THREAD_ENONE);
- DSIThread_MutexUnlock(&mutexTestDone);
- return(NULL);
- }
- //Called internally to delete objects from memory
- static void MemoryCleanup(void)
- {
- if(pclSerialObject)
- {
- //Close all stuff
- pclSerialObject->Close();
- delete pclSerialObject;
- pclSerialObject = NULL;
- }
- if(pclMessageObject)
- {
- delete pclMessageObject;
- pclMessageObject = NULL;
- }
- }
- ///////////////////////////////////////////////////////////////////////
- //
- // Processes a received serial message. This function is intended to be
- // called by the serial message driver code, to be defined by the user,
- // when a serial message is received from the ANT module.
- ///////////////////////////////////////////////////////////////////////
- static void SerialHaveMessage(ANT_MESSAGE& stMessage_, USHORT usSize_)
- {
- UCHAR ucANTChannel;
- //If no response function has been assigned, ignore the message and unlock
- //the receive buffer
- if (pfResponseFunc == NULL)
- return;
- ucANTChannel = stMessage_.aucData[MESG_CHANNEL_OFFSET] & CHANNEL_NUMBER_MASK;
- //Process the message to determine whether it is a response event or one
- //of the channel events and call the appropriate event function.
- switch (stMessage_.ucMessageID)
- {
- case MESG_RESPONSE_EVENT_ID:
- {
- if (stMessage_.aucData[MESG_EVENT_ID_OFFSET] != MESG_EVENT_ID) // this is a response
- {
- if (pucResponseBuffer)
- {
- memcpy(pucResponseBuffer, stMessage_.aucData, MESG_RESPONSE_EVENT_SIZE);
- pfResponseFunc(ucANTChannel, MESG_RESPONSE_EVENT_ID);
- }
- }
- else // this is an event
- {
- // If we are in auto transfer mode, stop sending packets
- if ((stMessage_.aucData[MESG_EVENT_CODE_OFFSET] == EVENT_TRANSFER_TX_FAILED) && (ucAutoTransferChannel == ucANTChannel))
- usNumDataPackets = 0;
- if (sLink[ucANTChannel].pfLinkEvent == NULL)
- break;
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, usSize_);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, stMessage_.aucData[MESG_EVENT_CODE_OFFSET]); // pass through any events not handled here
- }
- break;
- }
- case MESG_BROADCAST_DATA_ID:
- {
- if ( sLink[ucANTChannel].pfLinkEvent == NULL ||
- sLink[ucANTChannel].pucRxBuffer == NULL)
- {
- break;
- }
- // If size is greater than the standard data message size, then assume
- // that this is a data message with a flag at the end. Set the event accordingly.
- if(usSize_ > MESG_DATA_SIZE)
- {
- //Call channel event function with Broadcast message code
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, usSize_);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_FLAG_BROADCAST); // process the event
- }
- else
- {
- //Call channel event function with Broadcast message code
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, ANT_STANDARD_DATA_PAYLOAD_SIZE + MESG_CHANNEL_NUM_SIZE);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_BROADCAST); // process the event
- }
- break;
- }
- case MESG_ACKNOWLEDGED_DATA_ID:
- {
- if (sLink[ucANTChannel].pfLinkEvent == NULL)
- break;
- if(usSize_ > MESG_DATA_SIZE)
- {
- //Call channel event function with Broadcast message code
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, usSize_);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_FLAG_ACKNOWLEDGED); // process the event
- }
- else
- {
- //Call channel event function with Acknowledged message code
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, ANT_STANDARD_DATA_PAYLOAD_SIZE + MESG_CHANNEL_NUM_SIZE);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_ACKNOWLEDGED); // process the message
- }
- break;
- }
- case MESG_BURST_DATA_ID:
- {
- if (sLink[ucANTChannel].pfLinkEvent == NULL)
- break;
- if(usSize_ > MESG_DATA_SIZE)
- {
- //Call channel event function with Broadcast message code
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, usSize_);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_FLAG_BURST_PACKET); // process the event
- }
- else
- {
- //Call channel event function with Burst message code
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, ANT_STANDARD_DATA_PAYLOAD_SIZE + MESG_CHANNEL_NUM_SIZE);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_BURST_PACKET); // process the message
- }
- break;
- }
- case MESG_EXT_BROADCAST_DATA_ID:
- {
- if (sLink[ucANTChannel].pfLinkEvent == NULL)
- break;
- //Call channel event function with Broadcast message code
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, MESG_EXT_DATA_SIZE);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_EXT_BROADCAST); // process the event
- break;
- }
- case MESG_EXT_ACKNOWLEDGED_DATA_ID:
- {
- if (sLink[ucANTChannel].pfLinkEvent == NULL)
- break;
- //Call channel event function with Acknowledged message code
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, MESG_EXT_DATA_SIZE);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_EXT_ACKNOWLEDGED); // process the message
- break;
- }
- case MESG_EXT_BURST_DATA_ID:
- {
- if (sLink[ucANTChannel].pfLinkEvent == NULL)
- break;
- //Call channel event function with Burst message code
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, MESG_EXT_DATA_SIZE);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_EXT_BURST_PACKET); // process the message
- break;
- }
- case MESG_RSSI_BROADCAST_DATA_ID:
- {
- if (sLink[ucANTChannel].pfLinkEvent == NULL)
- break;
- //Call channel event function with Broadcast message code
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, MESG_RSSI_DATA_SIZE);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_RSSI_BROADCAST); // process the event
- break;
- }
- case MESG_RSSI_ACKNOWLEDGED_DATA_ID:
- {
- if (sLink[ucANTChannel].pfLinkEvent == NULL)
- break;
- //Call channel event function with Acknowledged message code
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, MESG_RSSI_DATA_SIZE);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_RSSI_ACKNOWLEDGED); // process the message
- break;
- }
- case MESG_RSSI_BURST_DATA_ID:
- {
- if (sLink[ucANTChannel].pfLinkEvent == NULL)
- break;
- //Call channel event function with Burst message code
- memcpy(sLink[ucANTChannel].pucRxBuffer, stMessage_.aucData, MESG_RSSI_DATA_SIZE);
- sLink[ucANTChannel].pfLinkEvent(ucANTChannel, EVENT_RX_RSSI_BURST_PACKET); // process the message
- break;
- }
- case MESG_SCRIPT_DATA_ID:
- {
- if (pucResponseBuffer)
- {
- memcpy(pucResponseBuffer, stMessage_.aucData, usSize_);
- pucResponseBuffer[10] = (UCHAR)usSize_;
- pfResponseFunc(ucANTChannel, MESG_SCRIPT_DATA_ID);
- }
- break;
- }
- case MESG_SCRIPT_CMD_ID:
- {
- if (pucResponseBuffer)
- {
- memcpy(pucResponseBuffer, stMessage_.aucData, MESG_SCRIPT_CMD_SIZE);
- pfResponseFunc(ucANTChannel, MESG_SCRIPT_CMD_ID);
- }
- break;
- }
- default:
- {
- if (pucResponseBuffer) // can we process this link
- {
- memcpy(pucResponseBuffer, stMessage_.aucData, usSize_);
- pfResponseFunc(ucANTChannel, stMessage_.ucMessageID );
- }
- break;
- }
- }
- return;
- }
|