bndapp.c 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  1. #include "broad.h"
  2. #include "type.h"
  3. #include "lsapi_oem.h"
  4. #include "lsapi_sys.h"
  5. #include "lsapi_os.h"
  6. #include "includes.h"
  7. #include "bndapp.h"
  8. #include "oem_lib.h"
  9. static void get_grouplist(int begin, int count);
  10. static void get_memberlist(int begin, int count);
  11. static int ui_random(int r){
  12. return 1;
  13. }
  14. /*通知登录状态*/
  15. void cb_login_state(int online){
  16. const char* str;
  17. if(online == USER_ONLINE){
  18. str = "USER_ONLINE";
  19. }
  20. else{
  21. str = "USER_OFFLINE";
  22. sutPocStatus.logined=0;
  23. }
  24. MSG_INFO(1,"loginstate==%s",str);
  25. }
  26. void cb_audio(AUDIO_STATE state, uid_t uid, const char* name, int flag){
  27. const char* str;
  28. size_t len;
  29. switch(state){
  30. case BND_SPEAK_START:
  31. str = "BND_SPEAK_START";
  32. sutPocStatus.mic=1;
  33. //MSG_INFO(1,str);
  34. break;
  35. case BND_SPEAK_STOP:
  36. str = "BND_SPEAK_STOP";
  37. paControl(true);
  38. sutPocStatus.mic=0;
  39. //MSG_INFO(1,str);
  40. break;
  41. case BND_LISTEN_START:
  42. str = "BND_LISTEN_START";
  43. sutPocStatus.spk=1;
  44. //spkCtl(1);
  45. paControl(true);
  46. break;
  47. case BND_LISTEN_STOP:
  48. str = "BND_LISTEN_STOP";
  49. sutPocStatus.spk=0;
  50. //spkCtl(0);
  51. break;
  52. case BND_TTS_START:
  53. paControl(true);
  54. sutPocStatus.TTS=1;
  55. break;
  56. case BND_TTS_STOP:
  57. paControl(true);
  58. sutPocStatus.TTS=0;
  59. MSG_INFO(1, "TTS---STOP");
  60. break;
  61. case BND_TONE_START:
  62. paControl(true);
  63. sutPocStatus.TONE=1;
  64. break;
  65. case BND_TONE_STOP:
  66. paControl(true);
  67. sutPocStatus.TONE=0;
  68. break;
  69. }
  70. // MSG_INFO(1,"stat=====%d",state);
  71. if(name!=NULL){
  72. backLightReset();
  73. tryWakeupApp();
  74. Utf8ToGbkOrUnicode(name,strlen(name),&sutPocStatus.CallName,&len,0);
  75. MSG_INFO(1,"state:%d[%s],uid:%d,len:%d,name:%s,flag:%d",state,str, uid,len,&sutPocStatus.CallName, flag);
  76. }
  77. }
  78. /*通知进入群组*/
  79. static bnd_member_t mm;
  80. static bnd_group_t GG;
  81. static char PlayTTSBuf[100]={0};
  82. void my_update(char *groupname,unsigned int gid){
  83. char len,i;
  84. char *Login="E5B7B2E799BBE5BD952C";
  85. char *EnterGroup="E8BF9BE585A52C";
  86. char tempbuf[12];
  87. if(groupname==NULL)return;
  88. memset(&mm,0,sizeof(mm));
  89. if(Utf8ToGbkOrUnicode(groupname,strlen(groupname),&sutPocStatus.LocalGroup.name,&len,0)){
  90. //MSG_INFO(1,"change erro-----");
  91. }
  92. //MSG_INFO(1,"groupname===%s",sutPocStatus.LocalGroup.name);
  93. sutPocStatus.LocalGroup.ID=gid;
  94. // MSG_INFO(1,"sutPocStatus.LocalGroup.ID22222222===%08x",sutPocStatus.LocalGroup.ID);
  95. //如果gid传入0,可查询当前群组信息
  96. broad_group_getbyid(0,&GG);
  97. if(GG.type==GRP_SINGLECALL){
  98. sutPocStatus.danHuStatus=1;
  99. }else{
  100. sutPocStatus.danHuStatus=0;
  101. }
  102. // MSG_INFO(1,"joinGroup==%d,%d,%s",gid,len,sutPocStatus.LocalGroup.name);
  103. broad_member_getbyid(0,&mm);
  104. if(Utf8ToGbkOrUnicode(mm.name,strlen(mm.name),&sutPocStatus.LocalUser.name,&len,0)){
  105. // MSG_INFO(1,"change erro-----");
  106. }
  107. // MSG_INFO(1,"joinmember==%s,uid===%d",&sutPocStatus.LocalUser.name,mm.uid);
  108. //群组登录成功为登陆标准
  109. sutPocStatus.logined=1;
  110. if(!sutPocStatus.firstLogin){
  111. //首次登陆播报群组和成员
  112. StrAsciiToHex(Login,tempbuf);
  113. snprintf(PlayTTSBuf, sizeof(PlayTTSBuf),"%s%s%s",mm.name,tempbuf,groupname);
  114. broad_play_tts(PlayTTSBuf,true);
  115. backLightReset();
  116. }else {
  117. //切换群组播报
  118. StrAsciiToHex(EnterGroup,tempbuf);
  119. snprintf(PlayTTSBuf, sizeof(PlayTTSBuf),"%s%s",tempbuf,groupname);
  120. broad_play_tts(PlayTTSBuf,true);
  121. }
  122. sutPocStatus.firstLogin=1;
  123. // LSAPI_OSI_ThreadSleep(500);
  124. MSG_INFO(1,"LocalGroup.ID333===%08x",gid);
  125. }
  126. void cb_join_group(const char* groupname, gid_t gid){
  127. int i;
  128. i++;
  129. my_update(groupname,(unsigned int)gid);
  130. }
  131. /*呼叫结果*/
  132. void cb_callmember(int ret){
  133. const char* str;
  134. if(ret==1){
  135. str = "call sucess";
  136. }else{
  137. str = "call failed";
  138. }
  139. MSG_INFO(1, "BND cb_callmember%s",str);
  140. }
  141. /*通知需要更新列表*/
  142. void cb_listupdate(int flag){
  143. const char* str;
  144. bnd_member_t mm;
  145. char num;
  146. if(flag==1){
  147. str = "you need get grouplist -- update";
  148. //get_grouplist(0,10);
  149. }else if(flag==2){
  150. str = "you need get memberlist -- update";
  151. if(num=broad_get_memberlist(sutPocStatus.LocalGroup.ID,&mm, 16, 0, 1)){
  152. //sutPocStatus.danHuStatus=0; //210623
  153. }
  154. MSG_INFO(1, "BND cb_listupdate----num===%d",num);
  155. }
  156. MSG_INFO(1, "BND cb_listupdate%s",str);
  157. }
  158. /*成员变化通知*/
  159. /*
  160. flag:1 离组
  161. gid:变化的gid
  162. num:个数
  163. uids:uid集合
  164. */
  165. void cb_memberchange(int flag, gid_t gid, int num, uid_t uids){
  166. const char* str;
  167. if(flag==1){
  168. MSG_INFO(1, "BND cb_memberchange_flag[%d]_gid[%d]_num[%d]_uids[%ld]",flag,gid,num,uids);
  169. }
  170. }
  171. bnd_time_t now;
  172. /*获取当前时间戳*/
  173. void current_zone_time(MY_CLOCK *myclock){
  174. char buffer[128] = {0};//打印128个字节会挂掉
  175. memset(&now, 0, sizeof(now));
  176. broad_current_zone_time(&now, 8);
  177. myclock->year=now.year;
  178. myclock->month=now.month;
  179. myclock->day=now.day;
  180. myclock->hour=now.hour;
  181. myclock->min=now.minute;
  182. myclock->sec=now.second;
  183. snprintf(buffer, sizeof(buffer), "-%02d-%02d--%02d-%02d:%02d---",now.year,now.month,now.day,now.hour, now.minute);
  184. MSG_INFO(1,buffer);
  185. }
  186. const char *platform_info_err="\xE8\xB4\xA6\xE5\x8F\xB7\xE4\xB8\x8D\xE5\xAD\x98\xE5\x9C\xA8";
  187. void cb_error_det(const char* info){
  188. unsigned char i=0;
  189. unsigned char buf[100];
  190. unsigned char tmp[3];
  191. if(strcmp(info,platform_info_err)==0){
  192. sutApp.platfrom_err=1;
  193. uISetNextStatus(UIS_MENU_INFO_SEL);
  194. //MSG_INFO(1,"UIS_MENU_INFO_SEL======");
  195. }
  196. for(i=0;i<strlen(info);i++){
  197. snprintf(tmp, sizeof(tmp),"%02x",info[i]);
  198. strcat(buf, tmp);
  199. }
  200. MSG_INFO(1,"error---det=%s",buf);
  201. broad_play_tts(info,true);
  202. }
  203. void UserGetBNDVer(char *VerSrc){
  204. char flag=0;
  205. char *p=0;
  206. char i;
  207. for(i=0;i<strlen(VerSrc);i++){
  208. if(VerSrc[i]=='-'){
  209. if(flag==0){
  210. flag=1;
  211. i++;
  212. p=&VerSrc[i];
  213. }else{
  214. VerSrc[i]=0;
  215. break;
  216. }
  217. }
  218. }
  219. strncpy(sutApp.pocVersion, p,strlen(p));
  220. }
  221. void UserGetBNDICCID(char *Src){
  222. char tmp[10];
  223. char flag=0;
  224. char *p=0;
  225. char i;
  226. char j=0;
  227. for(i=0;i<strlen(Src);i++){
  228. if(Src[i]==0x0d){
  229. sutApp.ICCID[i]=0;
  230. break;
  231. }
  232. sutApp.ICCID[i]=Src[i];
  233. }
  234. sutApp.ICCID[19]=0;
  235. }
  236. void ls_getModuleInfo_demo()
  237. {
  238. char Module[32];
  239. LSAPI_Log_Debug("enter ls_getModuleInfo_demo!");
  240. memset(Module, 0x00, 32);
  241. LSAPI_SYS_getModuleType(Module);
  242. MSG_INFO(1,"ls_getModuleInfo_demo:ModuleType %s", Module);
  243. memset(Module, 0x00, 32);
  244. LSAPI_SYS_getModuleVersion(Module);
  245. MSG_INFO(1,"ls_getModuleInfo_demo:ModuleVersion %s", Module);
  246. memset(Module, 0x00, 32);
  247. LSAPI_SYS_getModulebtime(Module);
  248. MSG_INFO(1,"ls_getModuleInfo_demo:Modulebtime %s", Module);
  249. }
  250. void BNDrequest_lbs_info_cb(char *z8filename,char *z12filename, char *z16filename, char *lbs_tts,char is_lbs_tts, char is_static_map)
  251. {
  252. MSG_INFO(1,"z8filename==%s", z8filename);
  253. if(is_static_map==0)sutPocStatus.GetLbsOnce=0;
  254. else if(is_static_map==1)sutPocStatus.GetLbsOnce=1;
  255. //MSG_INFO(1,"is_lbs_tts==%d", is_lbs_tts);
  256. MSG_INFO(1,"is_static_map==%d", is_static_map);
  257. }
  258. void XInweather_info_cb (char *lbs_tts,char is_lbs_tts){
  259. short len=0,i=0;
  260. //char temp[3]={0};
  261. if(is_lbs_tts==1)MSG_INFO(1,"weather_info_cb===is_OK");
  262. else {
  263. MSG_INFO(1,"weather_info_cb===is_failed");
  264. return;
  265. }
  266. if(Utf8ToGbkOrUnicode(lbs_tts,strlen(lbs_tts),sutApp.weather,&len,0)){
  267. MSG_INFO(1,"change erro-----");
  268. }
  269. MSG_INFO(1,"weather==%d,%s",len,sutApp.weather);
  270. }
  271. /*
  272. static int mm_index = 0;
  273. static int group_index = 0;
  274. static int rec_index = 0;
  275. */
  276. int open_bnd_app(void){
  277. char ver[64] = {0};
  278. char *p=0;
  279. char str[20]={0};
  280. broad_set_thread_priority(300);
  281. broad_init();
  282. broad_log(1);
  283. broad_get_version(ver);
  284. broad_register_audio_cb(cb_audio);
  285. volAdjAction(2, sutUIstatus.Status);
  286. // //设置一下TTS语音速度
  287. broad_set_rec_audio_mode(0);//关闭录音功能
  288. broad_register_join_group_cb(cb_join_group);
  289. broad_register_listupdate_cb(cb_listupdate);
  290. broad_register_member_change_cb(cb_memberchange);
  291. broad_set_is_destroy_temp_call(1);
  292. //错误状态返回
  293. broad_register_error_cb(cb_error_det);
  294. //broad_register_poc_at_cb(cb_poc_at_cb);//注册接收回调
  295. broad_set_tts_enable(1);//测试是否主动播报TTS
  296. LSAPI_OSI_ThreadSleep(1000);
  297. broad_login(cb_login_state);
  298. MSG_INFO(1, "BND app init--%s",ver);
  299. UserGetBNDVer(ver);
  300. memset(ver, 0, sizeof(ver));
  301. //if(LSAPI_SIM_GetICCID(ver)==0)UserGetBNDICCID(ver);
  302. //broad_get_vol(VOL_TYPE type);
  303. //获取帐号可用天数
  304. sutApp.VailDay= broad_get_account_day();
  305. MSG_INFO(1, "BND day--%d",sutApp.VailDay);
  306. //echat_write_ini
  307. // 旧平台
  308. if(!newPara.newold_plam)broad_write_custom(CHANGE_PLATFORM_CONTEXT,"std");
  309. else broad_write_custom(CHANGE_PLATFORM_CONTEXT,"xin");
  310. broad_read_custom(CHANGE_PLATFORM_CONTEXT,str);
  311. MSG_INFO(1, "BND PingTai--%s",str);
  312. sutApp.bndPocDone=1;
  313. if(newPara.newold_plam)
  314. broad_register_request_lbs_info_cb(BNDrequest_lbs_info_cb);
  315. //天气
  316. if(newPara.newold_plam)
  317. broad_register_weather_info_cb(XInweather_info_cb);
  318. return 0;
  319. }
  320. static void get_memberlist(int begin, int count){
  321. bnd_group_t grp;
  322. bnd_member_t mm[16];
  323. memset(&grp,0, sizeof(bnd_group_t));
  324. broad_group_getbyid(0, &grp);
  325. MSG_INFO(1,"long_ung gid:%d, gname:%s\n",grp.gid, grp.name);
  326. if(grp.gid){
  327. int size;
  328. size = broad_get_membercount(grp.gid);
  329. MSG_INFO(1,"long_ung member num:%d\n",size);
  330. memset(mm, 0, sizeof(bnd_member_t)*16);
  331. size = broad_get_memberlist(grp.gid, mm, 16, begin, count);
  332. if(size){
  333. int i;
  334. for(i=0;i<size;i++){
  335. MSG_INFO(1,"long_ung [%d]uid:%d,name:%s\n",mm[i].index,mm[i].uid, mm[i].name);
  336. }
  337. }
  338. MSG_INFO(1,"long_ung member-size:%d\n", size);
  339. }
  340. }
  341. static void get_grouplist(int begin, int count){
  342. int size;
  343. bnd_group_t groups[16];
  344. memset(groups,0,sizeof(bnd_group_t)*16);
  345. size = broad_get_grouplist(groups, 16, begin, count);
  346. if(size){
  347. int i;
  348. for(i=0;i<size;i++){
  349. MSG_INFO(1,"long_ung [%d]gid:%d,name:%s\n",groups[i].index,groups[i].gid, groups[i].name);
  350. }
  351. }
  352. MSG_INFO(1,"long_ung group-count:%d\n",size);
  353. }