MAX_CARLINK_A270S/MXC_A27-PCB4.5-270T/app/carlink/EC/include/ECTiny.h

853 lines
32 KiB
C
Raw Permalink Normal View History

2025-01-21 16:49:37 +08:00
#ifndef __ECTINY_API_H__
#define __ECTINY_API_H__
#include "ECTypes.h"
#define ECSDK_VERSION "1.0.10"
typedef struct {
void (*onECConnectStatus)(ECConnectedStatus status, ECConnectedType type);
void (*onMirrorStatus)(ECMirrorStatus status);
/**
* @brief Called when EasyConnected status changed.
*
* @param status The changed EasyConnected message.
*/
void (*onECStatusMessage)(ECStatusMessage status);
/**
* @brief Called when the phone app sends down HUD information.
*
* @param data HUD information.
*/
void (*onPhoneAppHUD)(const ECNavigationHudInfo *data);
/**
* @brief Called when the phone app sends down HUD Road Junction Picture.
* @param data
*/
void (*onPhoneAppHUDRoadJunctionPicture)(const ECHudRoadJunctionPictureInfo* data);
/*
* @brief Called when phone app tell the music info.
*
* @param data The information of music.
*/
void (*onPhoneAppMusicInfo)(const ECAppMusicInfo *data);
/**
* @brief Called when the phone app sends down some information.
*
* @param data Buffer of app information.
*
* @param length Buffer length.
*
* @note data is json string, the fields includes os, osVersion and ip.
* Called when ECSDK::openTransport succeed.
*/
void (*onPhoneAppInfo)(const void *data, uint32_t length);
/**
* @brief Called when ECSDK wants car to do call operations(dial or hang up) via Bluetooth.
*
* @param type Operation type.
*
* @param name The person's name of corresponding number.
*
* @param number Phone numbers.
*
* @note Phone app is not able to dial or hang up automatically due to the latest system access limitation,
* however, car is able to do it via Bluetooth. Therefore, ECSDK moves the call operations
* to car, which can dial or hang up when this method is called.
*/
void (*onCallAction)(ECCallType type, const char *name, const char *number);
/**
* @brief Called when bulk data is received.
*
* @param data Buffer of bulk data.
*
* @param length Buffer length.
*
*/
void (*onBulkDataReceived)(const void *data, uint32_t length);
/**
* @brief onRealMirrorSizeChanged
* @param realWidth
* @param realHeight
*
* \note The actual size of the projection screen does not equal the size of the video stream in some cases.
* The surrounding area is filled with black. This message calls back the actual size of the projection screen
*/
void (*onMirrorInfoChanged)(const ECVideoInfo *info);
/**
* @brief Called when the license authorization failed. After this interface was called,
* all connections would be forced closed.
*
* @param errCode Error code.
*
* @param errMsg Error message.
*/
void (*onLicenseAuthFail)(int32_t errCode, const char *errMsg);
/**
* @brief Called when the license authorization succeed.
*
* @param code success code. The code can gain specific meaning by ECAuthSuccessCode.
*
* @param msg success information.
*
* @param msg the description information.
*
*/
void (*onLicenseAuthSuccess)(int32_t code, const char *msg);
/**
* @brief Called when registered command was triggered by VR.
*
* @param carCmd The triggered command.
*
* @note Voice control can be implemented with this method by VR.
*
* @see ECSDK::registerCarCmds
*/
void (*onCarCmdNotified)(const ECCarCmd *carCmd);
/**
* @brief Called when phone app request the HU to start input.
*
* @param info relevant parameters about the input.
*/
void (*onInputStart)(const ECInputInfo *info);
/**
* @brief Called when phone app request the HU to cancel input.
*/
void (*onInputCancel)();
/**
* @brief Called when phone app tell the selection of input.
*/
void (*onInputSelection)(int32_t start, int32_t stop);
/**
* @brief Called when phone app tell the text of input.
*/
void (*onInputText)(const char *text);
/**
* @brief Called when phone app send the text of VR or TTS.
*/
void (*onVRTextReceived)(const ECVRTextInfo *info);
/**
* @brief Called when phone app tell the page list.
*
* @param pages Array of the struct ECPageInfo.
*
* @param length The length of the array.
*/
void (*onPageListReceived)(const ECPageInfo *pages, int32_t length);
/**
* @brief Called when phone app tell the icons.
*
* @param icons Array of the struct ECIconInfo.
*
* @param length The length of the array.
*/
void (*onPageIconReceived)(const ECIconInfo *icons, int32_t length);
/**
* @brief Called when phone app tell weather.
*
* @param data Buffer of weather information.
*
* @param length Buffer length.
*
* @note data pointed to a json string buffer.
*/
void (*onWeatherReceived)(const char *data, int32_t length);
/**
* @brief Called when phone app tell vr tips.
*
* @param data Buffer of tips information.
*
* @param length Buffer length.
*
* @note data pointed to a json string buffer.
*/
void (*onVRTipsReceived)(const char *data, int32_t length);
/**
* @brief Called when the app requests networking
*
* @param clientInfo Mobile phone related information
*
* @note
*/
void (*onRequestBuildNet)(const ECBTClientInfo *clientInfo);
/**
* @brief Called when canceling networking
*
* @note
*/
void (*onRequestBuildNetCancel)();
/**
* @brief Called when networking is completed
*
* @note
*/
void (*onPhoneBuildNetFinish)();
/**
* @brief Called when app sends AP information
*
* @param netDeviceInfo AP information
*
* @note
*/
void (*onPhoneAPInfo)(const ECBTNetInfo* netDeviceInfo);
/**
* @brief Called when mobile phone has a notification message.
* @param notification
*/
void (*onPhoneNotification)(const ECPhoneNotification* notification);
/**
* @brief Called when the phone app sends down HUD lane guidance Picture.
* @param notification
*/
void (*onPhoneAppHUDLaneGuidancePicture)(const ECHudLaneGuidancePictureInfo * data);
/**
* @brief Called when checkOTAUpdate was called, it will tell the result of checkOTAUpdate.
*
* @param downloadableSoftwares It pointer to a array of ECOTAUpdateSoftware, which is downloadable software.
*
* @param downloadableLength The length of the downloadable array, if downloadableLength < 0, means check occur error, downloadableLength is error value of ECOTAUpdateErrorCode.
*
* @param downloadedSoftwares It pointer to a array of ECOTAUpdateSoftware, which is downloaded software.
*
* @param downloadedLength The length of the downloaded array.
*/
void (*onOTAUpdateCheckResult)(const ECOTAUpdateSoftware* downloadableSoftwares, const int32_t downloadableLength, const ECOTAUpdateSoftware* downloadedSoftwares, const uint32_t downloadedLength);
/**
* @brief Called when remote downloadable software has been downloaded to phone.
*
* @param downloadableSoftwares It pointer to a array of ECOTAUpdateSoftware, which has been in phone, can be downloaded from phone to HU.
*
* @param downloadableLength The length of the downloadable array.
*/
void (*onOTAUpdateRequestDownload)(const ECOTAUpdateSoftware* downloadableSoftwares, const uint32_t downloadableLength);
/**
* @brief Called when startOTAUpdate is called, it will notify the progress of downloading.
*
* @param downloadingSoftwareId The id of the downloading software.
*
* @param progress The progress of the downloading software,which is a percentage.
*
* @param softwareLeftTime The left time of the downloading software.
*
* @param otaLeftTime The left time of all the specified software by startOTAUpdate.
*/
void (*onOTAUpdateProgress)(const char* downloadingSoftwareId, float progress, uint32_t softwareLeftTime, uint32_t otaLeftTime);
/**
* @brief Called when startOTAUpdate is called, it will notify software is downloaded.
*
* @param downloadedSoftwareId The id of the downloaded software.
*
* @param md5Path The md5 file path.
*
* @param packagePath The software path.
*
* @param iconPath The icon path.
*
* @param leftSoftwareNum The amount of software remaining to be downloaded.
*/
void (*onOTAUpdateCompleted)(const char* downloadedSoftwareId, const char* md5Path, const char* packagePath, const char* iconPath, uint32_t leftSoftwareNum);
/**
* @brief Called when checkOTAUpdate or startOTAUpdate failed.
*
* @param errCode error code, see ECOTAUpdateErrorCode.
*
* @param softwarId the id of software.
*/
void (*onOTAUpdateError)(int32_t errCode, const char* softwareId);
} IECCallBack;
typedef struct
{
uint32_t (*size)(const char* name);
int32_t (*read)(const char* name,void *data, uint32_t length, uint32_t offset);
int32_t (*write)(const char* name,void *data, uint32_t length, uint32_t offset);
void (*clear)(const char* name);
}IECAccessFile;
typedef struct
{
int32_t (*open)();
int32_t (*read)(void *data, uint32_t length);
int32_t (*write)(void *data, uint32_t length);
void (*close)();
}IECAccessDevice;
typedef struct
{
uint32_t (*registHid)(uint32_t deviceId,uint32_t descriptorSize);
void (*unRegistHid)(uint32_t deviceId);
uint32_t (*sendHiDDescriptor)(uint32_t deviceId, const unsigned char* descriptor, uint32_t len);
uint32_t (*sendHidEvent)(uint32_t deviceId, const unsigned char* event, uint32_t len);
}IECHidAccessDev;
typedef struct
{
int32_t (*open)();
int32_t (*read)(uint8_t* data, uint32_t len);
int32_t (*write)(const uint8_t* data, uint32_t len);
int32_t (*close)();
}IECBTAccessDev;
typedef struct
{
void (*start)(int32_t width, int32_t height);
void (*stop)();
void (*play)(const void *data, uint32_t len);
}IECVideoPlayer;
typedef struct
{
void (*start)(ECAudioType type, const ECAudioInfo *info);
void (*stop)(ECAudioType type);
void (*play)(ECAudioType type, const void *data, uint32_t len);
void (*setVolume)(ECAudioType type, uint32_t vol);
}IECAudioPlayer;
typedef struct
{
int32_t (*start)(const ECAudioInfo *info);
void (*stop)();
int32_t (*record)(void *data, uint32_t len);
}IECAudioRecorder;
typedef void *ECConfigHandle;
ECConfigHandle EC_createECConfig();
void EC_destroyECConfig(ECConfigHandle config);
void EC_setBaseConfig(ECConfigHandle config,const char *uuid, const char *version,const char *writableDir);
void EC_setCommonConfig(ECConfigHandle config, const char *cfgName, const char *value);
/**
* @brief ECTiny app版本
* @param type 0: 1:
*/
void EC_setLinkPhoneApp(ECConfigHandle config,int32_t type);
void EC_setCommonConfig1(ECConfigHandle config, const char *cfgName, int32_t value);
// This function must be called after the EC_start() function.
int32_t EC_resetECConfig(const char* config);
/**
* @brief ECTiny
* @param config
* @param listener
* @return EC_OK
* @note
* 1. EC_setBaseConfig() config
* 2.listener ECTiny listener EC_initialize() EC_release()
*/
int32_t EC_initialize(ECConfigHandle config, IECCallBack *listener);
/**
* @brief ECTiny
* @return EC_OK
* @note
* ECTiny线程处于block或者waiting状态ECTiny的一般使用场景不需要调用此函数
*/
int32_t EC_release();
/**
* @brief ECTiny日志
* @param level EC_LOG_LEVEL_ALLEC_LOG_LEVEL_ERROR或者其他高级别
* @param type EC_LOG_OUT_STD标准输出
* @param logDirectory
* @param module EC_LOG_MODULE_SDK | EC_LOG_MODULE_APP
* @return EC_OK
* @note
*/
int32_t EC_setLogInfo(const ECLogLevel level,const ECLogOutputType type,const char *logDirectory, int32_t module);
/**
* @return ECTiny
*/
const char* EC_getVersion();
/**
* @return ECTiny
*/
int32_t EC_getVersionCode();
/**
* @brief
* @return EC_OK
* @note
*/
int32_t EC_start();
/**
* @brief
* @return EC_OK
* @note ECTiny线程出于阻塞状态
* 使 EC_start() EC_stop()
*/
int32_t EC_stop();
/**
* @brief
* @param handle
* @return EC_OK
* @note RTOS ECTiny
* ECTiny会使用此接口读写license和OTA
*/
int32_t EC_bindAccessFile(IECAccessFile *handle);
/**
* @brief usb设备
* @param type
* @param dev usb设备操作接口
* @return EC_OK
* @note usb设备读写操作usb互联
* @see EC_unbindDevice()
*/
int32_t EC_bindUSBDevice(ECTransportType type, IECAccessDevice *dev);
/**
* @brief wifi互联ip
* @param type
* @param ip ip地址
* @return EC_OK
* @note ECTiny会直接连接ip
* @see EC_unbindDevice()
*/
int32_t EC_bindWIFIDevice(ECTransportType type, const char *ip);
/**
* @brief
* @param type
* @return EC_OK
* @note EC_bindUSBDevice()EC_bindWIFIDevice()
*/
int32_t EC_unbindDevice(ECTransportType type);
/**
* @brief HID设备
* @param dev HID设备
* @return EC_OK
* @see EC_unBindHidDevice()
*/
int32_t EC_bindHidDevice(IECHidAccessDev* dev);
/**
* @brief HID设备绑定
* @return EC_OK
* @see EC_bindHidDevice()
*/
int32_t EC_unBindHidDevice();
/**
* @brief ble设备操作接口
* @param ioHandle ble设备操作接口
* @return EC_OK
* @note BLE组网方式的互联
* @see EC_unBindBTDevice()
*/
int32_t EC_bindBTDevice( IECAccessDevice* ioHandle);
/**
* @brief ble设备解绑定
* @return EC_OK
* @see EC_bindBTDevice()
*/
int32_t EC_unBindBTDevice();
/**
* @brief
* @param mirrorCfg
* @return EC_OK
* @note
*/
int32_t EC_setMirrorConfig(const ECMirrorConfig *mirrorCfg);
/**
* @brief
* @param video
* @return EC_OK
* @note IECVideoPlayer ECTiny之后 ECTiny主动调用解码器的开始和停止
*/
int32_t EC_setVideoPlayer(IECVideoPlayer* video);
/**
* @brief
* @param audio
* @return EC_OK
* @note usb或者wifi时才需要设置此接口a2dp
*/
int32_t EC_setAudioPlayer(IECAudioPlayer* audio);
/**
* @brief
* @param audioRecorde
* @return EC_OK
* @note app回声降噪的项目才需要设置此接口
*/
int32_t EC_setAudioRecorder(IECAudioRecorder* audioRecorde);
/**
* @brief wifi状态通知接口
* @param action wifi模式ap/sta
* @param netInfo ECNetWorkInfo::state
* @return EC_OK
* @note /wifi发生变化时 ECTinywifi连接
*/
int32_t EC_notifyWifiStateChanged(ECWifiStateAction action, const ECNetWorkInfo* netInfo);
/**
* @brief
* @param phoneID id
* @param rly
* @return EC_OK
* @note BLE组网的连接方式
*/
int32_t EC_setRequestBuildNetRly(const char *phoneID, const ECBTRequestBuildNetRly *rly);
/**
* @brief ip地址上报给手机
* @param info
* @param num
* @return EC_OK
* @note BLE组网的连接方式
*/
int32_t EC_setNetInterfaceInfo(const ECNetInterfaceInfo *info,const int32_t num);
/**
* @brief
* @return EC_OK
* @note
* app会把 H264 ECTiny ECTiny会自动调用 IECVideoPlayer
* onECConnectStatus status==EC_CONNECT_STATUS_CONNECT_SUCCEED
* @see EC_stopMirror()
*/
int32_t EC_startMirror();
/**
* @brief
* @note
* @see EC_startMirror()
*/
void EC_stopMirror();
/**
* @brief /
* @return EC_OK
* @note EC_startMirror()/EC_stopMirror()
*/
int32_t EC_pauseMirror();
int32_t EC_resumeMirror();
/**
* @brief
* @param touch
* @param type
* @return EC_OK
* @note /appapp做出响应
*/
int32_t EC_sendTouchEvent(const ECTouchEventData *touch, ECTouchEventType type);
/**
* @brief
* @param btnCode ECBtnCode
* @param type ECBtnEventType
* @return EC_OK
* @note app
*/
int32_t EC_sendBtnEvent(int32_t btnCode, int32_t type);
/**
* @brief
* @return EC_OK
*/
int32_t EC_stopPhoneNavigation();
/**
* @brief vr语音
* @return EC_OK
*/
int32_t EC_stopPhoneVR();
/**
* @brief
* @param isNightModeOn 1:; 0:
* @return EC_OK
* @note app的显示模式设置为自动时app响应
*/
int32_t EC_uploadNightModeStatus(uint32_t isNightModeOn);
/**
* @brief
* @param status
* @return EC_OK
*/
int32_t EC_uploadDrivingStatus(ECDrivingStatus status);
/**
* @brief /
* @param supportType ECAudioType
* @param autoChangeToBT
* false后
* @return EC_OK
* @note onECConnectStatus()
* app才会下传相应声音EC_disableDownloadPhoneAppAudio()
*/
int32_t EC_enableDownloadPhoneAppAudio(uint32_t supportType, uint32_t autoChangeToBT);
/**
* @brief
*/
void EC_disableDownloadPhoneAppAudio();
/**
* @brief HUD导航信息
* @param supportFunction hud导航功能 ECAPPHUDSupportFunction hud功能
* @return EC_OK
* @note onECConnectStatus()
*
*/
int32_t EC_enableDownloadPhoneAppHud(uint32_t supportFunction);
/**
* @brief HUD导航信息
*/
void EC_disableDownloadPhoneAppHud();
/**
* @brief
* @param carBtMac
* @param phoneBtMac Mac地址
* @return EC_OK
* @note
*/
int32_t EC_setConnectedBTAddress(const char *carBtMac, const char *phoneBtMac);
/**
* @brief
* @param name
* @param adddress
* @param pin pin码
* @return EC_OK
*/
int32_t EC_sendCarBluetooth(const char *name, const char *adddress, const char *pin);
/**
* @brief
* @param page 访APP的相关界面或功能ECAppPage
* @return EC_OK
* @note
*/
int32_t EC_openAppPage(int32_t page);
/**
* @brief GPS信息
* @param status 0
* @param gps GPS信息
* @return EC_OK
* @note 使GPS的场景
*/
int32_t EC_queryGPS(uint32_t* status, ECGPSInfo* gps);
/**
* @brief
* @param gmtTime GMT(UTC)
* @param localTime
* @param timeZone
* @param len
* @param dateTime app当前时间字符串
* @param dateTimeLen app当前时间字符串长度
* @return EC_OK
* @note GMT时间涉及到系统函数和时区的计算使
*/
int32_t EC_queryTime(uint64_t *gmtTime, uint64_t *localTime, char *timeZone, uint32_t len, char* dateTime, uint32_t dateTimeLen);
/**
* @brief
* @param carStatus
* @param value status需要携带状态值
* @return EC_OK
* @note APPAPP需要根据状态做互联的相关逻辑处理
* APP可根据行车状态使
*/
int32_t EC_sendCarStatus(ECCarStatusType carStatus, ECCarStatusValue value);
/**
* @brief
* @param carCmds
* .type : ECCarCmdEFFECTType
* .id : id
* .cmd : "(打开|开启)空调""打开空调" "开启空调""放大地图"
* .vrText : IECCallback::onCarCmdNotified
* .pauseMusic : ECSDK::registerCarCmds
* .responser : 0 1
* .thresholdLevel : 0 1~9999使 type= EC_CAR_CMD_TYPE_EFFECTIVE_PAGE
* @param length
* @return EC_OK
* @note VR引擎识别后 IECCallback::onCarCmdNotified
*/
int32_t EC_registerCarCmds(const ECCarCmd *carCmds, uint32_t length);
/**
* @brief
* @param text
* @param level 0~10
* @return EC_OK
* @note APP
* ECSDK::enableDownloadPhoneAppAudio APP音频TTS类型USB/wifi传输车机端
*/
int32_t EC_playCarTTS(const char *text, uint32_t level);
/**
* @brief
* @param data JSON格式字符串
* {
* words:
* [
* ["词1", ..., "词m"], ///< 数据类型为string数组近音词集合数组中的第一个词为显示词。
* ...
* ["词a", ..., "词n"] ///< 数据类型为string数组近音词集合数组中的第一个词为显示词。
* ]
* }
* @param length Json字符串的长度
* @return EC_OK
* @note EC_registerCarCmds() 使
*/
int32_t EC_registerSimilarSoundingWords(const char *data, uint32_t length);
/**
* @brief
* @param text
* @return EC_OK
* @note
*/
int32_t EC_sendInputText(const char* text);
/**
* @brief
* @param actionId
* @param keyCode
* @return EC_OK
* @note Enter键keycode及ActionId对安卓手机都有效
* actionid=0 keycode=4inActive状态
*
*/
int32_t EC_sendInputAction(int32_t actionId, int32_t keyCode);
/**
* @brief
* @param start
* @param stop
* @return EC_OK
* @note
*
*/
int32_t EC_sendInputSelection(int32_t start, int32_t stop);
/**
* @brief
* @return EC_OK
* @note ECTiny与手机app传输建立之后 IECCallback::onPageListReceived
*/
int32_t EC_queryPageList();
/**
* @brief
* @param pages page编号的数组 EC_queryPageList
* @param length page编号的数组长度
* @return EC_OK
* @note ECTiny与手机app传输建立之后 IECCallback::onPageIconReceived
* icon的资源信息做到增量更新
* EC_queryPageList
*/
int32_t EC_queryPageIcon(int32_t* pages, int32_t length);
/**
* @brief
* @return EC_OK
* @note IECCallback::onWeatherReceived
*/
int32_t EC_queryWeather();
/**
* @brief
* @return EC_OK
* @note 使使
*/
int32_t EC_queryVRTips();
/**
* @brief url
* @param info
* @return EC_OK
*/
const char* EC_generateQRCodeUrl(ECQRInfo* info);
/**
* @brief
* @param enable 0 1
* @return EC_OK
*/
int32_t EC_requestPhoneNotification(int32_t enable);
/**
* @brief OTA升级
* @param cfg ota配置
* @param language
* @param mode ota升级模式
* @return EC_OK
*/
int32_t EC_checkOTAUpdate(const ECOTAConfig* cfg, const ECLanguage language, const ECOTAUpdateCheckMode mode);
/**
* @brief OTA升级
* @param softwareIds id
* @param softwareNum id数量
* @return EC_OK
*/
int32_t EC_startOTAUpdate(const char** softwareIds, const int32_t softwareNum);
/**
* @brief OTA升级
*/
void EC_stopOTAUpdate();
/**
* @brief iperf服务端
* @param ip
* @param port
* @return
* @note iperf功能/iperf测试时使iperf
*/
int32_t EC_startIperfTcpServer(const char* ip, int port);
void EC_stopIperfTcpServer();
#endif