Merge "Revert "Implementing support for NFC observe mode, polling loop fingerprints"" into main
diff --git a/1.2/Android.bp b/1.2/Android.bp
index a27f2bf..b23536e 100644
--- a/1.2/Android.bp
+++ b/1.2/Android.bp
@@ -45,4 +45,8 @@
         "android.hardware.nfc@1.2",
         "libhidlbase",
     ],
+
+    arch: {
+        arm: { cflags: ["-DST_LIB_32"] },
+    }
 }
diff --git a/1.2/StNfcService.cpp b/1.2/StNfcService.cpp
index 69f3dc1..efa38bf 100644
--- a/1.2/StNfcService.cpp
+++ b/1.2/StNfcService.cpp
@@ -25,7 +25,11 @@
 #include <hidl/LegacySupport.h>
 #include "Nfc.h"
 
+#if defined(ST_LIB_32)
+#define VENDOR_LIB_PATH "/vendor/lib/"
+#else
 #define VENDOR_LIB_PATH "/vendor/lib64/"
+#endif
 #define VENDOR_LIB_EXT ".so"
 
 // Generated HIDL files
diff --git a/1.2/hal_st21nfc.cc b/1.2/hal_st21nfc.cc
index 71cb7aa..a9e71f7 100644
--- a/1.2/hal_st21nfc.cc
+++ b/1.2/hal_st21nfc.cc
@@ -32,7 +32,11 @@
 #include "halcore.h"
 #include "st21nfc_dev.h"
 
+#if defined(ST_LIB_32)
+#define VENDOR_LIB_PATH "/vendor/lib/"
+#else
 #define VENDOR_LIB_PATH "/vendor/lib64/"
+#endif
 #define VENDOR_LIB_EXT ".so"
 
 extern void HalCoreCallback(void* context, uint32_t event, const void* d,
diff --git a/OWNERS b/OWNERS
index 45e7662..f46dccd 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,4 +1,2 @@
-zachoverflow@google.com
-jackcwyu@google.com
-georgekgchang@google.com
-alisher@google.com
+# Bug component: 48448
+include platform/packages/apps/Nfc:/OWNERS
\ No newline at end of file
diff --git a/aidl/Android.bp b/aidl/Android.bp
index f168a58..dc0c4f9 100644
--- a/aidl/Android.bp
+++ b/aidl/Android.bp
@@ -30,4 +30,7 @@
         "Nfc.cpp",
         "hal_st21nfc.cc",
     ],
+    arch: {
+        arm: { cflags: ["-DST_LIB_32"] },
+    }
 }
diff --git a/aidl/hal_st21nfc.cc b/aidl/hal_st21nfc.cc
index 5aa5f5e..70b9371 100644
--- a/aidl/hal_st21nfc.cc
+++ b/aidl/hal_st21nfc.cc
@@ -31,7 +31,11 @@
 #include "halcore.h"
 #include "st21nfc_dev.h"
 
+#if defined(ST_LIB_32)
+#define VENDOR_LIB_PATH "/vendor/lib/"
+#else
 #define VENDOR_LIB_PATH "/vendor/lib64/"
+#endif
 #define VENDOR_LIB_EXT ".so"
 
 bool dbg_logging = false;
@@ -62,6 +66,8 @@
 
 extern void hal_wrapper_send_config();
 extern void hal_wrapper_factoryReset();
