aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/inc
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/inc')
-rw-r--r--src/common/inc/ant_log.h174
-rw-r--r--src/common/inc/ant_native.h135
-rw-r--r--src/common/inc/ant_types.h125
-rw-r--r--src/common/inc/ant_utils.h139
-rw-r--r--src/common/inc/ant_version.h27
5 files changed, 600 insertions, 0 deletions
diff --git a/src/common/inc/ant_log.h b/src/common/inc/ant_log.h
new file mode 100644
index 0000000..bc45462
--- /dev/null
+++ b/src/common/inc/ant_log.h
@@ -0,0 +1,174 @@
+/*
+* ANT Stack
+*
+* Copyright 2009 Dynastream Innovations
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+/******************************************************************************\
+*
+* FILE NAME: ANT_log.h
+*
+* BRIEF:
+* This file defines logging functions
+*
+*
+\******************************************************************************/
+
+#ifndef __ANT_LOG_H
+#define __ANT_LOG_H
+
+#include <unistd.h>
+#include "ant_types.h"
+
+#define LEVEL_NONE 0
+#define LEVEL_ERROR 1
+#define LEVEL_WARNING 2
+#define LEVEL_INFO 3
+#define LEVEL_DEBUG 4
+#define LEVEL_VERBOSE 5
+
+#define STREAM_STDOUT 16
+#define STREAM_LOGCAT 17
+
+/* Define what stream output should go to depending on platform */
+#if defined(__ANDROID__) || defined(ANDROID)
+ #define ANT_OUTPUT_STREAM STREAM_LOGCAT
+#elif defined(__linux__) || defined(__linux) || defined(linux)
+ #define ANT_OUTPUT_STREAM STREAM_STDOUT
+#endif
+
+/* If no debug level defined, set default as none */
+#if !defined(ANT_DEBUG)
+ #define ANT_DEBUG LEVEL_NONE
+#endif
+
+/* Define to show function entry and exit */
+//#define ANT_STACK_TRACE
+
+/* Define to show message in byte form */
+//#define ANT_LOG_SERIAL
+
+/* Define to write serial log to file instead of logcat */
+//#define ANT_LOG_SERIAL_FILE "/data/system/antseriallog.txt"
+
+#undef LOG_TAG
+#define LOG_TAG "antradio"
+
+#if ANT_DEBUG == LEVEL_NONE
+ #undef ANT_STACK_TRACE
+ #undef ANT_LOG_SERIAL
+#endif
+
+#if ANT_DEBUG >= LEVEL_ERROR
+ #define OUTPUT_LEVEL_ERROR(...) OUTPUT_ERROR(__VA_ARGS__)
+#else
+ #define OUTPUT_LEVEL_ERROR(...) ((void)0)
+#endif
+#if ANT_DEBUG >= LEVEL_WARNING
+ #define OUTPUT_LEVEL_WARNING(...) OUTPUT_WARNING(__VA_ARGS__)
+#else
+ #define OUTPUT_LEVEL_WARNING(...) ((void)0)
+#endif
+#if ANT_DEBUG >= LEVEL_INFO
+ #define OUTPUT_LEVEL_INFO(...) OUTPUT_INFO(__VA_ARGS__)
+#else
+ #define OUTPUT_LEVEL_INFO(...) ((void)0)
+#endif
+#if ANT_DEBUG >= LEVEL_DEBUG
+ #define OUTPUT_LEVEL_DEBUG(...) OUTPUT_DEBUG(__VA_ARGS__)
+#else
+ #define OUTPUT_LEVEL_DEBUG(...) ((void)0)
+#endif
+#if ANT_DEBUG >= LEVEL_VERBOSE
+ #define OUTPUT_LEVEL_VERBOSE(...) OUTPUT_VERBOSE(__VA_ARGS__)
+#else
+ #define OUTPUT_LEVEL_VERBOSE(...) ((void)0)
+#endif
+
+#if ANT_OUTPUT_STREAM == STREAM_STDOUT
+ #include <stdio.h>
+ #define OUTPUT_VERBOSE(fmt, ...) fprintf(stdout, LOG_TAG "<V>: " fmt "\n", ##__VA_ARGS__)
+ #define OUTPUT_DEBUG(fmt, ...) fprintf(stdout, LOG_TAG "<D>: " fmt "\n", ##__VA_ARGS__)
+ #define OUTPUT_INFO(fmt, ...) fprintf(stdout, LOG_TAG "<I>: " fmt "\n", ##__VA_ARGS__)
+ #define OUTPUT_WARNING(fmt, ...) fprintf(stdout, LOG_TAG "<W>: " fmt "\n", ##__VA_ARGS__)
+ #define OUTPUT_ERROR(fmt, ...) fprintf(stdout, LOG_TAG "<E>: " fmt "\n", ##__VA_ARGS__)
+#elif ANT_OUTPUT_STREAM == STREAM_LOGCAT
+ #if (ANT_DEBUG >= LEVEL_VERBOSE) || (defined(ANT_LOG_SERIAL) && !defined(ANT_LOG_SERIAL_FILE))
+ #undef NDEBUG /* Define verbose logging for logcat if required */
+ #endif
+ #include <cutils/log.h>
+ #define OUTPUT_VERBOSE(...) ALOGV(__VA_ARGS__)
+ #define OUTPUT_DEBUG(...) ALOGD(__VA_ARGS__)
+ #define OUTPUT_INFO(...) ALOGI(__VA_ARGS__)
+ #define OUTPUT_WARNING(...) ALOGW(__VA_ARGS__)
+ #define OUTPUT_ERROR(...) ALOGE(__VA_ARGS__)
+#endif
+
+#define ANT_WARN(...) OUTPUT_WARNING(__VA_ARGS__)
+#define ANT_ERROR(...) OUTPUT_ERROR(__VA_ARGS__)
+
+#define ANT_DEBUG_V(...) OUTPUT_LEVEL_VERBOSE(__VA_ARGS__)
+#define ANT_DEBUG_D(...) OUTPUT_LEVEL_DEBUG(__VA_ARGS__)
+#define ANT_DEBUG_I(...) OUTPUT_LEVEL_INFO(__VA_ARGS__)
+#define ANT_DEBUG_W(...) OUTPUT_LEVEL_WARNING(__VA_ARGS__)
+#define ANT_DEBUG_E(...) OUTPUT_LEVEL_ERROR(__VA_ARGS__)
+
+#if defined(ANT_STACK_TRACE)
+ #define ANT_FUNC_START() OUTPUT_DEBUG("-> FUNC start %s", __FUNCTION__)
+ #define ANT_FUNC_END() OUTPUT_DEBUG("<- FUNC end %s", __FUNCTION__)
+#else
+ #define ANT_FUNC_START() ((void)0)
+ #define ANT_FUNC_END() ((void)0)
+#endif
+
+#if defined(ANT_LOG_SERIAL)
+static inline void ANT_SERIAL(ANT_U8 *buf, ANT_U8 len, char dir)
+{
+ static const char hexToChar[] = {'0','1','2','3','4','5','6','7',
+ '8','9','A','B','C','D','E','F'};
+ int i;
+ static char log[1024];
+ char *ptr = log;
+
+ *(ptr++) = dir;
+ *(ptr++) = 'x';
+ *(ptr++) = ' ';
+ for (i = 0; i < len; i++) {
+ *(ptr++) = '[';
+ *(ptr++) = hexToChar[(buf[i] & 0xF0) >> 4];
+ *(ptr++) = hexToChar[(buf[i] & 0x0F) >> 0];
+ *(ptr++) = ']';
+ }
+#if defined(ANT_LOG_SERIAL_FILE)
+ *(ptr++) = '\n';
+ FILE *fd = NULL;
+ fd = fopen(ANT_LOG_SERIAL_FILE, "a");
+ if (NULL == fd) {
+ LOGW("Could not open %s for serial output. %s", ANT_LOG_SERIAL_FILE, strerror(errno));
+ } else {
+ fwrite(log, 1, (ptr - log), fd);
+ if (fclose(fd)) {
+ LOGW("Could not close file for serial output. %s", strerror(errno));
+ }
+ }
+#else
+ *(ptr++) = '\0';
+ OUTPUT_VERBOSE("%s", log);
+#endif
+}
+#else
+ #define ANT_SERIAL(...) ((void)0)
+#endif
+
+#endif /* __ANT_LOG_H */
diff --git a/src/common/inc/ant_native.h b/src/common/inc/ant_native.h
new file mode 100644
index 0000000..6fe106d
--- /dev/null
+++ b/src/common/inc/ant_native.h
@@ -0,0 +1,135 @@
+/*
+ * ANT Stack
+ *
+ * Copyright 2009 Dynastream Innovations
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/******************************************************************************\
+*
+* FILE NAME: ant_native.h
+*
+* BRIEF:
+* This file defines the interface to the ANT transport layer
+*
+*
+\******************************************************************************/
+
+#ifndef __ANT_NATIVE_H
+#define __ANT_NATIVE_H
+
+/*******************************************************************************
+ *
+ * Include files
+ *
+ ******************************************************************************/
+#include "ant_types.h"
+
+/*******************************************************************************
+ *
+ * Constants
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Types
+ *
+ ******************************************************************************/
+typedef void (*ANTNativeANTEventCb)(ANT_U8 ucLen, ANT_U8* pucData);
+typedef void (*ANTNativeANTStateCb)(ANTRadioEnabledStatus uiNewState);
+
+/*******************************************************************************
+ *
+ * Data Structures
+ *
+ ******************************************************************************/
+
+/*******************************************************************************
+ *
+ * Function declarations
+ *
+ ******************************************************************************/
+
+/*------------------------------------------------------------------------------
+ * ant_init()
+ *
+ * Called to initialize the ANT stack
+ */
+ANTStatus ant_init(void);
+
+/*------------------------------------------------------------------------------
+ * ant_deinit()
+ *
+ * Called to de-initialize the ANT stack
+ */
+ANTStatus ant_deinit(void);
+
+/*------------------------------------------------------------------------------
+ * ant_enable_radio()
+ *
+ * Power on the chip and set it to a state which can read / write to it
+ */
+ANTStatus ant_enable_radio(void);
+
+/*------------------------------------------------------------------------------
+ * ant_disable_radio()
+ *
+ * Kill power to the ANT chip and set state which doesnt allow read / write
+ */
+ANTStatus ant_disable_radio(void);
+
+/*------------------------------------------------------------------------------
+ * ant_radio_enabled_status()
+ *
+ * Gets if the chip/transport is disabled/disabling/enabling/enabled
+ */
+ANTRadioEnabledStatus ant_radio_enabled_status(void);
+
+/*------------------------------------------------------------------------------
+ * set_ant_rx_callback()
+ *
+ * Sets the callback function for receiving ANT messages
+ */
+ANTStatus set_ant_rx_callback(ANTNativeANTEventCb rx_callback_func);
+
+/*------------------------------------------------------------------------------
+ * set_ant_state_callback()
+ *
+ * Sets the callback function for any ANT radio enabled status state changes
+ */
+ANTStatus set_ant_state_callback(ANTNativeANTStateCb state_callback_func);
+
+/*------------------------------------------------------------------------------
+ * ant_tx_message()
+ *
+ * Sends an ANT message command to the chip.
+ */
+ANTStatus ant_tx_message(ANT_U8 ucLen, ANT_U8 *pucMesg);
+
+/*------------------------------------------------------------------------------
+ * ant_radio_hard_reset()
+ *
+ * If supported, forces the chip to do a power cycle reset
+ */
+ANTStatus ant_radio_hard_reset(void);
+
+/*------------------------------------------------------------------------------
+ * ant_get_lib_version()
+ *
+ * Gets the current version and transport type of libantradio.so
+ */
+const char *ant_get_lib_version(void);
+
+#endif /* ifndef __ANT_NATIVE_H */
+
diff --git a/src/common/inc/ant_types.h b/src/common/inc/ant_types.h
new file mode 100644
index 0000000..bc896b6
--- /dev/null
+++ b/src/common/inc/ant_types.h
@@ -0,0 +1,125 @@
+/*
+ * ANT Stack
+ *
+ * Copyright 2009 Dynastream Innovations
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/******************************************************************************\
+*
+* FILE NAME: ANT_types.h
+*
+* BRIEF:
+* This file defines types used in the ANT stack
+*
+*
+\******************************************************************************/
+
+#ifndef __ANT_TYPES_H
+#define __ANT_TYPES_H
+
+#include <stdint.h>
+
+/* -------------------------------------------------------------
+ * 8 Bits Types
+ */
+typedef uint8_t ANT_U8;
+typedef int8_t ANT_S8;
+
+/* -------------------------------------------------------------
+ * 16 Bits Types
+ */
+typedef uint16_t ANT_U16;
+typedef int8_t ANT_S16;
+
+/* -------------------------------------------------------------
+ * 32 Bits Types
+ */
+typedef uint32_t ANT_U32;
+typedef int32_t ANT_S32;
+
+
+/* -------------------------------------------------------------
+ * Native Integer Types (# of bits irrelevant)
+ */
+typedef int ANT_INT;
+typedef unsigned int ANT_UINT;
+
+
+/* --------------------------------------------------------------
+ * Boolean Definitions
+ */
+typedef ANT_INT ANT_BOOL;
+
+#define ANT_TRUE (1 == 1)
+#define ANT_FALSE (1 == 0)
+
+/*
+*/
+#define ANT_NO_VALUE ((ANT_U32)0xFFFFFFFFUL)
+
+
+/* -------------------------------------------------------------
+ * ANTRadioEnabledStatus Type
+ */
+typedef ANT_UINT ANTRadioEnabledStatus;
+
+#define RADIO_STATUS_UNKNOWN ((ANTRadioEnabledStatus)0)
+#define RADIO_STATUS_ENABLING ((ANTRadioEnabledStatus)1)
+#define RADIO_STATUS_ENABLED ((ANTRadioEnabledStatus)2)
+#define RADIO_STATUS_DISABLING ((ANTRadioEnabledStatus)3)
+#define RADIO_STATUS_DISABLED ((ANTRadioEnabledStatus)4)
+#define RADIO_STATUS_NOT_SUPPORTED ((ANTRadioEnabledStatus)5)
+#define RADIO_STATUS_SERVICE_NOT_INSTALLED ((ANTRadioEnabledStatus)6)
+#define RADIO_STATUS_SERVICE_NOT_CONNECTED ((ANTRadioEnabledStatus)7)
+#define RADIO_STATUS_RESETTING ((ANTRadioEnabledStatus)8)
+#define RADIO_STATUS_RESET ((ANTRadioEnabledStatus)9)
+
+/*------------------------------------------------------------------------------
+ * ANTStatus Type
+ *
+ */
+typedef ANT_UINT ANTStatus;
+
+#define ANT_STATUS_SUCCESS ((ANTStatus)0)
+#define ANT_STATUS_FAILED ((ANTStatus)1)
+#define ANT_STATUS_PENDING ((ANTStatus)2)
+#define ANT_STATUS_INVALID_PARM ((ANTStatus)3)
+#define ANT_STATUS_IN_PROGRESS ((ANTStatus)4)
+#define ANT_STATUS_NOT_APPLICABLE ((ANTStatus)5)
+#define ANT_STATUS_NOT_SUPPORTED ((ANTStatus)6)
+#define ANT_STATUS_INTERNAL_ERROR ((ANTStatus)7)
+#define ANT_STATUS_TRANSPORT_INIT_ERR ((ANTStatus)8)
+#define ANT_STATUS_HARDWARE_ERR ((ANTStatus)9)
+#define ANT_STATUS_NO_VALUE_AVAILABLE ((ANTStatus)10)
+#define ANT_STATUS_CONTEXT_DOESNT_EXIST ((ANTStatus)11)
+#define ANT_STATUS_CONTEXT_NOT_DESTROYED ((ANTStatus)12)
+#define ANT_STATUS_CONTEXT_NOT_ENABLED ((ANTStatus)13)
+#define ANT_STATUS_CONTEXT_NOT_DISABLED ((ANTStatus)14)
+#define ANT_STATUS_NOT_DE_INITIALIZED ((ANTStatus)15)
+#define ANT_STATUS_NOT_INITIALIZED ((ANTStatus)16)
+#define ANT_STATUS_TOO_MANY_PENDING_CMDS ((ANTStatus)17)
+#define ANT_STATUS_DISABLING_IN_PROGRESS ((ANTStatus)18)
+
+#define ANT_STATUS_COMMAND_WRITE_FAILED ((ANTStatus)20)
+#define ANT_STATUS_SCRIPT_EXEC_FAILED ((ANTStatus)21)
+
+#define ANT_STATUS_FAILED_BT_NOT_INITIALIZED ((ANTStatus)23)
+#define ANT_STATUS_AUDIO_OPERATION_UNAVAILIBLE_RESOURCES ((ANTStatus)24)
+
+#define ANT_STATUS_TRANSPORT_UNSPECIFIED_ERROR ((ANTStatus)30)
+
+#define ANT_STATUS_NO_VALUE ((ANTStatus)100)
+
+#endif /* __ANT_TYPES_H */
+
diff --git a/src/common/inc/ant_utils.h b/src/common/inc/ant_utils.h
new file mode 100644
index 0000000..60abe8c
--- /dev/null
+++ b/src/common/inc/ant_utils.h
@@ -0,0 +1,139 @@
+/*
+ * ANT Stack
+ *
+ * Copyright 2009 Dynastream Innovations
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/******************************************************************************\
+*
+* FILE NAME: ANT_utils.h
+*
+* BRIEF:
+* This file defines utility functions
+*
+*
+\******************************************************************************/
+#ifndef __ANT_UTILS_H
+#define __ANT_UTILS_H
+
+#include "ant_types.h"
+
+/****************************************************************************
+ *
+ * Type Definitions
+ *
+ ****************************************************************************/
+
+
+
+/*------------------------------------------------------------------------------
+ * ANT_xxx()
+ *
+ * Brief:
+ * xxx
+ *
+ * Description:
+ * xxx
+ *
+ * Type:
+ * Syxxx/As
+ *
+ * Parameters:
+ * xxx [in] -
+ *
+ * Returns:
+ * xxx
+ */
+ANT_U16 ANT_UTILS_BEtoHost16(ANT_U8 * num);
+/*------------------------------------------------------------------------------
+ * ANT_xxx()
+ *
+ * Brief:
+ * xxx
+ *
+ * Description:
+ * xxx
+ *
+ * Type:
+ * Syxxx/As
+ *
+ * Parameters:
+ * xxx [in] -
+ *
+ * Returns:
+ * xxx
+ */
+ANT_U16 ANT_UTILS_LEtoHost16(ANT_U8 * num);
+/*------------------------------------------------------------------------------
+ * ANT_xxx()
+ *
+ * Brief:
+ * xxx
+ *
+ * Description:
+ * xxx
+ *
+ * Type:
+ * Syxxx/As
+ *
+ * Parameters:
+ * xxx [in] -
+ *
+ * Returns:
+ * xxx
+ */
+void ANT_UTILS_StoreBE16(ANT_U8 *buff, ANT_U16 be_value) ;
+/*------------------------------------------------------------------------------
+ * ANT_xxx()
+ *
+ * Brief:
+ * xxx
+ *
+ * Description:
+ * xxx
+ *
+ * Type:
+ * Syxxx/As
+ *
+ * Parameters:
+ * xxx [in] -
+ *
+ * Returns:
+ * xxx
+ */
+void ANT_UTILS_StoreLE16(ANT_U8 *buff, ANT_U16 le_value) ;
+/*------------------------------------------------------------------------------
+ * ANT_xxx()
+ *
+ * Brief:
+ * xxx
+ *
+ * Description:
+ * xxx
+ *
+ * Type:
+ * Syxxx/As
+ *
+ * Parameters:
+ * xxx [in] -
+ *
+ * Returns:
+ * xxx
+ */
+void ANT_UTILS_StoreBE32(ANT_U8 *buff, ANT_U32 be_value) ;
+
+
+
+#endif /* __ANT_UTILS_H */
+
diff --git a/src/common/inc/ant_version.h b/src/common/inc/ant_version.h
new file mode 100644
index 0000000..f6effae
--- /dev/null
+++ b/src/common/inc/ant_version.h
@@ -0,0 +1,27 @@
+/*
+ * ANT Stack
+ *
+ * Copyright 2011 Dynastream Innovations
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __ANT_VERSION_H
+#define __ANT_VERSION_H
+
+#define LIBANT_STACK_MAJOR "1"
+#define LIBANT_STACK_MINOR "4"
+#define LIBANT_STACK_INCRE "0"
+
+#endif // __ANT_VERSION_H
+