Renamed most C files to C++: *.c to *.cc

Also:
 - Fixed C++ related compilation errors.
 - Added missing 'extern "C"' guards in some of the header files.
 - Added missing LOCAL_CPP_EXTENSION to Android.mk files.
 - Added-back btif/src/btif_mce.cc and bta/mce/bta_mce_* to
   btif/Android.mk and bta/Android.mk respectively.
 - Fixed the alphabetical ordering of the *.cc files in some
   of the Android.mk files.
 - Added missing Copyright header to "osi/include/list.h"
 - Updated "osi/src/wakelock.cc" to use C++ std::string
   instead of dynamic allocation of C-style strings.

Test: code compilation, unit tests, and A2DP streaming
Change-Id: Ia2f7215ed9df32775c701b68fc86b09875b942c7
diff --git a/bta/Android.mk b/bta/Android.mk
index 7f4143b..88b9a57 100644
--- a/bta/Android.mk
+++ b/bta/Android.mk
@@ -27,51 +27,17 @@
 LOCAL_CPP_EXTENSION := .cc
 
 LOCAL_SRC_FILES:= \
-    ./dm/bta_dm_ci.cc \
-    ./dm/bta_dm_act.cc \
-    ./dm/bta_dm_pm.cc \
-    ./dm/bta_dm_main.cc \
-    ./dm/bta_dm_cfg.cc \
-    ./dm/bta_dm_api.cc \
-    ./dm/bta_dm_sco.cc \
-    ./closure/bta_closure.cc \
-    ./gatt/bta_gattc_api.cc \
-    ./gatt/bta_gatts_act.cc \
-    ./gatt/bta_gatts_main.cc \
-    ./gatt/bta_gattc_utils.cc \
-    ./gatt/bta_gatts_api.cc \
-    ./gatt/bta_gattc_main.cc \
-    ./gatt/bta_gattc_act.cc \
-    ./gatt/bta_gattc_cache.cc \
-    ./gatt/bta_gatts_utils.cc \
-    ./ag/bta_ag_sdp.c \
-    ./ag/bta_ag_sco.c \
-    ./ag/bta_ag_cfg.c \
-    ./ag/bta_ag_main.c \
-    ./ag/bta_ag_api.c \
-    ./ag/bta_ag_rfc.c \
-    ./ag/bta_ag_act.c \
-    ./ag/bta_ag_cmd.c \
-    ./ag/bta_ag_ci.c \
-    ./ag/bta_ag_at.c \
-    ./hf_client/bta_hf_client_act.c \
-    ./hf_client/bta_hf_client_api.c \
-    ./hf_client/bta_hf_client_main.c \
-    ./hf_client/bta_hf_client_rfc.c \
-    ./hf_client/bta_hf_client_at.c \
-    ./hf_client/bta_hf_client_sdp.c \
-    ./hf_client/bta_hf_client_sco.c \
-    ./hf_client/bta_hf_client_cmd.c \
-    ./hh/bta_hh_cfg.cc \
-    ./hh/bta_hh_act.cc \
-    ./hh/bta_hh_api.cc \
-    ./hh/bta_hh_le.cc \
-    ./hh/bta_hh_utils.cc \
-    ./hh/bta_hh_main.cc \
-    ./pan/bta_pan_main.c \
-    ./pan/bta_pan_ci.c \
-    ./pan/bta_pan_act.c \
-    ./pan/bta_pan_api.c \
+    ./ag/bta_ag_act.cc \
+    ./ag/bta_ag_api.cc \
+    ./ag/bta_ag_at.cc \
+    ./ag/bta_ag_cfg.cc \
+    ./ag/bta_ag_ci.cc \
+    ./ag/bta_ag_cmd.cc \
+    ./ag/bta_ag_main.cc \
+    ./ag/bta_ag_rfc.cc \
+    ./ag/bta_ag_sco.cc \
+    ./ag/bta_ag_sdp.cc \
+    ./ar/bta_ar.cc \
     ./av/bta_av_aact.cc \
     ./av/bta_av_act.cc \
     ./av/bta_av_api.cc \
@@ -79,24 +45,62 @@
     ./av/bta_av_ci.cc \
     ./av/bta_av_main.cc \
     ./av/bta_av_ssm.cc \
-    ./ar/bta_ar.c \
-    ./hl/bta_hl_act.c \
-    ./hl/bta_hl_api.c \
-    ./hl/bta_hl_main.c \
-    ./hl/bta_hl_utils.c \
-    ./hl/bta_hl_sdp.c \
-    ./hl/bta_hl_ci.c \
-    ./sdp/bta_sdp_api.c \
-    ./sdp/bta_sdp_act.c \
-    ./sdp/bta_sdp.c \
-    ./sdp/bta_sdp_cfg.c \
-    ./sys/bta_sys_main.c \
-    ./sys/bta_sys_conn.c \
-    ./sys/utl.c \
-    ./jv/bta_jv_act.c \
-    ./jv/bta_jv_cfg.c \
-    ./jv/bta_jv_main.c \
-    ./jv/bta_jv_api.c
+    ./closure/bta_closure.cc \
+    ./dm/bta_dm_act.cc \
+    ./dm/bta_dm_api.cc \
+    ./dm/bta_dm_cfg.cc \
+    ./dm/bta_dm_ci.cc \
+    ./dm/bta_dm_main.cc \
+    ./dm/bta_dm_pm.cc \
+    ./dm/bta_dm_sco.cc \
+    ./gatt/bta_gattc_act.cc \
+    ./gatt/bta_gattc_api.cc \
+    ./gatt/bta_gattc_cache.cc \
+    ./gatt/bta_gattc_main.cc \
+    ./gatt/bta_gattc_utils.cc \
+    ./gatt/bta_gatts_act.cc \
+    ./gatt/bta_gatts_api.cc \
+    ./gatt/bta_gatts_main.cc \
+    ./gatt/bta_gatts_utils.cc \
+    ./hf_client/bta_hf_client_act.cc \
+    ./hf_client/bta_hf_client_api.cc \
+    ./hf_client/bta_hf_client_at.cc \
+    ./hf_client/bta_hf_client_cmd.cc \
+    ./hf_client/bta_hf_client_main.cc \
+    ./hf_client/bta_hf_client_rfc.cc \
+    ./hf_client/bta_hf_client_sco.cc \
+    ./hf_client/bta_hf_client_sdp.cc \
+    ./hh/bta_hh_act.cc \
+    ./hh/bta_hh_api.cc \
+    ./hh/bta_hh_cfg.cc \
+    ./hh/bta_hh_le.cc \
+    ./hh/bta_hh_main.cc \
+    ./hh/bta_hh_utils.cc \
+    ./hl/bta_hl_act.cc \
+    ./hl/bta_hl_api.cc \
+    ./hl/bta_hl_ci.cc \
+    ./hl/bta_hl_main.cc \
+    ./hl/bta_hl_sdp.cc \
+    ./hl/bta_hl_utils.cc \
+    ./jv/bta_jv_act.cc \
+    ./jv/bta_jv_api.cc \
+    ./jv/bta_jv_cfg.cc \
+    ./jv/bta_jv_main.cc \
+    ./mce/bta_mce_act.cc \
+    ./mce/bta_mce_api.cc \
+    ./mce/bta_mce_cfg.cc \
+    ./mce/bta_mce_main.cc \
+    ./pan/bta_pan_act.cc \
+    ./pan/bta_pan_api.cc \
+    ./pan/bta_pan_ci.cc \
+    ./pan/bta_pan_main.cc \
+    ./sdp/bta_sdp.cc \
+    ./sdp/bta_sdp_act.cc \
+    ./sdp/bta_sdp_api.cc \
+    ./sdp/bta_sdp_cfg.cc \
+    ./sys/bta_sys_conn.cc \
+    ./sys/bta_sys_main.cc \
+    ./sys/utl.cc
 
 LOCAL_MODULE := libbt-bta
 LOCAL_MODULE_CLASS := STATIC_LIBRARIES
