泊声音乐的API.docx

上传人:b****7 文档编号:10612303 上传时间:2023-02-21 格式:DOCX 页数:91 大小:45.03KB
下载 相关 举报
泊声音乐的API.docx_第1页
第1页 / 共91页
泊声音乐的API.docx_第2页
第2页 / 共91页
泊声音乐的API.docx_第3页
第3页 / 共91页
泊声音乐的API.docx_第4页
第4页 / 共91页
泊声音乐的API.docx_第5页
第5页 / 共91页
点击查看更多>>
下载资源
资源描述

泊声音乐的API.docx

《泊声音乐的API.docx》由会员分享,可在线阅读,更多相关《泊声音乐的API.docx(91页珍藏版)》请在冰豆网上搜索。

泊声音乐的API.docx

泊声音乐的API

泊声JSON协议

[适用于泊声BA76等后续新产品V2.0版]

泊声音乐系统架构

1系统结构

2一些概念

2.1主机:

每个泊声的系统中包含且仅包含一个主机,所有的控制端与主机通信,由主机协调各通道工作。

所有通道的播放内容由主机指定。

2.2通道:

每一个房间为一个通道,每个通道包含左右声道,可以接两个喇叭(特定大功率通道可以接四个喇叭,但会特别标明),通道为系统中播放的主体。

2.3音源:

音源为可播放的媒体(歌曲)的分类来源,比如:

云音乐、本地音乐、FM电台1、FM电台2、AUX外接1、AUX外接2。

2.4媒体:

为可播放的对象,比如一首歌、一个电台、一个外接音频

3协议

3.1协议整体框架

JSON长度

JSON格式的协议内容(字符串)

4个字节,标记JSON的总长度,用于多帧数据传输

协议内容采用json标准(点击超链接可以了解json)。

整体框架如下:

/*****************************************************************/

{

“sendId”:

“ba76ec01001122334455”,

“recvId”:

“ba760001001122334456”,

“cmd”:

”xxxx”,

“direction”:

”request”,//requestorresponse

“arg”:

{

/*此处填充具体的cmd对应的参数*/

}

}

/****************************************************************/

1)搜索主机时,采用UDP广播,(搜索主机时,recvId用f填充)

发送端口18090,接收端口18090

2)其他的协议,采用TCP进行通讯,通讯端口:

20090

3)采用TCP数据通讯,都是控制端发送TCP短连接,TCP的断开由控制端主动断开

4)在发送数据前,须在数据前添加四个字节的数据长度,不足四个字节,用0填充,如协议数据长度为25个字节,则在发送前,添加四个字节”19000000”

5)编码集采用的是UTF-8

 

3.2数据类型约定

3.2.1sendId、recvId

sendId与recvId为一个20字符的字符串,字符串中每一个字符取值范围为0-9/A-F。

厂家ID

系统ID

设备类型ID

设备编号

2个字节长度。

标识厂家。

如“BA”

2个字节长度。

标识所属系统类型。

如“90”,“76”

2个字节长度。

标识设备类型。

2个字节长度。

标识具体设备编号。

设备ID解析

20字节

设备类型:

“00”通道

“01”主机

“ec”控制端

0x04面板

如“BA900000112233445566”

设备ID

12个字节长度。

标识具体设备唯一识别码

3.2.2diretcion

建议兼容“direction”、“direct”两个字段

3.2.3cmd、arg

具体参考“命令定义”

3.3命令归类

1.所有的通知均为UDP

2.除搜寻主机命令为UDP,其他的主动获取或设置命令均采用TCP传输

4命令定义

4.1系统启动通知[UDP]

Cmd

Request

Response

数值定义

“NotifySystemStart”

“arg”:

{

}

当系统启动后,会广播该命令,采用UDP,端口号18090

4.2搜寻设备

4.2.1搜寻主机[UDP]

Cmd

Request

Response

数值定义

“SearchHost”

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“deviceType”:

”xxxxx”,

“deviceId”:

”xxxxx”,

“deviceName”:

”xxxxx”,

“deviceVersion”:

”xxxxx”

}

 

当控制端搜寻主机时的命令,采用UDP,端口号18090

注:

“resultCode”:

