TestMegaphone.c 14.5 KB
#include <stdio.h>
#include <string.h>

#include "JZsdk_uart/JZsdk_Uart_Input.h"
#include "BaseConfig.h"
#include "JZsdkLib.h"

#include "JZsdk_uart/JZsdk_Uart_Input.h"
#include "JZsdk_Base/JZsdk_FrameComparsion/JZsdk_FrameComparsion.h"

extern int Connectmode;

T_JZsdkReturnCode TestMegaphone_Init()
{
    //1、重复发送连接帧,知道收到连接成功帧
    while (Connectmode == 0)
    {
        JZsdk_Uart_Send_ConnectFrame(UART_DEV_1);

        delayMs(100);
    }
    
    delayS(5);

    //2 喊话测试开始
    char ControlFrame[256];
    int  ControlFrameLen;
   
/***********************************************************************************************************************************
 * 
 *      音量修改
 * 
 * ***********************************************************************************************************************************/
    //设置音量大小
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_VOLUME ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x20; 
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //修改音色 为放中文女生
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_SET_TONE ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x01;
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //播放喊话器测试喊话器测试
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_START ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    memcpy(ControlFrame, "喊话器32音量", sizeof("喊话器32音量"));
    ControlFrameLen = sizeof("喊话器32音量");
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    delayS(5);

    //设置音量大小
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_VOLUME ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x40; 
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //播放喊话器测试喊话器测试
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_START ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    memcpy(ControlFrame, "喊话器64音量", sizeof("喊话器64音量"));
    ControlFrameLen = sizeof("喊话器64音量");
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    delayS(5);

    //设置音量大小
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_VOLUME ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x40; 
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //播放喊话器测试喊话器测试
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_START ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    memcpy(ControlFrame, "喊话器100音量", sizeof("喊话器100音量"));
    ControlFrameLen = sizeof("喊话器100音量");
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    delayS(5);

    //设置音量大小
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_VOLUME ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x64; 
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //播放喊话器测试喊话器测试
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_START ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    memcpy(ControlFrame, "喊话器测试,喊话器测试", sizeof("喊话器测试,喊话器测试"));
    ControlFrameLen = sizeof("喊话器测试,喊话器测试");
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    delayS(7);

    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);
    //播放喊话器测试喊话器测试
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_START ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    memcpy(ControlFrame, "喊话器测试,喊话器测试", sizeof("喊话器测试,喊话器测试"));
    ControlFrameLen = sizeof("喊话器测试,喊话器测试");
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    delayS(7);

/***********************************************************************************************************************************
 * 
 *      中文女声tts测试
 * 
 * ***********************************************************************************************************************************/

    //设置音量大小
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_VOLUME ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x64; 
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //修改音色 为放中文女生
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_SET_TONE ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x01;
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //播放喊话器测试喊话器测试
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_START ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    memcpy(ControlFrame, "中文音色测试", sizeof("中文音色测试"));
    ControlFrameLen = sizeof("中文音色测试");
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    delayS(5);

/***********************************************************************************************************************************
 * 
 *      广东话tts测试
 * 
 * ***********************************************************************************************************************************/

    //修改音色为广东话
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_SET_TONE ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x36;
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //播放喊话器测试喊话器测试
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_START ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    memcpy(ControlFrame, "广东话音色测试", sizeof("广东话音色测试"));
    ControlFrameLen = sizeof("广东话音色测试");
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    delayS(5);

/***********************************************************************************************************************************
 * 
 *      下一曲测试5分钟
 * 
 * ***********************************************************************************************************************************/

    //循环帧打开
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_PLAY_LOOP ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x01;
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //下一曲音乐播放
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_AUDIO_NEXTSONG ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //循环播放5分钟
    delayS(300);

    //循环关闭
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_PLAY_LOOP ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x00;
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //关闭播放
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_AUDIO_STOP ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    delayS(5);

    //循环帧打开
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_PLAY_LOOP ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x01;
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //修改音色 为放中文女生
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_SET_TONE ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x01;
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //播放喊话器测试喊话器测试
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_START ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    memcpy(ControlFrame, "喊话器测试,喊话器测试", sizeof("喊话器测试,喊话器测试"));
    ControlFrameLen = sizeof("喊话器测试,喊话器测试");
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //循环播放3分钟
    delayS(180);

    //循环关闭
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_PLAY_LOOP ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x00;
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //关闭播放
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_AUDIO_STOP ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    delayS(5);

/***********************************************************************************************************************************
 * 
 *      上一曲测试5分钟
 * 
 * ***********************************************************************************************************************************/

    //循环帧打开
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_PLAY_LOOP ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x01;
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //上一曲音乐播放
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_AUDIO_LASTSONG ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //循环播放5分钟
    delayS(300);

    //循环关闭
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_PLAY_LOOP ,ControlFrame, &ControlFrameLen);
    ControlFrame[9] = 0x00;
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    //关闭播放
    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_AUDIO_STOP ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);


/***********************************************************************************************************************************
 * 
 *      测试完成
 * 
 * ***********************************************************************************************************************************/

    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_START ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    memcpy(ControlFrame, "测试完成,测试完成", sizeof("测试完成,测试完成"));
    ControlFrameLen = sizeof("测试完成,测试完成");
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);

    memset(ControlFrame,0,sizeof(ControlFrame));
    JZsdk_GetFrameTemplate(JZ_INSCODE_5AFRAME_TTS_TRANS_STOP ,ControlFrame, &ControlFrameLen);
    JZsdk_Uart_Send_CustomOrder(UART_DEV_1, ControlFrame, ControlFrameLen);
}