NEW: release DJI Payload-SDK version 3.2

Signed-off-by: DJI-Martin <DJI-Martin@dji.com>
This commit is contained in:
DJI-Martin
2022-08-08 15:43:55 +08:00
parent 42099ba7df
commit 08b76b678d
50 changed files with 567 additions and 263 deletions

View File

@ -189,11 +189,16 @@ T_DjiReturnCode DjiTest_CameraEmuMediaStartService(void)
return DJI_ERROR_SYSTEM_MODULE_CODE_UNKNOWN;
}
returnCode = osalHandler->TaskCreate("user_camera_media_task", UserCameraMedia_SendVideoTask, 2048,
NULL, &s_userSendVideoThread);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("user send video task create error.");
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
if (DjiPlatform_GetSocketHandler() != NULL) {
returnCode = osalHandler->TaskCreate("user_camera_media_task", UserCameraMedia_SendVideoTask, 2048,
NULL, &s_userSendVideoThread);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("user send video task create error.");
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
} else {
USER_LOG_WARN(
"Socket handler is null. Probably because socket handler is not be registered. Camera media sample may not be running.");
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;

View File

@ -31,8 +31,8 @@
#include "dji_logger.h"
#include "dji_liveview.h"
/* Private constants ---------------------------------------------------------*/
#define TEST_CAMERA_MANAGER_MEDIA_FILE_NAME_MAX_SIZE 32
#define TEST_CAMERA_MANAGER_MEDIA_EXTEND_INFO_MAX_SIZE 128
#define TEST_CAMERA_MANAGER_MEDIA_FILE_NAME_MAX_SIZE 256
#define TEST_CAMERA_MANAGER_MEDIA_DOWNLOAD_FILE_NUM 5
/* Private types -------------------------------------------------------------*/
typedef struct {
@ -53,10 +53,14 @@ static const T_DjiTestCameraTypeStr s_cameraTypeStrList[] = {
{DJI_CAMERA_TYPE_L1, "Zenmuse L1"},
{DJI_CAMERA_TYPE_M30, "Zenmuse M30"},
{DJI_CAMERA_TYPE_M30T, "Zenmuse M30T"},
{DJI_CAMERA_TYPE_H20N, "Zenmuse H20N"},
};
static FILE *s_downloadMediaFile = NULL;
static T_DjiCameraManagerFileList s_meidaFileList;
static uint32_t downloadStartMs = 0;
static uint32_t downloadEndMs = 0;
static char downloadFileName[TEST_CAMERA_MANAGER_MEDIA_FILE_NAME_MAX_SIZE] = {0};
/* Private functions declaration ---------------------------------------------*/
static uint8_t DjiTest_CameraManagerGetCameraTypeIndex(E_DjiCameraType cameraType);
@ -817,7 +821,7 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
mountPosition, returnCode);
goto exitCameraModule;
}
USER_LOG_INFO("Mounted position %d camera's firmware is V%d.%d.%d.%d\r\n", mountPosition,
USER_LOG_INFO("Mounted position %d camera's firmware is V%02d.%02d.%02d.%02d\r\n", mountPosition,
firmwareVersion.firmware_version[0], firmwareVersion.firmware_version[1],
firmwareVersion.firmware_version[2], firmwareVersion.firmware_version[3]);
@ -850,7 +854,8 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_CAMERA_SHUTTER_SPEED: {
USER_LOG_INFO("--> Function a: Set camera shutter speed to 1/100 s");
DjiTest_WidgetLogAppend("--> Function a: Set camera shutter speed to 1/100 s");
if (cameraType == DJI_CAMERA_TYPE_H20 || cameraType == DJI_CAMERA_TYPE_H20T) {
if (cameraType == DJI_CAMERA_TYPE_H20 || cameraType == DJI_CAMERA_TYPE_H20T ||
cameraType == DJI_CAMERA_TYPE_M30 || cameraType == DJI_CAMERA_TYPE_M30T) {
USER_LOG_INFO("Set mounted position %d camera's exposure mode to manual mode.",
mountPosition);
returnCode = DjiTest_CameraManagerSetExposureMode(mountPosition,
@ -886,7 +891,8 @@ T_DjiReturnCode DjiTest_CameraManagerRunSample(E_DjiMountPosition mountPosition,
case E_DJI_TEST_CAMERA_MANAGER_SAMPLE_SELECT_SET_CAMERA_APERTURE: {
USER_LOG_INFO("--> Function b: Set camera aperture to 400(F/4)");
DjiTest_WidgetLogAppend("--> Function b: Set camera aperture to 400(F/4)");
if (cameraType == DJI_CAMERA_TYPE_H20 || cameraType == DJI_CAMERA_TYPE_H20T) {
if (cameraType == DJI_CAMERA_TYPE_H20 || cameraType == DJI_CAMERA_TYPE_H20T
|| cameraType == DJI_CAMERA_TYPE_M30 || cameraType == DJI_CAMERA_TYPE_M30T) {
USER_LOG_INFO("Set mounted position %d camera's exposure mode to manual mode.",
mountPosition);
returnCode = DjiTest_CameraManagerSetExposureMode(mountPosition,
@ -1188,12 +1194,7 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
{
T_DjiReturnCode returnCode;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
returnCode = DjiCameraManager_DownloadFileList(position, &s_meidaFileList);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Download file list failed, error code: 0x%08X.", returnCode);
return returnCode;
}
uint16_t downloadCount = 0;
returnCode = DjiCameraManager_RegDownloadFileDataCallback(position, DjiTest_CameraManagerDownloadFileDataCallback);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -1201,11 +1202,21 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
return returnCode;
}
returnCode = DjiCameraManager_DownloadFileList(position, &s_meidaFileList);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Download file list failed, error code: 0x%08X.", returnCode);
return returnCode;
}
if (s_meidaFileList.totalCount > 0) {
for (int i = 0; i < s_meidaFileList.totalCount; ++i) {
downloadCount = s_meidaFileList.totalCount;
printf(
"\033[1;33;40m -> Download file list finished, total file count is %d, the following %d is list details: \033[0m\r\n",
s_meidaFileList.totalCount, downloadCount);
for (int i = 0; i < downloadCount; ++i) {
if (s_meidaFileList.fileListInfo[i].fileSize < 1 * 1024 * 1024) {
USER_LOG_INFO(
"Media file_%03d name: %s, index: %d, time:%04d-%02d-%02d_%02d:%02d:%02d, size: %.2f KB, type: %d",
printf(
"\033[1;32;40m ### Media file_%03d name: %s, index: %d, time:%04d-%02d-%02d_%02d:%02d:%02d, size: %.2f KB, type: %d \033[0m\r\n",
i, s_meidaFileList.fileListInfo[i].fileName,
s_meidaFileList.fileListInfo[i].fileIndex,
s_meidaFileList.fileListInfo[i].createTime.year,
@ -1217,8 +1228,8 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
(dji_f32_t) s_meidaFileList.fileListInfo[i].fileSize / 1024,
s_meidaFileList.fileListInfo[i].type);
} else {
USER_LOG_INFO(
"Media file_%03d name: %s, index: %d, time:%04d-%02d-%02d_%02d:%02d:%02d, size: %.2f MB, type: %d",
printf(
"\033[1;32;40m ### Media file_%03d name: %s, index: %d, time:%04d-%02d-%02d_%02d:%02d:%02d, size: %.2f MB, type: %d \033[0m\r\n",
i, s_meidaFileList.fileListInfo[i].fileName,
s_meidaFileList.fileListInfo[i].fileIndex,
s_meidaFileList.fileListInfo[i].createTime.year,
@ -1231,16 +1242,23 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
s_meidaFileList.fileListInfo[i].type);
}
}
printf("\r\n");
osalHandler->TaskSleepMs(1000);
returnCode = DjiCameraManager_DownloadFileByIndex(position, s_meidaFileList.fileListInfo[0].fileIndex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Download media file by index failed, error code: 0x%08X.", returnCode);
return returnCode;
if (s_meidaFileList.totalCount < TEST_CAMERA_MANAGER_MEDIA_DOWNLOAD_FILE_NUM) {
downloadCount = s_meidaFileList.totalCount;
} else {
downloadCount = TEST_CAMERA_MANAGER_MEDIA_DOWNLOAD_FILE_NUM;
}
osalHandler->TaskSleepMs(1000);
for (int i = 0; i < downloadCount; ++i) {
returnCode = DjiCameraManager_DownloadFileByIndex(position, s_meidaFileList.fileListInfo[i].fileIndex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Download media file by index failed, error code: 0x%08X.", returnCode);
return returnCode;
}
}
returnCode = DjiCameraManager_DeleteFileByIndex(position, s_meidaFileList.fileListInfo[0].fileIndex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -1250,7 +1268,7 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
osalHandler->TaskSleepMs(1000);
} else {
USER_LOG_WARN("Media file is not existed in sdcard.");
USER_LOG_WARN("Media file is not existed in sdcard.\r\n");
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
@ -1259,11 +1277,9 @@ static T_DjiReturnCode DjiTest_CameraManagerMediaDownloadAndDeleteMediaFile(E_Dj
static T_DjiReturnCode DjiTest_CameraManagerDownloadFileDataCallback(T_DjiDownloadFilePacketInfo packetInfo,
const uint8_t *data, uint16_t len)
{
char fileName[TEST_CAMERA_MANAGER_MEDIA_FILE_NAME_MAX_SIZE];
char extendInfo[TEST_CAMERA_MANAGER_MEDIA_EXTEND_INFO_MAX_SIZE];
int32_t i;
sprintf(extendInfo, " FileIndex: %d", packetInfo.fileIndex);
float downloadSpeed = 0.0f;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
if (packetInfo.downloadFileEvent == DJI_DOWNLOAD_FILE_EVENT_START) {
for (i = 0; i < s_meidaFileList.totalCount; ++i) {
@ -1271,9 +1287,12 @@ static T_DjiReturnCode DjiTest_CameraManagerDownloadFileDataCallback(T_DjiDownlo
break;
}
}
sprintf(fileName, "%s", s_meidaFileList.fileListInfo[i].fileName);
USER_LOG_INFO("Start download media file %s", s_meidaFileList.fileListInfo[i].fileName);
s_downloadMediaFile = fopen(fileName, "wb+");
osalHandler->GetTimeMs(&downloadStartMs);
memset(downloadFileName, 0, sizeof(downloadFileName));
snprintf(downloadFileName, sizeof(downloadFileName), "%s", s_meidaFileList.fileListInfo[i].fileName);
USER_LOG_INFO("Start download media file");
s_downloadMediaFile = fopen(downloadFileName, "wb+");
if (s_downloadMediaFile == NULL) {
return DJI_ERROR_SYSTEM_MODULE_CODE_SYSTEM_ERROR;
}
@ -1282,13 +1301,24 @@ static T_DjiReturnCode DjiTest_CameraManagerDownloadFileDataCallback(T_DjiDownlo
if (s_downloadMediaFile != NULL) {
fwrite(data, 1, len, s_downloadMediaFile);
}
printf("\033[1;32;40m ### [Complete rate : %0.1f%%] (%s), size: %d, fileIndex: %d\033[0m\r\n",
packetInfo.progressInPercent, downloadFileName, packetInfo.fileSize, packetInfo.fileIndex);
printf("\033[1A");
USER_LOG_DEBUG("Transfer download media file data, len: %d, percent: %.1f", len, packetInfo.progressInPercent);
} else if (packetInfo.downloadFileEvent == DJI_DOWNLOAD_FILE_EVENT_END) {
if (s_downloadMediaFile != NULL) {
fwrite(data, 1, len, s_downloadMediaFile);
}
osalHandler->GetTimeMs(&downloadEndMs);
USER_LOG_INFO("End download media file");
downloadSpeed = (float) packetInfo.fileSize / (float) (downloadEndMs - downloadStartMs);
printf("\033[1;32;40m ### [Complete rate : %0.1f%%] (%s), size: %d, fileIndex: %d\033[0m\r\n",
packetInfo.progressInPercent, downloadFileName, packetInfo.fileSize, packetInfo.fileIndex);
printf("\033[1A");
printf("\r\n");
USER_LOG_INFO("End download media file, Download Speed %.2f KB/S\r\n\r\n", downloadSpeed);
fclose(s_downloadMediaFile);
s_downloadMediaFile = NULL;
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;

View File

@ -156,8 +156,9 @@ T_DjiReturnCode DjiTest_FcSubscriptionRunSample(void)
if (djiStat != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("get value of topic velocity error.");
} else {
USER_LOG_INFO("velocity: x = %f y = %f z = %f healthFlag = %d.", velocity.data.x, velocity.data.y,
velocity.data.z, velocity.health);
USER_LOG_INFO("velocity: x = %f y = %f z = %f healthFlag = %d, timestamp ms = %d us = %d.", velocity.data.x,
velocity.data.y,
velocity.data.z, velocity.health, timestamp.millisecond, timestamp.microsecond);
}
djiStat = DjiFcSubscription_GetLatestValueOfTopic(DJI_FC_SUBSCRIPTION_TOPIC_GPS_POSITION,

View File

@ -30,6 +30,7 @@
#include "dji_logger.h"
#include <math.h>
#include <widget_interaction_test/test_widget_interaction.h>
#include <dji_aircraft_info.h>
/* Private constants ---------------------------------------------------------*/
/* Private types -------------------------------------------------------------*/
@ -665,6 +666,12 @@ void DjiTest_FlightControlSetGetParamSample()
E_DjiFlightControllerGoHomeAltitude goHomeAltitude;
E_DjiFlightControllerRtkPositionEnableStatus rtkEnableStatus;
E_DjiFlightControllerRCLostAction rcLostAction;
T_DjiAircraftInfoBaseInfo aircraftInfoBaseInfo;
returnCode = DjiAircraftInfo_GetBaseInfo(&aircraftInfoBaseInfo);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("get aircraft base info error");
}
USER_LOG_INFO("Flight control set-get-param sample start");
DjiTest_WidgetLogAppend("Flight control set-get-param sample start");
@ -823,25 +830,27 @@ void DjiTest_FlightControlSetGetParamSample()
s_osalHandler->TaskSleepMs(1000);
/*! Set rc lost action */
USER_LOG_INFO("--> Step 15: Set rc lost action");
DjiTest_WidgetLogAppend("--> Step 15: Set rc lost action");
returnCode = DjiFlightController_SetRCLostAction(DJI_FLIGHT_CONTROLLER_RC_LOST_ACTION_GOHOME);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Set rc lost action failed, error code: 0x%08X", returnCode);
goto out;
}
s_osalHandler->TaskSleepMs(1000);
if (aircraftInfoBaseInfo.aircraftType != DJI_AIRCRAFT_TYPE_M300_RTK) {
USER_LOG_INFO("--> Step 15: Set rc lost action");
DjiTest_WidgetLogAppend("--> Step 15: Set rc lost action");
returnCode = DjiFlightController_SetRCLostAction(DJI_FLIGHT_CONTROLLER_RC_LOST_ACTION_GOHOME);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Set rc lost action failed, error code: 0x%08X", returnCode);
goto out;
}
s_osalHandler->TaskSleepMs(1000);
USER_LOG_INFO("--> Step 16: Get rc lost action\r\n");
DjiTest_WidgetLogAppend("--> Step 16: Get rc lost action\r\n");
returnCode = DjiFlightController_GetRCLostAction(&rcLostAction);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get rc lost action failed, error code: 0x%08X", returnCode);
goto out;
USER_LOG_INFO("--> Step 16: Get rc lost action\r\n");
DjiTest_WidgetLogAppend("--> Step 16: Get rc lost action\r\n");
returnCode = DjiFlightController_GetRCLostAction(&rcLostAction);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("Get rc lost action failed, error code: 0x%08X", returnCode);
goto out;
}
USER_LOG_INFO("Current rc lost action is %d\r\n", rcLostAction);
DjiTest_WidgetLogAppend("Current rc lost action is %d\r\n", rcLostAction);
s_osalHandler->TaskSleepMs(1000);
}
USER_LOG_INFO("Current rc lost action is %d\r\n", rcLostAction);
DjiTest_WidgetLogAppend("Current rc lost action is %d\r\n", rcLostAction);
s_osalHandler->TaskSleepMs(1000);
out:
USER_LOG_INFO("Flight control set-get-param sample end");

View File

@ -67,4 +67,4 @@ T_DjiReturnCode UtilFile_GetFileData(FILE *file, uint32_t offset, uint16_t len,
#endif // UTIL_FILE_H
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/
/************************ (C) COPYRIGHT DJI Innovations *******END OF FILE******/

View File

@ -36,7 +36,7 @@
#ifdef OPUS_INSTALLED
#include <opus.h>
#include <opus/opus.h>
#endif
@ -80,13 +80,10 @@ static bool s_isDecodeFinished = true;
static void SetSpeakerState(E_DjiWidgetSpeakerState speakerState);
static T_DjiReturnCode GetSpeakerState(T_DjiWidgetSpeakerState *speakerState);
static T_DjiReturnCode SetWorkMode(E_DjiWidgetSpeakerWorkMode workMode);
static T_DjiReturnCode GetWorkMode(E_DjiWidgetSpeakerWorkMode *workMode);
static T_DjiReturnCode SetPlayMode(E_DjiWidgetSpeakerPlayMode playMode);
static T_DjiReturnCode GetPlayMode(E_DjiWidgetSpeakerPlayMode *playMode);
static T_DjiReturnCode StartPlay(void);
static T_DjiReturnCode StopPlay(void);
static T_DjiReturnCode SetVolume(uint8_t volume);
static T_DjiReturnCode GetVolume(uint8_t *volume);
static T_DjiReturnCode ReceiveTtsData(E_DjiWidgetTransmitDataEvent event,
uint32_t offset, uint8_t *buf, uint16_t size);
static T_DjiReturnCode ReceiveAudioData(E_DjiWidgetTransmitDataEvent event,
@ -107,13 +104,10 @@ T_DjiReturnCode DjiTest_WidgetSpeakerStartService(void)
s_speakerHandler.GetSpeakerState = GetSpeakerState;
s_speakerHandler.SetWorkMode = SetWorkMode;
s_speakerHandler.GetWorkMode = GetWorkMode;
s_speakerHandler.StartPlay = StartPlay;
s_speakerHandler.StopPlay = StopPlay;
s_speakerHandler.SetPlayMode = SetPlayMode;
s_speakerHandler.GetPlayMode = GetPlayMode;
s_speakerHandler.SetVolume = SetVolume;
s_speakerHandler.GetVolume = GetVolume;
s_speakerHandler.ReceiveTtsData = ReceiveTtsData;
s_speakerHandler.ReceiveVoiceData = ReceiveAudioData;
@ -322,12 +316,13 @@ static T_DjiReturnCode DjiTest_PlayTtsData(void)
SetSpeakerState(DJI_WIDGET_SPEAKER_STATE_IN_TTS_CONVERSION);
#ifdef EKHO_INSTALLED
#if EKHO_INSTALLED
/*! Attention: you can use other tts opensource function to convert txt to speech, example used ekho v7.5 */
snprintf(cmdStr, sizeof(cmdStr), " ekho %s -s 20 -p 20 -a 100", data);
snprintf(cmdStr, sizeof(cmdStr), " ekho %s -s 20 -p 20 -a 100 -o %s", data, WIDGET_SPEAKER_TTS_OUTPUT_FILE_NAME);
#else
snprintf(cmdStr, sizeof(cmdStr), "tts_offline_sample '%s' %s", data,
WIDGET_SPEAKER_TTS_OUTPUT_FILE_NAME);
USER_LOG_WARN(
"Ekho is not installed, please visit https://www.eguidedog.net/ekho.php to install it or use other TTS tools to convert audio");
#endif
DjiUserUtil_RunSystemCmd(cmdStr);
SetSpeakerState(DJI_WIDGET_SPEAKER_STATE_PLAYING);
@ -335,7 +330,6 @@ static T_DjiReturnCode DjiTest_PlayTtsData(void)
memset(cmdStr, 0, sizeof(cmdStr));
snprintf(cmdStr, sizeof(cmdStr), "ffplay -nodisp -autoexit -ar 16000 -ac 1 -f s16le -i %s 2>/dev/null",
WIDGET_SPEAKER_TTS_OUTPUT_FILE_NAME);
#endif
return DjiUserUtil_RunSystemCmd(cmdStr);
}
@ -453,28 +447,6 @@ static T_DjiReturnCode SetWorkMode(E_DjiWidgetSpeakerWorkMode workMode)
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_DjiReturnCode GetWorkMode(E_DjiWidgetSpeakerWorkMode *workMode)
{
T_DjiReturnCode returnCode;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
returnCode = osalHandler->MutexLock(s_speakerMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
return returnCode;
}
*workMode = s_speakerState.workMode;
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
return returnCode;
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_DjiReturnCode SetPlayMode(E_DjiWidgetSpeakerPlayMode playMode)
{
T_DjiReturnCode returnCode;
@ -498,28 +470,6 @@ static T_DjiReturnCode SetPlayMode(E_DjiWidgetSpeakerPlayMode playMode)
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_DjiReturnCode GetPlayMode(E_DjiWidgetSpeakerPlayMode *playMode)
{
T_DjiReturnCode returnCode;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
returnCode = osalHandler->MutexLock(s_speakerMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
return returnCode;
}
*playMode = s_speakerState.playMode;
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
return returnCode;
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_DjiReturnCode StartPlay(void)
{
uint32_t pid;
@ -581,9 +531,10 @@ static T_DjiReturnCode SetVolume(uint8_t volume)
}
realVolume = 1.5f * (float) volume;
USER_LOG_INFO("Set widget speaker volume: %d", volume);
s_speakerState.volume = volume;
#ifdef PLATFORM_ARCH_x86_64
USER_LOG_INFO("Set widget speaker volume: %d", volume);
memset(cmdStr, 0, sizeof(cmdStr));
snprintf(cmdStr, sizeof(cmdStr), "pactl set-sink-volume %s %d%%", WIDGET_SPEAKER_USB_AUDIO_DEVICE_NAME,
(int32_t) realVolume);
@ -592,28 +543,9 @@ static T_DjiReturnCode SetVolume(uint8_t volume)
if (returnCode < 0) {
USER_LOG_ERROR("Set widget speaker volume error: %d", ret);
}
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("unlock mutex error: 0x%08llX.", returnCode);
return returnCode;
}
return DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_DjiReturnCode GetVolume(uint8_t *volume)
{
T_DjiReturnCode returnCode;
T_DjiOsalHandler *osalHandler = DjiPlatform_GetOsalHandler();
returnCode = osalHandler->MutexLock(s_speakerMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
USER_LOG_ERROR("lock mutex error: 0x%08llX.", returnCode);
return returnCode;
}
*volume = s_speakerState.volume;
#else
USER_LOG_WARN("Add set speaker volume function here!");
#endif
returnCode = osalHandler->MutexUnlock(s_speakerMutex);
if (returnCode != DJI_ERROR_SYSTEM_MODULE_CODE_SUCCESS) {
@ -737,7 +669,7 @@ static void *DjiTest_WidgetSpeakerTask(void *arg)
if (s_speakerState.state == DJI_WIDGET_SPEAKER_STATE_PLAYING) {
if (s_speakerState.playMode == DJI_WIDGET_SPEAKER_PLAY_MODE_LOOP_PLAYBACK) {
if (s_speakerState.workMode == DJI_WIDGET_SPEAKER_WORK_MODE_VOICE) {
USER_LOG_WARN("Waiting opus decoder finished...");
USER_LOG_DEBUG("Waiting opus decoder finished...");
while (s_isDecodeFinished == false) {
osalHandler->TaskSleepMs(1);
}
@ -754,7 +686,7 @@ static void *DjiTest_WidgetSpeakerTask(void *arg)
osalHandler->TaskSleepMs(1000);
} else {
if (s_speakerState.workMode == DJI_WIDGET_SPEAKER_WORK_MODE_VOICE) {
USER_LOG_WARN("Waiting opus decoder finished...");
USER_LOG_DEBUG("Waiting opus decoder finished...");
while (s_isDecodeFinished == false) {
osalHandler->TaskSleepMs(1);
}

View File

@ -7,6 +7,10 @@
"floating_window": {
"is_enable": true
},
"speaker": {
"is_enable_tts": true,
"is_enable_voice": true
},
"widget_list": [
{
"widget_index": 0,

View File

@ -7,6 +7,10 @@
"floating_window": {
"is_enable": true
},
"speaker": {
"is_enable_tts": true,
"is_enable_voice": true
},
"widget_list": [
{
"widget_index": 0,