0//只存在Respone中,表示CMD的执行状态,0-表示成功,其他数字对应其错误码。

4.2.2获取所有房间Id(recvId为主机ID)

Cmd

Request

Response

数值定义

“GetHostRoomList”

“arg”:

{

“hostId”:

”xxxxx”

}

“arg”:

{

“resultCode”:

0,

“hostId”:

”xxxxx”,

“roomList”:

[room0,room1]

}

Room信息定义如下:

“arg”:

{

“roomName”:

”xxxxx”,

“roomId”:

”xxxxx”

“devStat”:

”xxxxx”,

“channelStat”:

”xxxxx”

}

devStat:

open,

close,

unconnected

channelStat:

inClosed,

inNormal,

inTalk,

inParty,

inDlna,

inAirplay

4.3房间状态

4.3.1获取房间当前信息

Cmd

Request

Response

数值定义

“GetPlayingInfo”

“arg”:

{

}

roomStat为inTalk

Room定义如下:

“arg”:

{

“resultCode”:

0,

“roomStat”:

”inTalk”,

“talkId”:

xx

}

roomStat为inParty

Room定义如下:

“arg”:

{

“resultCode”:

0,

“roomStat”:

”inParty”,

“partyId”:

xx,

“media”:

{media}

}

roomStat为inDlna

Room定义如下:

“arg”:

{

“resultCode”:

0,

“roomStat”:

”inDlna”

}

roomStat为inAirplay

Room定义如下:

“arg”:

{

“resultCode”:

0,

“roomStat”:

”inAirplay”

}

roomStat为inNormal

Room定义如下:

“arg”:

{

“resultCode”:

0,

“roomStat”:

”inNormal”

“media”:

{media}

}

Media参考media类

roomStat:

inTalk,

inParty,

inDlna,

inAirplay,

inNormal,

inClosed

4.3.2房间信息变更通知

Cmd

Request

Response

数值定义

“NotifyPlayingInfo”

roomStat为inTalk

Room定义如下:

“arg”:

{

“roomStat”:

”inTalk”,

“talkId”:

xx

}

roomStat为inParty

Room定义如下:

“arg”:

{

“roomStat”:

”inParty”,

“partyId”:

xx,

“media”:

media

}

roomStat为inDlna

Room定义如下:

“arg”:

{

“roomStat”:

”inDlna”

}

roomStat为inAirplay

Room定义如下:

“arg”:

{

“roomStat”:

”inAirplay”

}

roomStat为inNormal

Room定义如下:

“arg”:

{

“roomStat”:

”inNormal”

“media”:

media

}

Media参考media类

4.3.3获取当前房间的基本状态信息(用于一次性获取较多的信息)

Cmd

Request

Response

数值定义

“GetRoomStatInfo”

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“devStat”:

”xxxxx”,

“playStat”:

”xxxxx”,

“volume”:

xx,

“playMode”:

”xxxxx”,

“roomStat”:

”xxxxx”,

“media”:

{media}

}

devStat:

“open”,

“close”,

“unconnected”

playStat:

“playing”

“pause”

volume数值:

范围0-31

roomStat:

inTalk,

inParty,

inDlna,

inAirplay,

inNormal,

inClosed

4.4设备信息

4.4.1获取设备信息

Cmd

Request

Response

数值定义

“GetDevInfo”

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“devName”:

”xxxxx”,

“softVer”:

”xxxxx”,

“hardVer”:

”xxxxx”

}

resultCode=0,正常

resultCode=2,无房间

4.4.2设置设备信息[用于更改房间名称]

Cmd

Request

Response

数值定义

“SetDevInfo”

“arg”:

{

“devName”:

”xxxxx”

}

“arg”:

{

“resultCode”:

0,

“devName”:

”xxxxx”

}

resultCode=0,正常

resultCode=2,无房间

resultCode=4,参数错误

4.4.3设备信息更改

Cmd

Request

Response

数值定义

“NotifyDevInfo”

“arg”:

{

“devName”:

”xxxxx”,

“softVer”:

”xxxxx”,

“hardVer”:

”xxxxx

}

4.5设备开关机状态

4.5.1获取设备开关机状态

Cmd

Request

Response

数值定义

“GetDevStat”

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“devStat”:

