A272R版本优化
This commit is contained in:
@ -204,7 +204,7 @@ void send_mul_touchscreen_x_y_2_carplay(
|
||||
unsigned short x2, unsigned short y2
|
||||
);
|
||||
/*
|
||||
* @brief 发送旋钮信息给苹果;
|
||||
* @brief 发送旋钮信息给苹果手机,不建议用这个;
|
||||
*/
|
||||
void KnobUpdate(char gSelectButtonPressed,
|
||||
char gHomeButtonPressed,
|
||||
@ -213,6 +213,15 @@ void KnobUpdate(char gSelectButtonPressed,
|
||||
double gYPosition,
|
||||
char gWheelPositionRelative
|
||||
);
|
||||
/*
|
||||
* @brief 发送旋钮信息给苹果手机;
|
||||
*/
|
||||
void sendKnobInfo( char gSelectButtonPressed,
|
||||
char gHomeButtonPressed,
|
||||
char gBackButtonPressed,
|
||||
char gXPosition,
|
||||
char gYPosition,
|
||||
char gWheelPositionRelative);
|
||||
|
||||
/*
|
||||
* @brief 请求iphone启动一个应用;
|
||||
@ -266,6 +275,8 @@ void process_record_stream(int handle, void *buffer, int len, int frames, unsign
|
||||
|
||||
int carplay_get_iphone_ip_addr(char *ipaddr);
|
||||
void carplay_wl_set_iphone_mac_addr(char bt_addr[6]);
|
||||
int carplay_get_connected_iphone_wifi_mac(char mac[18]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -131,6 +131,18 @@ typedef struct __carplay_cfg_info
|
||||
|
||||
}carplay_cfg_info;
|
||||
|
||||
typedef struct _carlink_flash_io
|
||||
{
|
||||
uint32_t (*get_data_arae_size)(void* ctx);
|
||||
uint32_t (*get_flash_block_erase_size)(void* ctx);
|
||||
int32_t (*op_flash)(void* flash_handle, void* ctx, int open);
|
||||
int32_t (*read_data)(void* flash_handle, void *data, uint32_t length, uint32_t offset, void* ctx);
|
||||
int32_t (*write_data)(void* flash_handle, void *data, uint32_t length, uint32_t offset, void* ctx);
|
||||
void* ctx;
|
||||
void* flash_handle;
|
||||
} carlink_flash_io;
|
||||
void register_carlink_flash_io_interface(carlink_flash_io *handle);
|
||||
|
||||
#if 0
|
||||
typedef struct __auto_cfg_info
|
||||
{
|
||||
|
BIN
MXC_A27-PCB4.5-270T/app/carlink/CP/lib/250517-carplay.a
Normal file
BIN
MXC_A27-PCB4.5-270T/app/carlink/CP/lib/250517-carplay.a
Normal file
Binary file not shown.
Binary file not shown.
@ -20,8 +20,10 @@
|
||||
#include "carlink_common.h"
|
||||
#include "board.h"
|
||||
|
||||
|
||||
#if CARLINK_CP
|
||||
|
||||
|
||||
struct carplay_ctx
|
||||
{
|
||||
struct ICalinkEventCallbacks carlinkEventCB;
|
||||
@ -35,6 +37,7 @@ struct carplay_ctx
|
||||
char mRemoteBTMac[6];
|
||||
char mIp[32];
|
||||
char mPhoneWifiMac[18];
|
||||
void* mVideoHandle;
|
||||
};
|
||||
|
||||
struct carplay_ctx g_cp_handle;
|
||||
@ -46,6 +49,85 @@ void start_mdnsd();
|
||||
void start_mdnsd_posix();
|
||||
void stop_mdnsd_posix();
|
||||
|
||||
#if DEVICE_TYPE_SELECT == SPI_NOR_FLASH
|
||||
#include "sfud.h"
|
||||
//根据spi nor flash实际使用情况分配
|
||||
#ifndef CARLINK_CP_OFFSET
|
||||
#define CARLINK_CP_OFFSET 0X39000
|
||||
#endif
|
||||
|
||||
#ifndef CARLINK_CP_SIZE
|
||||
#define CARLINK_CP_SIZE 0x2000
|
||||
#endif
|
||||
|
||||
static int g_sf_read_ptr;
|
||||
static int32_t cp_sf_op_flash(void* flash_handle, void* ctx, int open)
|
||||
{
|
||||
g_sf_read_ptr = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t cp_sf_read_data(void* flash_handle, void *data, uint32_t length, uint32_t offset, void* ctx)
|
||||
{
|
||||
printf("TRACE[%s][%d] start:len=%d\r\n", __func__ ,__LINE__,length);
|
||||
|
||||
int32_t ret = 0;
|
||||
char num[5] = {0};
|
||||
uint8_t* readData = NULL;
|
||||
|
||||
if (g_sf_read_ptr > CARLINK_CP_SIZE)
|
||||
return 0;
|
||||
|
||||
readData = malloc(CARLINK_CP_SIZE);
|
||||
memset(readData, 0, CARLINK_CP_SIZE);
|
||||
sfud_flash *sflash = sfud_get_device(0);
|
||||
if (SFUD_SUCCESS == sfud_read(sflash, CARLINK_CP_OFFSET, CARLINK_CP_SIZE, readData)) {
|
||||
memcpy(num, readData, 4);
|
||||
ret = atoi(num);
|
||||
if(ret > 0) {
|
||||
if (ret > length)
|
||||
ret = length;
|
||||
if (ret > CARLINK_CP_SIZE)
|
||||
ret = (CARLINK_CP_SIZE - 4);
|
||||
memcpy(data, readData + 4, ret);
|
||||
g_sf_read_ptr += CARLINK_CP_SIZE;
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
free(readData);
|
||||
printf("TRACE[%s][%d] end: ret=%d\r\n", __func__ ,__LINE__,ret);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
static int32_t cp_sf_write_data(void* flash_handle, void *data, uint32_t length, uint32_t offset, void* ctx)
|
||||
{
|
||||
int ret = 0;
|
||||
char* writeData = NULL;
|
||||
|
||||
if ((length + 4) > CARLINK_CP_SIZE)
|
||||
length = CARLINK_CP_SIZE - 4;
|
||||
|
||||
writeData = malloc(length + 4);
|
||||
|
||||
printf("TRACE[%s][%d] start: len=%d\r\n", __func__ ,__LINE__, length);
|
||||
sprintf(writeData, "%04d", length);
|
||||
memcpy(writeData + 4, data, length);
|
||||
|
||||
sfud_flash *sflash = sfud_get_device(0);
|
||||
sfud_erase(sflash, CARLINK_CP_OFFSET, CARLINK_CP_SIZE);
|
||||
if (SFUD_SUCCESS == sfud_erase_write(sflash, CARLINK_CP_OFFSET, length + 4, (void*)writeData)) {
|
||||
ret = length;
|
||||
}
|
||||
|
||||
free(writeData);
|
||||
printf("TRACE[%s][%d] end:ret=%d\r\n", __func__ ,__LINE__,ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void carplay_notify_event(struct carlink_event *ev, enum CARLINK_EVENT_TYPE type, bool disable_filter)
|
||||
{
|
||||
ev->link_type = CARLINK_CARPLAY_WIRELESS;
|
||||
@ -54,8 +136,6 @@ static void carplay_notify_event(struct carlink_event *ev, enum CARLINK_EVENT_TY
|
||||
carlink_notify_event(ev);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void iap2_link_status(void *ctx, IAP2_LINK_STATUS status){}
|
||||
static int iap2_write_data(void *ctx, char *buf, int len)
|
||||
{
|
||||
@ -85,7 +165,7 @@ static void iap2_msg_identify(void *ctx, int type, int ok)
|
||||
start_mdnsd_posix();
|
||||
}
|
||||
}
|
||||
static void iap2_msg_wl_carplay_update(void *ctx, int status)//<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD>"Carplay<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<22>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
static void iap2_msg_wl_carplay_update(void *ctx, int status)//手机端"Carplay车载"是否开启
|
||||
{
|
||||
struct carplay_ctx* pctx = (struct carplay_ctx*)ctx;
|
||||
|
||||
@ -147,9 +227,15 @@ static void audio_stop_callback_impl(void *ctx, int handle, int type)
|
||||
|
||||
static int video_start_callback_impl(void *ctx)
|
||||
{
|
||||
#if !DISABLE_CARLINK_H264_FRAME_BUF
|
||||
h264_dec_ctx_init();
|
||||
set_carlink_display_state(1);
|
||||
//key_value = 1;
|
||||
#else
|
||||
struct carplay_ctx* pctx = (struct carplay_ctx*)ctx;
|
||||
|
||||
pctx->mVideoHandle = h264_video_player_init();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -157,17 +243,24 @@ static void video_stop_callback_impl(void *ctx)
|
||||
{
|
||||
//key_value = 0;
|
||||
printf("%s:%d\r\n", __func__, __LINE__);
|
||||
#if !DISABLE_CARLINK_H264_FRAME_BUF
|
||||
set_carlink_display_state(0);
|
||||
#else
|
||||
struct carplay_ctx* pctx = (struct carplay_ctx*)ctx;
|
||||
|
||||
h264_video_player_uninit(pctx->mVideoHandle);
|
||||
#endif
|
||||
}
|
||||
static int video_proc_data_callback_impl(void *ctx, char *buf, int len)
|
||||
{
|
||||
#if !DISABLE_CARLINK_H264_FRAME_BUF
|
||||
video_frame_s* frame = NULL;
|
||||
//printf("video_proc_data len:%d\r\n", len);
|
||||
|
||||
get_retry:
|
||||
frame = get_h264_frame_buf();
|
||||
if (NULL == frame) {
|
||||
//printf("h264 frame is empty\r\n");
|
||||
printf("h264 frame is empty\r\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
goto get_retry;
|
||||
//continue;
|
||||
@ -177,6 +270,10 @@ get_retry:
|
||||
frame->len = len;
|
||||
|
||||
notify_h264_frame_ready(&frame);
|
||||
#else
|
||||
struct carplay_ctx* pctx = (struct carplay_ctx*)ctx;
|
||||
h264_video_player_proc(pctx->mVideoHandle, buf, len);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
static void carplay_viewArea_update_notify(void *ctx, int index){}
|
||||
@ -229,48 +326,45 @@ static void carlink_cp_input_event_proc(const struct carlink_event *ev)
|
||||
bool pressed = (bool)ev->u.para[1];
|
||||
//printf("key %d %d\n", key, (int)pressed);
|
||||
|
||||
#if 0
|
||||
if (key == 19) {//right
|
||||
if (!pressed)
|
||||
KnobUpdate(0, 0, 0, 0, 0, 0);
|
||||
if (0) {
|
||||
} else if (key == 19) {
|
||||
/*if (!pressed)
|
||||
sendKnobInfo(0, 0, 0, 0, 0, 0);//up在主界面向上移动光标
|
||||
else
|
||||
KnobUpdate(0, 0, 0, 1.0, 0, 0);
|
||||
sendKnobInfo(0, 0, 0, 0, 1, 0);*/
|
||||
if (pressed) {//退后台,手机停止发送carplay视频流
|
||||
carplay_send_change_modes(CarplayTransferType_Take, CarplayTransferPriority_UserInitiated,
|
||||
CarplayConstraint_Never, CarplayConstraint_Never,
|
||||
0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
} else if (key == 20) {
|
||||
if (!pressed)
|
||||
KnobUpdate(0, 0, 0, 0, 0, 0);
|
||||
/*if (!pressed)
|
||||
sendKnobInfo(0, 0, 0, 0, 0, 0); //down在主界面向下移动光标
|
||||
else
|
||||
KnobUpdate(0, 0, 0, -1.0, 0, 0);
|
||||
}if (key == 18) {//up
|
||||
if (!pressed)
|
||||
KnobUpdate(0, 0, 0, 0, 0, 0);
|
||||
else
|
||||
KnobUpdate(0, 0, 0, 0, 1.0, 0);
|
||||
} else if (key == 17) {//down
|
||||
if (!pressed)
|
||||
KnobUpdate(0, 0, 0, 0, 0, 0);
|
||||
else
|
||||
KnobUpdate(0, 0, 0, 0, -1.0, 0);
|
||||
} else if (key == 27) {
|
||||
KnobUpdate(1, 0, 0, 0, 0, 0);
|
||||
}
|
||||
#else
|
||||
|
||||
if (key == 19) {//right
|
||||
if (!pressed)
|
||||
request_UI("maps:");
|
||||
} else if (key == 20) {
|
||||
if (!pressed)
|
||||
request_UI("music:");
|
||||
} else if (key == 18) {//left
|
||||
sendKnobInfo(0, 0, 0, 0, -1, 0);*/
|
||||
if (pressed) {//回前台,手机重新发送carplay视频流
|
||||
carplay_send_change_modes(CarplayTransferType_Untake,
|
||||
0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0);
|
||||
request_UI(NULL);
|
||||
}
|
||||
} else if (key == 18) {//previos
|
||||
if (pressed)
|
||||
KnobUpdate(0, 0, 0, 0, 0, 1);
|
||||
sendKnobInfo(0, 0, 0, 0, 0, 1);
|
||||
//else
|
||||
// sendKnobInfo(0, 0, 0, 0, 0, 0);
|
||||
|
||||
} else if (key == 17) {//right
|
||||
} else if (key == 17) {//next
|
||||
if (pressed)
|
||||
KnobUpdate(0, 0, 0, 0, 0, -1);
|
||||
sendKnobInfo(0, 0, 0, 0, 0, -1);
|
||||
//else
|
||||
// sendKnobInfo(0, 0, 0, 0, 0, 0);
|
||||
} else if (key == 27) {// enter
|
||||
if (pressed)
|
||||
sendKnobInfo(1, 0, 0, 0, 0, 0);
|
||||
else
|
||||
sendKnobInfo(0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
static void onEventCarplay(void* ctx, const struct carlink_event *ev)
|
||||
@ -311,7 +405,7 @@ static void onEventCarplay(void* ctx, const struct carlink_event *ev)
|
||||
case CARLINK_EVENT_BT_DISCONNECT: {
|
||||
printf("bt disconnect, iap disconnect %d %d\r\n", pctx->mIapReady, pctx->mPhoneCarplayFlag);
|
||||
if (pctx->mIapReady && !pctx->mPhoneCarplayFlag) {
|
||||
//<EFBFBD>ֻ<EFBFBD><EFBFBD><EFBFBD>"Carplay<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<22>رգ<D8B1>ͬʱƻ<CAB1><C6BB><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD>ر<EFBFBD><D8B1>ˣ<EFBFBD>ִ<EFBFBD><D6B4>һ<EFBFBD><D2BB>carplay stop
|
||||
//手机端"Carplay车载"关闭,同时苹果手机蓝牙也关闭了,执行一下carplay stop
|
||||
carplay_stop();
|
||||
}
|
||||
pctx->mIapReady = false;
|
||||
@ -413,7 +507,7 @@ static void taskInitCarlinkCpProc(void* param)
|
||||
video_cbs.video_start_callback = video_start_callback_impl;
|
||||
video_cbs.video_stop_callback = video_stop_callback_impl;
|
||||
video_cbs.video_proc_data_callback = video_proc_data_callback_impl;
|
||||
video_cbs.ctx = NULL;
|
||||
video_cbs.ctx = (void*)pctx;
|
||||
video_register_callbacks((void *)(&video_cbs));
|
||||
|
||||
audio_callbacks_t audio_cbs;
|
||||
@ -504,13 +598,25 @@ static void carplay_init_parameter()
|
||||
|
||||
g_link_info->icurrent = 1000;
|
||||
g_link_info->enable_iap_carplay_sess = 1;
|
||||
#if DEVICE_TYPE_SELECT != EMMC_FLASH
|
||||
g_link_info->keychain_path_dir = "/sf";
|
||||
{
|
||||
static carlink_flash_io io = {0};
|
||||
io.op_flash = cp_sf_op_flash;
|
||||
io.read_data = cp_sf_read_data;
|
||||
io.write_data = cp_sf_write_data;
|
||||
//sfud_erase(sfud_get_device(0), CARLINK_CP_OFFSET, CARLINK_CP_SIZE);
|
||||
register_carlink_flash_io_interface(&io);
|
||||
}
|
||||
#else
|
||||
g_link_info->keychain_path_dir = DEVICE_PARTITION_NAME;
|
||||
#endif
|
||||
g_link_info->is_old_carplay_ver = 0;
|
||||
g_link_info->enable_single_ui = 1;
|
||||
|
||||
g_link_info->disable_carplay_audio = 1;//1. audio is stream to bt;
|
||||
|
||||
//g_link_info->mfi_ic_addr = 0x22; //cp2.0
|
||||
//g_link_info->mfi_ic_addr = 0x22; //cp2.0的地址由reset脚决定
|
||||
g_link_info->mfi_ic_addr = 0x20; //cp3.0
|
||||
g_link_info->mfi_ic_i2c_bus_num = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user