123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #include "ql_application.h"
- #include "hlog.h"
- #include "includes.h"
- ql_task_t Vir_Task;
- ql_task_t MainTask;
- ql_task_t Subtask;
- typedef void (*app_at_cb)(char*msg,int len);
- static app_at_cb at_cb_ptr=NULL;
- void ATcmd_register(app_at_cb cb){
- at_cb_ptr=cb;
- }
- void vir_at_task(void * argv){
- char r_date[128];
- static char resp[512];
-
- ql_rtos_semaphore_create(&atsemaRef,0);
- ql_rtos_queue_create(&at_queue_t,128,2);
-
- while(1){
- ql_rtos_semaphore_wait(atsemaRef, QL_WAIT_FOREVER);
- //ql_rtos_semaphore_get_cnt(atsemaRef,®ister);
- ql_rtos_queue_wait(at_queue_t, r_date, 128, QL_WAIT_FOREVER);
- // MSG_INFO(1,"r_date==%s,%d",r_date,strlen(r_date));
- if(QL_AT_RESP_OK==ql_atcmd_send_sync(r_date,resp,sizeof(resp),0,5)){ //5
- //MSG_INFO(1,"resp==%s,%d",resp,strlen(resp));
- if(at_cb_ptr!=NULL)at_cb_ptr(resp,strlen(resp));
- }
- }
- }
- void Creat_vir_at_task(){
- ql_rtos_task_create(&Vir_Task, 1024*4, 102,"vir_at_task", vir_at_task, NULL, 0);
- while(atsemaRef==0||at_queue_t==0){
- ql_rtos_task_sleep_ms(100);
- }
- if(NULL==Vir_Task){
- MSG_WARN(1,"vir_at_task init thread error");
- return;
- }
-
- }
- void Create_sub_stask(){
- ql_rtos_task_create(&Subtask, 1024*1, 103,"Creat_lbs_task", startSubTask, NULL, 0);
- if(NULL==Subtask){
- MSG_WARN(1,"Subtask init thread error");
- return;
- }
- }
- static int hpoc_main_task(void *argv){
- if(hlog_init()==true) MSG_INFO(1, "Log ok");
- ql_rtos_task_sleep_ms(5000);
- dataInit();
- boardInit();
- Create_sub_stask();
- //startSubTask();//线程会调用外设接口,必须在boardInit后启动
- ATcmd_register(pocCmdHandler);
- Creat_vir_at_task();
- Creat_Tone_task();
- ql_codec_choose(AUD_INTERNAL_CODEC, NULL);
- ql_set_audio_path_receiver();
- ql_set_volume(10);
- ql_rtos_task_create(&MainTask, 1024*32, 102,"main", appRun, NULL, 0);//应用主程序 //32
- for(;;){
- ql_rtos_task_sleep_ms(5000);
-
- }
-
- return 0;
- }
- application_init(hpoc_main_task,"hpoc_main_task",64, 1);//64
|