diff --git a/bta/BUILD.gn b/bta/BUILD.gn
index 6c60837..8ce9a9b 100644
--- a/bta/BUILD.gn
+++ b/bta/BUILD.gn
@@ -16,17 +16,17 @@
 
 static_library("bta") {
   sources = [
-    "ag/bta_ag_act.c",
-    "ag/bta_ag_api.c",
-    "ag/bta_ag_at.c",
-    "ag/bta_ag_cfg.c",
-    "ag/bta_ag_ci.c",
-    "ag/bta_ag_cmd.c",
-    "ag/bta_ag_main.c",
-    "ag/bta_ag_rfc.c",
-    "ag/bta_ag_sco.c",
-    "ag/bta_ag_sdp.c",
-    "ar/bta_ar.c",
+    "ag/bta_ag_act.cc",
+    "ag/bta_ag_api.cc",
+    "ag/bta_ag_at.cc",
+    "ag/bta_ag_cfg.cc",
+    "ag/bta_ag_ci.cc",
+    "ag/bta_ag_cmd.cc",
+    "ag/bta_ag_main.cc",
+    "ag/bta_ag_rfc.cc",
+    "ag/bta_ag_sco.cc",
+    "ag/bta_ag_sdp.cc",
+    "ar/bta_ar.cc",
     "av/bta_av_aact.cc",
     "av/bta_av_act.cc",
     "av/bta_av_api.cc",
@@ -51,45 +51,45 @@
     "gatt/bta_gatts_api.cc",
     "gatt/bta_gatts_main.cc",
     "gatt/bta_gatts_utils.cc",
-    "hf_client/bta_hf_client_act.c",
-    "hf_client/bta_hf_client_api.c",
-    "hf_client/bta_hf_client_at.c",
-    "hf_client/bta_hf_client_cmd.c",
-    "hf_client/bta_hf_client_main.c",
-    "hf_client/bta_hf_client_rfc.c",
-    "hf_client/bta_hf_client_sdp.c",
-    "hf_client/bta_hf_client_sco.c",
+    "hf_client/bta_hf_client_act.cc",
+    "hf_client/bta_hf_client_api.cc",
+    "hf_client/bta_hf_client_at.cc",
+    "hf_client/bta_hf_client_cmd.cc",
+    "hf_client/bta_hf_client_main.cc",
+    "hf_client/bta_hf_client_rfc.cc",
+    "hf_client/bta_hf_client_sdp.cc",
+    "hf_client/bta_hf_client_sco.cc",
     "hh/bta_hh_act.cc",
     "hh/bta_hh_api.cc",
     "hh/bta_hh_cfg.cc",
     "hh/bta_hh_le.cc",
     "hh/bta_hh_main.cc",
     "hh/bta_hh_utils.cc",
-    "hl/bta_hl_act.c",
-    "hl/bta_hl_api.c",
-    "hl/bta_hl_ci.c",
-    "hl/bta_hl_main.c",
-    "hl/bta_hl_sdp.c",
-    "hl/bta_hl_utils.c",
-    "jv/bta_jv_act.c",
-    "jv/bta_jv_api.c",
-    "jv/bta_jv_cfg.c",
-    "jv/bta_jv_main.c",
-    "mce/bta_mce_act.c",
-    "mce/bta_mce_api.c",
-    "mce/bta_mce_cfg.c",
-    "mce/bta_mce_main.c",
-    "pan/bta_pan_act.c",
-    "pan/bta_pan_api.c",
-    "pan/bta_pan_ci.c",
-    "pan/bta_pan_main.c",
-    "sdp/bta_sdp.c",
-    "sdp/bta_sdp_act.c",
-    "sdp/bta_sdp_api.c",
-    "sdp/bta_sdp_cfg.c",
-    "sys/bta_sys_conn.c",
-    "sys/bta_sys_main.c",
-    "sys/utl.c",
+    "hl/bta_hl_act.cc",
+    "hl/bta_hl_api.cc",
+    "hl/bta_hl_ci.cc",
+    "hl/bta_hl_main.cc",
+    "hl/bta_hl_sdp.cc",
+    "hl/bta_hl_utils.cc",
+    "jv/bta_jv_act.cc",
+    "jv/bta_jv_api.cc",
+    "jv/bta_jv_cfg.cc",
+    "jv/bta_jv_main.cc",
+    "mce/bta_mce_act.cc",
+    "mce/bta_mce_api.cc",
+    "mce/bta_mce_cfg.cc",
+    "mce/bta_mce_main.cc",
+    "pan/bta_pan_act.cc",
+    "pan/bta_pan_api.cc",
+    "pan/bta_pan_ci.cc",
+    "pan/bta_pan_main.cc",
+    "sdp/bta_sdp.cc",
+    "sdp/bta_sdp_act.cc",
+    "sdp/bta_sdp_api.cc",
+    "sdp/bta_sdp_cfg.cc",
+    "sys/bta_sys_conn.cc",
+    "sys/bta_sys_main.cc",
+    "sys/utl.cc",
   ]
 
   include_dirs = [
diff --git a/bta/ag/bta_ag_act.c b/bta/ag/bta_ag_act.cc
similarity index 99%
rename from bta/ag/bta_ag_act.c
rename to bta/ag/bta_ag_act.cc
index 6b0278f..bdadf65 100644
--- a/bta/ag/bta_ag_act.c
+++ b/bta/ag/bta_ag_act.cc
@@ -27,13 +27,12 @@
 #include "bta_ag_api.h"
 #include "bta_ag_co.h"
 #include "bta_ag_int.h"
+#include "bta_dm_api.h"
 #include "port_api.h"
 #include "utl.h"
 #include <string.h>
 #include "l2c_api.h"
 
-extern void bta_dm_pm_active(BD_ADDR peer_addr);
-
 /*****************************************************************************
 **  Constants
 *****************************************************************************/
diff --git a/bta/ag/bta_ag_api.c b/bta/ag/bta_ag_api.cc
similarity index 100%
rename from bta/ag/bta_ag_api.c
rename to bta/ag/bta_ag_api.cc
diff --git a/bta/ag/bta_ag_at.c b/bta/ag/bta_ag_at.cc
similarity index 100%
rename from bta/ag/bta_ag_at.c
rename to bta/ag/bta_ag_at.cc
diff --git a/bta/ag/bta_ag_at.h b/bta/ag/bta_ag_at.h
index bc4043f..957d1a4 100644
--- a/bta/ag/bta_ag_at.h
+++ b/bta/ag/bta_ag_at.h
@@ -24,6 +24,10 @@
 #ifndef BTA_AG_AT_H
 #define BTA_AG_AT_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /*****************************************************************************
 **  Constants
 *****************************************************************************/
@@ -117,5 +121,8 @@
 *****************************************************************************/
 extern void bta_ag_at_parse(tBTA_AG_AT_CB *p_cb, char *p_buf, uint16_t len);
 
-#endif /* BTA_AG_AT_H */
+#ifdef __cplusplus
+}
+#endif
 
+#endif /* BTA_AG_AT_H */
diff --git a/bta/ag/bta_ag_cfg.c b/bta/ag/bta_ag_cfg.cc
similarity index 98%
rename from bta/ag/bta_ag_cfg.c
rename to bta/ag/bta_ag_cfg.cc
index e5893e1..9c43da0 100644
--- a/bta/ag/bta_ag_cfg.c
+++ b/bta/ag/bta_ag_cfg.cc
@@ -26,6 +26,7 @@
 #include "bt_common.h"
 #include "bta_api.h"
 #include "bta_ag_api.h"
+#include "bta_ag_int.h"
 
 #ifndef BTA_AG_CIND_INFO
 #define BTA_AG_CIND_INFO     "(\"call\",(0,1)),(\"callsetup\",(0-3)),(\"service\",(0-3)),(\"signal\",(0-6)),(\"roam\",(0,1)),(\"battchg\",(0-5)),(\"callheld\",(0-2)),(\"bearer\",(0-7))"
diff --git a/bta/ag/bta_ag_ci.c b/bta/ag/bta_ag_ci.cc
similarity index 100%
rename from bta/ag/bta_ag_ci.c
rename to bta/ag/bta_ag_ci.cc
diff --git a/bta/ag/bta_ag_cmd.c b/bta/ag/bta_ag_cmd.cc
similarity index 99%
rename from bta/ag/bta_ag_cmd.c
rename to bta/ag/bta_ag_cmd.cc
index 8e0d8bc..f577b44 100644
--- a/bta/ag/bta_ag_cmd.c
+++ b/bta/ag/bta_ag_cmd.cc
@@ -342,8 +342,8 @@
 ** Returns          void
 **
 *******************************************************************************/
-static void bta_ag_send_result(tBTA_AG_SCB *p_scb, uint8_t code, char *p_arg,
-                               int16_t int_arg)
+static void bta_ag_send_result(tBTA_AG_SCB *p_scb, uint8_t code,
+                               const char *p_arg, int16_t int_arg)
 {
     char buf[BTA_AG_AT_MAX_LEN + 16];
     char *p = buf;
diff --git a/bta/ag/bta_ag_int.h b/bta/ag/bta_ag_int.h
index b284ce7..a6bd565 100644
--- a/bta/ag/bta_ag_int.h
+++ b/bta/ag/bta_ag_int.h
@@ -29,6 +29,10 @@
 #include "bta_ag_api.h"
 #include "bta_ag_at.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* Send RING & CLIP in one AT cmd */
 #ifndef BTA_AG_MULTI_RESULT_INCLUDED
 #define BTA_AG_MULTI_RESULT_INCLUDED FALSE
@@ -339,7 +343,7 @@
 
 /* config struct */
 extern tBTA_AG_CFG *p_bta_ag_cfg;
-extern tBTA_AG_HF_IND bta_ag_local_hf_ind_cfg[];
+extern const tBTA_AG_HF_IND bta_ag_local_hf_ind_cfg[];
 
 /*****************************************************************************
 **  Function prototypes
@@ -428,4 +432,9 @@
 extern void bta_ag_set_esco_param(bool set_reset, tBTM_ESCO_PARAMS *param);
 extern void bta_ag_ci_rx_data(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data);
 extern void bta_ag_rcvd_slc_ready(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data);
+
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* BTA_AG_INT_H */
diff --git a/bta/ag/bta_ag_main.c b/bta/ag/bta_ag_main.cc
similarity index 100%
rename from bta/ag/bta_ag_main.c
rename to bta/ag/bta_ag_main.cc
diff --git a/bta/ag/bta_ag_rfc.c b/bta/ag/bta_ag_rfc.cc
similarity index 100%
rename from bta/ag/bta_ag_rfc.c
rename to bta/ag/bta_ag_rfc.cc
diff --git a/bta/ag/bta_ag_sco.c b/bta/ag/bta_ag_sco.cc
similarity index 100%
rename from bta/ag/bta_ag_sco.c
rename to bta/ag/bta_ag_sco.cc
diff --git a/bta/ag/bta_ag_sdp.c b/bta/ag/bta_ag_sdp.cc
similarity index 100%
rename from bta/ag/bta_ag_sdp.c
rename to bta/ag/bta_ag_sdp.cc
diff --git a/bta/ar/bta_ar.c b/bta/ar/bta_ar.cc
similarity index 100%
rename from bta/ar/bta_ar.c
rename to bta/ar/bta_ar.cc
diff --git a/bta/ar/bta_ar_int.h b/bta/ar/bta_ar_int.h
index a14b615..d5741c3 100644
--- a/bta/ar/bta_ar_int.h
+++ b/bta/ar/bta_ar_int.h
@@ -27,6 +27,9 @@
 
 #include "bta_av_api.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 #ifndef BTA_AR_DEBUG
 #define BTA_AR_DEBUG    TRUE
@@ -56,4 +59,8 @@
 /* control block declaration */
 extern tBTA_AR_CB bta_ar_cb;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* BTA_AR_INT_H */
diff --git a/bta/dm/bta_dm_act.cc b/bta/dm/bta_dm_act.cc
index 4b4fc44..d15cc53 100644
--- a/bta/dm/bta_dm_act.cc
+++ b/bta/dm/bta_dm_act.cc
@@ -31,6 +31,7 @@
 #include "bt_target.h"
 #include "bt_types.h"
 #include "bta_api.h"
+#include "bta_dm_api.h"
 #include "bta_dm_co.h"
 #include "bta_dm_int.h"
 #include "bta_sys.h"
@@ -135,7 +136,6 @@
 static void bta_dm_observe_results_cb(tBTM_INQ_RESULTS *p_inq, uint8_t *p_eir);
 static void bta_dm_observe_cmpl_cb(void * p_result);
 static void bta_dm_delay_role_switch_cback(void *data);
-extern "C" void sdpu_uuid16_to_uuid128(uint16_t uuid16, uint8_t* p_uuid128);
 static void bta_dm_disable_timer_cback(void *data);
 
 
diff --git a/bta/dm/bta_dm_int.h b/bta/dm/bta_dm_int.h
index 62f59dd..0ab037c 100644
--- a/bta/dm/bta_dm_int.h
+++ b/bta/dm/bta_dm_int.h
@@ -1088,8 +1088,6 @@
 extern void bta_dm_disc_rmt_name (tBTA_DM_MSG *p_data);
 extern tBTA_DM_PEER_DEVICE * bta_dm_find_peer_device(const BD_ADDR peer_addr);
 
-extern "C" void bta_dm_pm_active(BD_ADDR peer_addr);
-
 void bta_dm_eir_update_uuid(uint16_t uuid16, bool adding);
 
 extern void bta_dm_enable_test_mode(tBTA_DM_MSG *p_data);
diff --git a/bta/dm/bta_dm_pm.cc b/bta/dm/bta_dm_pm.cc
index 7d55fa1..706d7cd 100644
--- a/bta/dm/bta_dm_pm.cc
+++ b/bta/dm/bta_dm_pm.cc
@@ -29,6 +29,7 @@
 #include "bt_common.h"
 #include "bta_sys.h"
 #include "bta_api.h"
+#include "bta_dm_api.h"
 #include "bta_dm_int.h"
 #include "btm_api.h"
 
diff --git a/bta/hf_client/bta_hf_client_act.c b/bta/hf_client/bta_hf_client_act.cc
similarity index 99%
rename from bta/hf_client/bta_hf_client_act.c
rename to bta/hf_client/bta_hf_client_act.cc
index b70b525..73a726b 100644
--- a/bta/hf_client/bta_hf_client_act.c
+++ b/bta/hf_client/bta_hf_client_act.cc
@@ -24,6 +24,7 @@
  ******************************************************************************/
 
 #include "bta_api.h"
+#include "bta_dm_api.h"
 #include "bta_hf_client_api.h"
 #include "bta_hf_client_int.h"
 #include "l2c_api.h"
@@ -34,8 +35,6 @@
 #include "osi/include/compat.h"
 #include <string.h>
 
-extern void bta_dm_pm_active(BD_ADDR peer_addr);
-
 /*****************************************************************************
 **  Constants
 *****************************************************************************/
diff --git a/bta/hf_client/bta_hf_client_api.c b/bta/hf_client/bta_hf_client_api.cc
similarity index 100%
rename from bta/hf_client/bta_hf_client_api.c
rename to bta/hf_client/bta_hf_client_api.cc
diff --git a/bta/hf_client/bta_hf_client_at.c b/bta/hf_client/bta_hf_client_at.cc
similarity index 97%
rename from bta/hf_client/bta_hf_client_at.c
rename to bta/hf_client/bta_hf_client_at.cc
index e67d4eb..e565a60 100644
--- a/bta/hf_client/bta_hf_client_at.c
+++ b/bta/hf_client/bta_hf_client_at.cc
@@ -70,7 +70,7 @@
 /* CIND: represents each indicators boundaries */
 typedef struct
 {
-    char* name;
+    const char* name;
     uint8_t min;
     uint8_t max;
     uint8_t namelen;
@@ -166,7 +166,8 @@
     alarm_cancel(bta_hf_client_cb.scb.at_cb.resp_timer);
 }
 
-static void bta_hf_client_send_at(tBTA_HF_CLIENT_AT_CMD cmd, char *buf, uint16_t buf_len)
+static void bta_hf_client_send_at(tBTA_HF_CLIENT_AT_CMD cmd, const char *buf,
+                                  uint16_t buf_len)
 {
     if ((bta_hf_client_cb.scb.at_cb.current_cmd == BTA_HF_CLIENT_AT_NONE ||
             bta_hf_client_cb.scb.svc_conn == false) &&
@@ -583,19 +584,27 @@
 
 /* Check if prefix match and skip spaces if any */
 #define AT_CHECK_EVENT(buf, event) \
-    if (strncmp("\r\n"event, buf,sizeof("\r\n"event) - 1) != 0) return buf; \
-    (buf) += sizeof("\r\n"event) - 1; \
-    while (*(buf) == ' ') (buf)++;
+do { \
+    if (strncmp("\r\n" event, buf, sizeof("\r\n" event) - 1) != 0) return buf; \
+    (buf) += sizeof("\r\n" event) - 1; \
+    while (*(buf) == ' ') (buf)++; \
+} while (0)
 
 /* check for <cr><lf> and forward buffer if match */
 #define AT_CHECK_RN(buf) \
+do { \
     if (strncmp("\r\n", buf, sizeof("\r\n") - 1) != 0) { \
         APPL_TRACE_DEBUG("%s missing end <cr><lf>", __func__); \
-        return NULL;} \
-    (buf) += sizeof("\r\n") - 1;
+        return NULL; \
+    } \
+    (buf) += sizeof("\r\n") - 1; \
+} while (0)
 
 /* skip rest of AT string up to <cr> */
-#define AT_SKIP_REST(buf) while(*(buf) != '\r') (buf)++;
+#define AT_SKIP_REST(buf) \
+do { \
+    while(*(buf) != '\r') (buf)++; \
+} while (0)
 
 static char *bta_hf_client_parse_ok(char *buffer)
 {
@@ -1525,7 +1534,7 @@
 
 void bta_hf_client_send_at_bac(void)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1560,7 +1569,7 @@
 
 void bta_hf_client_send_at_cind(bool status)
 {
-    char *buf;
+    const char *buf;
     tBTA_HF_CLIENT_AT_CMD cmd;
 
     APPL_TRACE_DEBUG("%s", __func__);
@@ -1581,7 +1590,7 @@
 
 void bta_hf_client_send_at_cmer(bool activate)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1616,7 +1625,7 @@
 
 void bta_hf_client_send_at_clip(bool activate)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1630,7 +1639,7 @@
 
 void bta_hf_client_send_at_ccwa(bool activate)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1645,7 +1654,7 @@
 
 void bta_hf_client_send_at_cmee(bool activate)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1659,7 +1668,7 @@
 
 void bta_hf_client_send_at_cops(bool query)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1673,7 +1682,7 @@
 
 void bta_hf_client_send_at_clcc(void)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1684,7 +1693,7 @@
 
 void bta_hf_client_send_at_bvra(bool enable)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1760,7 +1769,7 @@
 
 void bta_hf_client_send_at_bldn(void)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1771,7 +1780,7 @@
 
 void bta_hf_client_send_at_ata(void)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1782,7 +1791,7 @@
 
 void bta_hf_client_send_at_chup(void)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1836,7 +1845,7 @@
 
 void bta_hf_client_send_at_bcc(void)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1847,7 +1856,7 @@
 
 void bta_hf_client_send_at_cnum(void)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
@@ -1858,7 +1867,7 @@
 
 void bta_hf_client_send_at_nrec(void)
 {
-    char *buf;
+    const char *buf;
 
     APPL_TRACE_DEBUG("%s", __func__);
 
diff --git a/bta/hf_client/bta_hf_client_cmd.c b/bta/hf_client/bta_hf_client_cmd.cc
similarity index 100%
rename from bta/hf_client/bta_hf_client_cmd.c
rename to bta/hf_client/bta_hf_client_cmd.cc
diff --git a/bta/hf_client/bta_hf_client_main.c b/bta/hf_client/bta_hf_client_main.cc
similarity index 100%
rename from bta/hf_client/bta_hf_client_main.c
rename to bta/hf_client/bta_hf_client_main.cc
diff --git a/bta/hf_client/bta_hf_client_rfc.c b/bta/hf_client/bta_hf_client_rfc.cc
similarity index 100%
rename from bta/hf_client/bta_hf_client_rfc.c
rename to bta/hf_client/bta_hf_client_rfc.cc
diff --git a/bta/hf_client/bta_hf_client_sco.c b/bta/hf_client/bta_hf_client_sco.cc
similarity index 100%
rename from bta/hf_client/bta_hf_client_sco.c
rename to bta/hf_client/bta_hf_client_sco.cc
diff --git a/bta/hf_client/bta_hf_client_sdp.c b/bta/hf_client/bta_hf_client_sdp.cc
similarity index 100%
rename from bta/hf_client/bta_hf_client_sdp.c
rename to bta/hf_client/bta_hf_client_sdp.cc
diff --git a/bta/hl/bta_hl_act.c b/bta/hl/bta_hl_act.cc
similarity index 100%
rename from bta/hl/bta_hl_act.c
rename to bta/hl/bta_hl_act.cc
diff --git a/bta/hl/bta_hl_api.c b/bta/hl/bta_hl_api.cc
similarity index 100%
rename from bta/hl/bta_hl_api.c
rename to bta/hl/bta_hl_api.cc
diff --git a/bta/hl/bta_hl_ci.c b/bta/hl/bta_hl_ci.cc
similarity index 96%
rename from bta/hl/bta_hl_ci.c
rename to bta/hl/bta_hl_ci.cc
index 41f0130..e89dfdb 100644
--- a/bta/hl/bta_hl_ci.c
+++ b/bta/hl/bta_hl_ci.cc
@@ -28,6 +28,7 @@
 #include "btm_api.h"
 #include "bta_sys.h"
 #include "bta_hl_api.h"
+#include "bta_hl_ci.h"
 #include "bta_hl_co.h"
 #include "bta_hl_int.h"
 
@@ -46,9 +47,8 @@
 ** Returns          void
 **
 *******************************************************************************/
-extern void bta_hl_ci_get_tx_data(  tBTA_HL_MDL_HANDLE mdl_handle,
-                                    tBTA_HL_STATUS status,
-                                    uint16_t evt )
+void bta_hl_ci_get_tx_data(tBTA_HL_MDL_HANDLE mdl_handle,
+                           tBTA_HL_STATUS status, uint16_t evt)
 {
     tBTA_HL_CI_GET_PUT_DATA *p_evt =
         (tBTA_HL_CI_GET_PUT_DATA *)osi_malloc(sizeof(tBTA_HL_CI_GET_PUT_DATA));
diff --git a/bta/hl/bta_hl_int.h b/bta/hl/bta_hl_int.h
index 33a4155..e58bc18 100644
--- a/bta/hl/bta_hl_int.h
+++ b/bta/hl/bta_hl_int.h
@@ -862,8 +862,8 @@
                                             tBTA_HL_STATUS status);
 
 #if (BTA_HL_DEBUG == TRUE)
-    extern  char *bta_hl_status_code(tBTA_HL_STATUS status);
-    extern char *bta_hl_evt_code(tBTA_HL_INT_EVT evt_code);
+    extern  const char *bta_hl_status_code(tBTA_HL_STATUS status);
+    extern const char *bta_hl_evt_code(tBTA_HL_INT_EVT evt_code);
 #endif
 #ifdef __cplusplus
 }
diff --git a/bta/hl/bta_hl_main.c b/bta/hl/bta_hl_main.cc
similarity index 99%
rename from bta/hl/bta_hl_main.c
rename to bta/hl/bta_hl_main.cc
index b50ed35..1ee5843 100644
--- a/bta/hl/bta_hl_main.c
+++ b/bta/hl/bta_hl_main.cc
@@ -38,8 +38,8 @@
 
 
 #if (BTA_HL_DEBUG == TRUE)
-static char *bta_hl_cch_state_code(tBTA_HL_CCH_STATE state_code);
-static char *bta_hl_dch_state_code(tBTA_HL_DCH_STATE state_code);
+static const char *bta_hl_cch_state_code(tBTA_HL_CCH_STATE state_code);
+static const char *bta_hl_dch_state_code(tBTA_HL_DCH_STATE state_code);
 #endif
 
 extern uint16_t L2CA_AllocateRandomPsm(void);
@@ -2063,7 +2063,7 @@
 ** Returns          string pointer for the associated state name
 **
 *******************************************************************************/
-static char *bta_hl_cch_state_code(tBTA_HL_CCH_STATE state_code)
+static const char *bta_hl_cch_state_code(tBTA_HL_CCH_STATE state_code)
 {
     switch (state_code)
     {
@@ -2089,7 +2089,7 @@
 ** Returns          string pointer for the associated state name
 **
 *******************************************************************************/
-static char *bta_hl_dch_state_code(tBTA_HL_DCH_STATE state_code)
+static const char *bta_hl_dch_state_code(tBTA_HL_DCH_STATE state_code)
 {
     switch (state_code)
     {
diff --git a/bta/hl/bta_hl_sdp.c b/bta/hl/bta_hl_sdp.cc
similarity index 100%
rename from bta/hl/bta_hl_sdp.c
rename to bta/hl/bta_hl_sdp.cc
diff --git a/bta/hl/bta_hl_utils.c b/bta/hl/bta_hl_utils.cc
similarity index 99%
rename from bta/hl/bta_hl_utils.c
rename to bta/hl/bta_hl_utils.cc
index 3939e16..208d938 100644
--- a/bta/hl/bta_hl_utils.c
+++ b/bta/hl/bta_hl_utils.cc
@@ -310,8 +310,8 @@
             }
             break;
         default:
-            if (((*pp_rec = bta_hl_find_sink_or_src_srv_class_in_db(p_mcb->p_db,
-                                                                    *pp_rec)) == NULL))
+            if ((*pp_rec = bta_hl_find_sink_or_src_srv_class_in_db(p_mcb->p_db,
+                                                                    *pp_rec)) == NULL)
             {
                 found = false;
             }
@@ -3281,7 +3281,7 @@
 ** Returns          char * - status string pointer
 **
 *******************************************************************************/
-char *bta_hl_status_code(tBTA_HL_STATUS status)
+const char *bta_hl_status_code(tBTA_HL_STATUS status)
 {
     switch (status)
     {
@@ -3349,7 +3349,7 @@
 ** Returns          string pointer for the associated event name
 **
 *******************************************************************************/
-char *bta_hl_evt_code(tBTA_HL_INT_EVT evt_code)
+const char *bta_hl_evt_code(tBTA_HL_INT_EVT evt_code)
 {
     switch (evt_code)
     {
diff --git a/bta/include/bta_ag_api.h b/bta/include/bta_ag_api.h
index f2b0a99..4754f8e 100644
--- a/bta/include/bta_ag_api.h
+++ b/bta/include/bta_ag_api.h
@@ -431,13 +431,13 @@
 /* AG configuration structure */
 typedef struct
 {
-    char         *cind_info;
-    char         *bind_info;
+    const char   *cind_info;
+    const char   *bind_info;
     uint8_t        num_local_hf_ind;
     int32_t        conn_tout;
     uint16_t       sco_pkt_types;
-    char         *chld_val_ecc;
-    char         *chld_val;
+    const char   *chld_val_ecc;
+    const char   *chld_val;
 } tBTA_AG_CFG;
 
 /*****************************************************************************
diff --git a/bta/include/bta_dm_api.h b/bta/include/bta_dm_api.h
new file mode 100644
index 0000000..673465f
--- /dev/null
+++ b/bta/include/bta_dm_api.h
@@ -0,0 +1,40 @@
+/******************************************************************************
+ *
+ *  Copyright (C) 2006-2012 Broadcom Corporation
+ *
+ *  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.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ *  This is the interface file for device mananger functions.
+ *
+ ******************************************************************************/
+#ifndef BTA_DM_API_H
+#define BTA_DM_API_H
+
+#include "stack/include/bt_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Brings connection to active mode
+void bta_dm_pm_active(BD_ADDR peer_addr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BTA_DM_API_H */
diff --git a/bta/include/bta_dm_ci.h b/bta/include/bta_dm_ci.h
index 4d4bb81..ec2fab7 100644
--- a/bta/include/bta_dm_ci.h
+++ b/bta/include/bta_dm_ci.h
@@ -30,8 +30,7 @@
 **  Function Declarations
 *****************************************************************************/
 #ifdef __cplusplus
-extern "C"
-{
+extern "C" {
 #endif
 
 /*******************************************************************************
diff --git a/bta/include/bta_dm_co.h b/bta/include/bta_dm_co.h
index 47f6abb..c8900a2 100644
--- a/bta/include/bta_dm_co.h
+++ b/bta/include/bta_dm_co.h
@@ -276,4 +276,4 @@
 }
 #endif
 
-#endif
+#endif /* BTA_DM_CO_H */
diff --git a/bta/jv/bta_jv_act.c b/bta/jv/bta_jv_act.cc
similarity index 99%
rename from bta/jv/bta_jv_act.c
rename to bta/jv/bta_jv_act.cc
index 2b8d226..3f8caac 100644
--- a/bta/jv/bta_jv_act.c
+++ b/bta/jv/bta_jv_act.cc
@@ -2273,7 +2273,7 @@
     else if (!create)
         return NULL; /* we cannot alloc a struct if not asked to */
 
-    t = osi_calloc(sizeof(*t));
+    t = static_cast<struct fc_channel *>(osi_calloc(sizeof(*t)));
     t->chan = chan;
 
     if (!L2CA_RegisterFixedChannel(chan, &fcr)) {
@@ -2336,7 +2336,7 @@
     else
         sec_id = bta_jv_alloc_sec_id();
 
-    t = osi_calloc(sizeof(*t));
+    t = static_cast<fc_client *>(osi_calloc(sizeof(*t)));
     // Allocate it a unique ID
     do {
         t->id = ++fc_next_id;
diff --git a/bta/jv/bta_jv_api.c b/bta/jv/bta_jv_api.cc
similarity index 100%
rename from bta/jv/bta_jv_api.c
rename to bta/jv/bta_jv_api.cc
diff --git a/bta/jv/bta_jv_cfg.c b/bta/jv/bta_jv_cfg.cc
similarity index 100%
rename from bta/jv/bta_jv_cfg.c
rename to bta/jv/bta_jv_cfg.cc
diff --git a/bta/jv/bta_jv_main.c b/bta/jv/bta_jv_main.cc
similarity index 100%
rename from bta/jv/bta_jv_main.c
rename to bta/jv/bta_jv_main.cc
diff --git a/bta/mce/bta_mce_act.c b/bta/mce/bta_mce_act.cc
similarity index 100%
rename from bta/mce/bta_mce_act.c
rename to bta/mce/bta_mce_act.cc
diff --git a/bta/mce/bta_mce_api.c b/bta/mce/bta_mce_api.cc
similarity index 100%
rename from bta/mce/bta_mce_api.c
rename to bta/mce/bta_mce_api.cc
diff --git a/bta/mce/bta_mce_cfg.c b/bta/mce/bta_mce_cfg.cc
similarity index 100%
rename from bta/mce/bta_mce_cfg.c
rename to bta/mce/bta_mce_cfg.cc
diff --git a/bta/mce/bta_mce_main.c b/bta/mce/bta_mce_main.cc
similarity index 100%
rename from bta/mce/bta_mce_main.c
rename to bta/mce/bta_mce_main.cc
diff --git a/bta/pan/bta_pan_act.c b/bta/pan/bta_pan_act.cc
similarity index 100%
rename from bta/pan/bta_pan_act.c
rename to bta/pan/bta_pan_act.cc
diff --git a/bta/pan/bta_pan_api.c b/bta/pan/bta_pan_api.cc
similarity index 100%
rename from bta/pan/bta_pan_api.c
rename to bta/pan/bta_pan_api.cc
diff --git a/bta/pan/bta_pan_ci.c b/bta/pan/bta_pan_ci.cc
similarity index 100%
rename from bta/pan/bta_pan_ci.c
rename to bta/pan/bta_pan_ci.cc
diff --git a/bta/pan/bta_pan_main.c b/bta/pan/bta_pan_main.cc
similarity index 100%
rename from bta/pan/bta_pan_main.c
rename to bta/pan/bta_pan_main.cc
diff --git a/bta/sdp/bta_sdp.c b/bta/sdp/bta_sdp.cc
similarity index 100%
rename from bta/sdp/bta_sdp.c
rename to bta/sdp/bta_sdp.cc
diff --git a/bta/sdp/bta_sdp_act.c b/bta/sdp/bta_sdp_act.cc
similarity index 99%
rename from bta/sdp/bta_sdp_act.c
rename to bta/sdp/bta_sdp_act.cc
index 10b50c7..ac93704 100644
--- a/bta/sdp/bta_sdp_act.c
+++ b/bta/sdp/bta_sdp_act.cc
@@ -499,7 +499,8 @@
     bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_YES;
     bdcpy(bta_sdp_cb.remote_addr, p_data->get_search.bd_addr);
     /* set the uuid used in the search */
-    tBT_UUID *bta_sdp_search_uuid = osi_malloc(sizeof(tBT_UUID));
+    tBT_UUID *bta_sdp_search_uuid =
+        static_cast<tBT_UUID *>(osi_malloc(sizeof(tBT_UUID)));
     memcpy(bta_sdp_search_uuid, &(p_data->get_search.uuid),sizeof(tBT_UUID));
 
     /* initialize the search for the uuid */
diff --git a/bta/sdp/bta_sdp_api.c b/bta/sdp/bta_sdp_api.cc
similarity index 100%
rename from bta/sdp/bta_sdp_api.c
rename to bta/sdp/bta_sdp_api.cc
diff --git a/bta/sdp/bta_sdp_cfg.c b/bta/sdp/bta_sdp_cfg.cc
similarity index 100%
rename from bta/sdp/bta_sdp_cfg.c
rename to bta/sdp/bta_sdp_cfg.cc
diff --git a/bta/sys/bta_sys.h b/bta/sys/bta_sys.h
index 41e05cd..f0283dc 100644
--- a/bta/sys/bta_sys.h
+++ b/bta/sys/bta_sys.h
@@ -187,7 +187,7 @@
 **  events for BTA SYS HW manager
 *****************************************************************************/
 
-/* events sent to SYS HW manager - must be kept synchronized with tables in bta_sys_main.c */
+/* events sent to SYS HW manager - must be kept synchronized with tables in bta_sys_main.cc */
 enum
 {
     /* device manager local device API events */
diff --git a/bta/sys/bta_sys_conn.c b/bta/sys/bta_sys_conn.cc
similarity index 100%
rename from bta/sys/bta_sys_conn.c
rename to bta/sys/bta_sys_conn.cc
diff --git a/bta/sys/bta_sys_main.c b/bta/sys/bta_sys_main.cc
similarity index 100%
rename from bta/sys/bta_sys_main.c
rename to bta/sys/bta_sys_main.cc
diff --git a/bta/sys/utl.c b/bta/sys/utl.cc
similarity index 100%
rename from bta/sys/utl.c
rename to bta/sys/utl.cc
diff --git a/btcore/Android.mk b/btcore/Android.mk
index 5ee247f..e89e54d 100644
--- a/btcore/Android.mk
+++ b/btcore/Android.mk
@@ -21,13 +21,13 @@
 # Common variables
 # ========================================================
 btcoreCommonSrc := \
-    src/bdaddr.c \
-    src/device_class.c \
-    src/hal_util.c \
+    src/bdaddr.cc \
+    src/device_class.cc \
+    src/hal_util.cc \
     src/module.cc \
-    src/osi_module.c \
-    src/property.c \
-    src/uuid.c
+    src/osi_module.cc \
+    src/property.cc \
+    src/uuid.cc
 
 btcoreCommonTestSrc := \
 	./test/bdaddr_test.cc \
diff --git a/btcore/BUILD.gn b/btcore/BUILD.gn
index e2d94fc..b09f455 100644
--- a/btcore/BUILD.gn
+++ b/btcore/BUILD.gn
@@ -16,13 +16,13 @@
 
 static_library("btcore") {
   sources = [
-    "src/bdaddr.c",
-    "src/device_class.c",
-    "src/hal_util.c",
+    "src/bdaddr.cc",
+    "src/device_class.cc",
+    "src/hal_util.cc",
     "src/module.cc",
-    "src/property.c",
-    "src/uuid.c",
-    "src/osi_module.c",
+    "src/property.cc",
+    "src/uuid.cc",
+    "src/osi_module.cc",
   ]
 
   include_dirs = [
diff --git a/btcore/include/device_class.h b/btcore/include/device_class.h
index 8c2c3c0..6887336 100644
--- a/btcore/include/device_class.h
+++ b/btcore/include/device_class.h
@@ -24,6 +24,10 @@
 // Provides Class Of Device primitive as specified in the bluetooth spec.
 // [Class Of Device](https://www.bluetooth.org/en-us/specification/assigned-numbers/baseband)
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 // Device class may be defined in other structures.
 // Only use defined methods to manipulate internals.
 typedef struct bt_device_class_t {
@@ -90,3 +94,7 @@
 
 bool device_class_get_information(const bt_device_class_t *dc);
 void device_class_set_information(bt_device_class_t *dc, bool set);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/btcore/include/device_features.h b/btcore/include/device_features.h
index f3069e3..64ef866 100644
--- a/btcore/include/device_features.h
+++ b/btcore/include/device_features.h
@@ -20,8 +20,16 @@
 
 #include <stdint.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 // Represents a page of device feature enabled/disabled bits returned
 // by the local controller. See the bluetooth spec for bit indexes.
 typedef struct {
   uint8_t as_array[8];
 } bt_device_features_t;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/btcore/include/event_mask.h b/btcore/include/event_mask.h
index ec662b2..8dd92a7 100644
--- a/btcore/include/event_mask.h
+++ b/btcore/include/event_mask.h
@@ -20,9 +20,17 @@
 
 #include <stdint.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 // Represents a mask which can be used to tell the controller which
 // HCI events the stack wishes to be informed about. See the bluetooth
 // spec for more information on what each bit means.
 typedef struct {
-  uint8_t as_array[8];
+  const uint8_t as_array[8];
 } bt_event_mask_t;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/btcore/include/iac.h b/btcore/include/iac.h
index bcb8ab8..c9254d2 100644
--- a/btcore/include/iac.h
+++ b/btcore/include/iac.h
@@ -20,8 +20,16 @@
 
 #include <stdint.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 // Inquiry Access Code
 // [Bluetooth Baseband](https://www.bluetooth.org/en-us/specification/assigned-numbers/baseband)
 typedef struct {
   uint8_t iac[3];
 } __attribute__((packed))bt_inquiry_access_code_t;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/btcore/include/module.h b/btcore/include/module.h
index ff6a73a..8d06b51 100644
--- a/btcore/include/module.h
+++ b/btcore/include/module.h
@@ -29,13 +29,15 @@
 
 typedef future_t *(*module_lifecycle_fn)(void);
 
+#define BTCORE_MAX_MODULE_DEPENDENCIES 10
+
 typedef struct {
   const char *name;
   module_lifecycle_fn init;
   module_lifecycle_fn start_up;
   module_lifecycle_fn shut_down;
   module_lifecycle_fn clean_up;
-  const char *dependencies[];
+  const char *dependencies[BTCORE_MAX_MODULE_DEPENDENCIES];
 } module_t;
 
 // Prepares module management. Must be called before doing anything with modules.
diff --git a/btcore/include/osi_module.h b/btcore/include/osi_module.h
index 964a3fa..2411e35 100644
--- a/btcore/include/osi_module.h
+++ b/btcore/include/osi_module.h
@@ -18,4 +18,12 @@
 
 #pragma once
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 static const char OSI_MODULE[] = "osi_module";
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/btcore/include/uuid.h b/btcore/include/uuid.h
index ab997e3..c623dcc 100644
--- a/btcore/include/uuid.h
+++ b/btcore/include/uuid.h
@@ -21,6 +21,10 @@
 #include <hardware/bluetooth.h>
 #include <stdbool.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct uuid_string_t uuid_string_t;
 
 // Creates uuid string structure to hold a well formed UUID
@@ -75,3 +79,7 @@
 bool uuid_128_to_32(const bt_uuid_t *uuid, uint32_t *uuid32);
 
 void uuid_128_from_16(bt_uuid_t *uuid, uint16_t uuid16);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/btcore/include/version.h b/btcore/include/version.h
index a0696ad..ad0c38b 100644
--- a/btcore/include/version.h
+++ b/btcore/include/version.h
@@ -20,6 +20,10 @@
 
 #include <stdint.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct {
   uint8_t hci_version;
   uint16_t hci_revision;
@@ -27,3 +31,7 @@
   uint16_t manufacturer;
   uint16_t lmp_subversion;
 } bt_version_t;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/btcore/src/bdaddr.c b/btcore/src/bdaddr.cc
similarity index 100%
rename from btcore/src/bdaddr.c
rename to btcore/src/bdaddr.cc
diff --git a/btcore/src/device_class.c b/btcore/src/device_class.cc
similarity index 100%
rename from btcore/src/device_class.c
rename to btcore/src/device_class.cc
diff --git a/btcore/src/hal_util.c b/btcore/src/hal_util.cc
similarity index 100%
rename from btcore/src/hal_util.c
rename to btcore/src/hal_util.cc
diff --git a/btcore/src/osi_module.c b/btcore/src/osi_module.cc
similarity index 96%
rename from btcore/src/osi_module.c
rename to btcore/src/osi_module.cc
index e7a580d..ff71446 100644
--- a/btcore/src/osi_module.c
+++ b/btcore/src/osi_module.cc
@@ -39,7 +39,7 @@
   return future_new_immediate(FUTURE_SUCCESS);
 }
 
-EXPORT_SYMBOL const module_t osi_module = {
+EXPORT_SYMBOL extern const module_t osi_module = {
   .name = OSI_MODULE,
   .init = osi_init,
   .start_up = NULL,
diff --git a/btcore/src/property.c b/btcore/src/property.cc
similarity index 96%
rename from btcore/src/property.c
rename to btcore/src/property.cc
index 23cad19..9d49daa 100644
--- a/btcore/src/property.c
+++ b/btcore/src/property.cc
@@ -28,7 +28,7 @@
 
 bt_property_t *property_copy_array(const bt_property_t *properties, size_t count) {
   assert(properties != NULL);
-  bt_property_t *clone = osi_calloc(sizeof(bt_property_t) * count);
+  bt_property_t *clone = static_cast<bt_property_t *>(osi_calloc(sizeof(bt_property_t) * count));
 
   memcpy(&clone[0], &properties[0], sizeof(bt_property_t) * count);
   for (size_t i = 0; i < count; ++i) {
@@ -206,7 +206,7 @@
 }
 
 static bt_property_t *property_new_(void *val, size_t len, bt_property_type_t type) {
-  bt_property_t *property = osi_calloc(sizeof(bt_property_t));
+  bt_property_t *property = static_cast<bt_property_t *>(osi_calloc(sizeof(bt_property_t)));
 
   property->val = osi_malloc(len);
   memcpy(property->val, val, len);
diff --git a/btcore/src/uuid.c b/btcore/src/uuid.cc
similarity index 96%
rename from btcore/src/uuid.c
rename to btcore/src/uuid.cc
index 842f29e..f4d35e9 100644
--- a/btcore/src/uuid.c
+++ b/btcore/src/uuid.cc
@@ -42,7 +42,7 @@
 static bool uuid_is_base(const bt_uuid_t *uuid);
 
 uuid_string_t *uuid_string_new(void) {
-  return osi_calloc(UUID_WELL_FORMED_STRING_LEN_WITH_NULL);
+  return static_cast<uuid_string_t *>(osi_calloc(UUID_WELL_FORMED_STRING_LEN_WITH_NULL));
 }
 
 void uuid_string_free(uuid_string_t *uuid_string) {
@@ -62,7 +62,7 @@
   if (uuid_string[8] != '-' || uuid_string[13] != '-' || uuid_string[18] != '-' || uuid_string[23] != '-')
     return NULL;
 
-  bt_uuid_t *uuid = osi_calloc(sizeof(bt_uuid_t));
+  bt_uuid_t *uuid = static_cast<bt_uuid_t *>(osi_calloc(sizeof(bt_uuid_t)));
 
   const char *s = uuid_string;
   for (size_t i = 0; i < sizeof(bt_uuid_t); ++i, s+=2) {
diff --git a/btcore/test/bdaddr_test.cc b/btcore/test/bdaddr_test.cc
index 5114a51..0439c79 100644
--- a/btcore/test/bdaddr_test.cc
+++ b/btcore/test/bdaddr_test.cc
@@ -18,9 +18,7 @@
 
 #include <gtest/gtest.h>
 
-extern "C" {
 #include "btcore/include/bdaddr.h"
-}
 
 static const char* test_addr = "12:34:56:78:9a:bc";
 static const char* test_addr2 = "cb:a9:87:65:43:21";
diff --git a/btcore/test/device_class_test.cc b/btcore/test/device_class_test.cc
index c3098a2..af9ed79 100644
--- a/btcore/test/device_class_test.cc
+++ b/btcore/test/device_class_test.cc
@@ -20,9 +20,7 @@
 #include <gtest/gtest.h>
 #include "osi/test/AllocationTestHarness.h"
 
-extern "C" {
 #include "btcore/include/device_class.h"
-}  // "C"
 
 // Device Class is 3 bytes.
 static const int DC_MASK = 0xffffff;
diff --git a/btcore/test/property_test.cc b/btcore/test/property_test.cc
index 8032e97..649be35 100644
--- a/btcore/test/property_test.cc
+++ b/btcore/test/property_test.cc
@@ -20,9 +20,7 @@
 #include <gtest/gtest.h>
 #include "osi/test/AllocationTestHarness.h"
 
-extern "C" {
 #include "btcore/include/property.h"
-}  // "C"
 
 class PropertyTest : public AllocationTestHarness {};
 
diff --git a/btcore/test/uuid_test.cc b/btcore/test/uuid_test.cc
index deef64c..cb7f16b 100644
--- a/btcore/test/uuid_test.cc
+++ b/btcore/test/uuid_test.cc
@@ -19,9 +19,7 @@
 #include <gtest/gtest.h>
 #include "osi/test/AllocationTestHarness.h"
 
-extern "C" {
 #include "btcore/include/uuid.h"
-}
 
 static const char *UUID_EMPTY = "00000000-0000-0000-0000-000000000000";
 static const char *UUID_ONES = "11111111-1111-1111-1111-111111111111";
diff --git a/btif/Android.mk b/btif/Android.mk
index 17a1e82..d5deb20 100644
--- a/btif/Android.mk
+++ b/btif/Android.mk
@@ -52,10 +52,12 @@
   src/btif_hf_client.cc \
   src/btif_hh.cc \
   src/btif_hl.cc \
-  src/btif_sdp.cc \
+  src/btif_mce.cc \
   src/btif_pan.cc \
   src/btif_profile_queue.cc \
   src/btif_rc.cc \
+  src/btif_sdp.cc \
+  src/btif_sdp_server.cc \
   src/btif_sm.cc \
   src/btif_sock.cc \
   src/btif_sock_rfc.cc \
@@ -63,7 +65,6 @@
   src/btif_sock_sco.cc \
   src/btif_sock_sdp.cc \
   src/btif_sock_thread.cc \
-  src/btif_sdp_server.cc \
   src/btif_sock_util.cc \
   src/btif_storage.cc \
   src/btif_uid.cc \
diff --git a/btif/include/btif_common.h b/btif/include/btif_common.h
index c330e52..c53c8e5 100644
--- a/btif/include/btif_common.h
+++ b/btif/include/btif_common.h
@@ -219,6 +219,7 @@
 
 void bte_load_did_conf(const char *p_path);
 void bte_main_boot_entry(void);
+void bte_main_enable(void);
 void bte_main_disable(void);
 void bte_main_cleanup(void);
 #if (HCILP_INCLUDED == TRUE)
diff --git a/btif/include/btif_util.h b/btif/include/btif_util.h
index 7bcb937..3e260b3 100644
--- a/btif/include/btif_util.h
+++ b/btif/include/btif_util.h
@@ -74,6 +74,6 @@
 
 int ascii_2_hex (const char *p_ascii, int len, uint8_t *p_hex);
 
-extern "C" void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str, size_t str_len);
+void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str, size_t str_len);
 
 #endif /* BTIF_UTIL_H */
diff --git a/btif/src/btif_config_transcode.cc b/btif/src/btif_config_transcode.cc
index 5998737..302ea42 100644
--- a/btif/src/btif_config_transcode.cc
+++ b/btif/src/btif_config_transcode.cc
@@ -20,10 +20,8 @@
 
 #include <tinyxml2.h>
 
-extern "C" {
 #include "osi/include/config.h"
 #include "osi/include/log.h"
-}
 
 using namespace tinyxml2;
 
diff --git a/btif/src/btif_sdp_server.cc b/btif/src/btif_sdp_server.cc
index 0891a7a..b338411 100644
--- a/btif/src/btif_sdp_server.cc
+++ b/btif/src/btif_sdp_server.cc
@@ -18,7 +18,7 @@
 
 /************************************************************************************
  *
- *  Filename:      btif_sdp_server.c
+ *  Filename:      btif_sdp_server.cc
  *  Description:   SDP server Bluetooth Interface to create and remove SDP records.
  *                 To be used in combination with the RFCOMM/L2CAP(LE) sockets.
  *
diff --git a/btif/src/btif_sock_rfc.cc b/btif/src/btif_sock_rfc.cc
index a55ad41..b4fd65d 100644
--- a/btif/src/btif_sock_rfc.cc
+++ b/btif/src/btif_sock_rfc.cc
@@ -109,8 +109,6 @@
   return pth != -1;
 }
 
-extern "C" int PORT_FlowControl_MaxCredit(uint16_t handle, bool enable);
-
 bt_status_t btsock_rfc_init(int poll_thread_handle, uid_set_t* set) {
   pth = poll_thread_handle;
   uid_set = set;
diff --git a/btif/src/stack_manager.cc b/btif/src/stack_manager.cc
index 03bfb3f..d8dfb2d 100644
--- a/btif/src/stack_manager.cc
+++ b/btif/src/stack_manager.cc
@@ -55,7 +55,6 @@
 
 // Unvetted includes/imports, etc which should be removed or vetted in the future
 static future_t *hack_future;
-extern "C" void bte_main_enable();
 void btif_thread_post(thread_fn func, void *context);
 // End unvetted section
 
diff --git a/device/Android.mk b/device/Android.mk
index 29e2be7..c66df8b 100644
--- a/device/Android.mk
+++ b/device/Android.mk
@@ -33,8 +33,8 @@
     $(bluetooth_C_INCLUDES)
 
 LOCAL_SRC_FILES := \
-    src/controller.c \
-    src/interop.c
+    src/controller.cc \
+    src/interop.cc
 
 LOCAL_MODULE := libbtdevice
 LOCAL_MODULE_TAGS := optional
diff --git a/device/BUILD.gn b/device/BUILD.gn
index ada00ed..ffaa10d 100644
--- a/device/BUILD.gn
+++ b/device/BUILD.gn
@@ -16,8 +16,8 @@
 
 static_library("device") {
   sources = [
-    "src/controller.c",
-    "src/interop.c",
+    "src/controller.cc",
+    "src/interop.cc",
   ]
 
   include_dirs = [
diff --git a/device/src/controller.c b/device/src/controller.cc
similarity index 97%
rename from device/src/controller.c
rename to device/src/controller.cc
index 4440ea5..32e4f8c 100644
--- a/device/src/controller.c
+++ b/device/src/controller.cc
@@ -30,7 +30,9 @@
 #include "osi/include/future.h"
 #include "stack/include/btm_ble_api.h"
 
-const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x06\x7f" };
+const bt_event_mask_t BLE_EVENT_MASK = {
+  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x7f}
+};
 
 #if (BLE_INCLUDED)
 const bt_event_mask_t CLASSIC_EVENT_MASK = { HCI_DUMO_EVENT_MASK_EXT };
@@ -76,7 +78,7 @@
 static bool simple_pairing_supported;
 static bool secure_connections_supported;
 
-#define AWAIT_COMMAND(command) future_await(hci->transmit_command_futured(command))
+#define AWAIT_COMMAND(command) static_cast<BT_HDR *>(future_await(hci->transmit_command_futured(command)))
 
 // Module lifecycle functions
 
@@ -261,7 +263,7 @@
   return future_new_immediate(FUTURE_SUCCESS);
 }
 
-EXPORT_SYMBOL const module_t controller_module = {
+EXPORT_SYMBOL extern const module_t controller_module = {
   .name = CONTROLLER_MODULE,
   .init = NULL,
   .start_up = start_up,
diff --git a/device/src/interop.c b/device/src/interop.cc
similarity index 94%
rename from device/src/interop.c
rename to device/src/interop.cc
index 50020f7..e51f6b5 100644
--- a/device/src/interop.c
+++ b/device/src/interop.cc
@@ -74,9 +74,10 @@
   assert(length > 0);
   assert(length < sizeof(bt_bdaddr_t));
 
-  interop_addr_entry_t *entry = osi_calloc(sizeof(interop_addr_entry_t));
+  interop_addr_entry_t *entry =
+      static_cast<interop_addr_entry_t *>(osi_calloc(sizeof(interop_addr_entry_t)));
   memcpy(&entry->addr, addr, length);
-  entry->feature = feature;
+  entry->feature = static_cast<interop_feature_t>(feature);
   entry->length = length;
 
   interop_lazy_init_();
@@ -137,7 +138,8 @@
 
   const list_node_t *node = list_begin(interop_list);
   while (node != list_end(interop_list)) {
-    interop_addr_entry_t *entry = list_node(node);
+    interop_addr_entry_t *entry =
+        static_cast<interop_addr_entry_t *>(list_node(node));
     assert(entry);
 
     if (feature == entry->feature && memcmp(addr, &entry->addr, entry->length) == 0)
diff --git a/device/test/interop_test.cc b/device/test/interop_test.cc
index ef4f1c5..f530708 100644
--- a/device/test/interop_test.cc
+++ b/device/test/interop_test.cc
@@ -18,9 +18,7 @@
 
 #include <gtest/gtest.h>
 
-extern "C" {
 #include "device/include/interop.h"
-}
 
 TEST(InteropTest, test_lookup_hit) {
   bt_bdaddr_t test_address;
diff --git a/doc/network_ports.md b/doc/network_ports.md
index 5244a14..03e138e 100644
--- a/doc/network_ports.md
+++ b/doc/network_ports.md
@@ -4,5 +4,5 @@
 It should be used as a reference and as a mechanism to avoid port
 namespace conflicts.
 
-* TCP 8872 (hci/src/btsnoop_net.c) - read live btsnoop logs
-* TCP 8873 (hci/src/hci_inject.c) - inject HCI packets into HCI stream
+* TCP 8872 (hci/src/btsnoop_net.cc) - read live btsnoop logs
+* TCP 8873 (hci/src/hci_inject.cc) - inject HCI packets into HCI stream
diff --git a/doc/power_management.md b/doc/power_management.md
index b40f854..2b90130 100644
--- a/doc/power_management.md
+++ b/doc/power_management.md
@@ -21,7 +21,7 @@
   - `BTA_SYS_SCO_OPEN`
   - `BTA_SYS_SCO_CLOSE`
 
-Each of these correspond to a function name in `bta/sys/bta_sys_conn.c`, which
+Each of these correspond to a function name in `bta/sys/bta_sys_conn.cc`, which
 are called by each profile definition in `bta/$PROFILE`.
 
 The PM code makes calls into the BTM module to set various power
@@ -43,7 +43,7 @@
 
 The tables that determine which power levels are acceptable for which profiles
 and what actions to take for the above events are defined in the
-`bta/dm/bta_dm_cfg.c` file, as `bta_dm_pm_cfg`, `bta_dm_pm_spec`, and
+`bta/dm/bta_dm_cfg.cc` file, as `bta_dm_pm_cfg`, `bta_dm_pm_spec`, and
 `bta_dm_ssr_spec`.
 
 During a lookup attempt, the code iterates over the `bta_dm_pm_cfg` array,
@@ -75,7 +75,7 @@
 
 ### Initialization
 
-`bta_dm_pm.c`'s `bta_dm_init_pm` function calls out to register
+`bta_dm_pm.cc`'s `bta_dm_init_pm` function calls out to register
 `bta_dm_pm_cback` with the bta sys module for incoming power management events,
 and also registers `bta_dm_pm_btm_cback` with the btm module to handle responses
 and timeouts of HCI requests (via `bta_dm_pm_btm_status`).
@@ -83,17 +83,17 @@
 At this point, the power managment code is basically done until the first set of
 events come in through `bta_dm_pm_cback`.
 
-Throughout the `bta_dm_pm.c` file, connections whose power management states are
+Throughout the `bta_dm_pm.cc` file, connections whose power management states are
 managed are tracked in a global array called `bta_dm_conn_srvcs`. Unfortunately,
 while this variable is declared as an extern in the `bta_dm_int.h` file, it only
-seems to be used in the `bta_dm_act.c` file, and only for reinitialization.
+seems to be used in the `bta_dm_act.cc` file, and only for reinitialization.
 
 ### Event flow
 
 #### Events fired from SYS
 
   1. An event is fired from one of the methods mentioned above in
-     `bta/sys/bta_sys_conn.c`
+     `bta/sys/bta_sys_conn.cc`
   2. The `bta_dm_pm_cback` function is called.
      - The power mode config is looked up in the `bta_dm_pm_cfg` table. If none
        are found for the given profile ID and app ID, the function simply
diff --git a/doc/properties.md b/doc/properties.md
index 06c2bf4..c4ab97c 100644
--- a/doc/properties.md
+++ b/doc/properties.md
@@ -7,7 +7,7 @@
 
 * ``` bluetooth.enable_timeout_ms ```  
   Maximum amount of time Bluetooth can take to start-up, upload firmware etc.  
-  Used in hci/src/hci_layer.c, default 8000.
+  Used in hci/src/hci_layer.cc, default 8000.
 
 ### TODO: write descriptions of what each property means and how
 it's used.
diff --git a/embdrv/sbc/decoder/Android.mk b/embdrv/sbc/decoder/Android.mk
index fc6e8d6..4a967c0 100644
--- a/embdrv/sbc/decoder/Android.mk
+++ b/embdrv/sbc/decoder/Android.mk
@@ -4,6 +4,8 @@
 # ========================================================
 include $(CLEAR_VARS)
 
+LOCAL_CPP_EXTENSION := .cc
+
 # sbc decoder
 LOCAL_SRC_FILES := \
         ./srce/alloc.c \
diff --git a/embdrv/sbc/encoder/include/sbc_encoder.h b/embdrv/sbc/encoder/include/sbc_encoder.h
index 2877855..91b4874 100644
--- a/embdrv/sbc/encoder/include/sbc_encoder.h
+++ b/embdrv/sbc/encoder/include/sbc_encoder.h
@@ -191,12 +191,14 @@
 }SBC_ENC_PARAMS;
 
 #ifdef __cplusplus
-extern "C"
-{
+extern "C" {
 #endif
+
 extern void SBC_Encoder(SBC_ENC_PARAMS *strEncParams);
 extern void SBC_Encoder_Init(SBC_ENC_PARAMS *strEncParams);
+
 #ifdef __cplusplus
 }
 #endif
-#endif
+
+#endif /* SBC_ENCODER_H */
diff --git a/hci/Android.mk b/hci/Android.mk
index fce5f51..2f42798 100644
--- a/hci/Android.mk
+++ b/hci/Android.mk
@@ -6,21 +6,21 @@
 LOCAL_CPP_EXTENSION := .cc
 
 LOCAL_SRC_FILES := \
-    src/btsnoop.c \
-    src/btsnoop_mem.c \
-    src/btsnoop_net.c \
-    src/buffer_allocator.c \
-    src/hci_audio.c \
-    src/hci_hal.c \
-    src/hci_hal_h4.c \
-    src/hci_hal_mct.c \
-    src/hci_inject.c \
-    src/hci_layer.c \
-    src/hci_packet_factory.c \
-    src/hci_packet_parser.c \
-    src/low_power_manager.c \
+    src/btsnoop.cc \
+    src/btsnoop_mem.cc \
+    src/btsnoop_net.cc \
+    src/buffer_allocator.cc \
+    src/hci_audio.cc \
+    src/hci_hal.cc \
+    src/hci_hal_h4.cc \
+    src/hci_hal_mct.cc \
+    src/hci_inject.cc \
+    src/hci_layer.cc \
+    src/hci_packet_factory.cc \
+    src/hci_packet_parser.cc \
+    src/low_power_manager.cc \
     src/packet_fragmenter.cc \
-    src/vendor.c \
+    src/vendor.cc \
     ../EventLogTags.logtags
 
 LOCAL_C_INCLUDES := \
diff --git a/hci/BUILD.gn b/hci/BUILD.gn
index 23d3862..ec53c34 100644
--- a/hci/BUILD.gn
+++ b/hci/BUILD.gn
@@ -16,21 +16,21 @@
 
 static_library("hci") {
   sources = [
-    "src/btsnoop.c",
-    "src/btsnoop_mem.c",
-    "src/btsnoop_net.c",
-    "src/buffer_allocator.c",
-    "src/hci_audio.c",
-    "src/hci_hal.c",
-    "src/hci_hal_h4.c",
-    "src/hci_hal_mct.c",
-    "src/hci_inject.c",
-    "src/hci_layer.c",
-    "src/hci_packet_factory.c",
-    "src/hci_packet_parser.c",
-    "src/low_power_manager.c",
+    "src/btsnoop.cc",
+    "src/btsnoop_mem.cc",
+    "src/btsnoop_net.cc",
+    "src/buffer_allocator.cc",
+    "src/hci_audio.cc",
+    "src/hci_hal.cc",
+    "src/hci_hal_h4.cc",
+    "src/hci_hal_mct.cc",
+    "src/hci_inject.cc",
+    "src/hci_layer.cc",
+    "src/hci_packet_factory.cc",
+    "src/hci_packet_parser.cc",
+    "src/low_power_manager.cc",
     "src/packet_fragmenter.cc",
-    "src/vendor.c",
+    "src/vendor.cc",
   ]
 
   include_dirs = [
diff --git a/hci/include/hci_hal.h b/hci/include/hci_hal.h
index 0403826..764cfe2 100644
--- a/hci/include/hci_hal.h
+++ b/hci/include/hci_hal.h
@@ -29,6 +29,7 @@
 #endif
 
 typedef enum {
+  DATA_TYPE_UNKNOWN = 0,
   DATA_TYPE_COMMAND = 1,
   DATA_TYPE_ACL     = 2,
   DATA_TYPE_SCO     = 3,
diff --git a/hci/src/btsnoop.c b/hci/src/btsnoop.cc
similarity index 98%
rename from hci/src/btsnoop.c
rename to hci/src/btsnoop.cc
index 5a9e55e..a38ec5b 100644
--- a/hci/src/btsnoop.c
+++ b/hci/src/btsnoop.cc
@@ -81,7 +81,7 @@
   return NULL;
 }
 
-EXPORT_SYMBOL const module_t btsnoop_module = {
+EXPORT_SYMBOL extern const module_t btsnoop_module = {
   .name = BTSNOOP_MODULE,
   .init = NULL,
   .start_up = start_up,
diff --git a/hci/src/btsnoop_mem.c b/hci/src/btsnoop_mem.cc
similarity index 100%
rename from hci/src/btsnoop_mem.c
rename to hci/src/btsnoop_mem.cc
diff --git a/hci/src/btsnoop_net.c b/hci/src/btsnoop_net.cc
similarity index 99%
rename from hci/src/btsnoop_net.c
rename to hci/src/btsnoop_net.cc
index 0ede977..26605c0 100644
--- a/hci/src/btsnoop_net.c
+++ b/hci/src/btsnoop_net.cc
@@ -90,6 +90,7 @@
 }
 
 static void *listen_fn_(UNUSED_ATTR void *context) {
+  int enable = 1;
 
   prctl(PR_SET_NAME, (unsigned long)LISTEN_THREAD_NAME_, 0, 0, 0);
 
@@ -99,7 +100,6 @@
     goto cleanup;
   }
 
-  int enable = 1;
   if (setsockopt(listen_socket_, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) == -1) {
     LOG_ERROR(LOG_TAG, "%s unable to set SO_REUSEADDR: %s", __func__, strerror(errno));
     goto cleanup;
diff --git a/hci/src/buffer_allocator.c b/hci/src/buffer_allocator.cc
similarity index 100%
rename from hci/src/buffer_allocator.c
rename to hci/src/buffer_allocator.cc
diff --git a/hci/src/hci_audio.c b/hci/src/hci_audio.cc
similarity index 100%
rename from hci/src/hci_audio.c
rename to hci/src/hci_audio.cc
diff --git a/hci/src/hci_hal.c b/hci/src/hci_hal.cc
similarity index 100%
rename from hci/src/hci_hal.c
rename to hci/src/hci_hal.cc
diff --git a/hci/src/hci_hal_h4.c b/hci/src/hci_hal_h4.cc
similarity index 93%
rename from hci/src/hci_hal_h4.c
rename to hci/src/hci_hal_h4.cc
index 4febeb4..50b9265 100644
--- a/hci/src/hci_hal_h4.c
+++ b/hci/src/hci_hal_h4.cc
@@ -40,8 +40,26 @@
 
 #define BT_HCI_UNKNOWN_MESSAGE_TYPE_NUM 1010002
 
+static bool hal_init(const hci_hal_callbacks_t *upper_callbacks,
+                     thread_t *upper_thread);
+static bool hal_open(void);
+static void hal_close(void);
+static void packet_finished(serial_data_type_t type);
+static uint16_t transmit_data(serial_data_type_t type, uint8_t *data,
+                              uint16_t length);
+static size_t read_data(serial_data_type_t type, uint8_t *buffer,
+                        size_t max_size);
+static void event_uart_has_bytes(eager_reader_t *reader, void *context);
+
 // Our interface and modules we import
-static const hci_hal_t interface;
+static const hci_hal_t interface = {
+  hal_init,
+  hal_open,
+  hal_close,
+  read_data,
+  packet_finished,
+  transmit_data,
+};
 static const hci_hal_callbacks_t *callbacks;
 static const vendor_t *vendor;
 
@@ -54,8 +72,6 @@
 static bool stream_corruption_detected;
 static uint8_t stream_corruption_bytes_to_ignore;
 
-static void event_uart_has_bytes(eager_reader_t *reader, void *context);
-
 // Interface functions
 
 static bool hal_init(const hci_hal_callbacks_t *upper_callbacks, thread_t *upper_thread) {
@@ -67,7 +83,7 @@
   return true;
 }
 
-static bool hal_open() {
+static bool hal_open(void) {
   LOG_INFO(LOG_TAG, "%s", __func__);
   // TODO(zachoverflow): close if already open / or don't reopen (maybe at the hci layer level)
 
@@ -107,7 +123,7 @@
   return false;
 }
 
-static void hal_close() {
+static void hal_close(void) {
   LOG_INFO(LOG_TAG, "%s", __func__);
 
   eager_reader_free(uart_stream);
@@ -248,21 +264,10 @@
     }
 
     stream_has_interpretation = true;
-    current_data_type = type_byte;
+    current_data_type = static_cast<serial_data_type_t>(type_byte);
   }
 }
 
-static const hci_hal_t interface = {
-  hal_init,
-
-  hal_open,
-  hal_close,
-
-  read_data,
-  packet_finished,
-  transmit_data,
-};
-
 const hci_hal_t *hci_hal_h4_get_interface() {
   vendor = vendor_get_interface();
   return &interface;
diff --git a/hci/src/hci_hal_mct.c b/hci/src/hci_hal_mct.cc
similarity index 92%
rename from hci/src/hci_hal_mct.c
rename to hci/src/hci_hal_mct.cc
index 128beee..3700e09 100644
--- a/hci/src/hci_hal_mct.c
+++ b/hci/src/hci_hal_mct.cc
@@ -33,8 +33,29 @@
 
 #define HCI_HAL_SERIAL_BUFFER_SIZE 1026
 
+static bool hal_init(const hci_hal_callbacks_t *upper_callbacks,
+                     thread_t *upper_thread);
+static bool hal_open(void);
+static void hal_close(void);
+static size_t read_data(serial_data_type_t type, uint8_t *buffer,
+                        size_t max_size);
+static void packet_finished(UNUSED_ATTR serial_data_type_t type);
+static uint16_t transmit_data(serial_data_type_t type, uint8_t *data,
+                              uint16_t length);
+static uint16_t transmit_data_on(int fd, uint8_t *data, uint16_t length);
+static void event_event_stream_has_bytes(eager_reader_t *reader, void *context);
+static void event_acl_stream_has_bytes(eager_reader_t *reader, void *context);
+
+
 // Our interface and modules we import
-static const hci_hal_t interface;
+static const hci_hal_t interface = {
+  hal_init,
+  hal_open,
+  hal_close,
+  read_data,
+  packet_finished,
+  transmit_data,
+};
 static const hci_hal_callbacks_t *callbacks;
 static const vendor_t *vendor;
 
@@ -44,10 +65,6 @@
 static eager_reader_t *event_stream;
 static eager_reader_t *acl_stream;
 
-static uint16_t transmit_data_on(int fd, uint8_t *data, uint16_t length);
-static void event_event_stream_has_bytes(eager_reader_t *reader, void *context);
-static void event_acl_stream_has_bytes(eager_reader_t *reader, void *context);
-
 // Interface functions
 
 static bool hal_init(const hci_hal_callbacks_t *upper_callbacks, thread_t *upper_thread) {
@@ -59,7 +76,7 @@
   return true;
 }
 
-static bool hal_open() {
+static bool hal_open(void) {
   LOG_INFO(LOG_TAG, "%s", __func__);
   // TODO(zachoverflow): close if already open / or don't reopen (maybe at the hci layer level)
 
@@ -115,7 +132,7 @@
   return false;
 }
 
-static void hal_close() {
+static void hal_close(void) {
   LOG_INFO(LOG_TAG, "%s", __func__);
 
   eager_reader_free(event_stream);
@@ -193,17 +210,6 @@
   callbacks->data_ready(DATA_TYPE_ACL);
 }
 
-static const hci_hal_t interface = {
-  hal_init,
-
-  hal_open,
-  hal_close,
-
-  read_data,
-  packet_finished,
-  transmit_data,
-};
-
 const hci_hal_t *hci_hal_mct_get_interface() {
   vendor = vendor_get_interface();
   return &interface;
diff --git a/hci/src/hci_inject.c b/hci/src/hci_inject.cc
similarity index 96%
rename from hci/src/hci_inject.c
rename to hci/src/hci_inject.cc
index a5b6c27..2451646 100644
--- a/hci/src/hci_inject.c
+++ b/hci/src/hci_inject.cc
@@ -47,21 +47,27 @@
   size_t buffer_size;
 } client_t;
 
+static bool hci_inject_open(const hci_t *hci_interface);
+static void hci_inject_close(void);
+static int hci_packet_to_event(hci_packet_t packet);
+static void accept_ready(socket_t *socket, void *context);
+static void read_ready(socket_t *socket, void *context);
+static void client_free(void *ptr);
+
 static const port_t LISTEN_PORT = 8873;
 
-static const hci_inject_t interface;
+static const hci_inject_t interface = {
+  hci_inject_open,
+  hci_inject_close
+};
+
 static const hci_t *hci;
 static const allocator_t *buffer_allocator;
 static socket_t *listen_socket;
 static thread_t *thread;
 static list_t *clients;
 
-static int hci_packet_to_event(hci_packet_t packet);
-static void accept_ready(socket_t *socket, void *context);
-static void read_ready(socket_t *socket, void *context);
-static void client_free(void *ptr);
-
-bool hci_inject_open(const hci_t *hci_interface) {
+static bool hci_inject_open(const hci_t *hci_interface) {
 #if (BT_NET_DEBUG != TRUE)
   return true;          // Disable using network sockets for security reasons
 #endif
@@ -96,7 +102,7 @@
   return false;
 }
 
-void hci_inject_close(void) {
+static void hci_inject_close(void) {
 #if (BT_NET_DEBUG != TRUE)
   return;               // Disable using network sockets for security reasons
 #endif
@@ -198,11 +204,6 @@
   osi_free(client);
 }
 
-static const hci_inject_t interface = {
-  hci_inject_open,
-  hci_inject_close
-};
-
 const hci_inject_t *hci_inject_get_interface() {
   buffer_allocator = buffer_allocator_get_interface();
   return &interface;
diff --git a/hci/src/hci_layer.c b/hci/src/hci_layer.cc
similarity index 96%
rename from hci/src/hci_layer.c
rename to hci/src/hci_layer.cc
index 217fa91..6e5b4df 100644
--- a/hci/src/hci_layer.c
+++ b/hci/src/hci_layer.cc
@@ -46,7 +46,7 @@
 
 // TODO(zachoverflow): remove this hack extern
 #include <hardware/bluetooth.h>
-bt_bdaddr_t btif_local_bd_addr;
+extern bt_bdaddr_t btif_local_bd_addr;
 
 #define INBOUND_PACKET_TYPE_COUNT 3
 #define PACKET_TYPE_TO_INBOUND_INDEX(type) ((type) - 2)
@@ -104,7 +104,45 @@
 static const uint32_t EPILOG_TIMEOUT_MS = 3000;
 static const uint32_t COMMAND_PENDING_TIMEOUT_MS = 8000;
 
+static future_t *shut_down();
+
+static void event_finish_startup(void *context);
+static void firmware_config_callback(bool success);
+static void startup_timer_expired(void *context);
+
+static void event_postload(void *context);
+static void sco_config_callback(bool success);
+
+static void event_epilog(void *context);
+static void epilog_finished_callback(bool success);
+static void epilog_timer_expired(void *context);
+
+static void event_command_ready(fixed_queue_t *queue, void *context);
+static void event_packet_ready(fixed_queue_t *queue, void *context);
+static void transmit_fragment(BT_HDR *packet, bool send_transmit_finished);
+static void fragmenter_transmit_finished(BT_HDR *packet,
+                                         bool all_fragments_sent);
+static void dispatch_reassembled(BT_HDR *packet);
+static void command_timed_out(void *context);
+
+static void hal_says_data_ready(serial_data_type_t type);
+static bool filter_incoming_event(BT_HDR *packet);
+
+static serial_data_type_t event_to_data_type(uint16_t event);
+static waiting_command_t *get_waiting_command(command_opcode_t opcode);
+static void update_command_response_timer(void);
+
+
 // Our interface
+static const hci_hal_callbacks_t hal_callbacks = {
+  hal_says_data_ready
+};
+
+static const packet_fragmenter_callbacks_t packet_fragmenter_callbacks = {
+  transmit_fragment,
+  dispatch_reassembled,
+  fragmenter_transmit_finished
+};
 static bool interface_created;
 static hci_t interface;
 
@@ -112,11 +150,9 @@
 static const allocator_t *buffer_allocator;
 static const btsnoop_t *btsnoop;
 static const hci_hal_t *hal;
-static const hci_hal_callbacks_t hal_callbacks;
 static const hci_inject_t *hci_inject;
 static const low_power_manager_t *low_power_manager;
 static const packet_fragmenter_t *packet_fragmenter;
-static const packet_fragmenter_callbacks_t packet_fragmenter_callbacks;
 static const vendor_t *vendor;
 
 static future_t *startup_future;
@@ -140,33 +176,12 @@
 // The hand-off point for data going to a higher layer, set by the higher layer
 static fixed_queue_t *upwards_data_queue;
 
-static future_t *shut_down();
-
-static void event_finish_startup(void *context);
-static void firmware_config_callback(bool success);
-static void startup_timer_expired(void *context);
-
-static void event_postload(void *context);
-static void sco_config_callback(bool success);
-
-static void event_epilog(void *context);
-static void epilog_finished_callback(bool success);
-static void epilog_timer_expired(void *context);
-
-static void event_command_ready(fixed_queue_t *queue, void *context);
-static void event_packet_ready(fixed_queue_t *queue, void *context);
-static void command_timed_out(void *context);
-
-static void hal_says_data_ready(serial_data_type_t type);
-static bool filter_incoming_event(BT_HDR *packet);
-
-static serial_data_type_t event_to_data_type(uint16_t event);
-static waiting_command_t *get_waiting_command(command_opcode_t opcode);
-static void update_command_response_timer(void);
-
 // Module lifecycle functions
 
 static future_t *start_up(void) {
+  int power_state = BT_VND_PWR_OFF;
+  future_t *local_startup_future;
+
   LOG_INFO(LOG_TAG, "%s", __func__);
 
   // The host is only allowed to send at most one command initially,
@@ -231,7 +246,7 @@
   memset(incoming_packets, 0, sizeof(incoming_packets));
 
   // Make sure we run in a bounded amount of time
-  future_t *local_startup_future = future_new();
+  local_startup_future = future_new();
   startup_future = local_startup_future;
   alarm_set(startup_timer, startup_timeout_ms, startup_timer_expired, NULL);
 
@@ -252,7 +267,6 @@
     // TODO(sharvil): gracefully propagate failures from this layer.
   }
 
-  int power_state = BT_VND_PWR_OFF;
 #if (BT_CLEAN_TURN_ON_DISABLED == TRUE)
   LOG_WARN(LOG_TAG, "%s not turning off the chip before turning on.", __func__);
   // So apparently this hack was needed in the past because a Wingray kernel driver
@@ -327,7 +341,7 @@
   return NULL;
 }
 
-EXPORT_SYMBOL const module_t hci_module = {
+EXPORT_SYMBOL extern const module_t hci_module = {
   .name = HCI_MODULE,
   .init = NULL,
   .start_up = start_up,
@@ -355,7 +369,8 @@
     command_complete_cb complete_callback,
     command_status_cb status_callback,
     void *context) {
-  waiting_command_t *wait_entry = osi_calloc(sizeof(waiting_command_t));
+  waiting_command_t *wait_entry =
+      static_cast<waiting_command_t *>(osi_calloc(sizeof(waiting_command_t)));
 
   uint8_t *stream = command->data + command->offset;
   STREAM_TO_UINT16(wait_entry->opcode, stream);
@@ -372,7 +387,8 @@
 }
 
 static future_t *transmit_command_futured(BT_HDR *command) {
-  waiting_command_t *wait_entry = osi_calloc(sizeof(waiting_command_t));
+  waiting_command_t *wait_entry =
+      static_cast<waiting_command_t *>(osi_calloc(sizeof(waiting_command_t)));
   future_t *future = future_new();
 
   uint8_t *stream = command->data + command->offset;
@@ -472,7 +488,8 @@
 
 static void event_command_ready(fixed_queue_t *queue, UNUSED_ATTR void *context) {
   if (command_credits > 0) {
-    waiting_command_t *wait_entry = fixed_queue_dequeue(queue);
+    waiting_command_t *wait_entry =
+        static_cast<waiting_command_t *>(fixed_queue_dequeue(queue));
     command_credits--;
 
     // Move it to the list of commands awaiting response
@@ -527,7 +544,8 @@
   if (list_is_empty(commands_pending_response)) {
     LOG_ERROR(LOG_TAG, "%s with no commands pending response", __func__);
   } else {
-    waiting_command_t *wait_entry = list_front(commands_pending_response);
+    waiting_command_t *wait_entry =
+        static_cast<waiting_command_t *>(list_front(commands_pending_response));
     pthread_mutex_unlock(&commands_pending_response_lock);
 
     // We shouldn't try to recover the stack from this command timeout.
@@ -588,6 +606,7 @@
 
         break;
       case BODY:
+      {
         incoming->buffer->data[incoming->index] = byte;
         incoming->index++;
         incoming->bytes_remaining--;
@@ -598,6 +617,7 @@
 
         incoming->state = incoming->bytes_remaining == 0 ? FINISHED : incoming->state;
         break;
+      }
       case IGNORE:
         incoming->bytes_remaining--;
         if (incoming->bytes_remaining == 0) {
@@ -743,7 +763,7 @@
   else
     LOG_ERROR(LOG_TAG, "%s invalid event type, could not translate 0x%x", __func__, event);
 
-  return 0;
+  return DATA_TYPE_UNKNOWN;
 }
 
 static waiting_command_t *get_waiting_command(command_opcode_t opcode) {
@@ -752,7 +772,8 @@
   for (const list_node_t *node = list_begin(commands_pending_response);
       node != list_end(commands_pending_response);
       node = list_next(node)) {
-    waiting_command_t *wait_entry = list_node(node);
+    waiting_command_t *wait_entry =
+        static_cast<waiting_command_t *>(list_node(node));
 
     if (!wait_entry || wait_entry->opcode != opcode)
       continue;
@@ -813,16 +834,6 @@
   }
 }
 
-static const hci_hal_callbacks_t hal_callbacks = {
-  hal_says_data_ready
-};
-
-static const packet_fragmenter_callbacks_t packet_fragmenter_callbacks = {
-  transmit_fragment,
-  dispatch_reassembled,
-  fragmenter_transmit_finished
-};
-
 const hci_t *hci_layer_get_interface() {
   buffer_allocator = buffer_allocator_get_interface();
   hal = hci_hal_get_interface();
diff --git a/hci/src/hci_packet_factory.c b/hci/src/hci_packet_factory.cc
similarity index 100%
rename from hci/src/hci_packet_factory.c
rename to hci/src/hci_packet_factory.cc
diff --git a/hci/src/hci_packet_parser.c b/hci/src/hci_packet_parser.cc
similarity index 100%
rename from hci/src/hci_packet_parser.c
rename to hci/src/hci_packet_parser.cc
diff --git a/hci/src/low_power_manager.c b/hci/src/low_power_manager.cc
similarity index 95%
rename from hci/src/low_power_manager.c
rename to hci/src/low_power_manager.cc
index f82a69f..cac5285 100644
--- a/hci/src/low_power_manager.c
+++ b/hci/src/low_power_manager.cc
@@ -43,10 +43,11 @@
   LPM_WAKE_ASSERTED,
 } wake_state_t;
 
-// Our interface and modules we import
-static const low_power_manager_t interface;
-static const vendor_t *vendor;
-
+static void init(thread_t *post_thread);
+static void cleanup(void);
+static void post_command(low_power_command_t command);
+static void wake_assert(void);
+static void transmit_done(void);
 static void vendor_enable_disable_callback(bool success);
 
 static void event_disable(void *context);
@@ -59,6 +60,17 @@
 static void start_idle_timer();
 static void stop_idle_timer();
 
+
+// Our interface and modules we import
+static const low_power_manager_t interface = {
+  init,
+  cleanup,
+  post_command,
+  wake_assert,
+  transmit_done
+};
+static const vendor_t *vendor;
+
 static thread_fn event_functions[] = {
   event_disable,
   event_enable,
@@ -90,7 +102,7 @@
   reset_state();
 }
 
-static void cleanup() {
+static void cleanup(void) {
   reset_state();
   alarm_free(idle_alarm);
   idle_alarm = NULL;
@@ -105,7 +117,7 @@
   thread_post(thread, event_functions[command], NULL);
 }
 
-static void wake_assert() {
+static void wake_assert(void) {
   if (state != LPM_DISABLED) {
     stop_idle_timer();
 
@@ -120,7 +132,7 @@
   transmit_is_done = false;
 }
 
-static void transmit_done() {
+static void transmit_done(void) {
   transmit_is_done = true;
   if (wake_state == LPM_WAKE_W4_TX_DONE || wake_state == LPM_WAKE_ASSERTED) {
     wake_state = LPM_WAKE_W4_TIMEOUT;
@@ -230,14 +242,6 @@
   }
 }
 
-static const low_power_manager_t interface = {
-  init,
-  cleanup,
-  post_command,
-  wake_assert,
-  transmit_done
-};
-
 const low_power_manager_t *low_power_manager_get_interface() {
   vendor = vendor_get_interface();
   return &interface;
diff --git a/hci/src/vendor.c b/hci/src/vendor.cc
similarity index 85%
rename from hci/src/vendor.c
rename to hci/src/vendor.cc
index c6bbd43..bc90229 100644
--- a/hci/src/vendor.c
+++ b/hci/src/vendor.cc
@@ -30,23 +30,62 @@
 #include "osi/include/osi.h"
 
 
+static bool vendor_open(const uint8_t *local_bdaddr,
+                        const hci_t *hci_interface);
+static void vendor_close(void);
+static int send_command(vendor_opcode_t opcode, void *param);
+static int send_async_command(vendor_async_opcode_t opcode, void *param);
+static void set_callback(vendor_async_opcode_t opcode, vendor_cb callback);
+
+static void firmware_config_cb(bt_vendor_op_result_t result);
+static void sco_config_cb(bt_vendor_op_result_t result);
+static void low_power_mode_cb(bt_vendor_op_result_t result);
+static void sco_audiostate_cb(bt_vendor_op_result_t result);
+static void *buffer_alloc_cb(int size);
+static void buffer_free_cb(void *buffer);
+static uint8_t transmit_cb(UNUSED_ATTR uint16_t opcode, void *buffer,
+                           tINT_CMD_CBACK callback);
+static void epilog_cb(bt_vendor_op_result_t result);
+static void a2dp_offload_cb(bt_vendor_op_result_t result,
+                            bt_vendor_opcode_t op, uint8_t bta_av_handle);
+
 static const char *VENDOR_LIBRARY_NAME = "libbt-vendor.so";
 static const char *VENDOR_LIBRARY_SYMBOL_NAME = "BLUETOOTH_VENDOR_LIB_INTERFACE";
 
-static const vendor_t interface;
 static const allocator_t *buffer_allocator;
 static const hci_t *hci;
 static vendor_cb callbacks[VENDOR_LAST_OP];
 
+static const bt_vendor_callbacks_t lib_callbacks = {
+  sizeof(lib_callbacks),
+  firmware_config_cb,
+  sco_config_cb,
+  low_power_mode_cb,
+  sco_audiostate_cb,
+  buffer_alloc_cb,
+  buffer_free_cb,
+  transmit_cb,
+  epilog_cb,
+  a2dp_offload_cb
+};
+
+static const vendor_t interface = {
+  vendor_open,
+  vendor_close,
+  send_command,
+  send_async_command,
+  set_callback,
+};
+
 static void *lib_handle;
 static bt_vendor_interface_t *lib_interface;
-static const bt_vendor_callbacks_t lib_callbacks;
 
 // Interface functions
 
 static bool vendor_open(
     const uint8_t *local_bdaddr,
     const hci_t *hci_interface) {
+  int status;
   assert(lib_handle == NULL);
   hci = hci_interface;
 
@@ -64,7 +103,7 @@
 
   LOG_INFO(LOG_TAG, "alloc value %p", lib_callbacks.alloc);
 
-  int status = lib_interface->init(&lib_callbacks, (unsigned char *)local_bdaddr);
+  status = lib_interface->init(&lib_callbacks, (unsigned char *)local_bdaddr);
   if (status) {
     LOG_ERROR(LOG_TAG, "%s unable to initialize vendor library: %d", __func__, status);
     goto error;
@@ -177,7 +216,8 @@
 // Called back from vendor library when it wants to send an HCI command.
 static uint8_t transmit_cb(UNUSED_ATTR uint16_t opcode, void *buffer, tINT_CMD_CBACK callback) {
   assert(hci != NULL);
-  hci->transmit_command((BT_HDR *)buffer, transmit_completed_callback, NULL, callback);
+  hci->transmit_command((BT_HDR *)buffer, transmit_completed_callback, NULL,
+                        reinterpret_cast<void *>(callback));
   return true;
 }
 
@@ -201,27 +241,6 @@
   }
 }
 
-static const bt_vendor_callbacks_t lib_callbacks = {
-  sizeof(lib_callbacks),
-  firmware_config_cb,
-  sco_config_cb,
-  low_power_mode_cb,
-  sco_audiostate_cb,
-  buffer_alloc_cb,
-  buffer_free_cb,
-  transmit_cb,
-  epilog_cb,
-  a2dp_offload_cb
-};
-
-static const vendor_t interface = {
-  vendor_open,
-  vendor_close,
-  send_command,
-  send_async_command,
-  set_callback,
-};
-
 const vendor_t *vendor_get_interface() {
   buffer_allocator = buffer_allocator_get_interface();
   return &interface;
diff --git a/hci/test/hci_hal_h4_test.cc b/hci/test/hci_hal_h4_test.cc
index 1b861a0..9ea6cdf 100644
--- a/hci/test/hci_hal_h4_test.cc
+++ b/hci/test/hci_hal_h4_test.cc
@@ -20,7 +20,6 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include <stdint.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -31,7 +30,6 @@
 #include "hci_hal.h"
 #include "test_stubs.h"
 #include "vendor.h"
-}
 
 DECLARE_TEST_MODES(
   init,
diff --git a/hci/test/hci_hal_mct_test.cc b/hci/test/hci_hal_mct_test.cc
index f40f323..caf81ec 100644
--- a/hci/test/hci_hal_mct_test.cc
+++ b/hci/test/hci_hal_mct_test.cc
@@ -20,7 +20,6 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include <stdint.h>
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -31,7 +30,6 @@
 #include "hci_hal.h"
 #include "test_stubs.h"
 #include "vendor.h"
-}
 
 DECLARE_TEST_MODES(
   init,
diff --git a/hci/test/hci_layer_test.cc b/hci/test/hci_layer_test.cc
index 771d9e0..8db5331 100644
--- a/hci/test/hci_layer_test.cc
+++ b/hci/test/hci_layer_test.cc
@@ -20,7 +20,6 @@
 
 #include "AlarmTestHarness.h"
 
-extern "C" {
 #include <stdint.h>
 
 #include "device/include/controller.h"
@@ -40,7 +39,6 @@
 #include "vendor.h"
 
 extern const module_t hci_module;
-}
 
 DECLARE_TEST_MODES(
   start_up_async,
@@ -55,6 +53,9 @@
   ignoring_packets_following_packet
 );
 
+// TODO: Ugly hack to get around another ugly hack in hci_layer.cc
+bt_bdaddr_t btif_local_bd_addr;
+
 static const char *small_sample_data = "\"It is easy to see,\" replied Don Quixote";
 static const char *command_sample_data = "that thou art not used to this business of adventures; those are giants";
 static const char *ignored_data = "and if thou art afraid, away with thee out of this and betake thyself to prayer";
diff --git a/hci/test/low_power_manager_test.cc b/hci/test/low_power_manager_test.cc
index 0cc76fa..07e255d 100644
--- a/hci/test/low_power_manager_test.cc
+++ b/hci/test/low_power_manager_test.cc
@@ -20,7 +20,6 @@
 
 #include "AlarmTestHarness.h"
 
-extern "C" {
 #include <stdint.h>
 
 #include "low_power_manager.h"
@@ -29,7 +28,6 @@
 #include "osi/include/thread.h"
 #include "test_stubs.h"
 #include "vendor.h"
-}
 
 DECLARE_TEST_MODES(
   init,
diff --git a/hci/test/packet_fragmenter_test.cc b/hci/test/packet_fragmenter_test.cc
index 2924fe9..73dceff 100644
--- a/hci/test/packet_fragmenter_test.cc
+++ b/hci/test/packet_fragmenter_test.cc
@@ -20,7 +20,6 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include <stdint.h>
 
 #include "device/include/controller.h"
@@ -29,7 +28,6 @@
 #include "hci_internals.h"
 #include "packet_fragmenter.h"
 #include "test_stubs.h"
-}
 
 DECLARE_TEST_MODES(
   init,
diff --git a/include/bt_trace.h b/include/bt_trace.h
index 5d142c4..168602b 100644
--- a/include/bt_trace.h
+++ b/include/bt_trace.h
@@ -107,7 +107,7 @@
 #define BTTRC_ID_AVDT_SCB                  80         /* avdt scb */
 #define BTTRC_ID_AVDT_CCB                  81         /* avdt ccb */
 
-/* LayerIDs added for BTL-A. Probably should modify bte_logmsg.c in future. */
+/* LayerIDs added for BTL-A. Probably should modify bte_logmsg.cc in future. */
 #define BTTRC_ID_STK_RFCOMM                82
 #define BTTRC_ID_STK_RFCOMM_DATA           83
 #define BTTRC_ID_STK_OBEX                  84
diff --git a/include/bte.h b/include/bte.h
index 17ad4e1..2f92528 100644
--- a/include/bte.h
+++ b/include/bte.h
@@ -29,6 +29,10 @@
 #include <pthread.h>
 #include "bt_target.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* by default on shutdown, baudrate is reset 115kbits. this should NOT be need for platforms
  * that kill BTE driver and remove/reset BT chip
  */
@@ -96,6 +100,8 @@
 /* Pointer to function for sending HCI commands and data to the HCI tranport */
 extern int (*p_bte_hci_send)(uint16_t port, BT_HDR *p_msg);
 
+// Initialize control block memory for each stack component.
+extern void BTE_InitStack(void);
 
 /* Protocol trace mask */
 extern uint32_t bte_proto_trace_mask;
@@ -111,4 +117,8 @@
 
 extern const tBAUD_REG baud_rate_regs[];
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif  /* BTE_H */
diff --git a/include/bte_appl.h b/include/bte_appl.h
index d3fc346..8f3ed2d 100644
--- a/include/bte_appl.h
+++ b/include/bte_appl.h
@@ -24,6 +24,10 @@
 
 #pragma once
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct {
 #if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
     uint8_t ble_auth_req;
@@ -35,3 +39,7 @@
 } tBTE_APPL_CFG;
 
 extern tBTE_APPL_CFG bte_appl_cfg;
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/main/Android.mk b/main/Android.mk
index 11a61d7..efb87ff 100644
--- a/main/Android.mk
+++ b/main/Android.mk
@@ -22,55 +22,55 @@
 
 # platform specific
 LOCAL_SRC_FILES := \
-	bte_main.c \
-	bte_init.c \
-	bte_logmsg.c \
-	bte_init_cpp_logging.cc \
-	bte_conf.c \
-	stack_config.c
+    bte_conf.cc \
+    bte_init.cc \
+    bte_init_cpp_logging.cc \
+    bte_logmsg.cc \
+    bte_main.cc \
+    stack_config.cc
 
 # sbc encoder
 LOCAL_SRC_FILES += \
-	../embdrv/sbc/encoder/srce/sbc_analysis.c \
-	../embdrv/sbc/encoder/srce/sbc_dct.c \
-	../embdrv/sbc/encoder/srce/sbc_dct_coeffs.c \
-	../embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c \
-	../embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c \
-	../embdrv/sbc/encoder/srce/sbc_enc_coeffs.c \
-	../embdrv/sbc/encoder/srce/sbc_encoder.c \
-	../embdrv/sbc/encoder/srce/sbc_packing.c \
+    ../embdrv/sbc/encoder/srce/sbc_analysis.c \
+    ../embdrv/sbc/encoder/srce/sbc_dct.c \
+    ../embdrv/sbc/encoder/srce/sbc_dct_coeffs.c \
+    ../embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c \
+    ../embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c \
+    ../embdrv/sbc/encoder/srce/sbc_enc_coeffs.c \
+    ../embdrv/sbc/encoder/srce/sbc_encoder.c \
+    ../embdrv/sbc/encoder/srce/sbc_packing.c \
 
 LOCAL_SRC_FILES += \
-	../udrv/ulinux/uipc.c
+    ../udrv/ulinux/uipc.cc
 
 LOCAL_C_INCLUDES := . \
-	$(LOCAL_PATH)/../ \
-	$(LOCAL_PATH)/../bta/include \
-	$(LOCAL_PATH)/../bta/sys \
-	$(LOCAL_PATH)/../bta/dm \
-	$(LOCAL_PATH)/../btcore/include \
-	$(LOCAL_PATH)/../include \
-	$(LOCAL_PATH)/../stack/include \
-	$(LOCAL_PATH)/../stack/l2cap \
-	$(LOCAL_PATH)/../stack/a2dp \
-	$(LOCAL_PATH)/../stack/btm \
-	$(LOCAL_PATH)/../stack/avdt \
-	$(LOCAL_PATH)/../hcis \
-	$(LOCAL_PATH)/../hcis/include \
-	$(LOCAL_PATH)/../hcis/patchram \
-	$(LOCAL_PATH)/../udrv/include \
-	$(LOCAL_PATH)/../btif/include \
-	$(LOCAL_PATH)/../btif/co \
-	$(LOCAL_PATH)/../hci/include\
-	$(LOCAL_PATH)/../vnd/include \
-	$(LOCAL_PATH)/../brcm/include \
-	$(LOCAL_PATH)/../embdrv/sbc/encoder/include \
-	$(LOCAL_PATH)/../embdrv/sbc/decoder/include \
-	$(LOCAL_PATH)/../audio_a2dp_hw \
-	$(LOCAL_PATH)/../utils/include \
-	$(bluetooth_C_INCLUDES) \
-	external/tinyxml2 \
-	external/zlib
+    $(LOCAL_PATH)/../ \
+    $(LOCAL_PATH)/../bta/include \
+    $(LOCAL_PATH)/../bta/sys \
+    $(LOCAL_PATH)/../bta/dm \
+    $(LOCAL_PATH)/../btcore/include \
+    $(LOCAL_PATH)/../include \
+    $(LOCAL_PATH)/../stack/include \
+    $(LOCAL_PATH)/../stack/l2cap \
+    $(LOCAL_PATH)/../stack/a2dp \
+    $(LOCAL_PATH)/../stack/btm \
+    $(LOCAL_PATH)/../stack/avdt \
+    $(LOCAL_PATH)/../hcis \
+    $(LOCAL_PATH)/../hcis/include \
+    $(LOCAL_PATH)/../hcis/patchram \
+    $(LOCAL_PATH)/../udrv/include \
+    $(LOCAL_PATH)/../btif/include \
+    $(LOCAL_PATH)/../btif/co \
+    $(LOCAL_PATH)/../hci/include\
+    $(LOCAL_PATH)/../vnd/include \
+    $(LOCAL_PATH)/../brcm/include \
+    $(LOCAL_PATH)/../embdrv/sbc/encoder/include \
+    $(LOCAL_PATH)/../embdrv/sbc/decoder/include \
+    $(LOCAL_PATH)/../audio_a2dp_hw \
+    $(LOCAL_PATH)/../utils/include \
+    $(bluetooth_C_INCLUDES) \
+    external/tinyxml2 \
+    external/zlib
 
 LOCAL_SHARED_LIBRARIES := \
     libcutils \
diff --git a/main/BUILD.gn b/main/BUILD.gn
index d6e316f..704dcbd 100644
--- a/main/BUILD.gn
+++ b/main/BUILD.gn
@@ -22,12 +22,12 @@
 
   # platform specific
   sources += [
-    "bte_main.c",
-    "bte_init.c",
+    "bte_conf.cc",
+    "bte_init.cc",
     "bte_init_cpp_logging.cc",
-    "bte_logmsg.c",
-    "bte_conf.c",
-    "stack_config.c",
+    "bte_logmsg.cc",
+    "bte_main.cc",
+    "stack_config.cc",
   ]
 
   include_dirs = [
diff --git a/main/bte_conf.c b/main/bte_conf.cc
similarity index 98%
rename from main/bte_conf.c
rename to main/bte_conf.cc
index 01d8071..655094a 100644
--- a/main/bte_conf.c
+++ b/main/bte_conf.cc
@@ -23,6 +23,7 @@
 #include <string.h>
 
 #include "bta_api.h"
+#include "btif_common.h"
 #include "osi/include/compat.h"
 #include "osi/include/config.h"
 #include "osi/include/log.h"
diff --git a/main/bte_init.c b/main/bte_init.cc
similarity index 98%
rename from main/bte_init.c
rename to main/bte_init.cc
index d45a0d4..751acaa 100644
--- a/main/bte_init.c
+++ b/main/bte_init.cc
@@ -30,6 +30,8 @@
 #define BTA_INCLUDED FALSE
 #endif
 
+#include "bte.h"
+
 /* Include initialization functions definitions */
 #include "port_api.h"
 
diff --git a/main/bte_logmsg.c b/main/bte_logmsg.cc
similarity index 98%
rename from main/bte_logmsg.c
rename to main/bte_logmsg.cc
index ac05d04..c23d0cf 100644
--- a/main/bte_logmsg.c
+++ b/main/bte_logmsg.cc
@@ -245,7 +245,7 @@
   return NULL;
 }
 
-EXPORT_SYMBOL const module_t bte_logmsg_module = {
+EXPORT_SYMBOL extern const module_t bte_logmsg_module = {
   .name = BTE_LOGMSG_MODULE,
   .init = init,
   .start_up = NULL,
diff --git a/main/bte_main.c b/main/bte_main.cc
similarity index 98%
rename from main/bte_main.c
rename to main/bte_main.cc
index 9f521d9..4705756 100644
--- a/main/bte_main.c
+++ b/main/bte_main.cc
@@ -18,7 +18,7 @@
 
 /******************************************************************************
  *
- *  Filename:      bte_main.c
+ *  Filename:      bte_main.cc
  *
  *  Description:   Contains BTE core stack initialization and shutdown code
  *
@@ -46,6 +46,7 @@
 #include "bt_common.h"
 #include "device/include/interop.h"
 #include "hci_layer.h"
+#include "hcimsgs.h"
 #include "osi/include/alarm.h"
 #include "osi/include/fixed_queue.h"
 #include "osi/include/future.h"
@@ -54,10 +55,6 @@
 #include "osi/include/thread.h"
 #include "stack_config.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 /*******************************************************************************
 **  Constants & Macros
 *******************************************************************************/
@@ -269,7 +266,3 @@
         osi_free(p_msg);
     }
 }
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/main/stack_config.c b/main/stack_config.cc
similarity index 98%
rename from main/stack_config.c
rename to main/stack_config.cc
index 1981d21..72044df 100644
--- a/main/stack_config.c
+++ b/main/stack_config.cc
@@ -65,7 +65,7 @@
   return future_new_immediate(FUTURE_SUCCESS);
 }
 
-EXPORT_SYMBOL const module_t stack_config_module = {
+EXPORT_SYMBOL extern const module_t stack_config_module = {
   .name = STACK_CONFIG_MODULE,
   .init = init,
   .start_up = NULL,
diff --git a/osi/Android.mk b/osi/Android.mk
index 5e01b4d..22c44c5 100644
--- a/osi/Android.mk
+++ b/osi/Android.mk
@@ -24,32 +24,32 @@
 # TODO(mcchou): Remove socket_utils sources after platform specific
 # dependencies are abstracted.
 btosiCommonSrc := \
-    ./src/alarm.c \
+    ./src/alarm.cc \
     ./src/allocation_tracker.cc \
-    ./src/allocator.c \
-    ./src/array.c \
-    ./src/buffer.c \
-    ./src/compat.c \
-    ./src/config.c \
+    ./src/allocator.cc \
+    ./src/array.cc \
+    ./src/buffer.cc \
+    ./src/compat.cc \
+    ./src/config.cc \
     ./src/data_dispatcher.cc \
-    ./src/eager_reader.c \
-    ./src/fixed_queue.c \
-    ./src/future.c \
+    ./src/eager_reader.cc \
+    ./src/fixed_queue.cc \
+    ./src/future.cc \
     ./src/hash_map_utils.cc \
-    ./src/list.c \
+    ./src/list.cc \
     ./src/metrics.cc \
-    ./src/mutex.c \
-    ./src/osi.c \
-    ./src/properties.c \
-    ./src/reactor.c \
-    ./src/ringbuffer.c \
-    ./src/semaphore.c \
-    ./src/socket.c \
-    ./src/socket_utils/socket_local_client.c \
-    ./src/socket_utils/socket_local_server.c \
-    ./src/thread.c \
-    ./src/time.c \
-    ./src/wakelock.c
+    ./src/mutex.cc \
+    ./src/osi.cc \
+    ./src/properties.cc \
+    ./src/reactor.cc \
+    ./src/ringbuffer.cc \
+    ./src/semaphore.cc \
+    ./src/socket.cc \
+    ./src/socket_utils/socket_local_client.cc \
+    ./src/socket_utils/socket_local_server.cc \
+    ./src/thread.cc \
+    ./src/time.cc \
+    ./src/wakelock.cc
 
 btosiCommonTestSrc := \
     ./test/AlarmTestHarness.cc \
diff --git a/osi/BUILD.gn b/osi/BUILD.gn
index 63753f3..d32472d 100644
--- a/osi/BUILD.gn
+++ b/osi/BUILD.gn
@@ -16,35 +16,35 @@
 
 static_library("osi") {
   sources = [
-    "src/alarm.c",
+    "src/alarm.cc",
     "src/allocation_tracker.cc",
-    "src/allocator.c",
-    "src/array.c",
-    "src/buffer.c",
-    "src/compat.c",
-    "src/config.c",
+    "src/allocator.cc",
+    "src/array.cc",
+    "src/buffer.cc",
+    "src/compat.cc",
+    "src/config.cc",
     "src/data_dispatcher.cc",
-    "src/eager_reader.c",
-    "src/fixed_queue.c",
-    "src/future.c",
+    "src/eager_reader.cc",
+    "src/fixed_queue.cc",
+    "src/future.cc",
     "src/hash_map_utils.cc",
-    "src/list.c",
+    "src/list.cc",
     "src/metrics_linux.cc",
-    "src/mutex.c",
-    "src/osi.c",
-    "src/properties.c",
-    "src/reactor.c",
-    "src/ringbuffer.c",
-    "src/semaphore.c",
-    "src/socket.c",
+    "src/mutex.cc",
+    "src/osi.cc",
+    "src/properties.cc",
+    "src/reactor.cc",
+    "src/ringbuffer.cc",
+    "src/semaphore.cc",
+    "src/socket.cc",
 
     # TODO(mcchou): Remove these sources after platform specific
     # dependencies are abstracted.
-    "src/socket_utils/socket_local_client.c",
-    "src/socket_utils/socket_local_server.c",
-    "src/thread.c",
-    "src/time.c",
-    "src/wakelock.c",
+    "src/socket_utils/socket_local_client.cc",
+    "src/socket_utils/socket_local_server.cc",
+    "src/thread.cc",
+    "src/time.cc",
+    "src/wakelock.cc",
   ]
 
   include_dirs = [
diff --git a/osi/include/array.h b/osi/include/array.h
index 06b93f6..d275c417 100644
--- a/osi/include/array.h
+++ b/osi/include/array.h
@@ -22,6 +22,10 @@
 #include <stddef.h>
 #include <stdint.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct array_t array_t;
 
 // Returns a new array object that stores elements of size |element_size|. The returned
@@ -55,3 +59,7 @@
 // |array| nor |data| may be NULL. Returns true if the element could be inserted into
 // the array, false on error.
 bool array_append_ptr(array_t *array, void *data);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/osi/include/buffer.h b/osi/include/buffer.h
index 51d23a5..0abae36 100644
--- a/osi/include/buffer.h
+++ b/osi/include/buffer.h
@@ -21,6 +21,10 @@
 #include <stdbool.h>
 #include <stddef.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct buffer_t buffer_t;
 
 // Returns a new buffer of |size| bytes. Returns NULL if a buffer could not be
@@ -54,3 +58,7 @@
 // Returns the length of the writeable memory region referred to by |buf|.
 // |buf| must not be NULL.
 size_t buffer_length(const buffer_t *buf);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/osi/include/eager_reader.h b/osi/include/eager_reader.h
index c87995d..8e5ee60 100644
--- a/osi/include/eager_reader.h
+++ b/osi/include/eager_reader.h
@@ -25,6 +25,10 @@
 #include "osi/include/allocator.h"
 #include "osi/include/thread.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct eager_reader_t eager_reader_t;
 typedef struct reactor_t reactor_t;
 
@@ -65,3 +69,7 @@
 // Returns the inbound read thread for a given |reader| or NULL if the thread
 // is not running.
 thread_t* eager_reader_get_read_thread(const eager_reader_t *reader);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/osi/include/list.h b/osi/include/list.h
index 6ba35b2..254e36e 100644
--- a/osi/include/list.h
+++ b/osi/include/list.h
@@ -1,3 +1,21 @@
+/******************************************************************************
+ *
+ *  Copyright (C) 2016 Google, Inc.
+ *
+ *  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.
+ *
+ ******************************************************************************/
+
 #pragma once
 
 #include <stdbool.h>
diff --git a/osi/include/reactor.h b/osi/include/reactor.h
index c5206c2..a873968 100644
--- a/osi/include/reactor.h
+++ b/osi/include/reactor.h
@@ -26,6 +26,10 @@
 // This module implements the Reactor pattern.
 // See http://en.wikipedia.org/wiki/Reactor_pattern for details.
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct reactor_t reactor_t;
 typedef struct reactor_object_t reactor_object_t;
 
@@ -80,3 +84,7 @@
 // Unregisters a previously registered file descriptor with its reactor. |obj| may not be NULL.
 // |obj| is invalid after calling this function so the caller must drop all references to it.
 void reactor_unregister(reactor_object_t *obj);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/osi/include/socket_utils/socket_local.h b/osi/include/socket_utils/socket_local.h
index 1471b00..a44bb0c 100644
--- a/osi/include/socket_utils/socket_local.h
+++ b/osi/include/socket_utils/socket_local.h
@@ -16,6 +16,10 @@
 
 #pragma once
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define FILESYSTEM_SOCKET_PREFIX "/tmp/"
 #define ANDROID_RESERVED_SOCKET_PREFIX "/dev/socket/"
 
@@ -34,3 +38,7 @@
  */
 int osi_socket_make_sockaddr_un(const char *name, int namespaceId,
                                 struct sockaddr_un *p_addr, socklen_t *alen);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/osi/src/alarm.c b/osi/src/alarm.cc
similarity index 98%
rename from osi/src/alarm.c
rename to osi/src/alarm.cc
index b64d46e..390bb45 100644
--- a/osi/src/alarm.c
+++ b/osi/src/alarm.cc
@@ -165,7 +165,7 @@
   pthread_mutexattr_t attr;
   pthread_mutexattr_init(&attr);
 
-  alarm_t *ret = osi_calloc(sizeof(alarm_t));
+  alarm_t *ret = static_cast<alarm_t *>(osi_calloc(sizeof(alarm_t)));
 
   // Make this a recursive mutex to make it safe to call |alarm_cancel| from
   // within the callback function of the alarm.
@@ -184,9 +184,7 @@
   }
 
   ret->is_periodic = is_periodic;
-
-  alarm_stats_t *stats = &ret->stats;
-  stats->name = osi_strdup(name);
+  ret->stats.name = osi_strdup(name);
   // NOTE: The stats were reset by osi_calloc() above
 
   pthread_mutexattr_destroy(&attr);
@@ -472,6 +470,8 @@
   assert(alarms != NULL);
 
   const bool timer_was_set = timer_set;
+  alarm_t *next;
+  int64_t next_expiration;
 
   // If used in a zeroed state, disarms the timer.
   struct itimerspec timer_time;
@@ -480,8 +480,8 @@
   if (list_is_empty(alarms))
     goto done;
 
-  const alarm_t *next = list_front(alarms);
-  const int64_t next_expiration = next->deadline - now();
+  next = static_cast<alarm_t *>(list_front(alarms));
+  next_expiration = next->deadline - now();
   if (next_expiration < TIMER_INTERVAL_FOR_WAKELOCK_IN_MS) {
     if (!timer_set) {
       if (!wakelock_acquire()) {
@@ -649,7 +649,7 @@
     // the future. Release the monitor lock and exit right away since there's
     // nothing left to do.
     if (list_is_empty(alarms) ||
-        (alarm = list_front(alarms))->deadline > now()) {
+        (alarm = static_cast<alarm_t *>(list_front(alarms)))->deadline > now()) {
       reschedule_root_alarm();
       pthread_mutex_unlock(&monitor);
       continue;
diff --git a/osi/src/allocator.c b/osi/src/allocator.cc
similarity index 92%
rename from osi/src/allocator.c
rename to osi/src/allocator.cc
index 3d821a8..9759803 100644
--- a/osi/src/allocator.c
+++ b/osi/src/allocator.cc
@@ -30,10 +30,10 @@
   void *ptr = malloc(real_size);
   assert(ptr);
 
-  char *new_string = allocation_tracker_notify_alloc(
+  char *new_string = static_cast<char *>(allocation_tracker_notify_alloc(
       alloc_allocator_id,
       ptr,
-      size);
+      size));
   if (!new_string)
     return NULL;
 
@@ -50,10 +50,10 @@
   void *ptr = malloc(real_size);
   assert(ptr);
 
-  char *new_string = allocation_tracker_notify_alloc(
+  char *new_string = static_cast<char *>(allocation_tracker_notify_alloc(
       alloc_allocator_id,
       ptr,
-      size + 1);
+      size + 1));
   if (!new_string)
     return NULL;
 
diff --git a/osi/src/array.c b/osi/src/array.cc
similarity index 94%
rename from osi/src/array.c
rename to osi/src/array.cc
index 0baa9bb..36df8ae 100644
--- a/osi/src/array.c
+++ b/osi/src/array.cc
@@ -42,7 +42,7 @@
 array_t *array_new(size_t element_size) {
   assert(element_size > 0);
 
-  array_t *array = osi_calloc(sizeof(array_t) + element_size * INTERNAL_ELEMENTS);
+  array_t *array = static_cast<array_t *>(osi_calloc(sizeof(array_t) + element_size * INTERNAL_ELEMENTS));
 
   array->element_size = element_size;
   array->capacity = INTERNAL_ELEMENTS;
@@ -104,7 +104,7 @@
   if (is_moving)
     memcpy(new_data, array->internal_storage, array->length * array->element_size);
 
-  array->data = new_data;
+  array->data = static_cast<uint8_t *>(new_data);
   array->capacity = new_capacity;
   return true;
 }
diff --git a/osi/src/buffer.c b/osi/src/buffer.cc
similarity index 93%
rename from osi/src/buffer.c
rename to osi/src/buffer.cc
index 54129fb..c46d580 100644
--- a/osi/src/buffer.c
+++ b/osi/src/buffer.cc
@@ -36,7 +36,7 @@
 buffer_t *buffer_new(size_t size) {
   assert(size > 0);
 
-  buffer_t *buffer = osi_calloc(sizeof(buffer_t) + size);
+  buffer_t *buffer = static_cast<buffer_t *>(osi_calloc(sizeof(buffer_t) + size));
 
   buffer->root = buffer;
   buffer->refcount = 1;
@@ -55,7 +55,7 @@
   assert(slice_size > 0);
   assert(slice_size <= buf->length);
 
-  buffer_t *ret = osi_calloc(sizeof(buffer_t));
+  buffer_t *ret = static_cast<buffer_t *>(osi_calloc(sizeof(buffer_t)));
 
   ret->root = buf->root;
   ret->refcount = SIZE_MAX;
diff --git a/osi/src/compat.c b/osi/src/compat.cc
similarity index 98%
rename from osi/src/compat.c
rename to osi/src/compat.cc
index 7540349..44fe5a1 100644
--- a/osi/src/compat.c
+++ b/osi/src/compat.cc
@@ -18,7 +18,7 @@
 
 /************************************************************************************
  *
- *  Filename:      compat.c
+ *  Filename:      compat.cc
  *
  *  Description:   Compatibility functions for non-bionic C libraries
  *
diff --git a/osi/src/config.c b/osi/src/config.cc
similarity index 92%
rename from osi/src/config.c
rename to osi/src/config.cc
index 0f3f564..df8beb0 100644
--- a/osi/src/config.c
+++ b/osi/src/config.cc
@@ -63,7 +63,7 @@
 static entry_t *entry_find(const config_t *config, const char *section, const char *key);
 
 config_t *config_new_empty(void) {
-  config_t *config = osi_calloc(sizeof(config_t));
+  config_t *config = static_cast<config_t *>(osi_calloc(sizeof(config_t)));
 
   config->sections = list_new(section_free);
   if (!config->sections) {
@@ -111,12 +111,12 @@
   for (const list_node_t *node = list_begin(src->sections);
        node != list_end(src->sections);
        node = list_next(node)) {
-    section_t *sec = list_node(node);
+    section_t *sec = static_cast<section_t *>(list_node(node));
 
     for (const list_node_t *node_entry = list_begin(sec->entries);
          node_entry != list_end(sec->entries);
          node_entry = list_next(node_entry)) {
-      entry_t *entry = list_node(node_entry);
+      entry_t *entry = static_cast<entry_t *>(list_node(node_entry));
 
       config_set_string(ret, sec->name, entry->key, entry->value);
     }
@@ -217,7 +217,7 @@
   }
 
   for (const list_node_t *node = list_begin(sec->entries); node != list_end(sec->entries); node = list_next(node)) {
-    entry_t *entry = list_node(node);
+    entry_t *entry = static_cast<entry_t *>(list_node(node));
     if (!strcmp(entry->key, key)) {
       osi_free(entry->value);
       entry->value = osi_strdup(value);
@@ -295,7 +295,7 @@
   static const char *temp_file_ext = ".new";
   const int filename_len = strlen(filename);
   const int temp_filename_len = filename_len + strlen(temp_file_ext) + 1;
-  char *temp_filename = osi_calloc(temp_filename_len);
+  char *temp_filename = static_cast<char *>(osi_calloc(temp_filename_len));
   snprintf(temp_filename, temp_filename_len, "%s%s", filename, temp_file_ext);
 
   // Extract directory from file path (e.g. /data/misc/bluedroid).
@@ -446,7 +446,7 @@
 }
 
 static section_t *section_new(const char *name) {
-  section_t *section = osi_calloc(sizeof(section_t));
+  section_t *section = static_cast<section_t *>(osi_calloc(sizeof(section_t)));
 
   section->name = osi_strdup(name);
   section->entries = list_new(entry_free);
@@ -457,15 +457,16 @@
   if (!ptr)
     return;
 
-  section_t *section = ptr;
+  section_t *section = static_cast<section_t *>(ptr);
   osi_free(section->name);
   list_free(section->entries);
   osi_free(section);
 }
 
 static section_t *section_find(const config_t *config, const char *section) {
-  for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) {
-    section_t *sec = list_node(node);
+  for (const list_node_t *node = list_begin(config->sections);
+       node != list_end(config->sections); node = list_next(node)) {
+    section_t *sec = static_cast<section_t *>(list_node(node));
     if (!strcmp(sec->name, section))
       return sec;
   }
@@ -474,7 +475,7 @@
 }
 
 static entry_t *entry_new(const char *key, const char *value) {
-  entry_t *entry = osi_calloc(sizeof(entry_t));
+  entry_t *entry = static_cast<entry_t *>(osi_calloc(sizeof(entry_t)));
 
   entry->key = osi_strdup(key);
   entry->value = osi_strdup(value);
@@ -485,7 +486,7 @@
   if (!ptr)
     return;
 
-  entry_t *entry = ptr;
+  entry_t *entry = static_cast<entry_t *>(ptr);
   osi_free(entry->key);
   osi_free(entry->value);
   osi_free(entry);
@@ -496,8 +497,9 @@
   if (!sec)
     return NULL;
 
-  for (const list_node_t *node = list_begin(sec->entries); node != list_end(sec->entries); node = list_next(node)) {
-    entry_t *entry = list_node(node);
+  for (const list_node_t *node = list_begin(sec->entries);
+       node != list_end(sec->entries); node = list_next(node)) {
+    entry_t *entry = static_cast<entry_t *>(list_node(node));
     if (!strcmp(entry->key, key))
       return entry;
   }
diff --git a/osi/src/eager_reader.c b/osi/src/eager_reader.cc
similarity index 97%
rename from osi/src/eager_reader.c
rename to osi/src/eager_reader.cc
index 07a944c..f2ef1be 100644
--- a/osi/src/eager_reader.c
+++ b/osi/src/eager_reader.cc
@@ -75,7 +75,7 @@
   assert(max_buffer_count > 0);
   assert(thread_name != NULL && *thread_name != '\0');
 
-  eager_reader_t *ret = osi_calloc(sizeof(eager_reader_t));
+  eager_reader_t *ret = static_cast<eager_reader_t *>(osi_calloc(sizeof(eager_reader_t)));
 
   ret->allocator = allocator;
   ret->inbound_fd = fd_to_read;
@@ -182,7 +182,7 @@
   size_t bytes_consumed = 0;
   while (bytes_consumed < max_size) {
     if (!reader->current_buffer)
-      reader->current_buffer = fixed_queue_dequeue(reader->buffers);
+      reader->current_buffer = static_cast<data_buffer_t *>(fixed_queue_dequeue(reader->buffers));
 
     size_t bytes_to_copy = reader->current_buffer->length - reader->current_buffer->offset;
     if (bytes_to_copy > (max_size - bytes_consumed))
diff --git a/osi/src/fixed_queue.c b/osi/src/fixed_queue.cc
similarity index 97%
rename from osi/src/fixed_queue.c
rename to osi/src/fixed_queue.cc
index 7f4f0ab..e46ad50 100644
--- a/osi/src/fixed_queue.c
+++ b/osi/src/fixed_queue.cc
@@ -42,7 +42,7 @@
 static void internal_dequeue_ready(void *context);
 
 fixed_queue_t *fixed_queue_new(size_t capacity) {
-  fixed_queue_t *ret = osi_calloc(sizeof(fixed_queue_t));
+  fixed_queue_t *ret = static_cast<fixed_queue_t *>(osi_calloc(sizeof(fixed_queue_t)));
 
   pthread_mutex_init(&ret->lock, NULL);
   ret->capacity = capacity;
@@ -275,6 +275,6 @@
 static void internal_dequeue_ready(void *context) {
   assert(context != NULL);
 
-  fixed_queue_t *queue = context;
+  fixed_queue_t *queue = static_cast<fixed_queue_t *>(context);
   queue->dequeue_ready(queue, queue->dequeue_context);
 }
diff --git a/osi/src/future.c b/osi/src/future.cc
similarity index 93%
rename from osi/src/future.c
rename to osi/src/future.cc
index cf720c5..275d254 100644
--- a/osi/src/future.c
+++ b/osi/src/future.cc
@@ -36,7 +36,7 @@
 static void future_free(future_t *future);
 
 future_t *future_new(void) {
-  future_t *ret = osi_calloc(sizeof(future_t));
+  future_t *ret = static_cast<future_t *>(osi_calloc(sizeof(future_t)));
 
   ret->semaphore = semaphore_new(0);
   if (!ret->semaphore) {
@@ -52,7 +52,7 @@
 }
 
 future_t *future_new_immediate(void *value) {
-  future_t *ret = osi_calloc(sizeof(future_t));
+  future_t *ret = static_cast<future_t *>(osi_calloc(sizeof(future_t)));
 
   ret->result = value;
   ret->ready_can_be_called = false;
diff --git a/osi/src/list.c b/osi/src/list.cc
similarity index 100%
rename from osi/src/list.c
rename to osi/src/list.cc
diff --git a/osi/src/metrics.cc b/osi/src/metrics.cc
index 064f99e..f90ea51 100644
--- a/osi/src/metrics.cc
+++ b/osi/src/metrics.cc
@@ -19,14 +19,12 @@
 
 #define LOG_TAG "bt_osi_metrics"
 
-extern "C" {
 #include "osi/include/metrics.h"
 
 #include <errno.h>
 
 #include "osi/include/log.h"
 #include "osi/include/osi.h"
-}
 
 #include "osi/src/protos/bluetooth.pb.h"
 
diff --git a/osi/src/metrics_linux.cc b/osi/src/metrics_linux.cc
index f013236..663ce92 100644
--- a/osi/src/metrics_linux.cc
+++ b/osi/src/metrics_linux.cc
@@ -19,9 +19,7 @@
 
 #define LOG_TAG "bt_osi_metrics"
 
-extern "C" {
 #include "osi/include/metrics.h"
-}
 
 void metrics_pair_event(uint32_t disconnect_reason, uint64_t timestamp_ms,
                         uint32_t device_class, device_type_t device_type) {
diff --git a/osi/src/mutex.c b/osi/src/mutex.cc
similarity index 100%
rename from osi/src/mutex.c
rename to osi/src/mutex.cc
diff --git a/osi/src/osi.c b/osi/src/osi.cc
similarity index 100%
rename from osi/src/osi.c
rename to osi/src/osi.cc
diff --git a/osi/src/properties.c b/osi/src/properties.cc
similarity index 100%
rename from osi/src/properties.c
rename to osi/src/properties.cc
diff --git a/osi/src/reactor.c b/osi/src/reactor.cc
similarity index 100%
rename from osi/src/reactor.c
rename to osi/src/reactor.cc
diff --git a/osi/src/ringbuffer.c b/osi/src/ringbuffer.cc
similarity index 95%
rename from osi/src/ringbuffer.c
rename to osi/src/ringbuffer.cc
index 84d6043..67c8f54 100644
--- a/osi/src/ringbuffer.c
+++ b/osi/src/ringbuffer.cc
@@ -31,9 +31,9 @@
 };
 
 ringbuffer_t* ringbuffer_init(const size_t size) {
-  ringbuffer_t* p = osi_calloc(sizeof(ringbuffer_t));
+  ringbuffer_t* p = static_cast<ringbuffer_t *>(osi_calloc(sizeof(ringbuffer_t)));
 
-  p->base = osi_calloc(size);
+  p->base = static_cast<uint8_t *>(osi_calloc(size));
   p->head = p->tail = p->base;
   p->total = p->available = size;
 
diff --git a/osi/src/semaphore.c b/osi/src/semaphore.cc
similarity index 96%
rename from osi/src/semaphore.c
rename to osi/src/semaphore.cc
index 45a9150..d24d38b 100644
--- a/osi/src/semaphore.c
+++ b/osi/src/semaphore.cc
@@ -41,7 +41,7 @@
 };
 
 semaphore_t *semaphore_new(unsigned int value) {
-  semaphore_t *ret = osi_malloc(sizeof(semaphore_t));
+  semaphore_t *ret = static_cast<semaphore_t *>(osi_malloc(sizeof(semaphore_t)));
   ret->fd = eventfd(value, EFD_SEMAPHORE);
   if (ret->fd == INVALID_FD) {
     LOG_ERROR(LOG_TAG, "%s unable to allocate semaphore: %s", __func__, strerror(errno));
diff --git a/osi/src/socket.c b/osi/src/socket.cc
similarity index 97%
rename from osi/src/socket.c
rename to osi/src/socket.cc
index 4ebb3b8..166c2ce 100644
--- a/osi/src/socket.c
+++ b/osi/src/socket.cc
@@ -50,6 +50,7 @@
 
 socket_t *socket_new(void) {
   socket_t *ret = (socket_t *)osi_calloc(sizeof(socket_t));
+  int enable = 1;
 
   ret->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
   if (ret->fd == INVALID_FD) {
@@ -57,7 +58,6 @@
     goto error;
   }
 
-  int enable = 1;
   if (setsockopt(ret->fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)) == -1) {
     LOG_ERROR(LOG_TAG, "%s unable to set SO_REUSEADDR: %s", __func__, strerror(errno));
     goto error;
@@ -216,13 +216,13 @@
 static void internal_read_ready(void *context) {
   assert(context != NULL);
 
-  socket_t *socket = (void *)context;
+  socket_t *socket = static_cast<socket_t *>(context);
   socket->read_ready(socket, socket->context);
 }
 
 static void internal_write_ready(void *context) {
   assert(context != NULL);
 
-  socket_t *socket = (void *)context;
+  socket_t *socket = static_cast<socket_t *>(context);
   socket->write_ready(socket, socket->context);
 }
diff --git a/osi/src/socket_utils/README b/osi/src/socket_utils/README
index 8616447..07a28bd 100644
--- a/osi/src/socket_utils/README
+++ b/osi/src/socket_utils/README
@@ -30,7 +30,7 @@
  - osi/include/socket_utils/sockets.h
  - osi/include/socket_utils/socket_local.h
 [Source files]
- - osi/src/socket_utils/socket_local_client.c
- - osi/src/socket_utils/socket_local_server.c
+ - osi/src/socket_utils/socket_local_client.cc
+ - osi/src/socket_utils/socket_local_server.cc
 
 Please update the above list if adding more sources.
diff --git a/osi/src/socket_utils/socket_local_client.c b/osi/src/socket_utils/socket_local_client.cc
similarity index 100%
rename from osi/src/socket_utils/socket_local_client.c
rename to osi/src/socket_utils/socket_local_client.cc
diff --git a/osi/src/socket_utils/socket_local_server.c b/osi/src/socket_utils/socket_local_server.cc
similarity index 94%
rename from osi/src/socket_utils/socket_local_server.c
rename to osi/src/socket_utils/socket_local_server.cc
index 466cc1c..79f1790 100644
--- a/osi/src/socket_utils/socket_local_server.c
+++ b/osi/src/socket_utils/socket_local_server.cc
@@ -77,14 +77,14 @@
  *
  *  Returns fd on success, -1 on fail
  */
-int osi_socket_local_server(const char *name, int namespace, int type) {
+int osi_socket_local_server(const char *name, int namespaceId, int type) {
   int err;
   int s;
 
   s = socket(AF_LOCAL, type, 0);
   if (s < 0) return -1;
 
-  err = osi_socket_local_server_bind(s, name, namespace);
+  err = osi_socket_local_server_bind(s, name, namespaceId);
 
   if (err < 0) {
     close(s);
diff --git a/osi/src/thread.c b/osi/src/thread.cc
similarity index 93%
rename from osi/src/thread.c
rename to osi/src/thread.cc
index 8e9b3e1..6c9fab7 100644
--- a/osi/src/thread.c
+++ b/osi/src/thread.cc
@@ -66,7 +66,7 @@
   assert(name != NULL);
   assert(work_queue_capacity != 0);
 
-  thread_t *ret = osi_calloc(sizeof(thread_t));
+  thread_t *ret = static_cast<thread_t *>(osi_calloc(sizeof(thread_t)));
 
   ret->reactor = reactor_new();
   if (!ret->reactor)
@@ -183,7 +183,7 @@
 static void *run_thread(void *start_arg) {
   assert(start_arg != NULL);
 
-  struct start_arg *start = start_arg;
+  struct start_arg *start = static_cast<struct start_arg *>(start_arg);
   thread_t *thread = start->thread;
 
   assert(thread != NULL);
@@ -211,11 +211,11 @@
   // This allows a caller to safely tear down by enqueuing a teardown
   // work item and then joining the thread.
   size_t count = 0;
-  work_item_t *item = fixed_queue_try_dequeue(thread->work_queue);
+  work_item_t *item = static_cast<work_item_t *>(fixed_queue_try_dequeue(thread->work_queue));
   while (item && count <= fixed_queue_capacity(thread->work_queue)) {
     item->func(item->context);
     osi_free(item);
-    item = fixed_queue_try_dequeue(thread->work_queue);
+    item = static_cast<work_item_t *>(fixed_queue_try_dequeue(thread->work_queue));
     ++count;
   }
 
@@ -230,7 +230,7 @@
   assert(context != NULL);
 
   fixed_queue_t *queue = (fixed_queue_t *)context;
-  work_item_t *item = fixed_queue_dequeue(queue);
+  work_item_t *item = static_cast<work_item_t *>(fixed_queue_dequeue(queue));
   item->func(item->context);
   osi_free(item);
 }
diff --git a/osi/src/time.c b/osi/src/time.cc
similarity index 100%
rename from osi/src/time.c
rename to osi/src/time.cc
diff --git a/osi/src/wakelock.c b/osi/src/wakelock.cc
similarity index 90%
rename from osi/src/wakelock.c
rename to osi/src/wakelock.cc
index fc19cc4..534f82a 100644
--- a/osi/src/wakelock.c
+++ b/osi/src/wakelock.cc
@@ -31,6 +31,8 @@
 #include <time.h>
 #include <unistd.h>
 
+#include <string>
+
 #include "osi/include/alarm.h"
 #include "osi/include/allocator.h"
 #include "osi/include/log.h"
@@ -44,10 +46,10 @@
 
 static const clockid_t CLOCK_ID = CLOCK_BOOTTIME;
 static const char *WAKE_LOCK_ID = "bluetooth_timer";
-static char *DEFAULT_WAKE_LOCK_PATH = "/sys/power/wake_lock";
-static char *DEFAULT_WAKE_UNLOCK_PATH = "/sys/power/wake_unlock";
-static char *wake_lock_path = NULL;
-static char *wake_unlock_path = NULL;
+static const std::string DEFAULT_WAKE_LOCK_PATH = "/sys/power/wake_lock";
+static const std::string DEFAULT_WAKE_UNLOCK_PATH = "/sys/power/wake_unlock";
+static std::string wake_lock_path;
+static std::string wake_unlock_path;
 static ssize_t locked_id_len = -1;
 static pthread_once_t initialized = PTHREAD_ONCE_INIT;
 static int wake_lock_fd = INVALID_FD;
@@ -114,7 +116,7 @@
 }
 
 static bt_status_t wakelock_acquire_callout(void) {
-  return wakelock_os_callouts->acquire_wake_lock(WAKE_LOCK_ID);
+  return static_cast<bt_status_t>(wakelock_os_callouts->acquire_wake_lock(WAKE_LOCK_ID));
 }
 
 static bt_status_t wakelock_acquire_native(void) {
@@ -158,7 +160,7 @@
 }
 
 static bt_status_t wakelock_release_callout(void) {
-  return wakelock_os_callouts->release_wake_lock(WAKE_LOCK_ID);
+  return static_cast<bt_status_t>(wakelock_os_callouts->release_wake_lock(WAKE_LOCK_ID));
 }
 
 static bt_status_t wakelock_release_native(void) {
@@ -189,48 +191,38 @@
 static void wakelock_initialize_native(void) {
   LOG_DEBUG(LOG_TAG, "%s opening wake locks", __func__);
 
-  if (!wake_lock_path)
+  if (wake_lock_path.empty())
     wake_lock_path = DEFAULT_WAKE_LOCK_PATH;
 
-  wake_lock_fd = open(wake_lock_path, O_RDWR | O_CLOEXEC);
+  wake_lock_fd = open(wake_lock_path.c_str(), O_RDWR | O_CLOEXEC);
   if (wake_lock_fd == INVALID_FD) {
     LOG_ERROR(LOG_TAG, "%s can't open wake lock %s: %s",
-              __func__, wake_lock_path, strerror(errno));
+              __func__, wake_lock_path.c_str(), strerror(errno));
   }
 
-  if (!wake_unlock_path)
+  if (wake_unlock_path.empty())
     wake_unlock_path = DEFAULT_WAKE_UNLOCK_PATH;
 
-  wake_unlock_fd = open(wake_unlock_path, O_RDWR | O_CLOEXEC);
+  wake_unlock_fd = open(wake_unlock_path.c_str(), O_RDWR | O_CLOEXEC);
   if (wake_unlock_fd == INVALID_FD) {
     LOG_ERROR(LOG_TAG, "%s can't open wake unlock %s: %s",
-              __func__, wake_unlock_path, strerror(errno));
+              __func__, wake_unlock_path.c_str(), strerror(errno));
   }
 }
 
 void wakelock_cleanup(void) {
-  if (wake_lock_path && wake_lock_path != DEFAULT_WAKE_LOCK_PATH)
-    osi_free_and_reset((void **)&wake_lock_path);
-
-  if (wake_unlock_path && wake_unlock_path != DEFAULT_WAKE_UNLOCK_PATH)
-    osi_free_and_reset((void **)&wake_unlock_path);
-
+  wake_lock_path.clear();
+  wake_unlock_path.clear();
   initialized = PTHREAD_ONCE_INIT;
   pthread_mutex_destroy(&monitor);
 }
 
 void wakelock_set_paths(const char *lock_path, const char *unlock_path) {
-  if (lock_path) {
-    if (wake_lock_path && wake_lock_path != DEFAULT_WAKE_LOCK_PATH)
-      osi_free(wake_lock_path);
-    wake_lock_path = osi_strndup(lock_path, PATH_MAX);
-  }
+  if (lock_path)
+    wake_lock_path = lock_path;
 
-  if (unlock_path) {
-    if (wake_unlock_path && wake_unlock_path != DEFAULT_WAKE_UNLOCK_PATH)
-      osi_free(wake_unlock_path);
-    wake_unlock_path = osi_strndup(unlock_path, PATH_MAX);
-  }
+  if (unlock_path)
+    wake_unlock_path = unlock_path;
 }
 
 static period_ms_t now(void) {
diff --git a/osi/test/AllocationTestHarness.cc b/osi/test/AllocationTestHarness.cc
index 0132c73..5386237 100644
--- a/osi/test/AllocationTestHarness.cc
+++ b/osi/test/AllocationTestHarness.cc
@@ -20,9 +20,7 @@
 
 #include "osi/test/AllocationTestHarness.h"
 
-extern "C" {
 #include "osi/include/allocation_tracker.h"
-}
 
 void AllocationTestHarness::SetUp() {
   allocation_tracker_init();
diff --git a/osi/test/alarm_test.cc b/osi/test/alarm_test.cc
index ddd6800..331a043 100644
--- a/osi/test/alarm_test.cc
+++ b/osi/test/alarm_test.cc
@@ -20,13 +20,11 @@
 
 #include "AlarmTestHarness.h"
 
-extern "C" {
 #include "osi/include/alarm.h"
 #include "osi/include/fixed_queue.h"
 #include "osi/include/osi.h"
 #include "osi/include/semaphore.h"
 #include "osi/include/thread.h"
-}
 
 static semaphore_t *semaphore;
 static int cb_counter;
diff --git a/osi/test/allocation_tracker_test.cc b/osi/test/allocation_tracker_test.cc
index ac2f6fb..ce465e9 100644
--- a/osi/test/allocation_tracker_test.cc
+++ b/osi/test/allocation_tracker_test.cc
@@ -18,9 +18,7 @@
 
 #include <gtest/gtest.h>
 
-extern "C" {
 #include "osi/include/allocation_tracker.h"
-}
 
 void allocation_tracker_uninit(void);
 
diff --git a/osi/test/allocator_test.cc b/osi/test/allocator_test.cc
index 19c175b..ca408fa 100644
--- a/osi/test/allocator_test.cc
+++ b/osi/test/allocator_test.cc
@@ -21,9 +21,7 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include "osi/include/allocator.h"
-}
 
 class AllocatorTest : public AllocationTestHarness {};
 
diff --git a/osi/test/array_test.cc b/osi/test/array_test.cc
index 9cd40dc..5c1e1b4 100644
--- a/osi/test/array_test.cc
+++ b/osi/test/array_test.cc
@@ -2,9 +2,7 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include "osi/include/array.h"
-}
 
 class ArrayTest : public AllocationTestHarness {};
 
diff --git a/osi/test/config_test.cc b/osi/test/config_test.cc
index 0fb2fe1..3348880 100644
--- a/osi/test/config_test.cc
+++ b/osi/test/config_test.cc
@@ -2,9 +2,7 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include "osi/include/config.h"
-}
 
 static const char CONFIG_FILE[] = "/data/local/tmp/config_test.conf";
 static const char CONFIG_FILE_CONTENT[] =
diff --git a/osi/test/data_dispatcher_test.cc b/osi/test/data_dispatcher_test.cc
index 5afa7b32..9f00bb4 100644
--- a/osi/test/data_dispatcher_test.cc
+++ b/osi/test/data_dispatcher_test.cc
@@ -6,10 +6,8 @@
 
 #include "osi/include/data_dispatcher.h"
 
-extern "C" {
 #include "osi/include/fixed_queue.h"
 #include "osi/include/osi.h"
-}
 
 #define DUMMY_TYPE_0 34
 #define DUMMY_TYPE_1 42
diff --git a/osi/test/eager_reader_test.cc b/osi/test/eager_reader_test.cc
index 7156d56..e69905e 100644
--- a/osi/test/eager_reader_test.cc
+++ b/osi/test/eager_reader_test.cc
@@ -20,7 +20,6 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include <stdint.h>
 #include <unistd.h>
 
@@ -29,7 +28,6 @@
 #include "osi/include/osi.h"
 #include "osi/include/semaphore.h"
 #include "osi/include/thread.h"
-}
 
 #define BUFFER_SIZE 32
 
diff --git a/osi/test/fixed_queue_test.cc b/osi/test/fixed_queue_test.cc
index 675bd39..030241b 100644
--- a/osi/test/fixed_queue_test.cc
+++ b/osi/test/fixed_queue_test.cc
@@ -4,13 +4,11 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include "osi/include/allocator.h"
 #include "osi/include/fixed_queue.h"
 #include "osi/include/future.h"
 #include "osi/include/osi.h"
 #include "osi/include/thread.h"
-}
 
 static const size_t TEST_QUEUE_SIZE = 10;
 static const char *DUMMY_DATA_STRING = "Dummy data string";
diff --git a/osi/test/future_test.cc b/osi/test/future_test.cc
index a7a11af..9da8c82 100644
--- a/osi/test/future_test.cc
+++ b/osi/test/future_test.cc
@@ -20,11 +20,9 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include "osi/include/future.h"
 #include "osi/include/osi.h"
 #include "osi/include/thread.h"
-}
 
 static const char *pass_back_data0 = "fancy a sandwich? it's a fancy sandwich";
 static const char *pass_back_data1 = "what kind of ice cream truck plays the worst christmas song of all time?";
diff --git a/osi/test/hash_map_utils_test.cc b/osi/test/hash_map_utils_test.cc
index 9b4aa68..987a328 100644
--- a/osi/test/hash_map_utils_test.cc
+++ b/osi/test/hash_map_utils_test.cc
@@ -23,9 +23,7 @@
 
 #include "osi/include/hash_map_utils.h"
 
-extern "C" {
 #include "osi/include/allocator.h"
-}
 
 class HashMapUtilsTest : public AllocationTestHarness {
  protected:
diff --git a/osi/test/list_test.cc b/osi/test/list_test.cc
index b7d8ae8..af28b8d 100644
--- a/osi/test/list_test.cc
+++ b/osi/test/list_test.cc
@@ -2,10 +2,8 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include "osi/include/list.h"
 #include "osi/include/osi.h"
-}
 
 class ListTest : public AllocationTestHarness {};
 
diff --git a/osi/test/properties_test.cc b/osi/test/properties_test.cc
index 3d27526..17cbd6c 100644
--- a/osi/test/properties_test.cc
+++ b/osi/test/properties_test.cc
@@ -20,9 +20,7 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include "osi/include/properties.h"
-}
 
 class PropertiesTest : public AllocationTestHarness {};
 
diff --git a/osi/test/rand_test.cc b/osi/test/rand_test.cc
index cf0d7f6..720617b 100644
--- a/osi/test/rand_test.cc
+++ b/osi/test/rand_test.cc
@@ -2,9 +2,7 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include "osi/include/osi.h"
-}
 
 class RandTest : public AllocationTestHarness {};
 
diff --git a/osi/test/reactor_test.cc b/osi/test/reactor_test.cc
index a2c7b6e..4f8a0bd 100644
--- a/osi/test/reactor_test.cc
+++ b/osi/test/reactor_test.cc
@@ -6,9 +6,7 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include "osi/include/reactor.h"
-}
 
 class ReactorTest : public AllocationTestHarness {};
 
diff --git a/osi/test/ringbuffer_test.cc b/osi/test/ringbuffer_test.cc
index 8dd5bdc..f4ae86a 100644
--- a/osi/test/ringbuffer_test.cc
+++ b/osi/test/ringbuffer_test.cc
@@ -1,9 +1,7 @@
 #include <gtest/gtest.h>
 
-extern "C" {
 #include "osi/include/ringbuffer.h"
 #include "osi/include/osi.h"
-}
 
 TEST(RingbufferTest, test_new_simple) {
   ringbuffer_t *rb = ringbuffer_init(4096);
diff --git a/osi/test/semaphore_test.cc b/osi/test/semaphore_test.cc
index c30dd0b..e52b2d6 100644
--- a/osi/test/semaphore_test.cc
+++ b/osi/test/semaphore_test.cc
@@ -2,7 +2,6 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include <unistd.h>
 #include <sys/select.h>
 
@@ -10,7 +9,6 @@
 #include "osi/include/reactor.h"
 #include "osi/include/semaphore.h"
 #include "osi/include/thread.h"
-}
 
 struct SemaphoreTestSequenceHelper {
   semaphore_t *semaphore;
diff --git a/osi/test/test_stubs.h b/osi/test/test_stubs.h
index 79a5f46..9f8a607 100644
--- a/osi/test/test_stubs.h
+++ b/osi/test/test_stubs.h
@@ -16,6 +16,12 @@
  *
  ******************************************************************************/
 
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 // Helper macros for stubbing out functions and modules for testing.
 
 // Stub out a function, with call counting and mode awareness
@@ -97,3 +103,7 @@
 #define CURRENT_TEST_MODE _current_mode
 
 #define TEST_MODES_T _test_modes_t
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/osi/test/thread_test.cc b/osi/test/thread_test.cc
index b45365d..8f0904f 100644
--- a/osi/test/thread_test.cc
+++ b/osi/test/thread_test.cc
@@ -2,13 +2,11 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include <sys/select.h>
 
 #include "osi/include/reactor.h"
 #include "osi/include/thread.h"
 #include "osi/include/osi.h"
-}
 
 class ThreadTest : public AllocationTestHarness {};
 
diff --git a/osi/test/time_test.cc b/osi/test/time_test.cc
index 06ac707..79f21a3 100644
--- a/osi/test/time_test.cc
+++ b/osi/test/time_test.cc
@@ -20,9 +20,7 @@
 
 #include "AllocationTestHarness.h"
 
-extern "C" {
 #include "osi/include/time.h"
-}
 
 // Generous upper bound: 10 seconds
 static const uint32_t TEST_TIME_DELTA_UPPER_BOUND_MS = 10 * 1000;
diff --git a/service/test/fake_hal_util.cc b/service/test/fake_hal_util.cc
index d909ad2..46acf73 100644
--- a/service/test/fake_hal_util.cc
+++ b/service/test/fake_hal_util.cc
@@ -14,7 +14,7 @@
 //  limitations under the License.
 //
 
-extern "C" {
+#include "btcore/include/hal_util.h"
 
 // TODO(armansito): This provides a fake implementation of the function defined
 // in btcore/include/hal_util.h. We have to provide this to prevent having to
@@ -25,5 +25,3 @@
 int hal_util_load_bt_library(const struct hw_module_t** module) {
   return -1;
 }
-
-}  // extern "C"
diff --git a/stack/Android.mk b/stack/Android.mk
index 8cd9e46..27a79ee 100644
--- a/stack/Android.mk
+++ b/stack/Android.mk
@@ -41,119 +41,119 @@
     ./a2dp/a2dp_sbc_encoder.cc \
     ./a2dp/a2dp_sbc_up_sample.cc \
     ./a2dp/a2dp_vendor.cc \
-    ./avrc/avrc_api.c \
-    ./avrc/avrc_sdp.c \
-    ./avrc/avrc_opt.c \
-    ./avrc/avrc_bld_tg.c \
-    ./avrc/avrc_bld_ct.c \
-    ./avrc/avrc_pars_tg.c \
-    ./avrc/avrc_pars_ct.c \
-    ./avrc/avrc_utils.c \
-    ./hid/hidh_api.c \
-    ./hid/hidh_conn.c \
-    ./bnep/bnep_main.c \
-    ./bnep/bnep_utils.c \
-    ./bnep/bnep_api.c \
-    ./hcic/hciblecmds.c \
-    ./hcic/hcicmds.c \
+    ./avct/avct_api.cc \
+    ./avct/avct_bcb_act.cc \
+    ./avct/avct_ccb.cc \
+    ./avct/avct_l2c.cc \
+    ./avct/avct_l2c_br.cc \
+    ./avct/avct_lcb.cc \
+    ./avct/avct_lcb_act.cc \
+    ./avdt/avdt_ad.cc \
+    ./avdt/avdt_api.cc \
+    ./avdt/avdt_ccb.cc \
+    ./avdt/avdt_ccb_act.cc \
+    ./avdt/avdt_l2c.cc \
+    ./avdt/avdt_msg.cc \
+    ./avdt/avdt_scb.cc \
+    ./avdt/avdt_scb_act.cc \
+    ./avrc/avrc_api.cc \
+    ./avrc/avrc_bld_ct.cc \
+    ./avrc/avrc_bld_tg.cc \
+    ./avrc/avrc_opt.cc \
+    ./avrc/avrc_pars_ct.cc \
+    ./avrc/avrc_pars_tg.cc \
+    ./avrc/avrc_sdp.cc \
+    ./avrc/avrc_utils.cc \
+    ./bnep/bnep_api.cc \
+    ./bnep/bnep_main.cc \
+    ./bnep/bnep_utils.cc \
     ./btm/ble_advertiser_hci_interface.cc \
-    ./btm/btm_ble.c \
-    ./btm/btm_sec.c \
-    ./btm/btm_inq.c \
-    ./btm/btm_ble_addr.c \
+    ./btm/btm_acl.cc \
+    ./btm/btm_ble.cc \
+    ./btm/btm_ble_addr.cc \
+    ./btm/btm_ble_adv_filter.cc \
+    ./btm/btm_ble_batchscan.cc \
     ./btm/btm_ble_bgconn.cc \
-    ./btm/btm_main.c \
-    ./btm/btm_dev.c \
-    ./btm/btm_ble_gap.c \
-    ./btm/btm_ble_adv_filter.c \
+    ./btm/btm_ble_cont_energy.cc \
+    ./btm/btm_ble_gap.cc \
     ./btm/btm_ble_multi_adv.cc \
-    ./btm/btm_ble_batchscan.c \
-    ./btm/btm_ble_cont_energy.c \
-    ./btm/btm_ble_privacy.c \
-    ./btm/btm_acl.c \
-    ./btm/btm_sco.c \
-    ./btm/btm_pm.c \
-    ./btm/btm_devctl.c \
-    ./rfcomm/rfc_utils.c \
-    ./rfcomm/port_rfc.c \
-    ./rfcomm/rfc_l2cap_if.c \
-    ./rfcomm/rfc_mx_fsm.c \
-    ./rfcomm/port_utils.c \
-    ./rfcomm/rfc_port_fsm.c \
-    ./rfcomm/rfc_port_if.c \
-    ./rfcomm/port_api.c \
-    ./rfcomm/rfc_ts_frames.c \
-    ./mcap/mca_dact.c \
-    ./mcap/mca_dsm.c \
-    ./mcap/mca_l2c.c \
-    ./mcap/mca_main.c \
-    ./mcap/mca_csm.c \
-    ./mcap/mca_cact.c \
-    ./mcap/mca_api.c \
-    ./gatt/gatt_sr.c \
-    ./gatt/gatt_cl.c \
-    ./gatt/gatt_api.c \
-    ./gatt/gatt_auth.c \
-    ./gatt/gatt_utils.c \
-    ./gatt/gatt_main.c \
-    ./gatt/att_protocol.c \
-    ./gatt/gatt_attr.c \
-    ./gatt/gatt_db.c \
-    ./avct/avct_api.c \
-    ./avct/avct_l2c_br.c \
-    ./avct/avct_bcb_act.c \
-    ./avct/avct_l2c.c \
-    ./avct/avct_lcb.c \
-    ./avct/avct_ccb.c \
-    ./avct/avct_lcb_act.c \
-    ./smp/smp_main.c \
-    ./smp/smp_l2c.c \
-    ./smp/smp_cmac.c \
-    ./smp/smp_utils.c \
-    ./smp/smp_act.c \
-    ./smp/smp_keys.c \
-    ./smp/smp_api.c \
-    ./smp/aes.c \
-    ./smp/smp_br_main.c\
-    ./smp/p_256_curvepara.c \
-    ./smp/p_256_ecc_pp.c \
-    ./smp/p_256_multprecision.c \
-    ./avdt/avdt_ccb.c \
-    ./avdt/avdt_scb_act.c \
-    ./avdt/avdt_msg.c \
-    ./avdt/avdt_ccb_act.c \
-    ./avdt/avdt_api.c \
-    ./avdt/avdt_scb.c \
-    ./avdt/avdt_ad.c \
-    ./avdt/avdt_l2c.c \
-    ./sdp/sdp_server.c \
-    ./sdp/sdp_main.c \
-    ./sdp/sdp_db.c \
-    ./sdp/sdp_utils.c \
-    ./sdp/sdp_api.c \
-    ./sdp/sdp_discovery.c \
-    ./pan/pan_main.c \
-    ./srvc/srvc_battery.c \
-    ./srvc/srvc_dis.c \
-    ./srvc/srvc_eng.c \
-    ./pan/pan_api.c \
-    ./pan/pan_utils.c \
-    ./btu/btu_hcif.c \
-    ./btu/btu_init.c \
-    ./btu/btu_task.c \
-    ./l2cap/l2c_fcr.c \
-    ./l2cap/l2c_ucd.c \
-    ./l2cap/l2c_main.c \
-    ./l2cap/l2c_api.c \
-    ./l2cap/l2c_utils.c \
-    ./l2cap/l2c_csm.c \
-    ./l2cap/l2c_link.c \
-    ./l2cap/l2c_ble.c \
-    ./l2cap/l2cap_client.c \
-    ./gap/gap_api.c \
-    ./gap/gap_ble.c \
-    ./gap/gap_conn.c \
-    ./gap/gap_utils.c
+    ./btm/btm_ble_privacy.cc \
+    ./btm/btm_dev.cc \
+    ./btm/btm_devctl.cc \
+    ./btm/btm_inq.cc \
+    ./btm/btm_main.cc \
+    ./btm/btm_pm.cc \
+    ./btm/btm_sco.cc \
+    ./btm/btm_sec.cc \
+    ./btu/btu_hcif.cc \
+    ./btu/btu_init.cc \
+    ./btu/btu_task.cc \
+    ./gap/gap_api.cc \
+    ./gap/gap_ble.cc \
+    ./gap/gap_conn.cc \
+    ./gap/gap_utils.cc \
+    ./gatt/att_protocol.cc \
+    ./gatt/gatt_api.cc \
+    ./gatt/gatt_attr.cc \
+    ./gatt/gatt_auth.cc \
+    ./gatt/gatt_cl.cc \
+    ./gatt/gatt_db.cc \
+    ./gatt/gatt_main.cc \
+    ./gatt/gatt_sr.cc \
+    ./gatt/gatt_utils.cc \
+    ./hcic/hciblecmds.cc \
+    ./hcic/hcicmds.cc \
+    ./hid/hidh_api.cc \
+    ./hid/hidh_conn.cc \
+    ./l2cap/l2c_api.cc \
+    ./l2cap/l2c_ble.cc \
+    ./l2cap/l2c_csm.cc \
+    ./l2cap/l2c_fcr.cc \
+    ./l2cap/l2c_link.cc \
+    ./l2cap/l2c_main.cc \
+    ./l2cap/l2c_ucd.cc \
+    ./l2cap/l2c_utils.cc \
+    ./l2cap/l2cap_client.cc \
+    ./mcap/mca_api.cc \
+    ./mcap/mca_cact.cc \
+    ./mcap/mca_csm.cc \
+    ./mcap/mca_dact.cc \
+    ./mcap/mca_dsm.cc \
+    ./mcap/mca_l2c.cc \
+    ./mcap/mca_main.cc \
+    ./pan/pan_api.cc \
+    ./pan/pan_main.cc \
+    ./pan/pan_utils.cc \
+    ./rfcomm/port_api.cc \
+    ./rfcomm/port_rfc.cc \
+    ./rfcomm/port_utils.cc \
+    ./rfcomm/rfc_l2cap_if.cc \
+    ./rfcomm/rfc_mx_fsm.cc \
+    ./rfcomm/rfc_port_fsm.cc \
+    ./rfcomm/rfc_port_if.cc \
+    ./rfcomm/rfc_ts_frames.cc \
+    ./rfcomm/rfc_utils.cc \
+    ./sdp/sdp_api.cc \
+    ./sdp/sdp_db.cc \
+    ./sdp/sdp_discovery.cc \
+    ./sdp/sdp_main.cc \
+    ./sdp/sdp_server.cc \
+    ./sdp/sdp_utils.cc \
+    ./smp/aes.cc \
+    ./smp/p_256_curvepara.cc \
+    ./smp/p_256_ecc_pp.cc \
+    ./smp/p_256_multprecision.cc \
+    ./smp/smp_act.cc \
+    ./smp/smp_api.cc \
+    ./smp/smp_br_main.cc \
+    ./smp/smp_cmac.cc \
+    ./smp/smp_keys.cc \
+    ./smp/smp_l2c.cc \
+    ./smp/smp_main.cc \
+    ./smp/smp_utils.cc \
+    ./srvc/srvc_battery.cc \
+    ./srvc/srvc_dis.cc \
+    ./srvc/srvc_eng.cc
 
 LOCAL_MODULE := libbt-stack
 LOCAL_STATIC_LIBRARIES := libbt-hci
diff --git a/stack/BUILD.gn b/stack/BUILD.gn
index e4354cf..ece0632 100644
--- a/stack/BUILD.gn
+++ b/stack/BUILD.gn
@@ -21,122 +21,119 @@
     "a2dp/a2dp_sbc_encoder.cc",
     "a2dp/a2dp_sbc_up_sample.cc",
     "a2dp/a2dp_vendor.cc",
-    "avrc/avrc_api.c",
-    "avrc/avrc_sdp.c",
-    "avrc/avrc_opt.c",
-    "avrc/avrc_bld_tg.c",
-    "avrc/avrc_bld_ct.c",
-    "avrc/avrc_pars_tg.c",
-    "avrc/avrc_pars_ct.c",
-    "avrc/avrc_utils.c",
-    "hid/hidh_api.c",
-    "hid/hidh_conn.c",
-    "bnep/bnep_main.c",
-    "bnep/bnep_utils.c",
-    "bnep/bnep_api.c",
-    "hcic/hciblecmds.c",
-    "hcic/hcicmds.c",
+    "avct/avct_api.cc",
+    "avct/avct_bcb_act.cc",
+    "avct/avct_ccb.cc",
+    "avct/avct_l2c.cc",
+    "avct/avct_l2c_br.cc",
+    "avct/avct_lcb.cc",
+    "avct/avct_lcb_act.cc",
+    "avdt/avdt_ad.cc",
+    "avdt/avdt_api.cc",
+    "avdt/avdt_ccb.cc",
+    "avdt/avdt_ccb_act.cc",
+    "avdt/avdt_l2c.cc",
+    "avdt/avdt_msg.cc",
+    "avdt/avdt_scb.cc",
+    "avdt/avdt_scb_act.cc",
+    "avrc/avrc_api.cc",
+    "avrc/avrc_bld_ct.cc",
+    "avrc/avrc_bld_tg.cc",
+    "avrc/avrc_opt.cc",
+    "avrc/avrc_pars_ct.cc",
+    "avrc/avrc_pars_tg.cc",
+    "avrc/avrc_sdp.cc",
+    "avrc/avrc_utils.cc",
+    "bnep/bnep_api.cc",
+    "bnep/bnep_main.cc",
+    "bnep/bnep_utils.cc",
     "btm/ble_advertiser_hci_interface.cc",
-    "btm/btm_ble.c",
-    "btm/btm_sec.c",
-    "btm/btm_inq.c",
-    "btm/btm_ble_addr.c",
+    "btm/btm_acl.cc",
+    "btm/btm_ble.cc",
+    "btm/btm_ble_addr.cc",
+    "btm/btm_ble_adv_filter.cc",
+    "btm/btm_ble_batchscan.cc",
     "btm/btm_ble_bgconn.cc",
-    "btm/btm_main.c",
-    "btm/btm_dev.c",
-    "btm/btm_ble_gap.c",
-    "btm/btm_ble_adv_filter.c",
+    "btm/btm_ble_cont_energy.cc",
+    "btm/btm_ble_gap.cc",
     "btm/btm_ble_multi_adv.cc",
-    "btm/btm_ble_batchscan.c",
-    "btm/btm_ble_cont_energy.c",
-    "btm/btm_ble_privacy.c",
-    "btm/btm_acl.c",
-    "btm/btm_sco.c",
-    "btm/btm_pm.c",
-    "btm/btm_devctl.c",
-    "rfcomm/rfc_utils.c",
-    "rfcomm/port_rfc.c",
-    "rfcomm/rfc_l2cap_if.c",
-    "rfcomm/rfc_mx_fsm.c",
-    "rfcomm/port_utils.c",
-    "rfcomm/rfc_port_fsm.c",
-    "rfcomm/rfc_port_if.c",
-    "rfcomm/port_api.c",
-    "rfcomm/rfc_ts_frames.c",
-    "mcap/mca_dact.c",
-    "mcap/mca_dsm.c",
-    "mcap/mca_l2c.c",
-    "mcap/mca_main.c",
-    "mcap/mca_csm.c",
-    "mcap/mca_cact.c",
-    "mcap/mca_api.c",
-    "gatt/gatt_sr.c",
-    "gatt/gatt_cl.c",
-    "gatt/gatt_api.c",
-    "gatt/gatt_auth.c",
-    "gatt/gatt_utils.c",
-    "gatt/gatt_main.c",
-    "gatt/att_protocol.c",
-    "gatt/gatt_attr.c",
-    "gatt/gatt_db.c",
-    "avct/avct_api.c",
-    "avct/avct_bcb_act.c",
-    "avct/avct_l2c.c",
-    "avct/avct_l2c_br.c",
-    "avct/avct_lcb.c",
-    "avct/avct_ccb.c",
-    "avct/avct_lcb_act.c",
-    "smp/smp_main.c",
-    "smp/smp_l2c.c",
-    "smp/smp_cmac.c",
-    "smp/smp_utils.c",
-    "smp/smp_act.c",
-    "smp/smp_keys.c",
-    "smp/smp_api.c",
-    "smp/aes.c",
-    "smp/smp_br_main.c",
-    "smp/p_256_curvepara.c",
-    "smp/p_256_ecc_pp.c",
-    "smp/p_256_multprecision.c",
-    "avdt/avdt_ccb.c",
-    "avdt/avdt_scb_act.c",
-    "avdt/avdt_msg.c",
-    "avdt/avdt_ccb_act.c",
-    "avdt/avdt_api.c",
-    "avdt/avdt_scb.c",
-    "avdt/avdt_ad.c",
-    "avdt/avdt_l2c.c",
-    "sdp/sdp_server.c",
-    "sdp/sdp_main.c",
-    "sdp/sdp_db.c",
-    "sdp/sdp_utils.c",
-    "sdp/sdp_api.c",
-    "sdp/sdp_discovery.c",
-    "pan/pan_main.c",
-    "srvc/srvc_battery.c",
-    "srvc/srvc_battery_int.h",
-    "srvc/srvc_dis.c",
-    "srvc/srvc_dis_int.h",
-    "srvc/srvc_eng.c",
-    "srvc/srvc_eng_int.h",
-    "pan/pan_api.c",
-    "pan/pan_utils.c",
-    "btu/btu_hcif.c",
-    "btu/btu_init.c",
-    "btu/btu_task.c",
-    "l2cap/l2c_fcr.c",
-    "l2cap/l2c_ucd.c",
-    "l2cap/l2c_main.c",
-    "l2cap/l2c_api.c",
-    "l2cap/l2c_utils.c",
-    "l2cap/l2c_csm.c",
-    "l2cap/l2c_link.c",
-    "l2cap/l2c_ble.c",
-    "l2cap/l2cap_client.c",
-    "gap/gap_api.c",
-    "gap/gap_ble.c",
-    "gap/gap_conn.c",
-    "gap/gap_utils.c",
+    "btm/btm_ble_privacy.cc",
+    "btm/btm_dev.cc",
+    "btm/btm_devctl.cc",
+    "btm/btm_inq.cc",
+    "btm/btm_main.cc",
+    "btm/btm_pm.cc",
+    "btm/btm_sco.cc",
+    "btm/btm_sec.cc",
+    "btu/btu_hcif.cc",
+    "btu/btu_init.cc",
+    "btu/btu_task.cc",
+    "gap/gap_api.cc",
+    "gap/gap_ble.cc",
+    "gap/gap_conn.cc",
+    "gap/gap_utils.cc",
+    "gatt/att_protocol.cc",
+    "gatt/gatt_api.cc",
+    "gatt/gatt_attr.cc",
+    "gatt/gatt_auth.cc",
+    "gatt/gatt_cl.cc",
+    "gatt/gatt_db.cc",
+    "gatt/gatt_main.cc",
+    "gatt/gatt_sr.cc",
+    "gatt/gatt_utils.cc",
+    "hcic/hciblecmds.cc",
+    "hcic/hcicmds.cc",
+    "hid/hidh_api.cc",
+    "hid/hidh_conn.cc",
+    "l2cap/l2c_api.cc",
+    "l2cap/l2c_ble.cc",
+    "l2cap/l2c_csm.cc",
+    "l2cap/l2c_fcr.cc",
+    "l2cap/l2c_link.cc",
+    "l2cap/l2c_main.cc",
+    "l2cap/l2c_ucd.cc",
+    "l2cap/l2c_utils.cc",
+    "l2cap/l2cap_client.cc",
+    "mcap/mca_api.cc",
+    "mcap/mca_cact.cc",
+    "mcap/mca_csm.cc",
+    "mcap/mca_dact.cc",
+    "mcap/mca_dsm.cc",
+    "mcap/mca_l2c.cc",
+    "mcap/mca_main.cc",
+    "pan/pan_api.cc",
+    "pan/pan_main.cc",
+    "pan/pan_utils.cc",
+    "rfcomm/port_api.cc",
+    "rfcomm/port_rfc.cc",
+    "rfcomm/port_utils.cc",
+    "rfcomm/rfc_l2cap_if.cc",
+    "rfcomm/rfc_mx_fsm.cc",
+    "rfcomm/rfc_port_fsm.cc",
+    "rfcomm/rfc_port_if.cc",
+    "rfcomm/rfc_ts_frames.cc",
+    "rfcomm/rfc_utils.cc",
+    "sdp/sdp_api.cc",
+    "sdp/sdp_db.cc",
+    "sdp/sdp_discovery.cc",
+    "sdp/sdp_main.cc",
+    "sdp/sdp_server.cc",
+    "sdp/sdp_utils.cc",
+    "smp/aes.cc",
+    "smp/p_256_curvepara.cc",
+    "smp/p_256_ecc_pp.cc",
+    "smp/p_256_multprecision.cc",
+    "smp/smp_act.cc",
+    "smp/smp_api.cc",
+    "smp/smp_br_main.cc",
+    "smp/smp_cmac.cc",
+    "smp/smp_keys.cc",
+    "smp/smp_l2c.cc",
+    "smp/smp_main.cc",
+    "smp/smp_utils.cc",
+    "srvc/srvc_battery.cc",
+    "srvc/srvc_dis.cc",
+    "srvc/srvc_eng.cc",
   ]
 
   include_dirs = [
diff --git a/stack/avct/avct_api.c b/stack/avct/avct_api.cc
similarity index 100%
rename from stack/avct/avct_api.c
rename to stack/avct/avct_api.cc
diff --git a/stack/avct/avct_bcb_act.c b/stack/avct/avct_bcb_act.cc
similarity index 99%
rename from stack/avct/avct_bcb_act.c
rename to stack/avct/avct_bcb_act.cc
index ac5cb33..33275fa 100644
--- a/stack/avct/avct_bcb_act.c
+++ b/stack/avct/avct_bcb_act.cc
@@ -18,7 +18,7 @@
 
 /*****************************************************************************
 *
-*  Name:           avct_bcb_act.c
+*  Name:           avct_bcb_act.cc
 *
 *  Description:    This module contains action functions of the browsing control
 *                  state machine.
diff --git a/stack/avct/avct_ccb.c b/stack/avct/avct_ccb.cc
similarity index 100%
rename from stack/avct/avct_ccb.c
rename to stack/avct/avct_ccb.cc
diff --git a/stack/avct/avct_l2c.c b/stack/avct/avct_l2c.cc
similarity index 100%
rename from stack/avct/avct_l2c.c
rename to stack/avct/avct_l2c.cc
diff --git a/stack/avct/avct_l2c_br.c b/stack/avct/avct_l2c_br.cc
similarity index 99%
rename from stack/avct/avct_l2c_br.c
rename to stack/avct/avct_l2c_br.cc
index 6dee799..e63728c 100644
--- a/stack/avct/avct_l2c_br.c
+++ b/stack/avct/avct_l2c_br.cc
@@ -18,7 +18,7 @@
 
 /*****************************************************************************
 **
-**  Name:           avct_l2c_br.c
+**  Name:           avct_l2c_br.cc
 **
 **  Description:    This AVCTP module interfaces to L2CAP
 **
diff --git a/stack/avct/avct_lcb.c b/stack/avct/avct_lcb.cc
similarity index 100%
rename from stack/avct/avct_lcb.c
rename to stack/avct/avct_lcb.cc
diff --git a/stack/avct/avct_lcb_act.c b/stack/avct/avct_lcb_act.cc
similarity index 100%
rename from stack/avct/avct_lcb_act.c
rename to stack/avct/avct_lcb_act.cc
diff --git a/stack/avdt/avdt_ad.c b/stack/avdt/avdt_ad.cc
similarity index 100%
rename from stack/avdt/avdt_ad.c
rename to stack/avdt/avdt_ad.cc
diff --git a/stack/avdt/avdt_api.c b/stack/avdt/avdt_api.cc
similarity index 100%
rename from stack/avdt/avdt_api.c
rename to stack/avdt/avdt_api.cc
diff --git a/stack/avdt/avdt_ccb.c b/stack/avdt/avdt_ccb.cc
similarity index 100%
rename from stack/avdt/avdt_ccb.c
rename to stack/avdt/avdt_ccb.cc
diff --git a/stack/avdt/avdt_ccb_act.c b/stack/avdt/avdt_ccb_act.cc
similarity index 100%
rename from stack/avdt/avdt_ccb_act.c
rename to stack/avdt/avdt_ccb_act.cc
diff --git a/stack/avdt/avdt_l2c.c b/stack/avdt/avdt_l2c.cc
similarity index 100%
rename from stack/avdt/avdt_l2c.c
rename to stack/avdt/avdt_l2c.cc
diff --git a/stack/avdt/avdt_msg.c b/stack/avdt/avdt_msg.cc
similarity index 100%
rename from stack/avdt/avdt_msg.c
rename to stack/avdt/avdt_msg.cc
diff --git a/stack/avdt/avdt_scb.c b/stack/avdt/avdt_scb.cc
similarity index 100%
rename from stack/avdt/avdt_scb.c
rename to stack/avdt/avdt_scb.cc
diff --git a/stack/avdt/avdt_scb_act.c b/stack/avdt/avdt_scb_act.cc
similarity index 99%
rename from stack/avdt/avdt_scb_act.c
rename to stack/avdt/avdt_scb_act.cc
index 4104c2d..81744b5 100644
--- a/stack/avdt/avdt_scb_act.c
+++ b/stack/avdt/avdt_scb_act.cc
@@ -55,16 +55,6 @@
     0                           /* API_ABORT_REQ_EVT (no event) */
 };
 
-/* This table is used to look up the callback event based on the signaling
-** role when the stream is closed.
-*/
-const uint8_t avdt_scb_role_evt[] = {
-    AVDT_CLOSE_IND_EVT,         /* AVDT_CLOSE_ACP */
-    AVDT_CLOSE_CFM_EVT,         /* AVDT_CLOSE_INT */
-    AVDT_CLOSE_IND_EVT,         /* AVDT_OPEN_ACP */
-    AVDT_OPEN_CFM_EVT           /* AVDT_OPEN_INT */
-};
-
 /*******************************************************************************
 **
 ** Function         avdt_scb_gen_ssrc
diff --git a/stack/avrc/avrc_api.c b/stack/avrc/avrc_api.cc
similarity index 99%
rename from stack/avrc/avrc_api.c
rename to stack/avrc/avrc_api.cc
index ff74389..8b4eeb1 100644
--- a/stack/avrc/avrc_api.c
+++ b/stack/avrc/avrc_api.cc
@@ -202,7 +202,7 @@
 ******************************************************************************/
 void avrc_start_cmd_timer(uint8_t handle, uint8_t label, uint8_t msg_mask)
 {
-    tAVRC_PARAM *param = osi_malloc(sizeof(tAVRC_PARAM));
+    tAVRC_PARAM *param = static_cast<tAVRC_PARAM *>(osi_malloc(sizeof(tAVRC_PARAM)));
     param->handle = handle;
     param->label = label;
     param->msg_mask = msg_mask;
@@ -660,7 +660,7 @@
     uint8_t     *p_rsp_data;
     int         xx;
     bool        reject = false;
-    char        *p_drop_msg = "dropped";
+    const char  *p_drop_msg = "dropped";
     tAVRC_MSG_VENDOR *p_msg = &msg.vendor;
 
     if (cr == AVCT_CMD &&
@@ -779,6 +779,7 @@
             break;
 
         case AVRC_OP_VENDOR:
+        {
             p_data  = (uint8_t *)(p_pkt+1) + p_pkt->offset;
             p_begin = p_data;
             if (p_pkt->len < AVRC_VENDOR_HDR_SIZE) /* 6 = ctype, subunit*, opcode & CO_ID */
@@ -842,7 +843,8 @@
             {
                 avrc_send_next_vendor_cmd(handle);
             }
-            break;
+        }
+        break;
 
         case AVRC_OP_PASS_THRU:
             if (p_pkt->len < 5) /* 3 bytes: ctype, subunit*, opcode & op_id & len */
diff --git a/stack/avrc/avrc_bld_ct.c b/stack/avrc/avrc_bld_ct.cc
similarity index 100%
rename from stack/avrc/avrc_bld_ct.c
rename to stack/avrc/avrc_bld_ct.cc
diff --git a/stack/avrc/avrc_bld_tg.c b/stack/avrc/avrc_bld_tg.cc
similarity index 100%
rename from stack/avrc/avrc_bld_tg.c
rename to stack/avrc/avrc_bld_tg.cc
diff --git a/stack/avrc/avrc_opt.c b/stack/avrc/avrc_opt.cc
similarity index 100%
rename from stack/avrc/avrc_opt.c
rename to stack/avrc/avrc_opt.cc
diff --git a/stack/avrc/avrc_pars_ct.c b/stack/avrc/avrc_pars_ct.cc
similarity index 100%
rename from stack/avrc/avrc_pars_ct.c
rename to stack/avrc/avrc_pars_ct.cc
diff --git a/stack/avrc/avrc_pars_tg.c b/stack/avrc/avrc_pars_tg.cc
similarity index 100%
rename from stack/avrc/avrc_pars_tg.c
rename to stack/avrc/avrc_pars_tg.cc
diff --git a/stack/avrc/avrc_sdp.c b/stack/avrc/avrc_sdp.cc
similarity index 100%
rename from stack/avrc/avrc_sdp.c
rename to stack/avrc/avrc_sdp.cc
diff --git a/stack/avrc/avrc_utils.c b/stack/avrc/avrc_utils.cc
similarity index 100%
rename from stack/avrc/avrc_utils.c
rename to stack/avrc/avrc_utils.cc
diff --git a/stack/bnep/bnep_api.c b/stack/bnep/bnep_api.cc
similarity index 100%
rename from stack/bnep/bnep_api.c
rename to stack/bnep/bnep_api.cc
diff --git a/stack/bnep/bnep_int.h b/stack/bnep/bnep_int.h
index 65d37da..91d3dd1 100644
--- a/stack/bnep/bnep_int.h
+++ b/stack/bnep/bnep_int.h
@@ -192,7 +192,7 @@
 */
 extern tBNEP_CB bnep_cb;
 
-/* Functions provided by bnep_main.c
+/* Functions provided by bnep_main.cc
 */
 extern tBNEP_RESULT bnep_register_with_l2cap (void);
 extern void        bnep_disconnect (tBNEP_CONN *p_bcb, uint16_t reason);
@@ -201,7 +201,7 @@
 extern void        bnep_connected (tBNEP_CONN *p_bcb);
 
 
-/* Functions provided by bnep_utils.c
+/* Functions provided by bnep_utils.cc
 */
 extern tBNEP_CONN *bnepu_find_bcb_by_cid (uint16_t cid);
 extern tBNEP_CONN *bnepu_find_bcb_by_bd_addr (uint8_t *p_bda);
diff --git a/stack/bnep/bnep_main.c b/stack/bnep/bnep_main.cc
similarity index 100%
rename from stack/bnep/bnep_main.c
rename to stack/bnep/bnep_main.cc
diff --git a/stack/bnep/bnep_utils.c b/stack/bnep/bnep_utils.cc
similarity index 100%
rename from stack/bnep/bnep_utils.c
rename to stack/bnep/bnep_utils.cc
diff --git a/stack/btm/btm_acl.c b/stack/btm/btm_acl.cc
similarity index 99%
rename from stack/btm/btm_acl.c
rename to stack/btm/btm_acl.cc
index 8520fe9..eac50d0 100644
--- a/stack/btm/btm_acl.c
+++ b/stack/btm/btm_acl.cc
@@ -18,7 +18,7 @@
 
 /*****************************************************************************
 **
-**  Name:          btm_acl.c
+**  Name:          btm_acl.cc
 **
 **  Description:   This file contains functions that handle ACL connections.
 **                 This includes operations such as hold and sniff modes,
diff --git a/stack/btm/btm_ble.c b/stack/btm/btm_ble.cc
similarity index 99%
rename from stack/btm/btm_ble.c
rename to stack/btm/btm_ble.cc
index 23b3cde..f90fc67 100644
--- a/stack/btm/btm_ble.c
+++ b/stack/btm/btm_ble.cc
@@ -38,6 +38,7 @@
 #include "btu.h"
 #include "device/include/controller.h"
 #include "gap_api.h"
+#include "gatt_api.h"
 #include "hcimsgs.h"
 #include "l2c_int.h"
 #include "osi/include/log.h"
@@ -46,10 +47,7 @@
 #if (SMP_INCLUDED == TRUE)
 extern bool    aes_cipher_msg_auth_code(BT_OCTET16 key, uint8_t *input, uint16_t length,
                                                  uint16_t tlen, uint8_t *p_signature);
-extern void smp_link_encrypted(BD_ADDR bda, uint8_t encr_enable);
-extern bool    smp_proc_ltk_request(BD_ADDR bda);
 #endif
-extern void gatt_notify_enc_cmpl(BD_ADDR bd_addr);
 
 /*******************************************************************************/
 /* External Function to be called by other modules                             */
diff --git a/stack/btm/btm_ble_addr.c b/stack/btm/btm_ble_addr.cc
similarity index 98%
rename from stack/btm/btm_ble_addr.c
rename to stack/btm/btm_ble_addr.cc
index c7a4bde..93a1b03 100644
--- a/stack/btm/btm_ble_addr.c
+++ b/stack/btm/btm_ble_addr.cc
@@ -324,7 +324,7 @@
     BTM_TRACE_EVENT("%s next iteration", __func__);
 
     tSMP_ENC output;
-    tBTM_SEC_DEV_REC *p_dev_rec = data;
+    tBTM_SEC_DEV_REC *p_dev_rec = static_cast<tBTM_SEC_DEV_REC *>(data);
 
     BTM_TRACE_DEBUG("sec_flags = %02x device_type = %d", p_dev_rec->sec_flags,
                     p_dev_rec->device_type);
@@ -364,7 +364,9 @@
         /* check for next security record */
 
         list_node_t * n = list_foreach(btm_cb.sec_dev_rec, btm_ble_match_random_bda, NULL);
-        tBTM_SEC_DEV_REC *p_dev_rec = n ? list_node(n) : NULL;
+        tBTM_SEC_DEV_REC *p_dev_rec = NULL;
+        if (n != NULL)
+            p_dev_rec = static_cast<tBTM_SEC_DEV_REC *>(list_node(n));
 
         BTM_TRACE_EVENT("%s:  %sresolved", __func__, (p_dev_rec == NULL ? "not " : ""));
         p_mgnt_cb->busy = false;
@@ -391,7 +393,8 @@
 #if (BLE_PRIVACY_SPT == TRUE)
     list_node_t *end = list_end(btm_cb.sec_dev_rec);
     for (list_node_t *node = list_begin(btm_cb.sec_dev_rec); node != end; node = list_next(node)) {
-        tBTM_SEC_DEV_REC *p_dev_rec = list_node(node);
+        tBTM_SEC_DEV_REC *p_dev_rec =
+            static_cast<tBTM_SEC_DEV_REC *>(list_node(node));
         if (memcmp(p_dev_rec->ble.static_addr, bd_addr, BD_ADDR_LEN) == 0) {
             if ((p_dev_rec->ble.static_addr_type & (~BLE_ADDR_TYPE_ID_BIT)) !=
                 (addr_type & (~BLE_ADDR_TYPE_ID_BIT)))
diff --git a/stack/btm/btm_ble_adv_filter.c b/stack/btm/btm_ble_adv_filter.cc
similarity index 100%
rename from stack/btm/btm_ble_adv_filter.c
rename to stack/btm/btm_ble_adv_filter.cc
diff --git a/stack/btm/btm_ble_batchscan.c b/stack/btm/btm_ble_batchscan.cc
similarity index 98%
rename from stack/btm/btm_ble_batchscan.c
rename to stack/btm/btm_ble_batchscan.cc
index 71b262b..c61e781 100644
--- a/stack/btm/btm_ble_batchscan.c
+++ b/stack/btm/btm_ble_batchscan.cc
@@ -100,14 +100,16 @@
                 STREAM_TO_UINT8(adv_data.adv_pkt_len, p);
                 if (adv_data.adv_pkt_len > 0)
                 {
-                    adv_data.p_adv_pkt_data = osi_malloc(adv_data.adv_pkt_len);
+                    adv_data.p_adv_pkt_data =
+                        static_cast<uint8_t *>(osi_malloc(adv_data.adv_pkt_len));
                     memcpy(adv_data.p_adv_pkt_data, p, adv_data.adv_pkt_len);
                 }
 
                 STREAM_TO_UINT8(adv_data.scan_rsp_len, p);
                 if (adv_data.scan_rsp_len > 0)
                 {
-                    adv_data.p_scan_rsp_data = osi_malloc(adv_data.scan_rsp_len);
+                    adv_data.p_scan_rsp_data =
+                        static_cast<uint8_t *>(osi_malloc(adv_data.scan_rsp_len));
                     memcpy(adv_data.p_scan_rsp_data, p, adv_data.scan_rsp_len);
                 }
             }
@@ -219,7 +221,7 @@
 
         if (NULL != p_orig_data)
         {
-            p_app_data = osi_malloc(len + data_len);
+            p_app_data = static_cast<uint8_t *>(osi_malloc(len + data_len));
             memcpy(p_app_data, p_orig_data, len);
             memcpy(p_app_data+len, p_data, data_len);
             osi_free(p_orig_data);
@@ -229,7 +231,7 @@
         }
         else
         {
-            p_app_data = osi_malloc(data_len);
+            p_app_data = static_cast<uint8_t *>(osi_malloc(data_len));
             memcpy(p_app_data, p_data, data_len);
             ble_batchscan_cb.main_rep_q.p_data[index] = p_app_data;
             ble_batchscan_cb.main_rep_q.num_records[index] = num_records;
@@ -354,7 +356,7 @@
     uint8_t status = 0, subcode = 0, opcode = 0;
     uint8_t report_format = 0, num_records = 0, cb_evt = 0;
     uint16_t data_len = 0;
-    tBTM_BLE_BATCH_SCAN_STATE cur_state = 0;
+    tBTM_BLE_BATCH_SCAN_STATE cur_state = BTM_BLE_SCAN_INVALID_STATE;
     uint8_t *p_data = NULL;
 
     if (len < 2)
diff --git a/stack/btm/btm_ble_cont_energy.c b/stack/btm/btm_ble_cont_energy.cc
similarity index 100%
rename from stack/btm/btm_ble_cont_energy.c
rename to stack/btm/btm_ble_cont_energy.cc
diff --git a/stack/btm/btm_ble_gap.c b/stack/btm/btm_ble_gap.cc
similarity index 99%
rename from stack/btm/btm_ble_gap.c
rename to stack/btm/btm_ble_gap.cc
index e908ca0..f817734 100644
--- a/stack/btm/btm_ble_gap.c
+++ b/stack/btm/btm_ble_gap.cc
@@ -900,7 +900,7 @@
 #if (BLE_PRIVACY_SPT == TRUE)
 static bool is_resolving_list_bit_set(void *data, void *context)
 {
-    tBTM_SEC_DEV_REC *p_dev_rec = data;
+    tBTM_SEC_DEV_REC *p_dev_rec = static_cast<tBTM_SEC_DEV_REC *>(data);
 
     if ((p_dev_rec->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) != 0)
         return false;
@@ -978,7 +978,8 @@
         list_node_t *n = list_foreach(btm_cb.sec_dev_rec, is_resolving_list_bit_set, NULL);
         if (n) {
             /* if enhanced privacy is required, set Identity address and matching IRK peer */
-            tBTM_SEC_DEV_REC  *p_dev_rec = list_node(n);
+            tBTM_SEC_DEV_REC *p_dev_rec =
+                static_cast<tBTM_SEC_DEV_REC *>(list_node(n));
             memcpy(p_peer_addr_ptr, p_dev_rec->ble.static_addr, BD_ADDR_LEN);
             *p_peer_addr_type = p_dev_rec->ble.static_addr_type;
 
diff --git a/stack/btm/btm_ble_int.h b/stack/btm/btm_ble_int.h
index 7f6a1e5..c36b536 100644
--- a/stack/btm/btm_ble_int.h
+++ b/stack/btm/btm_ble_int.h
@@ -72,7 +72,7 @@
 extern tBTM_STATUS btm_ble_start_scan(void);
 extern void btm_ble_create_ll_conn_complete (uint8_t status);
 
-/* LE security function from btm_sec.c */
+/* LE security function from btm_sec.cc */
 #if (SMP_INCLUDED == TRUE)
 extern void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE_SEC_REQ_ACT *p_sec_req_act);
 extern void btm_ble_ltk_request_reply(BD_ADDR bda,  bool    use_stk, BT_OCTET16 stk);
diff --git a/stack/btm/btm_ble_privacy.c b/stack/btm/btm_ble_privacy.cc
similarity index 99%
rename from stack/btm/btm_ble_privacy.c
rename to stack/btm/btm_ble_privacy.cc
index 710054b..a9a5c16 100644
--- a/stack/btm/btm_ble_privacy.c
+++ b/stack/btm/btm_ble_privacy.cc
@@ -216,7 +216,7 @@
 
 bool clear_resolving_list_bit(void *data, void *context)
 {
-    tBTM_SEC_DEV_REC *p_dev_rec = data;
+    tBTM_SEC_DEV_REC *p_dev_rec = static_cast<tBTM_SEC_DEV_REC *>(data);
     p_dev_rec->ble.in_controller_list &= ~BTM_RESOLVING_LIST_BIT;
     return true;
 }
@@ -909,7 +909,7 @@
 
 bool is_on_resolving_list(void *data, void *context)
 {
-    tBTM_SEC_DEV_REC *p_dev = data;
+    tBTM_SEC_DEV_REC *p_dev = static_cast<tBTM_SEC_DEV_REC *>(data);
     if ((p_dev->ble.in_controller_list & BTM_RESOLVING_LIST_BIT) &&
         (p_dev->ble.in_controller_list & BTM_WHITE_LIST_BIT))
         return false;
diff --git a/stack/btm/btm_dev.c b/stack/btm/btm_dev.cc
similarity index 95%
rename from stack/btm/btm_dev.c
rename to stack/btm/btm_dev.cc
index 39bd134..f4d86a7 100644
--- a/stack/btm/btm_dev.c
+++ b/stack/btm/btm_dev.cc
@@ -211,8 +211,8 @@
 
 bool is_bd_addr_equal(void *data, void *context)
 {
-    tBTM_SEC_DEV_REC *p_dev_rec = data;
-    BD_ADDR *bd_addr = context;
+    tBTM_SEC_DEV_REC *p_dev_rec = static_cast<tBTM_SEC_DEV_REC *>(data);
+    BD_ADDR *bd_addr = static_cast<BD_ADDR *>(context);
 
     if (!memcmp(p_dev_rec->bd_addr, bd_addr, BD_ADDR_LEN))
         return false;
@@ -339,8 +339,8 @@
 
 bool is_handle_equal(void *data, void *context)
 {
-    tBTM_SEC_DEV_REC *p_dev_rec = data;
-    uint16_t *handle = context;
+    tBTM_SEC_DEV_REC *p_dev_rec = static_cast<tBTM_SEC_DEV_REC *>(data);
+    uint16_t *handle = static_cast<uint16_t *>(context);
 
     if (p_dev_rec->hci_handle == *handle
 #if (BLE_INCLUDED == TRUE)
@@ -366,15 +366,15 @@
 {
     list_node_t *n = list_foreach(btm_cb.sec_dev_rec, is_handle_equal, &handle);
     if (n)
-        return list_node(n);
+        return static_cast<tBTM_SEC_DEV_REC *>(list_node(n));
 
     return NULL;
 }
 
 bool is_address_equal(void *data, void *context)
 {
-    tBTM_SEC_DEV_REC *p_dev_rec = data;
-    BD_ADDR *bd_addr = context;
+    tBTM_SEC_DEV_REC *p_dev_rec = static_cast<tBTM_SEC_DEV_REC *>(data);
+    BD_ADDR *bd_addr = static_cast<BD_ADDR *>(context);
 
     if (!memcmp (p_dev_rec->bd_addr, *bd_addr, BD_ADDR_LEN))
         return false;
@@ -406,7 +406,7 @@
 
     list_node_t *n = list_foreach(btm_cb.sec_dev_rec, is_address_equal, (void*)bd_addr);
     if (n)
-        return list_node(n);
+        return static_cast<tBTM_SEC_DEV_REC *>(list_node(n));
 
     return NULL;
 }
@@ -429,7 +429,8 @@
 
     list_node_t *end = list_end(btm_cb.sec_dev_rec);
     for (list_node_t *node = list_begin(btm_cb.sec_dev_rec); node != end; node = list_next(node)) {
-        tBTM_SEC_DEV_REC *p_dev_rec = list_node(node);
+        tBTM_SEC_DEV_REC *p_dev_rec =
+            static_cast<tBTM_SEC_DEV_REC *>(list_node(node));
 
         if (p_target_rec == p_dev_rec)
             continue;
@@ -513,7 +514,8 @@
 
     list_node_t *end = list_end(btm_cb.sec_dev_rec);
     for (list_node_t *node = list_begin(btm_cb.sec_dev_rec); node != end; node = list_next(node)) {
-        tBTM_SEC_DEV_REC *p_dev_rec = list_node(node);
+        tBTM_SEC_DEV_REC *p_dev_rec =
+            static_cast<tBTM_SEC_DEV_REC *>(list_node(node));
 
         if ((p_dev_rec->sec_flags & (BTM_SEC_LINK_KEY_KNOWN | BTM_SEC_LE_LINK_KEY_KNOWN)) == 0) {
             // Device is not paired
@@ -559,7 +561,8 @@
         list_remove(btm_cb.sec_dev_rec, p_dev_rec);
     }
 
-    p_dev_rec = osi_calloc(sizeof(tBTM_SEC_DEV_REC));
+    p_dev_rec =
+        static_cast<tBTM_SEC_DEV_REC *>(osi_calloc(sizeof(tBTM_SEC_DEV_REC)));
     list_append(btm_cb.sec_dev_rec, p_dev_rec);
 
     // Initialize defaults
diff --git a/stack/btm/btm_devctl.c b/stack/btm/btm_devctl.cc
similarity index 99%
rename from stack/btm/btm_devctl.c
rename to stack/btm/btm_devctl.cc
index 9dd03f6..a31cf79 100644
--- a/stack/btm/btm_devctl.c
+++ b/stack/btm/btm_devctl.cc
@@ -142,7 +142,7 @@
 
 bool set_sec_state_idle(void *data, void *context)
 {
-    tBTM_SEC_DEV_REC *p_dev_rec = data;
+    tBTM_SEC_DEV_REC *p_dev_rec = static_cast<tBTM_SEC_DEV_REC *>(data);
     p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
     return true;
 }
diff --git a/stack/btm/btm_inq.c b/stack/btm/btm_inq.cc
similarity index 100%
rename from stack/btm/btm_inq.c
rename to stack/btm/btm_inq.cc
diff --git a/stack/btm/btm_int.h b/stack/btm/btm_int.h
index 38be619..bdf12c0 100644
--- a/stack/btm/btm_int.h
+++ b/stack/btm/btm_int.h
@@ -51,12 +51,12 @@
 
 extern tBTM_CB btm_cb;
 
-/* Internal functions provided by btm_main.c
+/* Internal functions provided by btm_main.cc
 ********************************************
 */
 extern void         btm_init (void);
 
-/* Internal functions provided by btm_inq.c
+/* Internal functions provided by btm_inq.cc
 *******************************************
 */
 extern tBTM_STATUS  btm_initiate_rem_name(BD_ADDR remote_bda,
@@ -83,7 +83,7 @@
 
 extern bool    btm_lookup_eir(BD_ADDR_PTR p_rem_addr);
 
-/* Internal functions provided by btm_acl.c
+/* Internal functions provided by btm_acl.cc
 ********************************************
 */
 extern void         btm_acl_init (void);
@@ -147,7 +147,7 @@
                                    FLOW_SPEC *p_flow);
 
 
-/* Internal functions provided by btm_sco.c
+/* Internal functions provided by btm_sco.cc
 ********************************************
 */
 extern void btm_sco_init (void);
@@ -168,7 +168,7 @@
 extern uint16_t btm_find_scb_by_handle (uint16_t handle);
 extern void btm_sco_flush_sco_data(uint16_t sco_inx);
 
-/* Internal functions provided by btm_devctl.c
+/* Internal functions provided by btm_devctl.cc
 **********************************************
 */
 extern void btm_dev_init(void);
@@ -194,7 +194,7 @@
 extern void btm_report_device_status (tBTM_DEV_STATUS status);
 
 
-/* Internal functions provided by btm_dev.c
+/* Internal functions provided by btm_dev.cc
 **********************************************
 */
 extern bool    btm_dev_support_switch (BD_ADDR bd_addr);
@@ -209,7 +209,7 @@
 extern bool               btm_set_bond_type_dev(BD_ADDR bd_addr,
                                                 tBTM_BOND_TYPE bond_type);
 
-/* Internal functions provided by btm_sec.c
+/* Internal functions provided by btm_sec.cc
 **********************************************
 */
 extern bool    btm_dev_support_switch (BD_ADDR bd_addr);
diff --git a/stack/btm/btm_main.c b/stack/btm/btm_main.cc
similarity index 100%
rename from stack/btm/btm_main.c
rename to stack/btm/btm_main.cc
diff --git a/stack/btm/btm_pm.c b/stack/btm/btm_pm.cc
similarity index 100%
rename from stack/btm/btm_pm.c
rename to stack/btm/btm_pm.cc
diff --git a/stack/btm/btm_sco.c b/stack/btm/btm_sco.cc
similarity index 100%
rename from stack/btm/btm_sco.c
rename to stack/btm/btm_sco.cc
diff --git a/stack/btm/btm_sec.c b/stack/btm/btm_sec.cc
similarity index 99%
rename from stack/btm/btm_sec.c
rename to stack/btm/btm_sec.cc
index 6d5822e..480a7de 100644
--- a/stack/btm/btm_sec.c
+++ b/stack/btm/btm_sec.cc
@@ -3029,7 +3029,7 @@
 
 bool is_state_getting_name(void *data, void *context)
 {
-    tBTM_SEC_DEV_REC *p_dev_rec = data;
+    tBTM_SEC_DEV_REC *p_dev_rec = static_cast<tBTM_SEC_DEV_REC *>(data);
 
     if (p_dev_rec->sec_state == BTM_SEC_STATE_GETTING_NAME) {
         return false;
@@ -3069,7 +3069,7 @@
     {
         list_node_t *node = list_foreach(btm_cb.sec_dev_rec, is_state_getting_name, NULL);
         if (node != NULL) {
-            p_dev_rec = list_node(node);
+            p_dev_rec = static_cast<tBTM_SEC_DEV_REC *>(list_node(node));
             p_bd_addr = p_dev_rec->bd_addr;
         } else {
             p_dev_rec = NULL;
@@ -5774,8 +5774,8 @@
 
 bool is_sec_state_equal(void *data, void *context)
 {
-    tBTM_SEC_DEV_REC *p_dev_rec = data;
-    uint8_t *state = context;
+    tBTM_SEC_DEV_REC *p_dev_rec = static_cast<tBTM_SEC_DEV_REC *>(data);
+    uint8_t *state = static_cast<uint8_t *>(context);
 
     if (p_dev_rec->sec_state == *state)
         return false;
@@ -5797,7 +5797,7 @@
 {
     list_node_t *n = list_foreach(btm_cb.sec_dev_rec, is_sec_state_equal, &state);
     if (n)
-        return list_node(n);
+        return static_cast<tBTM_SEC_DEV_REC *>(list_node(n));
 
     return NULL;
 }
diff --git a/stack/btu/btu_hcif.c b/stack/btu/btu_hcif.cc
similarity index 99%
rename from stack/btu/btu_hcif.c
rename to stack/btu/btu_hcif.cc
index 40e3a99..8b2d567 100644
--- a/stack/btu/btu_hcif.c
+++ b/stack/btu/btu_hcif.cc
@@ -921,7 +921,8 @@
 
 static void btu_hcif_command_complete_evt(BT_HDR *response, void *context)
 {
-    BT_HDR *event = osi_calloc(sizeof(BT_HDR) + sizeof(command_complete_hack_t));
+    BT_HDR *event =
+      static_cast<BT_HDR *>(osi_calloc(sizeof(BT_HDR) + sizeof(command_complete_hack_t)));
     command_complete_hack_t *hack = (command_complete_hack_t *)&event->data[0];
 
     hack->callback = btu_hcif_command_complete_evt_on_task;
@@ -1118,7 +1119,8 @@
 
 static void btu_hcif_command_status_evt(uint8_t status, BT_HDR *command, void *context)
 {
-    BT_HDR *event = osi_calloc(sizeof(BT_HDR) + sizeof(command_status_hack_t));
+    BT_HDR *event =
+        static_cast<BT_HDR *>(osi_calloc(sizeof(BT_HDR) + sizeof(command_status_hack_t)));
     command_status_hack_t *hack = (command_status_hack_t *)&event->data[0];
 
     hack->callback = btu_hcif_command_status_evt_on_task;
diff --git a/stack/btu/btu_init.c b/stack/btu/btu_init.cc
similarity index 100%
rename from stack/btu/btu_init.c
rename to stack/btu/btu_init.cc
diff --git a/stack/btu/btu_task.c b/stack/btu/btu_task.cc
similarity index 99%
rename from stack/btu/btu_task.c
rename to stack/btu/btu_task.cc
index 6a9f9ac..fc015ae 100644
--- a/stack/btu/btu_task.c
+++ b/stack/btu/btu_task.cc
@@ -29,6 +29,7 @@
 #include "bt_types.h"
 #include "bt_utils.h"
 #include "btcore/include/module.h"
+#include "bte.h"
 #include "btif_common.h"
 #include "btm_api.h"
 #include "btm_int.h"
@@ -81,7 +82,7 @@
 #include "btm_ble_int.h"
 #endif
 
-extern void BTE_InitStack(void);
+
 
 /* Define BTU storage area
 */
diff --git a/stack/gap/gap_api.c b/stack/gap/gap_api.cc
similarity index 100%
rename from stack/gap/gap_api.c
rename to stack/gap/gap_api.cc
diff --git a/stack/gap/gap_ble.c b/stack/gap/gap_ble.cc
similarity index 100%
rename from stack/gap/gap_ble.c
rename to stack/gap/gap_ble.cc
diff --git a/stack/gap/gap_conn.c b/stack/gap/gap_conn.cc
similarity index 99%
rename from stack/gap/gap_conn.c
rename to stack/gap/gap_conn.cc
index b441d62..0d2fc52 100644
--- a/stack/gap/gap_conn.c
+++ b/stack/gap/gap_conn.cc
@@ -123,7 +123,7 @@
 ** Returns          handle of the connection if successful, else GAP_INVALID_HANDLE
 **
 *******************************************************************************/
-uint16_t GAP_ConnOpen (char *p_serv_name, uint8_t service_id, bool    is_server,
+uint16_t GAP_ConnOpen(const char *p_serv_name, uint8_t service_id, bool is_server,
                      BD_ADDR p_rem_bda, uint16_t psm, tL2CAP_CFG_INFO *p_cfg,
                      tL2CAP_ERTM_INFO *ertm_info, uint16_t security, uint8_t chan_mode_mask,
                      tGAP_CONN_CALLBACK *p_cb, tBT_TRANSPORT transport)
@@ -358,7 +358,8 @@
 
     while (max_len)
     {
-        BT_HDR *p_buf = fixed_queue_try_peek_first(p_ccb->rx_queue);
+        BT_HDR *p_buf =
+            static_cast<BT_HDR *>(fixed_queue_try_peek_first(p_ccb->rx_queue));
         if (p_buf == NULL)
             break;
 
diff --git a/stack/gap/gap_utils.c b/stack/gap/gap_utils.cc
similarity index 100%
rename from stack/gap/gap_utils.c
rename to stack/gap/gap_utils.cc
diff --git a/stack/gatt/att_protocol.c b/stack/gatt/att_protocol.cc
similarity index 100%
rename from stack/gatt/att_protocol.c
rename to stack/gatt/att_protocol.cc
diff --git a/stack/gatt/gatt_api.c b/stack/gatt/gatt_api.cc
similarity index 99%
rename from stack/gatt/gatt_api.c
rename to stack/gatt/gatt_api.cc
index 5c74911..4391edf 100644
--- a/stack/gatt/gatt_api.c
+++ b/stack/gatt/gatt_api.cc
@@ -796,12 +796,15 @@
                 memcpy(&p_clcb->uuid, &p_read->service.uuid, sizeof(tBT_UUID));
                 break;
             case GATT_READ_MULTIPLE:
+            {
                 p_clcb->s_handle = 0;
                 /* copy multiple handles in CB */
                 tGATT_READ_MULTI *p_read_multi =
                     (tGATT_READ_MULTI *)osi_malloc(sizeof(tGATT_READ_MULTI));
                 p_clcb->p_attr_buf = (uint8_t*)p_read_multi;
                 memcpy(p_read_multi, &p_read->read_multiple, sizeof(tGATT_READ_MULTI));
+                /* TODO: Missing "break" statement! */
+            }
             case GATT_READ_BY_HANDLE:
             case GATT_READ_PARTIAL:
                 memset(&p_clcb->uuid, 0, sizeof(tBT_UUID));
diff --git a/stack/gatt/gatt_attr.c b/stack/gatt/gatt_attr.cc
similarity index 100%
rename from stack/gatt/gatt_attr.c
rename to stack/gatt/gatt_attr.cc
diff --git a/stack/gatt/gatt_auth.c b/stack/gatt/gatt_auth.cc
similarity index 100%
rename from stack/gatt/gatt_auth.c
rename to stack/gatt/gatt_auth.cc
diff --git a/stack/gatt/gatt_cl.c b/stack/gatt/gatt_cl.cc
similarity index 100%
rename from stack/gatt/gatt_cl.c
rename to stack/gatt/gatt_cl.cc
diff --git a/stack/gatt/gatt_db.c b/stack/gatt/gatt_db.cc
similarity index 100%
rename from stack/gatt/gatt_db.c
rename to stack/gatt/gatt_db.cc
diff --git a/stack/gatt/gatt_int.h b/stack/gatt/gatt_int.h
index 8734706..4990d7f 100644
--- a/stack/gatt/gatt_int.h
+++ b/stack/gatt/gatt_int.h
@@ -491,11 +491,7 @@
 }
 #endif
 
-/* internal functions */
-extern void gatt_init (void);
-extern void gatt_free(void);
-
-/* from gatt_main.c */
+/* from gatt_main.cc */
 extern bool gatt_disconnect (tGATT_TCB *p_tcb);
 extern bool gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT transport, bool opportunistic);
 extern bool gatt_connect (BD_ADDR rem_bda,  tGATT_TCB *p_tcb, tBT_TRANSPORT transport);
@@ -511,11 +507,11 @@
 extern void gatt_chk_srv_chg(tGATTS_SRV_CHG *p_srv_chg_clt);
 extern void gatt_add_a_bonded_dev_for_srv_chg (BD_ADDR bda);
 
-/* from gatt_attr.c */
+/* from gatt_attr.cc */
 extern uint16_t gatt_profile_find_conn_id_by_bd_addr(BD_ADDR bda);
 
 
-/* Functions provided by att_protocol.c */
+/* Functions provided by att_protocol.cc */
 extern tGATT_STATUS attp_send_cl_msg (tGATT_TCB *p_tcb, uint16_t clcb_idx, uint8_t op_code, tGATT_CL_MSG *p_msg);
 extern BT_HDR *attp_build_sr_msg(tGATT_TCB *p_tcb, uint8_t op_code, tGATT_SR_MSG *p_msg);
 extern tGATT_STATUS attp_send_sr_msg (tGATT_TCB *p_tcb, BT_HDR *p_msg);
@@ -571,7 +567,6 @@
 extern bool    gatt_find_app_for_bg_dev(BD_ADDR bd_addr, tGATT_IF *p_gatt_if);
 extern tGATT_BG_CONN_DEV * gatt_find_bg_dev(BD_ADDR remote_bda);
 extern void gatt_deregister_bgdev_list(tGATT_IF gatt_if);
-extern void gatt_reset_bgdev_list(void);
 
 /* server function */
 extern uint8_t gatt_sr_find_i_rcb_by_handle(uint16_t handle);
@@ -627,7 +622,7 @@
                                            uint16_t len, uint8_t *p_data);
 extern void gatt_send_queue_write_cancel (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, tGATT_EXEC_FLAG flag);
 
-/* gatt_auth.c */
+/* gatt_auth.cc */
 extern bool    gatt_security_check_start(tGATT_CLCB *p_clcb);
 extern void gatt_verify_signature(tGATT_TCB *p_tcb, BT_HDR *p_buf);
 extern tGATT_SEC_ACTION gatt_determine_sec_act(tGATT_CLCB *p_clcb );
@@ -635,7 +630,7 @@
 extern tGATT_SEC_ACTION gatt_get_sec_act(tGATT_TCB *p_tcb);
 extern void gatt_set_sec_act(tGATT_TCB *p_tcb, tGATT_SEC_ACTION sec_act);
 
-/* gatt_db.c */
+/* gatt_db.cc */
 extern bool    gatts_init_service_db (tGATT_SVC_DB *p_db, tBT_UUID *p_service, bool    is_pri, uint16_t s_hdl, uint16_t num_handle);
 extern uint16_t gatts_add_included_service (tGATT_SVC_DB *p_db, uint16_t s_handle, uint16_t e_handle, tBT_UUID service);
 extern uint16_t gatts_add_characteristic (tGATT_SVC_DB *p_db, tGATT_PERM perm, tGATT_CHAR_PROP property, tBT_UUID *p_char_uuid);
@@ -650,5 +645,4 @@
 extern void gatts_update_srv_list_elem(uint8_t i_sreg, uint16_t handle, bool    is_primary);
 extern tBT_UUID * gatts_get_service_uuid (tGATT_SVC_DB *p_db);
 
-extern void gatt_reset_bgdev_list(void);
 #endif
diff --git a/stack/gatt/gatt_main.c b/stack/gatt/gatt_main.cc
similarity index 100%
rename from stack/gatt/gatt_main.c
rename to stack/gatt/gatt_main.cc
diff --git a/stack/gatt/gatt_sr.c b/stack/gatt/gatt_sr.cc
similarity index 100%
rename from stack/gatt/gatt_sr.c
rename to stack/gatt/gatt_sr.cc
diff --git a/stack/gatt/gatt_utils.c b/stack/gatt/gatt_utils.cc
similarity index 100%
rename from stack/gatt/gatt_utils.c
rename to stack/gatt/gatt_utils.cc
diff --git a/stack/hcic/hciblecmds.c b/stack/hcic/hciblecmds.cc
similarity index 100%
rename from stack/hcic/hciblecmds.c
rename to stack/hcic/hciblecmds.cc
diff --git a/stack/hcic/hcicmds.c b/stack/hcic/hcicmds.cc
similarity index 100%
rename from stack/hcic/hcicmds.c
rename to stack/hcic/hcicmds.cc
diff --git a/stack/hid/hidh_api.c b/stack/hid/hidh_api.cc
similarity index 100%
rename from stack/hid/hidh_api.c
rename to stack/hid/hidh_api.cc
diff --git a/stack/hid/hidh_conn.c b/stack/hid/hidh_conn.cc
similarity index 100%
rename from stack/hid/hidh_conn.c
rename to stack/hid/hidh_conn.cc
diff --git a/stack/include/btu.h b/stack/include/btu.h
index 66fef48..dc53b83 100644
--- a/stack/include/btu.h
+++ b/stack/include/btu.h
@@ -59,7 +59,7 @@
 
 extern const BD_ADDR        BT_BD_ANY;
 
-/* Functions provided by btu_task.c
+/* Functions provided by btu_task.cc
 ************************************
 */
 
@@ -67,13 +67,13 @@
 extern void btu_check_bt_sleep (void);
 #endif
 
-/* Functions provided by btu_hcif.c
+/* Functions provided by btu_hcif.cc
 ************************************
 */
 extern void  btu_hcif_process_event (uint8_t controller_id, BT_HDR *p_buf);
 extern void  btu_hcif_send_cmd (uint8_t controller_id, BT_HDR *p_msg);
 
-/* Functions provided by btu_core.c
+/* Functions provided by btu_init.cc
 ************************************
 */
 extern void  btu_init_core(void);
diff --git a/stack/include/gap_api.h b/stack/include/gap_api.h
index 0cd23df..22087b7 100644
--- a/stack/include/gap_api.h
+++ b/stack/include/gap_api.h
@@ -148,7 +148,7 @@
 ** Returns          handle of the connection if successful, else GAP_INVALID_HANDLE
 **
 *******************************************************************************/
-extern uint16_t GAP_ConnOpen (char *p_serv_name, uint8_t service_id, bool    is_server,
+extern uint16_t GAP_ConnOpen(const char *p_serv_name, uint8_t service_id, bool is_server,
                                     BD_ADDR p_rem_bda, uint16_t psm, tL2CAP_CFG_INFO *p_cfg,
                                     tL2CAP_ERTM_INFO *ertm_info,
                                     uint16_t security, uint8_t chan_mode_mask,
diff --git a/stack/include/gatt_api.h b/stack/include/gatt_api.h
index f671a84..4ec8bf6 100644
--- a/stack/include/gatt_api.h
+++ b/stack/include/gatt_api.h
@@ -1101,9 +1101,22 @@
 *******************************************************************************/
 extern void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, bool    enable,
                                                     tBT_TRANSPORT transport);
- 
-#ifdef __cplusplus
 
+// Enables the GATT profile on the device.
+// It clears out the control blocks, and registers with L2CAP.
+extern void gatt_init(void);
+
+// Frees resources used by the GATT profile.
+extern void gatt_free(void);
+
+// Link encryption complete notification for all encryption process
+// initiated outside GATT.
+extern void gatt_notify_enc_cmpl(BD_ADDR bd_addr);
+
+// Reset bg device list.
+extern void gatt_reset_bgdev_list(void);
+
+#ifdef __cplusplus
 }
 #endif
 
diff --git a/stack/include/hcidefs.h b/stack/include/hcidefs.h
index 2e5282d..c064501 100644
--- a/stack/include/hcidefs.h
+++ b/stack/include/hcidefs.h
@@ -836,9 +836,9 @@
 /* the event mask for 2.0 + EDR and later (includes Lisbon events) */
 #define HCI_LISBON_EVENT_MASK_0             0xFFFFFFFF
 #define HCI_LISBON_EVENT_MASK_1             0x1DBFFFFF
-#define HCI_LISBON_EVENT_MASK               "\x0D\xBF\xFF\xFF\xFF\xFF\xFF\xFF"
-#define HCI_LISBON_EVENT_MASK_EXT           "\x1D\xBF\xFF\xFF\xFF\xFF\xFF\xFF"
-#define HCI_DUMO_EVENT_MASK_EXT             "\x3D\xBF\xFF\xFF\xFF\xFF\xFF\xFF"
+#define HCI_LISBON_EVENT_MASK           {0x0D, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
+#define HCI_LISBON_EVENT_MASK_EXT       {0x1D, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
+#define HCI_DUMO_EVENT_MASK_EXT         {0x3D, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
 /*  0x00001FFF FFFFFFFF Default - no Lisbon events
     0x00000800 00000000 Synchronous Connection Complete Event
     0x00001000 00000000 Synchronous Connection Changed Event
diff --git a/stack/include/mca_api.h b/stack/include/mca_api.h
index 08b522c..5cd82e4 100644
--- a/stack/include/mca_api.h
+++ b/stack/include/mca_api.h
@@ -28,6 +28,10 @@
 #include "bt_target.h"
 #include "l2c_api.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* move the following to bt_target.h or other place later */
 #define MCA_NUM_TC_TBL  ((MCA_NUM_REGS)*(MCA_NUM_LINKS)*(MCA_NUM_MDLS+1))
 #define MCA_NUM_CCBS	((MCA_NUM_REGS)*(MCA_NUM_LINKS))    /* Number of control channel control blocks	*/
@@ -492,4 +496,8 @@
 *******************************************************************************/
 extern uint16_t MCA_GetL2CapChannel (tMCA_DL mdl);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* MCA_API_H */
diff --git a/stack/include/pan_api.h b/stack/include/pan_api.h
index 5b57c2a..a7c7b53 100644
--- a/stack/include/pan_api.h
+++ b/stack/include/pan_api.h
@@ -279,9 +279,9 @@
 *******************************************************************************/
 extern tPAN_RESULT PAN_SetRole (uint8_t role,
                                 uint8_t *sec_mask,
-                                char *p_user_name,
-                                char *p_gn_name,
-                                char *p_nap_name);
+                                const char *p_user_name,
+                                const char *p_gn_name,
+                                const char *p_nap_name);
 
 /*******************************************************************************
 **
diff --git a/stack/include/port_api.h b/stack/include/port_api.h
index cdbd17a..88dd162 100644
--- a/stack/include/port_api.h
+++ b/stack/include/port_api.h
@@ -409,6 +409,20 @@
 *******************************************************************************/
 extern int PORT_FlowControl (uint16_t handle, bool    enable);
 
+/*******************************************************************************
+**
+** Function         PORT_FlowControl_MaxCredit
+**
+** Description      This function directs a specified connection to pass
+**                  flow control message to the peer device.  Enable flag passed
+**                  shows if port can accept more data. It also sends max credit
+**                  when data flow enabled
+**
+** Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
+**                  enable     - enables data flow
+**
+*******************************************************************************/
+extern int PORT_FlowControl_MaxCredit(uint16_t handle, bool enable);
 
 /*******************************************************************************
 **
@@ -587,8 +601,8 @@
 **                  p_len       - Bytes written
 **
 *******************************************************************************/
-extern int PORT_WriteData (uint16_t handle, char *p_data, uint16_t max_len,
-                           uint16_t *p_len);
+extern int PORT_WriteData (uint16_t handle, const char *p_data,
+                           uint16_t max_len, uint16_t *p_len);
 
 /*******************************************************************************
 **
diff --git a/stack/include/sdp_api.h b/stack/include/sdp_api.h
index ae6983c..f58d834 100644
--- a/stack/include/sdp_api.h
+++ b/stack/include/sdp_api.h
@@ -680,6 +680,11 @@
 *******************************************************************************/
 bool    SDP_FindServiceUUIDInRec(tSDP_DISC_REC *p_rec, tBT_UUID *p_uuid);
 
+// Converts UUID-16 to UUID-128 by including the base UUID.
+// |uuid16| is the 2-byte UUID to convert.
+// The result with the expanded 128-bit UUID is stored in |p_uuid128|.
+void sdpu_uuid16_to_uuid128(uint16_t uuid16, uint8_t* p_uuid128);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/stack/include/smp_api.h b/stack/include/smp_api.h
index ab4d29b..fc843fb 100644
--- a/stack/include/smp_api.h
+++ b/stack/include/smp_api.h
@@ -219,8 +219,28 @@
 **
 **  Returns         Boolean - true: creation of local SC OOB data set started.
 *******************************************************************************/
-extern bool    SMP_CreateLocalSecureConnectionsOobData (
-                                                                  tBLE_BD_ADDR *addr_to_send_to);
+extern bool SMP_CreateLocalSecureConnectionsOobData(tBLE_BD_ADDR *addr_to_send_to);
+
+#if (SMP_INCLUDED == TRUE)
+// Called when LTK request is received from controller.
+extern bool smp_proc_ltk_request(BD_ADDR bda);
+
+// Called when link is encrypted and notified to slave device.
+// Proceed to send LTK, DIV and ER to master if bonding the devices.
+extern void smp_link_encrypted(BD_ADDR bda, uint8_t encr_enable);
+#endif /* SMP_INCLUDED == TRUE */
+
+//
+// The AES-CMAC Generation Function with tlen implemented.
+// |key| - CMAC key in little endian order, expect SRK when used by SMP.
+// |input| - text to be signed in little endian byte order.
+// |length| - length of the input in byte.
+// |tlen| - lenth of mac desired
+// |p_signature| - data pointer to where signed data to be stored, tlen long.
+// Returns false if out of resources, true in other cases.
+//
+bool aes_cipher_msg_auth_code(BT_OCTET16 key, uint8_t *input, uint16_t length,
+                              uint16_t tlen, uint8_t *p_signature);
 
 #ifdef __cplusplus
 }
diff --git a/stack/l2cap/l2c_api.c b/stack/l2cap/l2c_api.cc
similarity index 100%
rename from stack/l2cap/l2c_api.c
rename to stack/l2cap/l2c_api.cc
diff --git a/stack/l2cap/l2c_ble.c b/stack/l2cap/l2c_ble.cc
similarity index 100%
rename from stack/l2cap/l2c_ble.c
rename to stack/l2cap/l2c_ble.cc
diff --git a/stack/l2cap/l2c_csm.c b/stack/l2cap/l2c_csm.cc
similarity index 100%
rename from stack/l2cap/l2c_csm.c
rename to stack/l2cap/l2c_csm.cc
diff --git a/stack/l2cap/l2c_fcr.c b/stack/l2cap/l2c_fcr.cc
similarity index 99%
rename from stack/l2cap/l2c_fcr.c
rename to stack/l2cap/l2c_fcr.cc
index 90c9dc2..304886d 100644
--- a/stack/l2cap/l2c_fcr.c
+++ b/stack/l2cap/l2c_fcr.cc
@@ -115,9 +115,9 @@
 *******************************************************************************/
 static unsigned short l2c_fcr_updcrc(unsigned short icrc, unsigned char *icp, int icnt)
 {
-    register unsigned short crc = icrc;
-    register unsigned char  *cp = icp;
-    register          int   cnt = icnt;
+    unsigned short crc = icrc;
+    unsigned char *cp = icp;
+    int cnt = icnt;
 
     while (cnt--)
     {
diff --git a/stack/l2cap/l2c_int.h b/stack/l2cap/l2c_int.h
index c8bd58f..4312a02 100644
--- a/stack/l2cap/l2c_int.h
+++ b/stack/l2cap/l2c_int.h
@@ -561,7 +561,7 @@
 extern tL2C_CB  l2cb;
 
 
-/* Functions provided by l2c_main.c
+/* Functions provided by l2c_main.cc
 ************************************
 */
 void l2c_init(void);
@@ -575,7 +575,7 @@
 extern void     l2c_rcv_acl_data (BT_HDR *p_msg);
 extern void     l2c_process_held_packets (bool    timed_out);
 
-/* Functions provided by l2c_utils.c
+/* Functions provided by l2c_utils.cc
 ************************************
 */
 extern tL2C_LCB *l2cu_allocate_lcb (BD_ADDR p_bd_addr, bool    is_bonding, tBT_TRANSPORT transport);
@@ -636,7 +636,7 @@
 extern void    l2cu_process_fixed_chnl_resp (tL2C_LCB *p_lcb);
 extern bool    l2cu_is_ccb_active (tL2C_CCB *p_ccb);
 
-/* Functions provided by l2c_ucd.c
+/* Functions provided by l2c_ucd.cc
 ************************************
 */
 #if (L2CAP_UCD_INCLUDED == TRUE)
@@ -682,7 +682,7 @@
 extern void    l2cu_initialize_amp_ccb (tL2C_LCB *p_lcb);
 extern void    l2cu_adjust_out_mps (tL2C_CCB *p_ccb);
 
-/* Functions provided by l2c_link.c
+/* Functions provided by l2c_link.cc
 ************************************
 */
 extern bool     l2c_link_hci_conn_req (BD_ADDR bd_addr);
@@ -719,7 +719,7 @@
 extern void l2cu_set_info_rsp_mask (uint32_t mask);
 #endif
 
-/* Functions provided by l2c_csm.c
+/* Functions provided by l2c_csm.cc
 ************************************
 */
 extern void l2c_csm_execute (tL2C_CCB *p_ccb, uint16_t event, void *p_data);
@@ -727,7 +727,7 @@
 extern void l2c_enqueue_peer_data (tL2C_CCB *p_ccb, BT_HDR *p_buf);
 
 
-/* Functions provided by l2c_fcr.c
+/* Functions provided by l2c_fcr.cc
 ************************************
 */
 extern void     l2c_fcr_cleanup (tL2C_CCB *p_ccb);
@@ -751,7 +751,7 @@
 extern void     l2c_fcr_adj_monitor_retran_timeout (tL2C_CCB *p_ccb);
 extern void     l2c_fcr_stop_timer (tL2C_CCB *p_ccb);
 
-/* Functions provided by l2c_ble.c
+/* Functions provided by l2c_ble.cc
 ************************************
 */
 #if (BLE_INCLUDED == TRUE)
diff --git a/stack/l2cap/l2c_link.c b/stack/l2cap/l2c_link.cc
similarity index 99%
rename from stack/l2cap/l2c_link.c
rename to stack/l2cap/l2c_link.cc
index 4ace43a..4ec50b3 100644
--- a/stack/l2cap/l2c_link.c
+++ b/stack/l2cap/l2c_link.cc
@@ -444,7 +444,7 @@
                 BT_HDR *p_buf;
                 while (!list_is_empty(p_lcb->link_xmit_data_q))
                 {
-                    p_buf = list_front(p_lcb->link_xmit_data_q);
+                    p_buf = static_cast<BT_HDR *>(list_front(p_lcb->link_xmit_data_q));
                     list_remove(p_lcb->link_xmit_data_q, p_buf);
                     osi_free(p_buf);
                 }
diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.cc
similarity index 99%
rename from stack/l2cap/l2c_main.c
rename to stack/l2cap/l2c_main.cc
index a87efd8..b7e3b06 100644
--- a/stack/l2cap/l2c_main.c
+++ b/stack/l2cap/l2c_main.cc
@@ -769,7 +769,7 @@
 
     for (const list_node_t *node = list_begin(l2cb.rcv_pending_q);
         node != list_end(l2cb.rcv_pending_q);)  {
-        BT_HDR *p_buf = list_node(node);
+        BT_HDR *p_buf = static_cast<BT_HDR *>(list_node(node));
         node = list_next(node);
         if (!timed_out || (!p_buf->layer_specific) || (--p_buf->layer_specific == 0)) {
             list_remove(l2cb.rcv_pending_q, p_buf);
diff --git a/stack/l2cap/l2c_ucd.c b/stack/l2cap/l2c_ucd.cc
similarity index 100%
rename from stack/l2cap/l2c_ucd.c
rename to stack/l2cap/l2c_ucd.cc
diff --git a/stack/l2cap/l2c_utils.c b/stack/l2cap/l2c_utils.cc
similarity index 99%
rename from stack/l2cap/l2c_utils.c
rename to stack/l2cap/l2c_utils.cc
index 5e3780f..bf83b44 100644
--- a/stack/l2cap/l2c_utils.c
+++ b/stack/l2cap/l2c_utils.cc
@@ -211,7 +211,8 @@
     if (p_lcb->link_xmit_data_q)
     {
         while (!list_is_empty(p_lcb->link_xmit_data_q)) {
-            BT_HDR *p_buf = list_front(p_lcb->link_xmit_data_q);
+            BT_HDR *p_buf =
+                static_cast<BT_HDR *>(list_front(p_lcb->link_xmit_data_q));
             list_remove(p_lcb->link_xmit_data_q, p_buf);
             osi_free(p_buf);
         }
diff --git a/stack/l2cap/l2cap_client.c b/stack/l2cap/l2cap_client.cc
similarity index 98%
rename from stack/l2cap/l2cap_client.c
rename to stack/l2cap/l2cap_client.cc
index 7e8b3cb..c425a6c 100644
--- a/stack/l2cap/l2cap_client.c
+++ b/stack/l2cap/l2cap_client.cc
@@ -370,7 +370,8 @@
   assert(packet != NULL);
 
   // TODO(sharvil): eliminate copy into BT_HDR.
-  BT_HDR *bt_packet = osi_malloc(buffer_length(packet) + L2CAP_MIN_OFFSET);
+  BT_HDR *bt_packet =
+      static_cast<BT_HDR *>(osi_malloc(buffer_length(packet) + L2CAP_MIN_OFFSET));
   bt_packet->offset = L2CAP_MIN_OFFSET;
   bt_packet->len = buffer_length(packet);
   memcpy(bt_packet->data + bt_packet->offset, buffer_ptr(packet), buffer_length(packet));
@@ -384,7 +385,8 @@
       break;
     }
 
-    BT_HDR *fragment = osi_malloc(client->remote_mtu + L2CAP_MIN_OFFSET);
+    BT_HDR *fragment =
+        static_cast<BT_HDR *>(osi_malloc(client->remote_mtu + L2CAP_MIN_OFFSET));
     fragment->offset = L2CAP_MIN_OFFSET;
     fragment->len = client->remote_mtu;
     memcpy(fragment->data + fragment->offset, bt_packet->data + bt_packet->offset, client->remote_mtu);
diff --git a/stack/mcap/mca_api.c b/stack/mcap/mca_api.cc
similarity index 100%
rename from stack/mcap/mca_api.c
rename to stack/mcap/mca_api.cc
diff --git a/stack/mcap/mca_cact.c b/stack/mcap/mca_cact.cc
similarity index 100%
rename from stack/mcap/mca_cact.c
rename to stack/mcap/mca_cact.cc
diff --git a/stack/mcap/mca_csm.c b/stack/mcap/mca_csm.cc
similarity index 100%
rename from stack/mcap/mca_csm.c
rename to stack/mcap/mca_csm.cc
diff --git a/stack/mcap/mca_dact.c b/stack/mcap/mca_dact.cc
similarity index 100%
rename from stack/mcap/mca_dact.c
rename to stack/mcap/mca_dact.cc
diff --git a/stack/mcap/mca_dsm.c b/stack/mcap/mca_dsm.cc
similarity index 100%
rename from stack/mcap/mca_dsm.c
rename to stack/mcap/mca_dsm.cc
diff --git a/stack/mcap/mca_l2c.c b/stack/mcap/mca_l2c.cc
similarity index 100%
rename from stack/mcap/mca_l2c.c
rename to stack/mcap/mca_l2c.cc
diff --git a/stack/mcap/mca_main.c b/stack/mcap/mca_main.cc
similarity index 100%
rename from stack/mcap/mca_main.c
rename to stack/mcap/mca_main.cc
diff --git a/stack/pan/pan_api.c b/stack/pan/pan_api.cc
similarity index 98%
rename from stack/pan/pan_api.c
rename to stack/pan/pan_api.cc
index 1a4f740..19da970 100644
--- a/stack/pan/pan_api.c
+++ b/stack/pan/pan_api.cc
@@ -133,11 +133,11 @@
 *******************************************************************************/
 tPAN_RESULT PAN_SetRole (uint8_t role,
                          uint8_t *sec_mask,
-                         char *p_user_name,
-                         char *p_gn_name,
-                         char *p_nap_name)
+                         const char *p_user_name,
+                         const char *p_gn_name,
+                         const char *p_nap_name)
 {
-    char                *p_desc;
+    const char          *p_desc;
     uint8_t             security[3] = {PAN_PANU_SECURITY_LEVEL,
                                        PAN_GN_SECURITY_LEVEL,
                                        PAN_NAP_SECURITY_LEVEL};
diff --git a/stack/pan/pan_int.h b/stack/pan/pan_int.h
index 9da20fe..7779724 100644
--- a/stack/pan/pan_int.h
+++ b/stack/pan/pan_int.h
@@ -133,7 +133,8 @@
                             tBNEP_RESULT result,
                             uint16_t num_filters,
                             uint8_t *p_filters);
-extern uint32_t pan_register_with_sdp (uint16_t uuid, uint8_t sec_mask, char *p_name, char *p_desc);
+extern uint32_t pan_register_with_sdp (uint16_t uuid, uint8_t sec_mask,
+                                       const char *p_name, const char *p_desc);
 extern tPAN_CONN *pan_allocate_pcb (BD_ADDR p_bda, uint16_t handle);
 extern tPAN_CONN *pan_get_pcb_by_handle (uint16_t handle);
 extern tPAN_CONN *pan_get_pcb_by_addr (BD_ADDR p_bda);
diff --git a/stack/pan/pan_main.c b/stack/pan/pan_main.cc
similarity index 100%
rename from stack/pan/pan_main.c
rename to stack/pan/pan_main.cc
diff --git a/stack/pan/pan_utils.c b/stack/pan/pan_utils.cc
similarity index 98%
rename from stack/pan/pan_utils.c
rename to stack/pan/pan_utils.cc
index fe578f0..3a5d030 100644
--- a/stack/pan/pan_utils.c
+++ b/stack/pan/pan_utils.cc
@@ -58,7 +58,8 @@
 ** Returns
 **
 *******************************************************************************/
-uint32_t pan_register_with_sdp (uint16_t uuid, uint8_t sec_mask, char *p_name, char *p_desc)
+uint32_t pan_register_with_sdp (uint16_t uuid, uint8_t sec_mask,
+                                const char *p_name, const char *p_desc)
 {
     uint32_t sdp_handle;
     uint16_t browse_list = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
diff --git a/stack/rfcomm/port_api.c b/stack/rfcomm/port_api.cc
similarity index 99%
rename from stack/rfcomm/port_api.c
rename to stack/rfcomm/port_api.cc
index 6b0130c..83b0ab7 100644
--- a/stack/rfcomm/port_api.c
+++ b/stack/rfcomm/port_api.cc
@@ -1657,7 +1657,8 @@
 **                  p_len       - Byte count received
 **
 *******************************************************************************/
-int PORT_WriteData (uint16_t handle, char *p_data, uint16_t max_len, uint16_t *p_len)
+int PORT_WriteData (uint16_t handle, const char *p_data, uint16_t max_len,
+                    uint16_t *p_len)
 {
     tPORT      *p_port;
     BT_HDR     *p_buf;
diff --git a/stack/rfcomm/port_int.h b/stack/rfcomm/port_int.h
index c20027c..e30685b 100644
--- a/stack/rfcomm/port_int.h
+++ b/stack/rfcomm/port_int.h
@@ -220,7 +220,7 @@
 } tPORT_CB;
 
 /*
-** Functions provided by the port_utils.c
+** Functions provided by the port_utils.cc
 */
 extern tPORT    *port_allocate_port (uint8_t dlci, BD_ADDR bd_addr);
 extern void     port_set_defaults (tPORT *p_port);
@@ -235,7 +235,7 @@
 extern void     port_flow_control_peer(tPORT *p_port, bool    enable, uint16_t count);
 
 /*
-** Functions provided by the port_rfc.c
+** Functions provided by the port_rfc.cc
 */
 extern int  port_open_continue (tPORT *p_port);
 extern void port_start_port_open (tPORT *p_port);
diff --git a/stack/rfcomm/port_rfc.c b/stack/rfcomm/port_rfc.cc
similarity index 100%
rename from stack/rfcomm/port_rfc.c
rename to stack/rfcomm/port_rfc.cc
diff --git a/stack/rfcomm/port_utils.c b/stack/rfcomm/port_utils.cc
similarity index 100%
rename from stack/rfcomm/port_utils.c
rename to stack/rfcomm/port_utils.cc
diff --git a/stack/rfcomm/rfc_int.h b/stack/rfcomm/rfc_int.h
index 1c2e6c2..dd3259e 100644
--- a/stack/rfcomm/rfc_int.h
+++ b/stack/rfcomm/rfc_int.h
@@ -276,7 +276,7 @@
 extern void rfc_mx_sm_execute (tRFC_MCB *p_mcb, uint16_t event, void *p_data);
 
 /*
-** Functions provided by the rfc_port_fsm.c
+** Functions provided by the rfc_port_fsm.cc
 */
 extern void rfc_port_sm_execute (tPORT *p_port, uint16_t event, void *p_data);
 
@@ -292,7 +292,7 @@
 extern void rfc_process_l2cap_congestion (tRFC_MCB *p_mcb, bool    is_congested);
 
 /*
-** Functions provided by the rfc_utils.c
+** Functions provided by the rfc_utils.cc
 */
 tRFC_MCB  *rfc_alloc_multiplexer_channel (BD_ADDR bd_addr, bool    is_initiator);
 extern void      rfc_release_multiplexer_channel (tRFC_MCB *p_rfc_mcb);
@@ -313,7 +313,7 @@
 extern void      rfc_check_send_cmd(tRFC_MCB *p_mcb, BT_HDR *p_buf);
 
 /*
-** Functions provided by the rfc_ts_frames.c
+** Functions provided by the rfc_ts_frames.cc
 */
 extern void     rfc_send_sabme (tRFC_MCB *p_rfc_mcb, uint8_t dlci);
 extern void     rfc_send_ua (tRFC_MCB *p_rfc_mcb, uint8_t dlci);
@@ -334,12 +334,6 @@
 extern void     rfc_process_mx_message (tRFC_MCB *p_rfc_mcb, BT_HDR *p_buf);
 extern uint8_t  rfc_parse_data (tRFC_MCB *p_rfc_mcb, MX_FRAME *p_frame, BT_HDR *p_buf);
 
-/*
-** Functions provided by the rfc_disp.c
-*/
-
-
-
 /* Call back functions from RFCOMM */
 extern void rfcomm_l2cap_if_init (void);
 
diff --git a/stack/rfcomm/rfc_l2cap_if.c b/stack/rfcomm/rfc_l2cap_if.cc
similarity index 100%
rename from stack/rfcomm/rfc_l2cap_if.c
rename to stack/rfcomm/rfc_l2cap_if.cc
diff --git a/stack/rfcomm/rfc_mx_fsm.c b/stack/rfcomm/rfc_mx_fsm.cc
similarity index 99%
rename from stack/rfcomm/rfc_mx_fsm.c
rename to stack/rfcomm/rfc_mx_fsm.cc
index 26bd8b7..8168962 100644
--- a/stack/rfcomm/rfc_mx_fsm.c
+++ b/stack/rfcomm/rfc_mx_fsm.cc
@@ -117,7 +117,7 @@
     switch (event)
     {
     case RFC_MX_EVENT_START_REQ:
-
+    {
         /* Initialize L2CAP MTU */
         p_mcb->peer_l2cap_mtu = L2CAP_DEFAULT_MTU - RFCOMM_MIN_OFFSET - 1;
 
@@ -134,6 +134,7 @@
 
         p_mcb->state = RFC_MX_STATE_WAIT_CONN_CNF;
         return;
+    }
 
     case RFC_MX_EVENT_START_RSP:
     case RFC_MX_EVENT_CONN_CNF:
diff --git a/stack/rfcomm/rfc_port_fsm.c b/stack/rfcomm/rfc_port_fsm.cc
similarity index 100%
rename from stack/rfcomm/rfc_port_fsm.c
rename to stack/rfcomm/rfc_port_fsm.cc
diff --git a/stack/rfcomm/rfc_port_if.c b/stack/rfcomm/rfc_port_if.cc
similarity index 100%
rename from stack/rfcomm/rfc_port_if.c
rename to stack/rfcomm/rfc_port_if.cc
diff --git a/stack/rfcomm/rfc_ts_frames.c b/stack/rfcomm/rfc_ts_frames.cc
similarity index 100%
rename from stack/rfcomm/rfc_ts_frames.c
rename to stack/rfcomm/rfc_ts_frames.cc
diff --git a/stack/rfcomm/rfc_utils.c b/stack/rfcomm/rfc_utils.cc
similarity index 100%
rename from stack/rfcomm/rfc_utils.c
rename to stack/rfcomm/rfc_utils.cc
diff --git a/stack/sdp/sdp_api.c b/stack/sdp/sdp_api.cc
similarity index 100%
rename from stack/sdp/sdp_api.c
rename to stack/sdp/sdp_api.cc
diff --git a/stack/sdp/sdp_db.c b/stack/sdp/sdp_db.cc
similarity index 100%
rename from stack/sdp/sdp_db.c
rename to stack/sdp/sdp_db.cc
diff --git a/stack/sdp/sdp_discovery.c b/stack/sdp/sdp_discovery.cc
similarity index 100%
rename from stack/sdp/sdp_discovery.c
rename to stack/sdp/sdp_discovery.cc
diff --git a/stack/sdp/sdp_main.c b/stack/sdp/sdp_main.cc
similarity index 100%
rename from stack/sdp/sdp_main.c
rename to stack/sdp/sdp_main.cc
diff --git a/stack/sdp/sdp_server.c b/stack/sdp/sdp_server.cc
similarity index 100%
rename from stack/sdp/sdp_server.c
rename to stack/sdp/sdp_server.cc
diff --git a/stack/sdp/sdp_utils.c b/stack/sdp/sdp_utils.cc
similarity index 100%
rename from stack/sdp/sdp_utils.c
rename to stack/sdp/sdp_utils.cc
diff --git a/stack/sdp/sdpint.h b/stack/sdp/sdpint.h
index 2797869..4a9f726 100644
--- a/stack/sdp/sdpint.h
+++ b/stack/sdp/sdpint.h
@@ -235,7 +235,7 @@
 /* Global SDP data */
 extern tSDP_CB  sdp_cb;
 
-/* Functions provided by sdp_main.c */
+/* Functions provided by sdp_main.cc */
 extern void     sdp_init (void);
 extern void     sdp_disconnect (tCONN_CB*p_ccb, uint16_t reason);
 
@@ -243,7 +243,7 @@
 extern uint16_t sdp_set_max_attr_list_size (uint16_t max_size);
 #endif
 
-/* Functions provided by sdp_conn.c
+/* Functions provided by sdp_conn.cc
 */
 extern void sdp_conn_rcv_l2e_conn_ind (BT_HDR *p_msg);
 extern void sdp_conn_rcv_l2e_conn_cfm (BT_HDR *p_msg);
@@ -258,7 +258,7 @@
 
 extern tCONN_CB *sdp_conn_originate (uint8_t *p_bd_addr);
 
-/* Functions provided by sdp_utils.c
+/* Functions provided by sdp_utils.cc
 */
 extern tCONN_CB *sdpu_find_ccb_by_cid (uint16_t cid);
 extern tCONN_CB *sdpu_find_ccb_by_db (tSDP_DISCOVERY_DB *p_db);
@@ -283,16 +283,15 @@
 extern uint16_t sdpu_get_attrib_seq_len(tSDP_RECORD *p_rec, tSDP_ATTR_SEQ *attr_seq);
 extern uint16_t sdpu_get_attrib_entry_len(tSDP_ATTRIBUTE *p_attr);
 extern uint8_t *sdpu_build_partial_attrib_entry (uint8_t *p_out, tSDP_ATTRIBUTE *p_attr, uint16_t len, uint16_t *offset);
-extern void sdpu_uuid16_to_uuid128(uint16_t uuid16, uint8_t* p_uuid128);
 
-/* Functions provided by sdp_db.c
+/* Functions provided by sdp_db.cc
 */
 extern tSDP_RECORD    *sdp_db_service_search (tSDP_RECORD *p_rec, tSDP_UUID_SEQ *p_seq);
 extern tSDP_RECORD    *sdp_db_find_record (uint32_t handle);
 extern tSDP_ATTRIBUTE *sdp_db_find_attr_in_rec (tSDP_RECORD *p_rec, uint16_t start_attr, uint16_t end_attr);
 
 
-/* Functions provided by sdp_server.c
+/* Functions provided by sdp_server.cc
 */
 #if (SDP_SERVER_ENABLED == TRUE)
 extern void     sdp_server_handle_client_req (tCONN_CB *p_ccb, BT_HDR *p_msg);
@@ -300,7 +299,7 @@
 #define sdp_server_handle_client_req(p_ccb, p_msg)
 #endif
 
-/* Functions provided by sdp_discovery.c
+/* Functions provided by sdp_discovery.cc
 */
 #if (SDP_CLIENT_ENABLED == TRUE)
 extern void sdp_disc_connected (tCONN_CB *p_ccb);
diff --git a/stack/smp/aes.c b/stack/smp/aes.cc
similarity index 100%
rename from stack/smp/aes.c
rename to stack/smp/aes.cc
diff --git a/stack/smp/p_256_curvepara.c b/stack/smp/p_256_curvepara.cc
similarity index 100%
rename from stack/smp/p_256_curvepara.c
rename to stack/smp/p_256_curvepara.cc
diff --git a/stack/smp/p_256_ecc_pp.c b/stack/smp/p_256_ecc_pp.cc
similarity index 100%
rename from stack/smp/p_256_ecc_pp.c
rename to stack/smp/p_256_ecc_pp.cc
diff --git a/stack/smp/p_256_multprecision.c b/stack/smp/p_256_multprecision.cc
similarity index 100%
rename from stack/smp/p_256_multprecision.c
rename to stack/smp/p_256_multprecision.cc
diff --git a/stack/smp/smp_act.c b/stack/smp/smp_act.cc
similarity index 97%
rename from stack/smp/smp_act.c
rename to stack/smp/smp_act.cc
index e9ad892..4a14555 100644
--- a/stack/smp/smp_act.c
+++ b/stack/smp/smp_act.cc
@@ -27,22 +27,6 @@
 extern fixed_queue_t *btu_general_alarm_queue;
 
 #if (SMP_INCLUDED == TRUE)
-const uint8_t smp_association_table[2][SMP_IO_CAP_MAX][SMP_IO_CAP_MAX] =
-{
-    /* initiator */
-    {{SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY,   SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY}, /* Display Only */
-        {SMP_MODEL_ENCRYPTION_ONLY,  SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY}, /* SMP_CAP_IO = 1 */
-        {SMP_MODEL_KEY_NOTIF, SMP_MODEL_KEY_NOTIF,  SMP_MODEL_PASSKEY,   SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF}, /* keyboard only */
-        {SMP_MODEL_ENCRYPTION_ONLY,  SMP_MODEL_ENCRYPTION_ONLY,   SMP_MODEL_ENCRYPTION_ONLY,  SMP_MODEL_ENCRYPTION_ONLY,    SMP_MODEL_ENCRYPTION_ONLY},/* No Input No Output */
-        {SMP_MODEL_KEY_NOTIF, SMP_MODEL_KEY_NOTIF,  SMP_MODEL_PASSKEY,   SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_KEY_NOTIF}}, /* keyboard display */
-    /* responder */
-    {{SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY,   SMP_MODEL_KEY_NOTIF, SMP_MODEL_ENCRYPTION_ONLY,    SMP_MODEL_KEY_NOTIF}, /* Display Only */
-        {SMP_MODEL_ENCRYPTION_ONLY,  SMP_MODEL_ENCRYPTION_ONLY,   SMP_MODEL_KEY_NOTIF,   SMP_MODEL_ENCRYPTION_ONLY,    SMP_MODEL_KEY_NOTIF}, /* SMP_CAP_IO = 1 */
-        {SMP_MODEL_PASSKEY,   SMP_MODEL_PASSKEY,    SMP_MODEL_PASSKEY,   SMP_MODEL_ENCRYPTION_ONLY,    SMP_MODEL_PASSKEY}, /* keyboard only */
-        {SMP_MODEL_ENCRYPTION_ONLY,  SMP_MODEL_ENCRYPTION_ONLY,   SMP_MODEL_ENCRYPTION_ONLY,  SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_ENCRYPTION_ONLY},/* No Input No Output */
-        {SMP_MODEL_PASSKEY,   SMP_MODEL_PASSKEY,    SMP_MODEL_KEY_NOTIF, SMP_MODEL_ENCRYPTION_ONLY, SMP_MODEL_PASSKEY}} /* keyboard display */
-    /* display only */    /*SMP_CAP_IO = 1 */  /* keyboard only */   /* No InputOutput */  /* keyboard display */
-};
 
 #define SMP_KEY_DIST_TYPE_MAX       4
 const tSMP_ACT smp_distribute_act [] =
diff --git a/stack/smp/smp_api.c b/stack/smp/smp_api.cc
similarity index 100%
rename from stack/smp/smp_api.c
rename to stack/smp/smp_api.cc
diff --git a/stack/smp/smp_br_main.c b/stack/smp/smp_br_main.cc
similarity index 100%
rename from stack/smp/smp_br_main.c
rename to stack/smp/smp_br_main.cc
diff --git a/stack/smp/smp_cmac.c b/stack/smp/smp_cmac.cc
similarity index 100%
rename from stack/smp/smp_cmac.c
rename to stack/smp/smp_cmac.cc
diff --git a/stack/smp/smp_int.h b/stack/smp/smp_int.h
index 357ad17..93256ad 100644
--- a/stack/smp/smp_int.h
+++ b/stack/smp/smp_int.h
@@ -357,7 +357,7 @@
 }
 #endif
 
-/* Functions provided by att_main.c */
+/* Functions provided by att_main.cc */
 extern void smp_init (void);
 
 /* smp main */
@@ -394,7 +394,7 @@
 extern void             smp_set_br_state(tSMP_BR_STATE state);
 
 
-/* smp_act.c */
+/* smp_act.cc */
 extern void smp_send_pair_req(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
 extern void smp_send_confirm(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
 extern void smp_send_pair_fail(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
@@ -468,7 +468,7 @@
 extern void smp_l2cap_if_init (void);
 extern void smp_data_ind (BD_ADDR bd_addr, BT_HDR *p_buf);
 
-/* smp_util.c */
+/* smp_util.cc */
 extern bool    smp_send_cmd(uint8_t cmd_code, tSMP_CB *p_cb);
 extern void smp_cb_cleanup(tSMP_CB *p_cb);
 extern void smp_reset_control_value(tSMP_CB *p_cb);
@@ -496,7 +496,7 @@
 extern void smp_remove_fixed_channel(tSMP_CB *p_cb);
 extern bool    smp_request_oob_data(tSMP_CB *p_cb);
 
-/* smp_keys.c */
+/* smp_keys.cc */
 extern void smp_generate_srand_mrand_confirm (tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
 extern void smp_generate_compare (tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
 extern void smp_generate_stk (tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
@@ -530,7 +530,7 @@
                                                  uint8_t len);
 #endif
 
-/* smp_cmac.c */
+/* smp_cmac.cc */
 extern bool    aes_cipher_msg_auth_code(BT_OCTET16 key, uint8_t *input, uint16_t length,
                                                  uint16_t tlen, uint8_t *p_signature);
 extern void print128(BT_OCTET16 x, const uint8_t *key_name);
diff --git a/stack/smp/smp_keys.c b/stack/smp/smp_keys.cc
similarity index 100%
rename from stack/smp/smp_keys.c
rename to stack/smp/smp_keys.cc
diff --git a/stack/smp/smp_l2c.c b/stack/smp/smp_l2c.cc
similarity index 100%
rename from stack/smp/smp_l2c.c
rename to stack/smp/smp_l2c.cc
diff --git a/stack/smp/smp_main.c b/stack/smp/smp_main.cc
similarity index 100%
rename from stack/smp/smp_main.c
rename to stack/smp/smp_main.cc
diff --git a/stack/smp/smp_utils.c b/stack/smp/smp_utils.cc
similarity index 100%
rename from stack/smp/smp_utils.c
rename to stack/smp/smp_utils.cc
diff --git a/stack/srvc/srvc_battery.c b/stack/srvc/srvc_battery.cc
similarity index 100%
rename from stack/srvc/srvc_battery.c
rename to stack/srvc/srvc_battery.cc
diff --git a/stack/srvc/srvc_dis.c b/stack/srvc/srvc_dis.cc
similarity index 100%
rename from stack/srvc/srvc_dis.c
rename to stack/srvc/srvc_dis.cc
diff --git a/stack/srvc/srvc_eng.c b/stack/srvc/srvc_eng.cc
similarity index 100%
rename from stack/srvc/srvc_eng.c
rename to stack/srvc/srvc_eng.cc
diff --git a/test/suite/rfcomm/rfcomm_test.cc b/test/suite/rfcomm/rfcomm_test.cc
index 3fe0f46..93a23f1 100644
--- a/test/suite/rfcomm/rfcomm_test.cc
+++ b/test/suite/rfcomm/rfcomm_test.cc
@@ -19,10 +19,8 @@
 #include "adapter/bluetooth_test.h"
 #include "rfcomm/rfcomm_test.h"
 
-extern "C" {
 #include "btcore/include/bdaddr.h"
 #include "btcore/include/uuid.h"
-}
 
 namespace bttest {
 
diff --git a/test/suite/rfcomm/rfcomm_unittest.cc b/test/suite/rfcomm/rfcomm_unittest.cc
index 44f1cb8..c9fd9d6 100644
--- a/test/suite/rfcomm/rfcomm_unittest.cc
+++ b/test/suite/rfcomm/rfcomm_unittest.cc
@@ -19,11 +19,10 @@
 #include "adapter/bluetooth_test.h"
 #include "rfcomm/rfcomm_test.h"
 
-extern "C" {
 #include "btcore/include/bdaddr.h"
+
 #include <sys/socket.h>
 #include <unistd.h>
-}
 
 namespace {
 static const char HANDSHAKE_COMMAND[] = "AT+BRSF=29\r";
diff --git a/udrv/BUILD.gn b/udrv/BUILD.gn
index 90c84b5..1993cc3 100644
--- a/udrv/BUILD.gn
+++ b/udrv/BUILD.gn
@@ -16,7 +16,7 @@
 
 source_set("udrv") {
   sources = [
-    "ulinux/uipc.c",
+    "ulinux/uipc.cc",
   ]
 
   include_dirs = [
diff --git a/udrv/ulinux/uipc.c b/udrv/ulinux/uipc.cc
similarity index 98%
rename from udrv/ulinux/uipc.c
rename to udrv/ulinux/uipc.cc
index 41403eb..f913500 100644
--- a/udrv/ulinux/uipc.c
+++ b/udrv/ulinux/uipc.cc
@@ -18,7 +18,7 @@
 
 /*****************************************************************************
  *
- *  Filename:      uipc.c
+ *  Filename:      uipc.cc
  *
  *  Description:   UIPC implementation for bluedroid
  *
@@ -353,7 +353,8 @@
     OSI_NO_INTR(send(uipc_main.signal_fds[1], &sig_on, sizeof(sig_on), 0));
 }
 
-static int uipc_setup_server_locked(tUIPC_CH_ID ch_id, char *name, tUIPC_RCV_CBACK *cback)
+static int uipc_setup_server_locked(tUIPC_CH_ID ch_id, const char *name,
+                                    tUIPC_RCV_CBACK *cback)
 {
     int fd;
 
@@ -503,7 +504,7 @@
 }
 
 
-static void uipc_read_task(void *arg)
+static void *uipc_read_task(void *arg)
 {
     int ch_id;
     int result;
@@ -557,6 +558,8 @@
     uipc_main.tid = 0;
 
     BTIF_TRACE_EVENT("UIPC READ THREAD DONE");
+
+    return nullptr;
 }
 
 
@@ -564,7 +567,8 @@
 {
     uipc_main.running = 1;
 
-    if (pthread_create(&uipc_main.tid, (const pthread_attr_t *) NULL, (void*)uipc_read_task, NULL) < 0)
+    if (pthread_create(&uipc_main.tid, (const pthread_attr_t *) NULL,
+                       uipc_read_task, nullptr) < 0)
     {
         BTIF_TRACE_ERROR("uipc_thread_create pthread_create failed:%d", errno);
         return -1;
diff --git a/utils/Android.mk b/utils/Android.mk
index e28d5fa..5ba3e88 100644
--- a/utils/Android.mk
+++ b/utils/Android.mk
@@ -4,15 +4,17 @@
 # ========================================================
 include $(CLEAR_VARS)
 
+LOCAL_CPP_EXTENSION := .cc
+
 LOCAL_C_INCLUDES := \
-	$(LOCAL_PATH)/include \
-	$(LOCAL_PATH)/../btcore/include \
-	$(LOCAL_PATH)/../stack/include \
-	$(LOCAL_PATH)/../ \
-	$(bluetooth_C_INCLUDES)
+    $(LOCAL_PATH)/include \
+    $(LOCAL_PATH)/../btcore/include \
+    $(LOCAL_PATH)/../stack/include \
+    $(LOCAL_PATH)/../ \
+    $(bluetooth_C_INCLUDES)
 
 LOCAL_SRC_FILES := \
-	./src/bt_utils.c
+    ./src/bt_utils.cc
 
 LOCAL_MODULE := libbt-utils
 LOCAL_MODULE_TAGS := optional
diff --git a/utils/BUILD.gn b/utils/BUILD.gn
index e7a5315..13d57a1 100644
--- a/utils/BUILD.gn
+++ b/utils/BUILD.gn
@@ -16,7 +16,7 @@
 
 static_library("utils") {
   sources = [
-    "src/bt_utils.c",
+    "src/bt_utils.cc",
   ]
 
   include_dirs = [
diff --git a/utils/src/bt_utils.c b/utils/src/bt_utils.cc
similarity index 97%
rename from utils/src/bt_utils.c
rename to utils/src/bt_utils.cc
index 2d851c0..4797233 100644
--- a/utils/src/bt_utils.c
+++ b/utils/src/bt_utils.cc
@@ -18,7 +18,7 @@
 
 /************************************************************************************
  *
- *  Filename:      bt_utils.c
+ *  Filename:      bt_utils.cc
  *
  *  Description:   Miscellaneous helper functions
  *
@@ -75,7 +75,7 @@
   return NULL;
 }
 
-EXPORT_SYMBOL const module_t bt_utils_module = {
+EXPORT_SYMBOL extern const module_t bt_utils_module = {
   .name = BT_UTILS_MODULE,
   .init = init,
   .start_up = NULL,
diff --git a/vendor_libs/linux/Android.mk b/vendor_libs/linux/Android.mk
index d535e2a..3cdaabc 100644
--- a/vendor_libs/linux/Android.mk
+++ b/vendor_libs/linux/Android.mk
@@ -22,8 +22,10 @@
 # ========================================================
 include $(CLEAR_VARS)
 
+LOCAL_CPP_EXTENSION := .cc
+
 LOCAL_SRC_FILES := \
-        bt_vendor_linux.c
+        bt_vendor_linux.cc
 
 LOCAL_C_INCLUDES := \
         $(LOCAL_PATH)/../../
diff --git a/vendor_libs/linux/BUILD.gn b/vendor_libs/linux/BUILD.gn
index be0c4b4..1b7d5d9 100644
--- a/vendor_libs/linux/BUILD.gn
+++ b/vendor_libs/linux/BUILD.gn
@@ -17,7 +17,7 @@
 shared_library("bt-vendor-linux") {
   output_name = "libbt-vendor"
   sources = [
-    "bt_vendor_linux.c",
+    "bt_vendor_linux.cc",
   ]
 
   deps = [
diff --git a/vendor_libs/linux/bt_vendor_linux.c b/vendor_libs/linux/bt_vendor_linux.cc
similarity index 100%
rename from vendor_libs/linux/bt_vendor_linux.c
rename to vendor_libs/linux/bt_vendor_linux.cc