”xxxxx”

}

“open”

“close”

resultCode=0,正常

resultCode=2,无房间

4.5.2开关机

Cmd

Request

Response

数值定义

“SetDevStat”

“arg”:

{

“devStat”:

”xxxxx”

}

“arg”:

{

“resultCode”:

0,

“devStat”:

”xxxxx”

}

“open”

“close”

resultCode=0,正常

resultCode=2,无房间

resultCode=4,参数错误

resultCode=100,对讲状态中(对讲状态下不允许设置房间状态)

4.5.3开关机状态更改通知

Cmd

Request

Response

数值定义

“NotifyDevStat”

“arg”:

{

“devStat”:

”xxxxx”

}

“open”

“close”

4.6音量

4.6.1获取音量

Cmd

Request

Response

数值定义

“GetVolume”

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“volume”:

xx

}

数值,

范围0-31

resultCode=0,正常

resultCode=2,无房间

4.6.2设置音量

Cmd

Request

Response

数值定义

“SetVolume”

“arg”:

{

“volume”:

xx

}

“arg”:

{

“resultCode”:

0,

“volume”:

xx

}

数值,

范围0-31

resultCode=0,正常

resultCode=2,无房间

resultCode=4,参数错误

4.6.3音量更改通知

Cmd

Request

Response

数值定义

“NotifyVolume”

“arg”:

{

“volume”:

xx

}

 

数值,

范围0-31

4.7音效

4.7.1获取音效

Cmd

Request

Response

数值定义

“GetEq”

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“eq”:

”xxxxx”

}

参考”eq的定义如下”

resultCode=0,正常

resultCode=2,无房间

eq的定义如下:

EQ类型

类型中文名

Flat

单调

Classical

经典

Club

俱乐部

Dance

舞曲

Fullbass

全低音

Fullbassandtreble

全低高音

Fulltreble

全高音

Headphones

耳机

LargeHall

大音乐厅

Live

实况

Party

聚会

Pop

流行

Reggae

雷盖

Rock

摇滚

Ska

斯卡

Soft

柔和

Softrock

慢摇

Techno

电子乐

UserDefine

用户自定义,用于后续的音效均衡器

4.7.2设置音效

Cmd

Request

Response

数值定义

“SetEq”

“arg”:

{

“eq”:

”xxxxx”

}

“arg”:

{

“resultCode”:

0,

“eq”:

”xxxxx”

}

参考”eq的定义如下”

resultCode=0,正常

resultCode=2,无房间

resultCode=4,参数错误

4.7.3音效更改通知

Cmd

Request

Response

数值定义

“NotifyEq”

“arg”:

{

“eq”:

”xxxxx”

}

4.8低音

4.8.1获取低音

Cmd

Request

Response

数值定义

“GetBass”

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“bass”:

xx

}

数值范围:

[-10,10]

resultCode=0,正常

resultCode=2,无房间

4.8.2设置低音

Cmd

Request

Response

数值定义

“SetBass”

“arg”:

{

“bass”:

xx

}

“arg”:

{

“resultCode”:

0,

“bass”:

xx

}

数值范围:

[-10,10]

resultCode=0,正常

resultCode=2,无房间

resultCode=4,参数错误

4.8.3低音更改通知

Cmd

Request

Response

数值定义

“NotifyBass”

“arg”:

{

“bass”:

xx

}

数值范围:

[-10,10]

4.9高音

4.9.1获取高音

Cmd

Request

Response

数值定义

“GetTreble

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“treb”:

xx

}

数值范围:

[-10,10]

resultCode=0,正常

resultCode=2,无房间

4.9.2设置高音

Cmd

Request

Response

数值定义

“SetTreble

“arg”:

{

“treb”:

xx

}

“arg”:

{

“resultCode”:

0,

“treb”:

xx

}

数值范围:

[-10,10]

resultCode=0,正常

resultCode=2,无房间

resultCode=4,参数错误

4.9.3高音更改通知

Cmd

Request

Response

数值定义

“NotifyTreble

“arg”:

{

“treb”:

xx

}

数值范围:

[-10,10]

4.10静音

4.10.1获取静音状态

Cmd

Request

Response

数值定义

“GetMute”

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“muteStat”:

