123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463 |
- #include "broad.h"
- #include "type.h"
- #include "lsapi_oem.h"
- #include "lsapi_sys.h"
- #include "lsapi_os.h"
- #include "includes.h"
- #include "bndapp.h"
- #include "oem_lib.h"
- static void get_grouplist(int begin, int count);
- static void get_memberlist(int begin, int count);
- static int ui_random(int r){
- return 1;
- }
- /*通知登录状态*/
- void cb_login_state(int online){
- const char* str;
- if(online == USER_ONLINE){
- str = "USER_ONLINE";
- }
-
- else{
- str = "USER_OFFLINE";
- sutPocStatus.logined=0;
- }
-
- MSG_INFO(1,"loginstate==%s",str);
-
- }
- void cb_audio(AUDIO_STATE state, uid_t uid, const char* name, int flag){
- const char* str;
- size_t len;
- switch(state){
-
- case BND_SPEAK_START:
- str = "BND_SPEAK_START";
- sutPocStatus.mic=1;
- //MSG_INFO(1,str);
- break;
- case BND_SPEAK_STOP:
- str = "BND_SPEAK_STOP";
- paControl(true);
- sutPocStatus.mic=0;
- //MSG_INFO(1,str);
-
- break;
- case BND_LISTEN_START:
- str = "BND_LISTEN_START";
- sutPocStatus.spk=1;
- //spkCtl(1);
- paControl(true);
-
- break;
- case BND_LISTEN_STOP:
- str = "BND_LISTEN_STOP";
- sutPocStatus.spk=0;
- //spkCtl(0);
- break;
- case BND_TTS_START:
- paControl(true);
- sutPocStatus.TTS=1;
- break;
- case BND_TTS_STOP:
- paControl(true);
- sutPocStatus.TTS=0;
- MSG_INFO(1, "TTS---STOP");
- break;
- case BND_TONE_START:
- paControl(true);
- sutPocStatus.TONE=1;
- break;
- case BND_TONE_STOP:
- paControl(true);
- sutPocStatus.TONE=0;
- break;
-
-
- }
- // MSG_INFO(1,"stat=====%d",state);
- if(name!=NULL){
- backLightReset();
- tryWakeupApp();
- Utf8ToGbkOrUnicode(name,strlen(name),&sutPocStatus.CallName,&len,0);
- MSG_INFO(1,"state:%d[%s],uid:%d,len:%d,name:%s,flag:%d",state,str, uid,len,&sutPocStatus.CallName, flag);
- }
-
-
- }
- /*通知进入群组*/
- static bnd_member_t mm;
- static bnd_group_t GG;
- static char PlayTTSBuf[100]={0};
- void my_update(char *groupname,unsigned int gid){
-
- char len,i;
- char *Login="E5B7B2E799BBE5BD952C";
- char *EnterGroup="E8BF9BE585A52C";
- char tempbuf[12];
-
- if(groupname==NULL)return;
- memset(&mm,0,sizeof(mm));
-
- if(Utf8ToGbkOrUnicode(groupname,strlen(groupname),&sutPocStatus.LocalGroup.name,&len,0)){
- //MSG_INFO(1,"change erro-----");
- }
-
-
- //MSG_INFO(1,"groupname===%s",sutPocStatus.LocalGroup.name);
-
- sutPocStatus.LocalGroup.ID=gid;
-
- // MSG_INFO(1,"sutPocStatus.LocalGroup.ID22222222===%08x",sutPocStatus.LocalGroup.ID);
- //如果gid传入0,可查询当前群组信息
- broad_group_getbyid(0,&GG);
-
- if(GG.type==GRP_SINGLECALL){
- sutPocStatus.danHuStatus=1;
- }else{
- sutPocStatus.danHuStatus=0;
- }
-
- // MSG_INFO(1,"joinGroup==%d,%d,%s",gid,len,sutPocStatus.LocalGroup.name);
-
- broad_member_getbyid(0,&mm);
-
- if(Utf8ToGbkOrUnicode(mm.name,strlen(mm.name),&sutPocStatus.LocalUser.name,&len,0)){
- // MSG_INFO(1,"change erro-----");
- }
-
- // MSG_INFO(1,"joinmember==%s,uid===%d",&sutPocStatus.LocalUser.name,mm.uid);
-
- //群组登录成功为登陆标准
- sutPocStatus.logined=1;
- if(!sutPocStatus.firstLogin){
- //首次登陆播报群组和成员
- StrAsciiToHex(Login,tempbuf);
- snprintf(PlayTTSBuf, sizeof(PlayTTSBuf),"%s%s%s",mm.name,tempbuf,groupname);
- broad_play_tts(PlayTTSBuf,true);
- backLightReset();
- }else {
- //切换群组播报
- StrAsciiToHex(EnterGroup,tempbuf);
- snprintf(PlayTTSBuf, sizeof(PlayTTSBuf),"%s%s",tempbuf,groupname);
- broad_play_tts(PlayTTSBuf,true);
- }
- sutPocStatus.firstLogin=1;
- // LSAPI_OSI_ThreadSleep(500);
- MSG_INFO(1,"LocalGroup.ID333===%08x",gid);
- }
- void cb_join_group(const char* groupname, gid_t gid){
- int i;
- i++;
- my_update(groupname,(unsigned int)gid);
- }
- /*呼叫结果*/
- void cb_callmember(int ret){
- const char* str;
- if(ret==1){
- str = "call sucess";
- }else{
- str = "call failed";
- }
- MSG_INFO(1, "BND cb_callmember%s",str);
-
- }
- /*通知需要更新列表*/
- void cb_listupdate(int flag){
- const char* str;
- bnd_member_t mm;
-
- char num;
- if(flag==1){
- str = "you need get grouplist -- update";
- //get_grouplist(0,10);
- }else if(flag==2){
- str = "you need get memberlist -- update";
- if(num=broad_get_memberlist(sutPocStatus.LocalGroup.ID,&mm, 16, 0, 1)){
-
- //sutPocStatus.danHuStatus=0; //210623
- }
-
- MSG_INFO(1, "BND cb_listupdate----num===%d",num);
- }
- MSG_INFO(1, "BND cb_listupdate%s",str);
- }
- /*成员变化通知*/
- /*
- flag:1 离组
- gid:变化的gid
- num:个数
- uids:uid集合
- */
- void cb_memberchange(int flag, gid_t gid, int num, uid_t uids){
- const char* str;
- if(flag==1){
- MSG_INFO(1, "BND cb_memberchange_flag[%d]_gid[%d]_num[%d]_uids[%ld]",flag,gid,num,uids);
- }
- }
- bnd_time_t now;
- /*获取当前时间戳*/
- void current_zone_time(MY_CLOCK *myclock){
- char buffer[128] = {0};//打印128个字节会挂掉
- memset(&now, 0, sizeof(now));
- broad_current_zone_time(&now, 8);
- myclock->year=now.year;
- myclock->month=now.month;
- myclock->day=now.day;
- myclock->hour=now.hour;
- myclock->min=now.minute;
- myclock->sec=now.second;
- snprintf(buffer, sizeof(buffer), "-%02d-%02d--%02d-%02d:%02d---",now.year,now.month,now.day,now.hour, now.minute);
- MSG_INFO(1,buffer);
- }
- const char *platform_info_err="\xE8\xB4\xA6\xE5\x8F\xB7\xE4\xB8\x8D\xE5\xAD\x98\xE5\x9C\xA8";
- void cb_error_det(const char* info){
- unsigned char i=0;
- unsigned char buf[100];
- unsigned char tmp[3];
- if(strcmp(info,platform_info_err)==0){
- sutApp.platfrom_err=1;
- uISetNextStatus(UIS_MENU_INFO_SEL);
- //MSG_INFO(1,"UIS_MENU_INFO_SEL======");
- }
-
- for(i=0;i<strlen(info);i++){
- snprintf(tmp, sizeof(tmp),"%02x",info[i]);
- strcat(buf, tmp);
- }
-
- MSG_INFO(1,"error---det=%s",buf);
- broad_play_tts(info,true);
- }
- void UserGetBNDVer(char *VerSrc){
- char flag=0;
- char *p=0;
- char i;
- for(i=0;i<strlen(VerSrc);i++){
- if(VerSrc[i]=='-'){
- if(flag==0){
- flag=1;
- i++;
- p=&VerSrc[i];
- }else{
- VerSrc[i]=0;
- break;
- }
- }
- }
- strncpy(sutApp.pocVersion, p,strlen(p));
- }
- void UserGetBNDICCID(char *Src){
- char tmp[10];
- char flag=0;
- char *p=0;
- char i;
- char j=0;
- for(i=0;i<strlen(Src);i++){
- if(Src[i]==0x0d){
- sutApp.ICCID[i]=0;
- break;
- }
- sutApp.ICCID[i]=Src[i];
- }
- sutApp.ICCID[19]=0;
- }
- void ls_getModuleInfo_demo()
- {
- char Module[32];
- LSAPI_Log_Debug("enter ls_getModuleInfo_demo!");
- memset(Module, 0x00, 32);
- LSAPI_SYS_getModuleType(Module);
- MSG_INFO(1,"ls_getModuleInfo_demo:ModuleType %s", Module);
- memset(Module, 0x00, 32);
- LSAPI_SYS_getModuleVersion(Module);
- MSG_INFO(1,"ls_getModuleInfo_demo:ModuleVersion %s", Module);
- memset(Module, 0x00, 32);
- LSAPI_SYS_getModulebtime(Module);
- MSG_INFO(1,"ls_getModuleInfo_demo:Modulebtime %s", Module);
- }
- void BNDrequest_lbs_info_cb(char *z8filename,char *z12filename, char *z16filename, char *lbs_tts,char is_lbs_tts, char is_static_map)
- {
-
- MSG_INFO(1,"z8filename==%s", z8filename);
- if(is_static_map==0)sutPocStatus.GetLbsOnce=0;
- else if(is_static_map==1)sutPocStatus.GetLbsOnce=1;
- //MSG_INFO(1,"is_lbs_tts==%d", is_lbs_tts);
- MSG_INFO(1,"is_static_map==%d", is_static_map);
-
- }
- void XInweather_info_cb (char *lbs_tts,char is_lbs_tts){
- short len=0,i=0;
- //char temp[3]={0};
- if(is_lbs_tts==1)MSG_INFO(1,"weather_info_cb===is_OK");
- else {
- MSG_INFO(1,"weather_info_cb===is_failed");
- return;
- }
- if(Utf8ToGbkOrUnicode(lbs_tts,strlen(lbs_tts),sutApp.weather,&len,0)){
- MSG_INFO(1,"change erro-----");
- }
- MSG_INFO(1,"weather==%d,%s",len,sutApp.weather);
-
- }
- /*
- static int mm_index = 0;
- static int group_index = 0;
- static int rec_index = 0;
- */
- int open_bnd_app(void){
- char ver[64] = {0};
- char *p=0;
- char str[20]={0};
- broad_set_thread_priority(300);
- broad_init();
- broad_log(1);
- broad_get_version(ver);
- broad_register_audio_cb(cb_audio);
-
-
- volAdjAction(2, sutUIstatus.Status);
- // //设置一下TTS语音速度
- broad_set_rec_audio_mode(0);//关闭录音功能
- broad_register_join_group_cb(cb_join_group);
- broad_register_listupdate_cb(cb_listupdate);
- broad_register_member_change_cb(cb_memberchange);
- broad_set_is_destroy_temp_call(1);
- //错误状态返回
- broad_register_error_cb(cb_error_det);
- //broad_register_poc_at_cb(cb_poc_at_cb);//注册接收回调
- broad_set_tts_enable(1);//测试是否主动播报TTS
- LSAPI_OSI_ThreadSleep(1000);
- broad_login(cb_login_state);
- MSG_INFO(1, "BND app init--%s",ver);
- UserGetBNDVer(ver);
- memset(ver, 0, sizeof(ver));
- //if(LSAPI_SIM_GetICCID(ver)==0)UserGetBNDICCID(ver);
- //broad_get_vol(VOL_TYPE type);
- //获取帐号可用天数
- sutApp.VailDay= broad_get_account_day();
- MSG_INFO(1, "BND day--%d",sutApp.VailDay);
- //echat_write_ini
- // 旧平台
- if(!newPara.newold_plam)broad_write_custom(CHANGE_PLATFORM_CONTEXT,"std");
- else broad_write_custom(CHANGE_PLATFORM_CONTEXT,"xin");
-
- broad_read_custom(CHANGE_PLATFORM_CONTEXT,str);
- MSG_INFO(1, "BND PingTai--%s",str);
- sutApp.bndPocDone=1;
-
- if(newPara.newold_plam)
- broad_register_request_lbs_info_cb(BNDrequest_lbs_info_cb);
- //天气
- if(newPara.newold_plam)
- broad_register_weather_info_cb(XInweather_info_cb);
-
- return 0;
- }
- static void get_memberlist(int begin, int count){
- bnd_group_t grp;
- bnd_member_t mm[16];
- memset(&grp,0, sizeof(bnd_group_t));
- broad_group_getbyid(0, &grp);
- MSG_INFO(1,"long_ung gid:%d, gname:%s\n",grp.gid, grp.name);
- if(grp.gid){
- int size;
- size = broad_get_membercount(grp.gid);
- MSG_INFO(1,"long_ung member num:%d\n",size);
- memset(mm, 0, sizeof(bnd_member_t)*16);
- size = broad_get_memberlist(grp.gid, mm, 16, begin, count);
- if(size){
- int i;
- for(i=0;i<size;i++){
- MSG_INFO(1,"long_ung [%d]uid:%d,name:%s\n",mm[i].index,mm[i].uid, mm[i].name);
- }
- }
- MSG_INFO(1,"long_ung member-size:%d\n", size);
-
- }
- }
- static void get_grouplist(int begin, int count){
- int size;
- bnd_group_t groups[16];
- memset(groups,0,sizeof(bnd_group_t)*16);
- size = broad_get_grouplist(groups, 16, begin, count);
- if(size){
- int i;
- for(i=0;i<size;i++){
- MSG_INFO(1,"long_ung [%d]gid:%d,name:%s\n",groups[i].index,groups[i].gid, groups[i].name);
- }
- }
- MSG_INFO(1,"long_ung group-count:%d\n",size);
- }
|