设备接口说明

优质
小牛编辑
132浏览
2023-12-01

1.1. flora接口说明

参考github的说明 flora

1.2. 蓝牙接口说明

YodaOS 上,蓝牙统一被bluetooth_service接管, 通过flora和蓝牙服务通讯,实现蓝牙操作。蓝牙服务在系统的源码路径如下:

frameworks/native/services/bluetooth_service

在目录frameworks/native/services/bluetooth_service/demo 下有一个测试程序和监控程序, 测试程序是测试蓝牙服务提供的接口 bluetooth_test.c , 监控程序bluetooth_monitor.c, 是打印蓝牙服务接收到到消息,用来程序调试用。

采用flora发送和接收消息。

1.2.1. A2DP 高质量音频数据传输的协议 source 操作

调用flora库的接口给bluetooth_service

flora_agent_post(agent, "bluetooth.a2dpsource.command", msg, FLORA_MSGTYPE_INSTANT)

msg的消息类型如下:

{
    name:"Rokid-Me-9999zz",
    proto:"A2DPSOURCE",
    command:"",    
}

command的取值类型:

类型意义
"ON"打开设备
"OFF"关闭设备
"DISCONNECT_PEER"断开链接点
"DISCOVERY"搜索蓝牙设备
"GETSTATE"获取当前状态

GETSTATE调用的是flora的同步接口, 参考如下:

152      flora_call_result result = {0};
153    if (flora_agent_call(agent, "bluetooth.a2dpsource.command", msg, "bluetoothservice-agent", &result, 0) == FLORA_CLI_SUCCESS) {
154    if (result.data && result.ret_code == FLORA_CLI_SUCCESS) {
155                     const char *buf = NULL;
156                     caps_read_string(result.data, &buf);
157                     printf("data :: %s\n", buf);
158                 }  
159   flora_result_delete(&result);
}
160

1.2.2. A2DP 高质量音频数据传输的协议 sink 操作

调用flora库的接口给bluetooth_service

flora_agent_post(agent, "bluetooth.a2dpsink.command", msg, FLORA_MSGTYPE_INSTANT)

msg的消息类型如下:

{
    name:"Rokid-Me-9999zz",
    proto:"A2DPSINK",
    command:"",    
}

1.3. 灯效接口说明

YodaOS对于AVS灯效的支持依靠lightservice支持,lightservice的源码路径:

frameworks/native/services/lightservice

控制灯效的接口如下,通过flora向lightservice发送"rokid.light.animation"以及msg消息,例如唤醒灯效:

int degree = 360;
Client::connect("unix:/var/run/flora.sock", &cb, 0, cli)
shared_ptr<Caps> msg = Caps::new_instance();
msg->write("awake");
msg->write(degree);

cli->post("rokid.light.animation", msg, FLORA_MSGTYPE_INSTANT);

msg消息值和对应的说明

函数名参数说明
activeint degreeListening Start
thinkingNULL
speakingNULL
idleNULL
micOnNULLMicrophone on
micOffNULLMicrophone off
alertNULLTimer/Alarm/Reminder
alertShortNULLTimer Short/Alarm
alertDismissNULL
incomingNotificationNULL
queuedNotificationNULL
noNotificationNULL
doNotDisturbNULL
btConnectStateNULLBluetooth connect
errorNULLerror
volumedouble value value = [0, 1]Volume setting
bootNULLstarting up
bootEndNULLfinish starting up
configNULLwifi config
configEndNULLfinish wifi config

1.4. 本地音效接口说明

通过调用rplayer 播放本地音频文件进行声音提示。接口说明参见rplayer

yim-avs进程的音效文件都放在源代码目录:frameworks/yimo/res

音频文件在运行环境中的目录路径为:/data/yimo/res