﻿#ifndef __BCA_ANTCALLBACKINTERFACE_H__
#define __BCA_ANTCALLBACKINTERFACE_H__
 
#include "BCA_Lib.h"
#ifdef __cplusplus
extern "C" {
#endif
//
//      callback interface
//
BCA_LIB_API void* BCA_OpenDevice(unsigned char device_no = 0);
//      init ant device
BCA_LIB_API int BCA_Init(void* antDevice);
//      regist send callback function
BCA_LIB_API void BCA_RegisterSendFunc(void* antDevice, 
                                        void (*func)(void* context, unsigned char channel, void* cookie), 
                                        void* cookie);
//      regist receive callback function
BCA_LIB_API void BCA_RegisterReceiveFunc(void* antDevice, 
                                            void (*func)(void* context, unsigned char channel, unsigned char event, 
                                            void* data, unsigned int length, void* cookie), void* cookie);
//      regist event callback function
BCA_LIB_API void BCA_RegisterEventFunc(void* antDevice, 
                                         void (*func)(void* context, unsigned char channel, unsigned char event, void* data, void* cookie),
                                         void* cookie);

//      open channel
BCA_LIB_API int BCA_OpenChannel(void* antDevice,
                                   unsigned char channel_no,       //      channel number(0-7)
                                   unsigned char channel_type,     //      master/slave 
                                   unsigned char shared,           //      shared/noshared
                                   unsigned short device_no,       //      device no 0-65535
                                   unsigned char device_type,      //      device type 0,1-127
                                   unsigned char trans_type,       //      trans type 0,1-255
                                   unsigned char freq,             //      +2400Mhz(0-255)
                                   double hz);                     //      channel period(0.5-32768Hz)
//      close channel
BCA_LIB_API int BCA_CloseChannel(void* antDevice,
                                                                  unsigned char channel_no); 
//      send data
BCA_LIB_API int BCA_SendData(void* antDevice, 
                               unsigned char channel_no, 
                               void* data, 
                               unsigned int length);
//      Send Acknowledged Data
BCA_LIB_API int BCA_SendAcknowledgedData(void* antDevice, 
                                            unsigned char channel_no, 
                                            void* data, 
                                            unsigned int length);
//      Send BurstTransfer Data
BCA_LIB_API int BCA_SendBurstTransfer(void* antDevice, 
                                         unsigned char channel_no, 
                                         void* data, 
                                         unsigned int length);
//      reset ANT device
BCA_LIB_API int BCA_Reset(void* antDevice);
//      clsoe ANT device
BCA_LIB_API int BCA_CloseDevice(void* antDevice);
//      set transmit power
BCA_LIB_API int BCA_SetTransmitPower(void* antDevice, 
                                        unsigned char power);
//      set channel transmit power
BCA_LIB_API int BCA_SetChannelTxPower(void* antDevice, 
                                         unsigned char channel_no, 
                                         unsigned char power);
//      pairing function
 
//      regist pairing callback function
BCA_LIB_API void BCA_RegisterPairingFunc(void* antDevice, 
                                               void (*func)(void* context, int* devicelist, unsigned char count, void* cookie), 
                                               void* cookie);
//      start pairing
BCA_LIB_API int BCA_StartPairing(       void* antDevice,
                                              int freq, 
                                              double hz,              //      channel period(0.5-32768Hz)
                                              int search_sec);
//      stop pairing
BCA_LIB_API int BCA_StopPairing(void* antDevice);
//      get pairing serach device info
BCA_LIB_API int BCA_GetPairingDeviceInfo(void* antDevice, 
                                                unsigned char index, 
                                                int *device_no, 
                                                int *device_type, 
                                                int *trans_type);

#ifdef __cplusplus
}
#endif
 
#endif //       __BCA_ANTCALLBACKINTERFACE_H__