+extern void hal_wrapper_set_observer_mode(uint8_t enable);
+extern void hal_wrapper_get_observer_mode();
 
 /* Make sure to always post nfc_stack_callback_t in a separate thread.
 This prevents a possible deadlock in upper layer on some sequences.
@@ -317,7 +323,32 @@
     (void)pthread_mutex_unlock(&hal_mtx);
     return ret;
   }
-  if (!HalSendDownstream(dev.hHAL, p_data, data_len)) {
+
+  uint8_t NCI_ANDROID_PASSIVE_OBSERVER_PREFIX[] = {0x2f, 0x0c, 0x02, 0x02};
+  uint8_t NCI_QUERY_ANDROID_PASSIVE_OBSERVER_PREFIX[] = {0x2f, 0x0c, 0x01, 0x4};
+  if (data_len == 4 && !memcmp(p_data, NCI_QUERY_ANDROID_PASSIVE_OBSERVER_PREFIX,
+                               sizeof(NCI_QUERY_ANDROID_PASSIVE_OBSERVER_PREFIX))) {
+    uint8_t CORE_GET_CONFIG_OBSERVER[5] = {0x20, 0x03, 0x02, 0x01, 0xa3};
+    hal_wrapper_get_observer_mode();
+    if (!HalSendDownstream(dev.hHAL, CORE_GET_CONFIG_OBSERVER, 5)) {
+      STLOG_HAL_E("HAL st21nfc %s  SendDownstream failed", __func__);
+      (void)pthread_mutex_unlock(&hal_mtx);
+      return 0;
+    }
+  }
+
+  else if (data_len == 5 && !memcmp(p_data, NCI_ANDROID_PASSIVE_OBSERVER_PREFIX,
+                               sizeof(NCI_ANDROID_PASSIVE_OBSERVER_PREFIX))) {
+    uint8_t CORE_SET_CONFIG_OBSERVER[7] = {0x20, 0x02, 0x04, 0x01,
+                                           0xa3, 0x01, p_data[4]};
+
+    hal_wrapper_set_observer_mode(p_data[4]);
+    if (!HalSendDownstream(dev.hHAL, CORE_SET_CONFIG_OBSERVER, 7)) {
+      STLOG_HAL_E("HAL st21nfc %s  SendDownstream failed", __func__);
+      (void)pthread_mutex_unlock(&hal_mtx);
+      return 0;
+    }
+  } else if (!HalSendDownstream(dev.hHAL, p_data, data_len)) {
     STLOG_HAL_E("HAL st21nfc %s  SendDownstream failed", __func__);
     (void)pthread_mutex_unlock(&hal_mtx);
     return 0;
diff --git a/aidl/main.cpp b/aidl/main.cpp
index a9d7275..4529543 100644
--- a/aidl/main.cpp
+++ b/aidl/main.cpp
@@ -22,7 +22,11 @@
 
 #include "Nfc.h"
 
+#if defined(ST_LIB_32)
+#define VENDOR_LIB_PATH "/vendor/lib/"
+#else
 #define VENDOR_LIB_PATH "/vendor/lib64/"
+#endif
 #define VENDOR_LIB_EXT ".so"
 
 using ::aidl::android::hardware::nfc::Nfc;
diff --git a/st21nfc/Android.bp b/st21nfc/Android.bp
index 6358c4a..8a3f316 100644
--- a/st21nfc/Android.bp
+++ b/st21nfc/Android.bp
@@ -38,6 +38,7 @@
         "adaptation/i2clayer.cc",
         "hal/halcore.cc",
         "hal_wrapper.cc",
+        "hal/hal_fwlog.cc",
 	"hal/hal_fd.cc",
     ],
 
diff --git a/st21nfc/hal/hal_fwlog.cc b/st21nfc/hal/hal_fwlog.cc
new file mode 100644
index 0000000..eaddb9d
--- /dev/null
+++ b/st21nfc/hal/hal_fwlog.cc
@@ -0,0 +1,184 @@
+/******************************************************************************
+ *
+ *  Copyright (C) 2023 ST Microelectronics S.A.
+ *
+ *  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.
+ *
+ *
+ ******************************************************************************/
+#define LOG_TAG "NfcHalFwLog"
+
+#include "hal_fwlog.h"
+#include <cutils/properties.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <hardware/nfc.h>
+#include <string.h>
+#include "android_logmsg.h"
+#include "halcore.h"
+
+extern void DispHal(const char* title, const void* data, size_t length);
+
+uint8_t handlePollingLoopData(uint8_t format, uint8_t* tlvBuffer,
+                              uint16_t data_len, uint8_t** NewTlv) {
+  uint8_t value_len = 0;
+  uint8_t flag= 0;
+
+  uint32_t timestamp = (tlvBuffer[data_len - 4] << 24) |
+                       (tlvBuffer[data_len - 3] << 16) |
+                       (tlvBuffer[data_len - 2] << 8) | tlvBuffer[data_len - 1];
+
+  uint32_t ts = 0;
+
+  if ((format & 0x30) == 0x30) {
+    // ST54L: 3.95us unit
+    ts = (uint32_t)(((timestamp * 1024) / 259) + 0.5);
+  } else {
+    // ST54J/K: 4.57us unit
+    ts = (uint32_t)(((timestamp * 128) / 28) + 0.5);
+  }
+
+  int t = tlvBuffer[0];
+
+  switch (t) {
+    case T_fieldOn:
+    case T_fieldOff:
+      STLOG_HAL_D("%s - FieldOn/Off", __func__);
+      *NewTlv = (uint8_t*)malloc(8 * sizeof(uint8_t));
+      value_len = 0x06;
+      (*NewTlv)[0] = TYPE_REMOTE_FIELD;
+      (*NewTlv)[1] = flag;
+      (*NewTlv)[2] = value_len;
+      (*NewTlv)[3] = (ts >> 24) & 0xFF;
+      (*NewTlv)[4] = (ts >> 16) & 0xFF;
+      (*NewTlv)[5] = (ts >> 8) & 0xFF;
+      (*NewTlv)[6] = ts & 0xFF;
+      (*NewTlv)[7] = 0xFF;
+      (*NewTlv)[8] = (t == T_fieldOn) ? 0x1 : 0x0;
+      break;
+    case T_CERxError:
+    case T_CERx: {
+      STLOG_HAL_D("%s - T_CERx", __func__);
+      int tlv_size = tlvBuffer[1]-2;
+      if (tlv_size < 9) {
+      tlv_size = 8;
+      }
+      value_len = tlv_size- 3;
+      *NewTlv = (uint8_t*)malloc(tlv_size * sizeof(uint8_t));
+      uint8_t gain;
+      uint8_t type;
+      int length_value = tlv_size - 8;
+      gain = (tlvBuffer[3] & 0xF0) >> 4;
+
+      switch (tlvBuffer[2] & 0xF) {
+        case 0x1:
+           flag |= 0x01;
+           type = TYPE_A;
+           break;
+        case 0x2:
+        case 0x3:
+        case 0x4:
+        case 0x5:
+        case 0x6:
+        case 0xB:
+        case 0xD:
+            type = TYPE_A;
+          break;
+        case 0x7:
+        case 0xC:
+            type = TYPE_B;
+          break;
+        case 0x8:
+        case 0x9:
+          type = TYPE_F;
+          break;
+        case 0xA:
+          type = TYPE_V;
+          break;
+        default:
+          type = TYPE_UNKNOWN;
+          break;
+      }
+      if (tlvBuffer[5] != 0) {
+        // if error flag is set, consider the frame as unknown.
+        type = TYPE_UNKNOWN;
+      }
+      (*NewTlv)[0] = type;
+      (*NewTlv)[1] = flag;
+      (*NewTlv)[2] = value_len;
+      (*NewTlv)[3] = (ts >> 24) & 0xFF;
+      (*NewTlv)[4] = (ts >> 16) & 0xFF;
+      (*NewTlv)[5] = (ts >> 8) & 0xFF;
+      (*NewTlv)[6] = ts & 0xFF;
+      (*NewTlv)[7] = gain;
+      if (tlv_size > 8) {
+      memcpy(*NewTlv + 8, tlvBuffer + 8, length_value);
+    }
+    } break;
+    default:
+      break;
+  }
+  if (value_len)
+    return value_len + 3;
+  else
+    return 0;
+}
+
+int notifyPollingLoopFrames(uint8_t* p_data, uint16_t data_len,
+                            uint8_t* bufferToSend) {
+  int current_tlv_length = 0;
+  int tlv_len = 0;
+  int ntf_len = 4;
+  uint8_t* tlvFormatted = NULL;
+  uint8_t* ObserverNtf = NULL;
+  uint8_t* PreviousObserverNtf;
+  uint8_t NCI_ANDROID_PASSIVE_OBSERVER_HEADER[4] = {0x6f, 0xc, 0x01, 0x3};
+
+  for (int current_tlv_pos = 6;
+       current_tlv_pos + p_data[current_tlv_pos + 1] + 2 <= data_len;
+       current_tlv_pos += current_tlv_length) {
+    current_tlv_length = p_data[current_tlv_pos + 1] + 2;
+    uint8_t* tlvBuffer = p_data + current_tlv_pos;
+
+    tlv_len = handlePollingLoopData(p_data[3], tlvBuffer, current_tlv_length,
+                                    &tlvFormatted);
+
+    if (tlvFormatted != NULL) {
+
+      if (ObserverNtf == NULL) {
+        ObserverNtf = (uint8_t*)malloc(4 * sizeof(uint8_t));
+        memcpy(ObserverNtf, NCI_ANDROID_PASSIVE_OBSERVER_HEADER, 4);
+      }
+
+      PreviousObserverNtf = ObserverNtf;
+
+      ObserverNtf = (uint8_t*)malloc((ntf_len + tlv_len) * sizeof(uint8_t));
+      memcpy(ObserverNtf, PreviousObserverNtf, ntf_len);
+      memcpy(ObserverNtf + ntf_len, tlvFormatted, tlv_len);
+      ObserverNtf[2] = ntf_len + tlv_len - 3;
+      ntf_len += tlv_len;
+      free(tlvFormatted);
+      tlvFormatted = NULL;
+      free(PreviousObserverNtf);
+    }
+  }
+  if (ObserverNtf != nullptr) {
+    if (ntf_len <= 258) {
+      memcpy(bufferToSend, ObserverNtf, ntf_len);
+    }
+    free(ObserverNtf);
+    return ntf_len;
+  } else {
+    return 0;
+  }
+}
diff --git a/st21nfc/hal/hal_fwlog.h b/st21nfc/hal/hal_fwlog.h
new file mode 100644
index 0000000..bb5c1b5
--- /dev/null
+++ b/st21nfc/hal/hal_fwlog.h
@@ -0,0 +1,53 @@
+/** ----------------------------------------------------------------------
+ *
+ * Copyright (C) 2023 ST Microelectronics S.A.
+ *
+ * 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 HAL_FWLOG_H_
+#define HAL_FWLOG_H_
+
+#include "halcore.h"
+
+    static const int T_CERx = 0x09;
+static const int T_fieldOn = 0x10;
+static const int T_fieldOff = 0x11;
+static const int T_CERxError = 0x19;
+
+static const uint8_t PROPRIETARY_GID = 0x6F;
+static const uint8_t ANDROID_OID = 0x0C;
+static const uint8_t TYPE_REMOTE_FIELD = 0x00;
+static const uint8_t TYPE_A = 0x01;
+static const uint8_t TYPE_B = 0x02;
+static const uint8_t TYPE_F = 0x03;
+static const uint8_t TYPE_V = 0x04;
+
+static const uint8_t TYPE_UNKNOWN = 0x07;
+
+typedef union timestamp_bytes {
+  uint8_t ts1;
+  uint8_t ts2;
+  uint8_t ts3;
+  uint8_t ts4;
+} timestamp_bytes;
+
+int notifyPollingLoopFrames(uint8_t *p_data, uint16_t data_len,
+                            uint8_t *bufferToSend);
+uint8_t handlePollingLoopData(uint8_t *tlvBuffer, uint16_t data_len,
+                              uint8_t **NewTlv);
+
+#endif
diff --git a/st21nfc/hal_wrapper.cc b/st21nfc/hal_wrapper.cc
index ae94577..43fe06e 100644
--- a/st21nfc/hal_wrapper.cc
+++ b/st21nfc/hal_wrapper.cc
@@ -26,6 +26,7 @@
 
 #include "android_logmsg.h"
 #include "hal_fd.h"
+#include "hal_fwlog.h"
 #include "halcore.h"
 #include "st21nfc_dev.h"
 
@@ -62,6 +63,7 @@
 static uint8_t nciPropEnableFwDbgTraces[256];
 static uint8_t nciPropGetFwDbgTracesConfig[] = {0x2F, 0x02, 0x05, 0x03,
                                                 0x00, 0x14, 0x01, 0x00};
+static uint8_t nciAndroidPassiveObserver[256];
 static bool isDebuggable;
 
 bool mReadFwConfigDone = false;
@@ -75,6 +77,8 @@
 unsigned long hal_field_timer = 0;
 
 static bool sEnableFwLog = false;
+uint8_t mObserverMode = 0;
+bool mObserverRsp = false;
 
 void wait_ready() {
   pthread_mutex_lock(&mutex);
@@ -107,6 +111,9 @@
   mReadFwConfigDone = false;
   mError_count = 0;
 
+  mObserverMode = 0;
+  mObserverRsp = false;
+
   mHalWrapperCallback = p_cback;
   mHalWrapperDataCallback = p_data_cback;
 
@@ -134,7 +141,7 @@
   mHalWrapperState = HAL_WRAPPER_STATE_CLOSING;
   // Send PROP_NFC_MODE_SET_CMD
   if (!HalSendDownstreamTimer(mHalHandle, propNfcModeSetCmdQb,
-                              sizeof(propNfcModeSetCmdQb), 40)) {
+                              sizeof(propNfcModeSetCmdQb), 100)) {
     STLOG_HAL_E("NFC-NCI HAL: %s  HalSendDownstreamTimer failed", __func__);
     return -1;
   }
@@ -161,10 +168,10 @@
       STLOG_HAL_V("%s - Enter", __func__);
       set_ready(0);
 
-      if (!HalSendDownstreamTimer(mHalHandle, ConfigBuffer, retlen, 500)) {
+      mHalWrapperState = HAL_WRAPPER_STATE_PROP_CONFIG;
+      if (!HalSendDownstreamTimer(mHalHandle, ConfigBuffer, retlen, 1000)) {
         STLOG_HAL_E("NFC-NCI HAL: %s  SendDownstream failed", __func__);
       }
-      mHalWrapperState = HAL_WRAPPER_STATE_PROP_CONFIG;
       wait_ready();
     }
     free(ConfigBuffer);
@@ -176,11 +183,11 @@
   STLOG_HAL_V("%s - Enter", __func__);
   set_ready(0);
 
+  mReadFwConfigDone = true;
   if (!HalSendDownstreamTimer(mHalHandle, nciPropGetFwDbgTracesConfig,
-                              sizeof(nciPropGetFwDbgTracesConfig), 500)) {
+                              sizeof(nciPropGetFwDbgTracesConfig), 1000)) {
     STLOG_HAL_E("%s - SendDownstream failed", __func__);
   }
-  mReadFwConfigDone = true;
   wait_ready();
 }
 
@@ -195,6 +202,13 @@
   STLOG_HAL_V("%s - mfactoryReset = %d", __func__, mfactoryReset);
 }
 
+void hal_wrapper_set_observer_mode(uint8_t enable) {
+  mObserverMode = enable;
+  mObserverRsp = true;
+}
+void hal_wrapper_get_observer_mode() {
+  mObserverRsp = true;
+}
 void hal_wrapper_update_complete() {
   STLOG_HAL_V("%s ", __func__);
   mHalWrapperCallback(HAL_NFC_OPEN_CPLT_EVT, HAL_NFC_STATUS_OK);
@@ -207,8 +221,18 @@
   unsigned long num = 0;
   unsigned long swp_log = 0;
   unsigned long rf_log = 0;
+  int mObserverLength = 0;
   int nciPropEnableFwDbgTraces_size = sizeof(nciPropEnableFwDbgTraces);
 
+  if (mObserverMode && (p_data[0] == 0x6f) && (p_data[1] == 0x02)) {
+    // Firmware logs must not be formatted before sending to upper layer.
+    if ((mObserverLength = notifyPollingLoopFrames(
+             p_data, data_len, nciAndroidPassiveObserver)) > 0) {
+      DispHal("RX DATA", (nciAndroidPassiveObserver), mObserverLength);
+      mHalWrapperDataCallback(mObserverLength, nciAndroidPassiveObserver);
+    }
+  }
+
   switch (mHalWrapperState) {
     case HAL_WRAPPER_STATE_CLOSED:  // 0
       STLOG_HAL_V("%s - mHalWrapperState = HAL_WRAPPER_STATE_CLOSED", __func__);
@@ -246,6 +270,7 @@
             mHalWrapperCallback(HAL_NFC_OPEN_CPLT_EVT, HAL_NFC_STATUS_FAILED);
             I2cCloseLayer();
           } else {
+            mHalWrapperState = HAL_WRAPPER_STATE_UPDATE;
             if (((p_data[3] == 0x01) && (p_data[8] == HW_ST54L)) ||
                 ((p_data[2] == 0x41) && (p_data[3] == 0xA2))) {  // ST54L
               FwUpdateHandler(mHalHandle, data_len, p_data);
@@ -258,7 +283,6 @@
                 STLOG_HAL_E("%s - SendDownstream failed", __func__);
               }
             }
-            mHalWrapperState = HAL_WRAPPER_STATE_UPDATE;
           }
         } else if (mFwUpdateTaskMask == 0 || mRetryFwDwl == 0) {
           STLOG_HAL_V("%s - Proceeding with normal startup", __func__);
@@ -312,12 +336,12 @@
       } else if ((p_data[0] == 0x60) && (p_data[1] == 0x06)) {
         STLOG_HAL_V("%s - Sending PROP_NFC_MODE_SET_CMD", __func__);
         // Send PROP_NFC_MODE_SET_CMD(ON)
+        mHalWrapperState = HAL_WRAPPER_STATE_NFC_ENABLE_ON;
         if (!HalSendDownstreamTimer(mHalHandle, propNfcModeSetCmdOn,
-                                    sizeof(propNfcModeSetCmdOn), 100)) {
+                                    sizeof(propNfcModeSetCmdOn), 500)) {
           STLOG_HAL_E("NFC-NCI HAL: %s  HalSendDownstreamTimer failed",
                       __func__);
         }
-        mHalWrapperState = HAL_WRAPPER_STATE_NFC_ENABLE_ON;
       } else {
         mHalWrapperDataCallback(data_len, p_data);
       }
@@ -488,6 +512,32 @@
 
     case HAL_WRAPPER_STATE_READY:  // 5
       STLOG_HAL_V("%s - mHalWrapperState = HAL_WRAPPER_STATE_READY", __func__);
+      if (mObserverRsp) {
+        if ((p_data[0] == 0x40) && (p_data[1] == 0x02)) {
+          uint8_t rsp_status = p_data[3];
+          mObserverRsp = false;
+          p_data[0] = 0x4f;
+          p_data[1] = 0x0c;
+          p_data[2] = 0x02;
+          p_data[3] = 0x02;
+          p_data[4] = rsp_status;
+          data_len = 0x5;
+        } else if ((p_data[0] == 0x40) && (p_data[1] == 0x03) && (data_len > 7)) {
+            uint8_t rsp_status = p_data[3];
+            mObserverRsp = false;
+            if (p_data[7] != mObserverMode) {
+                STLOG_HAL_E("mObserverMode got out of sync");
+                mObserverMode = p_data[7];
+            }
+            p_data[0] = 0x4f;
+            p_data[1] = 0x0c;
+            p_data[2] = 0x03;
+            p_data[3] = 0x04;
+            p_data[4] = rsp_status;
+            p_data[5] =  p_data[7];
+            data_len = 0x6;
+          }
+      }
       if (!((p_data[0] == 0x60) && (p_data[3] == 0xa0))) {
         if (mHciCreditLent && (p_data[0] == 0x60) && (p_data[1] == 0x06)) {
           if (p_data[4] == 0x01) {  // HCI connection
@@ -521,8 +571,8 @@
           (void)pthread_mutex_lock(&mutex_activerw);
           // start timer
           mTimerStarted = true;
-          HalSendDownstreamTimer(mHalHandle, 5000);
           mIsActiveRW = true;
+          HalSendDownstreamTimer(mHalHandle, 5000);
           (void)pthread_mutex_unlock(&mutex_activerw);
         } else if ((p_data[0] == 0x6f) && (p_data[1] == 0x06)) {
           (void)pthread_mutex_lock(&mutex_activerw);