Version 1.9.2
- Bug fix from qualcomm for HIDL interface.
diff --git a/src/common/inc/ant_version.h b/src/common/inc/ant_version.h
index 74184b4..fea1d60 100644
--- a/src/common/inc/ant_version.h
+++ b/src/common/inc/ant_version.h
@@ -21,7 +21,7 @@
#define LIBANT_STACK_MAJOR "1"
#define LIBANT_STACK_MINOR "9"
-#define LIBANT_STACK_INCRE "1"
+#define LIBANT_STACK_INCRE "2"
#endif // __ANT_VERSION_H
diff --git a/src/qcomm-hidl/AntHidlClient.cpp b/src/qcomm-hidl/AntHidlClient.cpp
index a411af3..1e90cfc 100644
--- a/src/qcomm-hidl/AntHidlClient.cpp
+++ b/src/qcomm-hidl/AntHidlClient.cpp
@@ -66,29 +66,30 @@
android::sp<IAntHci> anthci;
typedef std::unique_lock<std::mutex> Lock;
-
+#define POLL_TIMEOUT_MS 100
struct ant_hci_t {
public:
std::condition_variable rx_cond;
std::condition_variable on_cond;
+ std::condition_variable data_cond;
std::mutex on_mtx;
std::mutex rx_mtx;
+ std::mutex data_mtx;
ant_power_state_t state;
- bool rx_processing;
+ volatile bool rx_processing;
};
static struct ant_hci_t ant_hci;
Return<void> initialization_complete(bool is_hci_initialize)
{
- ALOGI("%s: is_hci_initialize: %d", __func__, is_hci_initialize);
+ ALOGI("%s start ", __func__ );
Lock lk(ant_hci.on_mtx);
if (is_hci_initialize)
{
ant_hci.state = ANT_RADIO_ENABLED;
- ALOGI("%s: is_hci_initialize: %d", __func__, is_hci_initialize);
}
else
{
@@ -121,11 +122,10 @@
Return<void> antControlReceived(const hidl_vec<uint8_t>& event)
{
- ALOGI("%s: Start ", __func__);
- Lock lk(ant_hci.rx_mtx);
-
+ ALOGV("%s:start ", __func__);
// Make sure we don't overwrite a message still processing.
- while(ant_hci.rx_processing)
+ Lock lk(ant_hci.rx_mtx);
+ if(ant_hci.rx_processing && ant_hci.state == ANT_RADIO_ENABLED)
{
ant_hci.rx_cond.wait(lk);
}
@@ -133,18 +133,19 @@
memcpy(&aucRxBuffer[0][0], event.data(), event.size());
iRxBufferLength[0] = event.size();
- ant_hci.rx_cond.notify_all();
- ALOGI("%s: End", __func__);
+ std::unique_lock< std::mutex> lock(ant_hci.data_mtx);
+ ALOGD("%s: notify data avail", __func__);
+ ant_hci.data_cond.notify_all();
+ ALOGV("%s: End", __func__);
return Void();
}
Return<void> antDataReceived(const hidl_vec<uint8_t>& event)
{
- ALOGI("%s: ", __func__);
- Lock lk(ant_hci.rx_mtx);
-
+ ALOGV("%s:start ", __func__);
// Make sure we don't overwrite a message still processing.
- while(ant_hci.rx_processing)
+ Lock lk(ant_hci.rx_mtx);
+ if(ant_hci.rx_processing && ant_hci.state == ANT_RADIO_ENABLED)
{
ant_hci.rx_cond.wait(lk);
}
@@ -152,8 +153,10 @@
memcpy(&aucRxBuffer[0][0], event.data(), event.size());
iRxBufferLength[0] = event.size();
- ant_hci.rx_cond.notify_all();
- ALOGI("%s: exit", __func__);
+ std::unique_lock< std::mutex> lock(ant_hci.data_mtx);
+ ALOGD("%s: notify data avail", __func__);
+ ant_hci.data_cond.notify_all();
+ ALOGV("%s: exit", __func__);
return Void();
}
};
@@ -170,7 +173,7 @@
ant_hci.rx_processing = false;
android::sp<IAntHciCallbacks> callbacks = new AntHciCallbacks();
anthci->initialize(callbacks);
- ALOGI("%s: exit", __func__);
+ ALOGV("%s: exit", __func__);
return true;
} else {
return false;
@@ -182,11 +185,13 @@
if(anthci != nullptr)
{
+ std::unique_lock< std::mutex> lock(ant_hci.data_mtx);
+ ant_hci.data_cond.notify_all();
anthci->close();
}
+ ant_hci.state = ANT_RADIO_DISABLED;
ant_rx_clear();
anthci =nullptr;
- ant_hci.state = ANT_RADIO_DISABLED;
ALOGI("%s: exit", __func__);
}
@@ -221,18 +226,22 @@
ANTStatus ant_rx_check()
{
- ALOGI("%s: start", __func__);
- Lock lk(ant_hci.rx_mtx);
- ant_hci.rx_cond.wait(lk);
- ALOGI("%s: exit", __func__);
+ ALOGV("%s: start", __func__);
if (ant_hci.rx_processing)
{
return ANT_STATUS_SUCCESS;
}
- else
+ while (ant_hci.rx_processing == 0)
{
- return ANT_STATUS_NO_VALUE_AVAILABLE;
+ std::unique_lock< std::mutex> lock(ant_hci.data_mtx);
+ ant_hci.data_cond.wait_for(lock,std::chrono::milliseconds(POLL_TIMEOUT_MS));
+ if (ant_hci.state != ANT_RADIO_ENABLED)
+ {
+ return ANT_STATUS_NO_VALUE_AVAILABLE;
+ }
}
+ ALOGV("%s: exit rx_processing =%d", __func__,ant_hci.rx_processing);
+ return ANT_STATUS_SUCCESS;
}
void ant_rx_clear()
diff --git a/src/qcomm-hidl/ant_rx_chardev.c b/src/qcomm-hidl/ant_rx_chardev.c
index 153660c..3e102d2 100644
--- a/src/qcomm-hidl/ant_rx_chardev.c
+++ b/src/qcomm-hidl/ant_rx_chardev.c
@@ -105,6 +105,14 @@
{
readChannelMsg(0, &stRxThreadInfo->astChannels[0]);
}
+ else
+ {
+ ANT_WARN("rx check failed , cleaning up");
+ break;
+ }
+ // Need to indicate that we are done handling the rx buffer and it can be
+ // overwritten again.
+ ant_rx_clear();
}
/* disable ANT radio if not already disabling */
@@ -338,9 +346,6 @@
}
out:
- // Need to indicate that we are done handling the rx buffer and it can be
- // overwritten again.
- ant_rx_clear();
ANT_FUNC_END();
return iRet;
}