/** * @brief BT process calibration data * * @param priv a pointer to bt_private structure * @param data a pointer to cal data * @param size cal data size * @param mac mac address buf * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int bt_process_cal_cfg(bt_private * priv, u8 * data, u32 size, char *mac) { u8 bt_mac[ETH_ALEN]; u8 cal_data[32]; int ret = BT_STATUS_FAILURE; memset(bt_mac, 0, sizeof(bt_mac)); bt_parse_cal_cfg(data, size, cal_data, sizeof(cal_data)); if (mac != NULL) { /* Convert MAC format */ bt_mac2u8(bt_mac, mac); PRINTM(CMD, "HCI: new BT Address %02x:%02x:%02x:%02x:%02x:%02x\n", bt_mac[0], bt_mac[1], bt_mac[2], bt_mac[3], bt_mac[4], bt_mac[5]); if (BT_STATUS_SUCCESS != bt_load_cal_data(priv, cal_data, bt_mac)) { PRINTM(FATAL, "BT: Fail to load calibrate data\n"); goto done; } } else { if (BT_STATUS_SUCCESS != bt_load_cal_data(priv, cal_data, NULL)) { PRINTM(FATAL, "BT: Fail to load calibrate data\n"); goto done; } } ret = BT_STATUS_SUCCESS; done: LEAVE(); return ret; }
/** * @brief BT process calibration data * * @param priv a pointer to bt_private structure * @param data a pointer to cal data * @param size cal data size * @param mac mac address buf * @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE */ int bt_process_cal_cfg(bt_private * priv, u8 * data, u32 size, char *mac) { u8 bt_mac[ETH_ALEN]; u8 cal_data[32]; u8 *mac_data = NULL; u32 cal_data_len; int ret = BT_STATUS_FAILURE; memset(bt_mac, 0, sizeof(bt_mac)); cal_data_len = sizeof(cal_data); if (BT_STATUS_SUCCESS != bt_parse_cal_cfg(data, size, cal_data, &cal_data_len)) { goto done; } if (mac != NULL) { /* Convert MAC format */ bt_mac2u8(bt_mac, mac); PRINTM(CMD, "HCI: new BT Address " MACSTR "\n", MAC2STR(bt_mac)); mac_data = bt_mac; } if (BT_STATUS_SUCCESS != bt_load_cal_data(priv, cal_data, mac_data)) { PRINTM(FATAL, "BT: Fail to load calibrate data\n"); goto done; } ret = BT_STATUS_SUCCESS; done: LEAVE(); return ret; }