”xxxxx”

}

“mute”

“normal”

resultCode=0,正常

resultCode=2,无房间

4.10.2设置静音

Cmd

Request

Response

数值定义

“SetMute”

“arg”:

{

“muteStat”:

”xxxxx”

}

“arg”:

{

“resultCode”:

0,

“muteStat”:

”xxxxx”

}

“mute”

“normal”

resultCode=0,正常

resultCode=2,无房间

resultCode=4,参数错误

4.10.3静音通知

Cmd

Request

Response

数值定义

“NotifyMute”

“arg”:

{

“muteStat”:

”xxxxx”

}

“mute”

“normal”

4.11播放模式

4.11.1获取播放模式

Cmd

Request

Response

数值定义

“GetPlayMode”

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“playMode”:

”xxxxx”

}

“normal”

“circle”

“shuffle”

“single”

resultCode=0,正常

resultCode=2,无房间

4.11.2设置播放模式

Cmd

Request

Response

数值定义

“SetPlayMode”

“arg”:

{

“playMode”:

”xxxxx”

}

“arg”:

{

“resultCode”:

0,

“playMode”:

”xxxxx”

}

“normal”

“circle”

“shuffle”

“single”

resultCode=0,正常

resultCode=2,无房间

resultCode=4,参数错误

4.11.3播放模式更改通知

Cmd

Request

Response

数值定义

“NotifyPlayMode”

“arg”:

{

“playMode”:

”xxxxx”

}

“normal”

“circle”

“shuffle”

“single”

4.12电话静音设置

4.12.1查询电话静音是否被设置

Cmd

Request

Response

数值定义

“GetPhoneMuteConfig”

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“phoneMuteEnable”:

”xxxxx”

}

“enable”

“disable”

resultCode=0,正常

resultCode=2,无房间

4.12.2使能/失能电话静音

Cmd

Request

Response

数值定义

“SetPhoneMuteConfig”

“arg”:

{

“phoneMuteEnable”:

”xxxxx”

}

“arg”:

{

“resultCode”:

0,

“phoneMuteEnable”:

”xxxxx”

}

“enable”

“disable”

resultCode=0,正常

resultCode=2,无房间

resultCode=4,参数错误

4.12.3电话静音使能/使能通知

Cmd

Request

Response

数值定义

“NotifyPhoneMuteConfig”

“arg”:

{

“phoneMuteEnable”:

”xxxxx”

}

“enable”

“disable”

4.13电话静音状态信息

4.13.1进入/退出电话静音状态通知

Cmd

Request

Response

数值定义

“NotifyPhoneMute”

“arg”:

{

“phoneMute”:

”xxxxx”

}

“normal”

“mute”

4.14警报状态通知(暂时未提供,后续完善)

Cmd

Request

Response

数值定义

“NotifyAlarm”

“arg”:

{

“alarmType”:

”xxxxx1”,

“alarmStat”:

”xxxxx2”

}

alarmType:

“FIRE”

“STEAL”

alarmStat:

“normal”

“alarm”

4.15通道锁定(暂时未提供,后续完善)

4.15.1获取通道锁定的状态

Cmd

Request

Response

数值定义

“GetLockStat”

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“lockStat”:

”xxxxx”

}

“normal”

“lock”

4.15.2设置通道锁定

Cmd

Request

Response

数值定义

“SetLockStat”

“arg”:

{

“lockStat”:

”xxxxx”

}

“arg”:

{

“resultCode”:

0,

“lockStat”:

”xxxxx”

}

“normal”

“lock”

4.15.3通道锁定和解锁通知

Cmd

Request

Response

数值定义

“NotifyLock”

“arg”:

{

“lockStat”:

”xxxxx”

}

“normal”

“lock”

4.16时间(recvId为主机)

4.16.1.1获取当前系统时间

Cmd

Request

Response

数值定义

“GetSysTime”

“arg”:

{

}

“arg”:

{

“resultCode”:

0,

“time”:

”HH:

MM:

SS”

}

4.16.2设置当前系统时间

Cmd

Request

Response

数值定义

“SetSysTime”

“arg”:

{

“time”:

”HH:

MM:

SS”

}

“arg”:

{

“resultC

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 商务科技

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1