htest.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #include "ql_application.h"
  2. #include "hlog.h"
  3. #include "includes.h"
  4. ql_task_t Vir_Task;
  5. ql_task_t MainTask;
  6. ql_task_t Subtask;
  7. typedef void (*app_at_cb)(char*msg,int len);
  8. static app_at_cb at_cb_ptr=NULL;
  9. void ATcmd_register(app_at_cb cb){
  10. at_cb_ptr=cb;
  11. }
  12. void vir_at_task(void * argv){
  13. char r_date[128];
  14. static char resp[512];
  15. ql_rtos_semaphore_create(&atsemaRef,0);
  16. ql_rtos_queue_create(&at_queue_t,128,2);
  17. while(1){
  18. ql_rtos_semaphore_wait(atsemaRef, QL_WAIT_FOREVER);
  19. //ql_rtos_semaphore_get_cnt(atsemaRef,&register);
  20. ql_rtos_queue_wait(at_queue_t, r_date, 128, QL_WAIT_FOREVER);
  21. // MSG_INFO(1,"r_date==%s,%d",r_date,strlen(r_date));
  22. if(QL_AT_RESP_OK==ql_atcmd_send_sync(r_date,resp,sizeof(resp),0,5)){ //5
  23. //MSG_INFO(1,"resp==%s,%d",resp,strlen(resp));
  24. if(at_cb_ptr!=NULL)at_cb_ptr(resp,strlen(resp));
  25. }
  26. }
  27. }
  28. void Creat_vir_at_task(){
  29. ql_rtos_task_create(&Vir_Task, 1024*4, 102,"vir_at_task", vir_at_task, NULL, 0);
  30. while(atsemaRef==0||at_queue_t==0){
  31. ql_rtos_task_sleep_ms(100);
  32. }
  33. if(NULL==Vir_Task){
  34. MSG_WARN(1,"vir_at_task init thread error");
  35. return;
  36. }
  37. }
  38. void Create_sub_stask(){
  39. ql_rtos_task_create(&Subtask, 1024*1, 103,"Creat_lbs_task", startSubTask, NULL, 0);
  40. if(NULL==Subtask){
  41. MSG_WARN(1,"Subtask init thread error");
  42. return;
  43. }
  44. }
  45. static int hpoc_main_task(void *argv){
  46. if(hlog_init()==true) MSG_INFO(1, "Log ok");
  47. ql_rtos_task_sleep_ms(5000);
  48. dataInit();
  49. boardInit();
  50. Create_sub_stask();
  51. //startSubTask();//线程会调用外设接口,必须在boardInit后启动
  52. ATcmd_register(pocCmdHandler);
  53. Creat_vir_at_task();
  54. Creat_Tone_task();
  55. ql_codec_choose(AUD_INTERNAL_CODEC, NULL);
  56. ql_set_audio_path_receiver();
  57. ql_set_volume(10);
  58. ql_rtos_task_create(&MainTask, 1024*32, 102,"main", appRun, NULL, 0);//应用主程序 //32
  59. for(;;){
  60. ql_rtos_task_sleep_ms(5000);
  61. }
  62. return 0;
  63. }
  64. application_init(hpoc_main_task,"hpoc_main_task",64, 1);//64