void ql_entry(void) { s32 ret; bool keepGoing = TRUE; bool isContinued = FALSE; u32 cnt = 0; Ql_DebugTrace("OpenCPU: Hello TTS !\r\n\r\n"); /* Print out messages through DEBUG port */ Ql_SetDebugMode(BASIC_MODE); /* Only after the device reboots, * the set debug-mode takes effect. */ // Initialize TTS, and register callback function Ql_TTS_Initialize(&Callback_TTS_Play); while(keepGoing) { Ql_GetEvent(&g_event); switch(g_event.eventType) { case EVENT_UARTDATA: { // TODO: receive and handle data from UART ascii* pChar; s16 strLen; PortData_Event* pDataEvt = (PortData_Event*)&g_event.eventData.uartdata_evt; /* Change audio path (Command: audio path=0/1/2) * 0 = the main audio path * 1 = earphone audio path * 2 = loudspeaker audio path */ Ql_memset(g_buffer, 0x0, sizeof(g_buffer)); strLen = Ql_sprintf(g_buffer, "audio path="); pChar = Ql_strstr((char*)pDataEvt->data, g_buffer); if (pChar) { u8 audPath; char* p1; char* p2; Ql_DebugTrace((char*)pDataEvt->data); p1 = Ql_strstr((char*)pDataEvt->data, "="); p2 = Ql_strstr((char*)pDataEvt->data, "\r\n"); Ql_memset(g_buffer, 0x0, sizeof(g_buffer)); memcpy(g_buffer, p1 + 1, p2 - p1 -1); if (Ql_strcmp(g_buffer, "1") == 0) { audPath = QL_AUDIO_PATH_HEADSET; } else if (Ql_strcmp(g_buffer, "2") == 0) { audPath = QL_AUDIO_PATH_LOUDSPEAKER; } else { audPath = QL_AUDIO_PATH_NORMAL; } if (!Ql_VoiceCallChangePath(audPath)) { Ql_DebugTrace("Fail to change audio path.\r\n"); } else { Ql_DebugTrace("Change audio path to %d.\r\n", audPath); } break; } // Start tts speech (Command: start tts=...) strLen = Ql_sprintf(g_buffer, "start tts="); ret = Ql_strncmp((char*)pDataEvt->data, g_buffer, strLen); if (0 == ret) { char* pCh = NULL; pCh = Ql_strstr((char*)pDataEvt->data, "="); if (pCh != NULL) { Ql_memset(g_buffer, 0x0, sizeof(g_buffer)); Ql_strncpy(g_buffer, pCh + 1, pDataEvt->len - (pCh - (char*)pDataEvt->data + 1) - 2); Ql_DebugTrace("Ql_TTS_Play(), len=%d\r\n", Ql_strlen(g_buffer)); ret = Ql_TTS_Play((u8*)g_buffer, sizeof(g_buffer)); if (ret < 0) { Ql_DebugTrace("Fail to play TTS.\r\n"); break; } else { Ql_DebugTrace("Playing finished.\r\n"); } } break; } // Stop TTS (Command: stop tts) Ql_memset(g_buffer, 0x0, Ql_strlen(g_buffer)); strLen = Ql_sprintf(g_buffer, "stop tts\r\n"); ret = Ql_strncmp((char*)pDataEvt->data, g_buffer, strLen); if (0 == ret) { Ql_DebugTrace(g_buffer); Ql_TTS_Stop(); break; } // Query TTS' status (Command: tts?) Ql_memset(g_buffer, 0x0, Ql_strlen(g_buffer)); strLen = Ql_sprintf(g_buffer, "tts?\r\n"); ret = Ql_strncmp((char*)pDataEvt->data, g_buffer, strLen); if (0 == ret) { Ql_DebugTrace(g_buffer); ret = Ql_TTS_Query(); switch (ret) { case TTS_STATUS_IDLE: Ql_DebugTrace("TTS: idle\r\n"); break; case TTS_STATUS_PLAYING: Ql_DebugTrace("TTS: playing\r\n"); break; default: Ql_DebugTrace("Fail to query TTS' status. Error code: %d\r\n", ret); break; } break; } // Set volume (Command: tts vol=0..100) Ql_memset(g_buffer, 0x0, sizeof(g_buffer)); strLen = Ql_sprintf(g_buffer, "tts vol="); pChar = Ql_strstr((char*)pDataEvt->data, g_buffer); if (pChar) { u8 ttsVol; char* p1; char* p2; Ql_DebugTrace((char*)pDataEvt->data); p1 = Ql_strstr((char*)pDataEvt->data, "="); p2 = Ql_strstr((char*)pDataEvt->data, "\r\n"); Ql_memset(g_buffer, 0x0, sizeof(g_buffer)); memcpy(g_buffer, p1 + 1, p2 - p1 -1); ttsVol = Ql_atoi(g_buffer); ttsVol = (ttsVol > 100) ? 100 : ttsVol; Ql_SetVolume_Ex(VOL_TYPE_MEDIA, QL_AUDIO_PATH_HEADSET, ttsVol); break; } // Set TTS Style // Set TTS fastest voice speed Ql_memset(g_buffer, 0x0, sizeof(g_buffer)); strLen = Ql_sprintf(g_buffer, "tts Style1="); pChar = Ql_strstr((char*)pDataEvt->data, g_buffer); if (pChar) { u32 ret; ret = Ql_TTS_SetStyle(TTS_PARAM_VOICE_SPEED,TTS_SPEED_MAX); Ql_DebugTrace("Set TTS fastest voice speed.\r\n"); break; } // Set TTS minimized volume. Ql_memset(g_buffer, 0x0, sizeof(g_buffer)); strLen = Ql_sprintf(g_buffer, "tts Style2="); pChar = Ql_strstr((char*)pDataEvt->data, g_buffer); if (pChar) { u32 ret; ret = Ql_TTS_SetStyle(TTS_PARAM_VOLUME,TTS_VOLUME_MIN); Ql_DebugTrace("Set TTS minimized volume.\r\n"); break; } // Set TTS voice effect --eccentric Ql_memset(g_buffer, 0x0, sizeof(g_buffer)); strLen = Ql_sprintf(g_buffer, "tts Style3="); pChar = Ql_strstr((char*)pDataEvt->data, g_buffer); if (pChar) { u32 ret; ret = Ql_TTS_SetStyle(TTS_PARAM_VEMODE,TTS_VEMODE_ECCENTRIC); Ql_DebugTrace("Set TTS voice effect --eccentric.\r\n"); break; } } /************************************* * 'Case' another EVENT if needed. * **************************************/ default: break; } } }
void ql_entry() { bool keepGoing = TRUE; QlEventBuffer flSignalBuffer; s32 period = 10; Ql_DebugTrace("at: ql_entry\r\n"); Ql_SetDebugMode(BASIC_MODE); Ql_OpenModemPort(ql_md_port1); Ql_memset(atbuffer,0,100); //Ql_sprintf((char *)atbuffer,"AT+QLOCPU=0\n"); Ql_sprintf((char *)atbuffer,"AT+CPIN?\n"); Ql_SendToModem(ql_md_port1,atbuffer,Ql_strlen((char*)atbuffer)); while(keepGoing) { Ql_GetEvent(&flSignalBuffer); switch(flSignalBuffer.eventType) { case EVENT_TIMER: { Ql_sprintf((char *)buffer,"\r\nTimer expired\r\n"); Ql_SendToUart(ql_uart_port1, (u8*)buffer,Ql_strlen(buffer)); Ql_memset(atbuffer,0,100); Ql_sprintf((char *)atbuffer,"AT+QAUDCH=1\n"); Ql_SendToModem(ql_md_port1,atbuffer,Ql_strlen((char *)atbuffer)); //Ql_PlayAudio(QL_AUDIO_EMS_TADA,0); break; } case EVENT_MODEMDATA: { Ql_DebugTrace("\r\nEVENT_MODEMDATA type=%d \r\n",flSignalBuffer.eventData.modemdata_evt.type); if (flSignalBuffer.eventData.modemdata_evt.type==DATA_AT) { pData = (char*)flSignalBuffer.eventData.modemdata_evt.data; custom_at_handler(); } break; } case EVENT_UARTDATA: { Ql_DebugTrace("\r\nEVENT_UARTDATA PORT=%d\r\n",flSignalBuffer.eventData.uartdata_evt.port); Ql_DebugTrace("\r\nuart data =%s\r\n",flSignalBuffer.eventData.uartdata_evt.data); break; } case EVENT_SERIALSTATUS: { bool val = flSignalBuffer.eventData.portstatus_evt.val; u8 port = flSignalBuffer.eventData.portstatus_evt.port; u8 type = flSignalBuffer.eventData.portstatus_evt.type; Ql_DebugTrace("EVENT_SERIALSTATUS port=%d type=%d val=%d\r\n",port,type,val); break; } default: break; } } }
void fillBuffer(char* ctxt){ if ((__buf_command_pos+Ql_strlen(ctxt))>BUFFER_COMMAND_LEN) __buf_command_pos=0; Ql_sprintf(&__buf_command[__buf_command_pos], "%s", ctxt); __buf_command_pos+=Ql_strlen(ctxt); }
void ql_entry() { bool keepGoing = TRUE; QlEventBuffer flSignalBuffer; s32 period = 10; char buffer[100]; char *pData, *p; Ql_SetDebugMode(BASIC_MODE); Ql_DebugTrace("pwm: ql_entry\r\n"); Ql_OpenModemPort(ql_md_port1); while(keepGoing) { Ql_GetEvent(&flSignalBuffer); switch(flSignalBuffer.eventType) { case EVENT_UARTDATA: { if (flSignalBuffer.eventData.uartdata_evt.len>0) { s32 pin; s32 mod = 0; s32 pinpullenable = 0; s32 pindirection = 0; s32 pinlevel = 0; s32 iret; pData = (char*)flSignalBuffer.eventData.uartdata_evt.data; //command-->select QL_PINNAME_BUZZER pin function to mode1, it is Net light function p = Ql_strstr(pData,"1"); if (p) { iret = Ql_pinSubscribe(QL_PINNAME_BUZZER, QL_PINMODE_1, NULL); Ql_sprintf(buffer, "\r\nSubscribe(%d),pin=%d,mod=%d\r\n",iret,QL_PINNAME_BUZZER,QL_PINMODE_1); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); break; } //command-->select QL_PINNAME_BUZZER pin function to mode3, it is pwm function p = Ql_strstr(pData,"3"); if (p) { QlPinParameter pinparameter; pinparameter.pinconfigversion = QL_PIN_VERSION; pinparameter.pinparameterunion.pwmparameter.pwmsource = QL_PWMSOURCE_32K; pinparameter.pinparameterunion.pwmparameter.pwmclkdiv = QL_PWMSOURCE_DIV8; pinparameter.pinparameterunion.pwmparameter.lowpulesnumber = 4000; pinparameter.pinparameterunion.pwmparameter.highpulesnumber = 8000; iret = Ql_pinSubscribe(QL_PINNAME_BUZZER, QL_PINMODE_3, &pinparameter); Ql_sprintf(buffer, "\r\nSubscribe(%d),pin=%d,mod=%d\r\n",iret,QL_PINNAME_BUZZER,QL_PINMODE_3); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); break; } //command-->unsubscribe p = Ql_strstr(pData,"u"); if (p) { iret = Ql_pinUnSubscribe(QL_PINNAME_BUZZER); Ql_sprintf(buffer, "\r\nUnSubscribe(%d),pin=%d\r\n",iret,QL_PINNAME_BUZZER); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); break; } //command-->control start pwm p = Ql_strstr(pData,"s"); if (p) { iret = Ql_pinControl(QL_PINNAME_BUZZER, QL_PINCONTROL_START); Ql_sprintf(buffer, "\r\nStart(%d),pin=%d\r\n",iret,QL_PINNAME_BUZZER); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); break; } //command-->control stop pwm p = Ql_strstr(pData,"t"); if (p) { iret = Ql_pinControl(QL_PINNAME_BUZZER, QL_PINCONTROL_STOP); Ql_sprintf(buffer, "\r\nStop(%d),pin=%d\r\n",iret,QL_PINNAME_BUZZER); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); break; } } break; } default: break; } } }
static void CallBack_UART_Hdlr(Enum_SerialPort port, Enum_UARTEventType msg, bool level, void* customizedPara) { u32 rdLen=0; s32 ret; char *p=NULL; char *p1=NULL; char *p2=NULL; u8 write_buffer[4]={'a','b','c','D'}; u8 read_buffer[6]={0x00,0x00,0x00,0x00,0x00,0x00}; u8 registerAdrr[2]={0x01,0x45}; switch (msg) { case EVENT_UART_READY_TO_READ: { Ql_memset(m_Read_Buffer, 0x0, sizeof(m_Read_Buffer)); rdLen = Ql_UART_Read(port, m_Read_Buffer, sizeof(m_Read_Buffer)); //command-->Init the IIC , type 0 Лђеп 1. p = Ql_strstr(m_Read_Buffer,"Ql_IIC_Init="); if(p) { char* p1 = NULL; char* p2 = NULL; u8 NumberBuf[10]; s8 IIC_type=0; p1 = Ql_strstr(m_Read_Buffer, "="); p2 = Ql_strstr(m_Read_Buffer, "\r\n"); Ql_memset(NumberBuf, 0x0, sizeof(NumberBuf)); Ql_memcpy(NumberBuf, p1 + 1, p2 - p1 -1); IIC_type = Ql_atoi(NumberBuf); if(0 == IIC_type)// simultion iic test, and we choose PINNAME_GPIO4, PINNAME_GPIO5 for IIC SCL and SDA pins { ret = Ql_IIC_Init(0,PINNAME_CTS,PINNAME_RTS,0); if(ret < 0) { APP_DEBUG("\r\n<--Failed!! Ql_IIC_Init channel 0 fail ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--pins(%d & %d) Ql_IIC_Init channel 0 ret=%d-->\r\n",PINNAME_CTS,PINNAME_RTS,ret); break; } else if(1 == IIC_type)// IIC controller { ret = Ql_IIC_Init(1,PINNAME_RI,PINNAME_DCD,1); if(ret < 0) { APP_DEBUG("\r\n<--Failed!! IIC controller Ql_IIC_Init channel 1 fail ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--pins(SCL=%d,SDA=%d) IIC controller Ql_IIC_Init channel 1 ret=%d-->\r\n",PINNAME_RI,PINNAME_DCD,ret); break; } else { APP_DEBUG("\r\n<--IIC type error!!!!-->\r\n"); break; } } //command-->IIC config, IIC controller interface Ql_memset(m_buffer, 0x0, sizeof(m_buffer)); Ql_sprintf(m_buffer, "Ql_IIC_Config=0\r\n");// simultion IIC (channel 0) ret = Ql_strncmp(m_Read_Buffer, m_buffer, Ql_strlen(m_buffer)); if(0 == ret) { ret = Ql_IIC_Config(0,TRUE, 0x07, 0);// simultion IIC interface ,do not care the IicSpeed. if(ret < 0) { APP_DEBUG("\r\n<--Failed !!Ql_IIC_Config channel 0 fail ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--Ql_IIC_Config channel 0 ret=%d-->\r\n",ret); break; } //command-->IIC config, IIC controller interface Ql_memset(m_buffer, 0x0, sizeof(m_buffer)); Ql_sprintf(m_buffer, "Ql_IIC_Config=1\r\n");// IIC controller (channel 1) ret = Ql_strncmp(m_Read_Buffer, m_buffer, Ql_strlen(m_buffer)); if(0 == ret) { ret = Ql_IIC_Config(1,TRUE, 0x07, 300);// just for the IIC controller if(ret < 0) { APP_DEBUG("\r\n<--Failed !! IIC controller Ql_IIC_Config channel 1 fail ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--IIC controller Ql_IIC_Config channel 1 ret=%d-->\r\n",ret); break; } //command-->IIC write Ql_memset(m_buffer, 0x0, sizeof(m_buffer)); Ql_sprintf(m_buffer, "Ql_IIC_Write=0\r\n");// channel 0 ret = Ql_strncmp(m_Read_Buffer, m_buffer, Ql_strlen(m_buffer)); if(0 == ret) { ret = Ql_IIC_Write(0, 0x07, write_buffer, 4); if(ret < 0) { APP_DEBUG("\r\n<--Failed !! Ql_IIC_Write channel 0 fail ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--channel 0 Ql_IIC_Write ret=%d-->\r\n",ret); break; } Ql_memset(m_buffer, 0x0, sizeof(m_buffer)); Ql_sprintf(m_buffer, "Ql_IIC_Write=1\r\n");// channel 1 ret = Ql_strncmp(m_Read_Buffer, m_buffer, Ql_strlen(m_buffer)); if(0 == ret) { ret = Ql_IIC_Write(1, 0x07, write_buffer,4); if(ret < 0) { APP_DEBUG("\r\n<--Failed !! IIC controller Ql_IIC_Write channel 1 fail ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--IIC controller Ql_IIC_Write ret=%d-->\r\n",ret); break; } //command-->IIC read Ql_memset(m_buffer, 0x0, sizeof(m_buffer)); Ql_sprintf(m_buffer, "Ql_IIC_Read=0\r\n");// channel 0 ret = Ql_strncmp(m_Read_Buffer, m_buffer, Ql_strlen(m_buffer)); if(0 == ret) { ret = Ql_IIC_Read(0, 0x07, read_buffer, 6); if(ret < 0) { APP_DEBUG("\r\n<--Failed !! Ql_IIC_Read channel 0 fail ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--channel 0 Ql_IIC_Read ret=%d-->\r\n",ret); break; } Ql_memset(m_buffer, 0x0, sizeof(m_buffer)); Ql_sprintf(m_buffer, "Ql_IIC_Read=1\r\n");// channel 1 ret = Ql_strncmp(m_Read_Buffer, m_buffer, Ql_strlen(m_buffer)); if(0 == ret) { ret = Ql_IIC_Read(1, 0x07, write_buffer, 6); if(ret < 0) { APP_DEBUG("\r\n<--Failed !! IIC controller Ql_IIC_Read channel 1 fail ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--IIC controller Ql_IIC_Read ret=%d-->\r\n",ret); break; } //command-->IIC write then read Ql_memset(m_buffer, 0x0, sizeof(m_buffer)); Ql_sprintf(m_buffer, "Ql_IIC_Write_Read=0\r\n");// channel 0 ret = Ql_strncmp(m_Read_Buffer, m_buffer, Ql_strlen(m_buffer)); if(0 == ret) { ret = Ql_IIC_Write_Read(0, 0x07, registerAdrr, 2,read_buffer, 6); if(ret < 0) { APP_DEBUG("\r\n<--Failed !! Ql_IIC_Write_Read channel 0 fail ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--channel 0 Ql_IIC_Write_Read ret=%d-->\r\n",ret); break; } Ql_memset(m_buffer, 0x0, sizeof(m_buffer)); Ql_sprintf(m_buffer, "Ql_IIC_Write_Read=1\r\n");// channel 1 ret = Ql_strncmp(m_Read_Buffer, m_buffer, Ql_strlen(m_buffer)); if(0 == ret) { ret = Ql_IIC_Write_Read(1, 0x07, registerAdrr, 2,read_buffer, 6); if(ret < 0) { APP_DEBUG("\r\n<--Failed !! IIC controller Ql_IIC_Write_Read channel 1 fail ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--IIC controller Ql_IIC_Write_Read ret=%d-->\r\n",ret); break; } //command-->IIC write then read Ql_memset(m_buffer, 0x0, sizeof(m_buffer)); Ql_sprintf(m_buffer, "Ql_IIC_Uninit=0\r\n");// channel 0 ret = Ql_strncmp(m_Read_Buffer, m_buffer, Ql_strlen(m_buffer)); if(0 == ret) { ret = Ql_IIC_Uninit(0); if(ret < 0) { APP_DEBUG("\r\n<--Failed !! Ql_IIC_Uninit channel 0 fail ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--channel 0 Ql_IIC_Uninit ret=%d-->\r\n",ret); break; } Ql_memset(m_buffer, 0x0, sizeof(m_buffer)); Ql_sprintf(m_buffer, "Ql_IIC_Uninit=1\r\n");// channel 1 ret = Ql_strncmp(m_Read_Buffer, m_buffer, Ql_strlen(m_buffer)); if(0 == ret) { ret = Ql_IIC_Uninit(1); if(ret < 0) { APP_DEBUG("\r\n<--Failed !! IIC controller Ql_IIC_Uninit channel 1 fail ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--IIC controller (chnnlNo 1) Ql_IIC_Uninit ret=%d-->\r\n",ret); break; } APP_DEBUG("\r\n<--Not found this command, please check you command-->\r\n"); } default: break; } }
/****************************************************************** * Please refer to how to configure the constant * 'Customer_user_qlconfig' in ql_customer_config.c *******************************************************************/ void ql_entry() { bool keepGoing = TRUE; QlEventBuffer flSignalBuffer; s32 period = 10; char buffer[100]; char *pData, *p; QlAudioPlayPath path; Ql_SetDebugMode(BASIC_MODE); Ql_DebugTrace("headset: ql_entry\r\n"); Ql_OpenModemPort(ql_md_port1); while(keepGoing) { Ql_GetEvent(&flSignalBuffer); switch(flSignalBuffer.eventType) { case EVENT_POWERKEY: { if(flSignalBuffer.eventData.powerkey_evt.powerkey == POWERKEY_ON) { Ql_PowerOnAck(); Ql_sprintf(buffer, "\r\nNow, Power on System\r\n"); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); path = Ql_VoiceCallGetCurrentPath(); Ql_sprintf(buffer, "\r\nCurrent Voice call path is %d\r\n",path); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); Ql_VoiceCallChangePath(QL_AUDIO_PATH_LOUDSPEAKER); if(path == QL_AUDIO_PATH_NORMAL) { Ql_sprintf(buffer, "\r\nnow change to QL_AUDIO_PATH_LOUDSPEAKER\r\n"); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); } } else if(flSignalBuffer.eventData.powerkey_evt.powerkey == POWERKEY_OFF) { if( flSignalBuffer.eventData.powerkey_evt.isPressed) { Ql_sprintf(buffer, "\r\nNow, Press PWRKEY\r\n"); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); } else { Ql_sprintf(buffer, "\r\nNow, Release PWRKEY\r\n"); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); } } break; } case EVENT_HEADSET: { switch(flSignalBuffer.eventData.headset_evt.headsettype) { case HEADSET_PLUGOUT: Ql_sprintf(buffer, "\r\nHEADSET_PLUGOUT"); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); path = Ql_VoiceCallGetCurrentPath(); Ql_sprintf(buffer, "\r\nCurrent Voice call path is %d\r\n",path); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); #if 1 if(path != QL_AUDIO_PATH_LOUDSPEAKER) { Ql_sprintf(buffer, "\r\nnow change to QL_AUDIO_PATH_LOUDSPEAKER\r\n"); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); Ql_VoiceCallChangePath(QL_AUDIO_PATH_LOUDSPEAKER); } #endif break; case HEADSET_PLUGIN: Ql_sprintf(buffer, "\r\nHEADSET_PLUGIN"); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); path = Ql_VoiceCallGetCurrentPath(); Ql_sprintf(buffer, "\r\nCurrent Voice call path is %d\r\n",path); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); #if 1 if(path != QL_AUDIO_PATH_HEADSET) { Ql_sprintf(buffer, "\r\nnow change to QL_AUDIO_PATH_HEADSET\r\n"); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); Ql_VoiceCallChangePath(QL_AUDIO_PATH_HEADSET); } #endif break; case HEADSET_KEYPRESS: Ql_sprintf(buffer, "\r\nHEADSET_KEYPRESS"); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); break; case HEADSET_KEYRELEASE: Ql_sprintf(buffer, "\r\nHEADSET_KEYRELEASE"); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); break; case HEADSET_ADC: Ql_sprintf(buffer, "\r\nHEADSET_ADC:%d",flSignalBuffer.eventData.headset_evt.data1); Ql_SendToUart(ql_uart_port1,(u8*)buffer,Ql_strlen(buffer)); break; } break; } case EVENT_MODEMDATA: { //Ql_DebugTrace("\r\nEVENT_MODEMDATA type=%d \r\n",flSignalBuffer.eventData.modemdata_evt.type); //Ql_DebugTrace("\r\nmodemdata =%s\r\n",flSignalBuffer.eventData.uartdata_evt.data); //if (flSignalBuffer.eventData.modemdata_evt.type==DATA_AT) Ql_SendToUart(ql_uart_port1,(u8*)flSignalBuffer.eventData.uartdata_evt.data,flSignalBuffer.eventData.uartdata_evt.len); break; } case EVENT_UARTDATA: { //Ql_DebugTrace("\r\nEVENT_UARTDATA PORT=%d\r\n",flSignalBuffer.eventData.uartdata_evt.port); //Ql_DebugTrace("\r\nuart data =%s\r\n",flSignalBuffer.eventData.uartdata_evt.data); Ql_SendToModem(ql_md_port1,(u8*)flSignalBuffer.eventData.uartdata_evt.data,flSignalBuffer.eventData.uartdata_evt.len); break; } default: break; } } }
void queryPinStatus() { QlPinSubscribe subscribe; QlPinMode wrkMode; QlPinParameter pinParam; ST_Pin pins[10]; char notes[100]; int i; // Fill in pins Ql_sprintf(pins[0].pinName, "QL_PINNAME_KBR0"); pins[0].pinNo= QL_PINNAME_KBR0; Ql_sprintf(pins[1].pinName, "QL_PINNAME_KBR1"); pins[1].pinNo= QL_PINNAME_KBR1; Ql_sprintf(pins[2].pinName, "QL_PINNAME_KBR2"); pins[2].pinNo= QL_PINNAME_KBR2; Ql_sprintf(pins[3].pinName, "QL_PINNAME_KBR3"); pins[3].pinNo= QL_PINNAME_KBR3; Ql_sprintf(pins[4].pinName, "QL_PINNAME_KBR4"); pins[4].pinNo= QL_PINNAME_KBR4; Ql_sprintf(pins[5].pinName, "QL_PINNAME_KBC0"); pins[5].pinNo= QL_PINNAME_KBC0; Ql_sprintf(pins[6].pinName, "QL_PINNAME_KBC1"); pins[6].pinNo= QL_PINNAME_KBC1; Ql_sprintf(pins[7].pinName, "QL_PINNAME_KBC2"); pins[7].pinNo= QL_PINNAME_KBC2; Ql_sprintf(pins[8].pinName, "QL_PINNAME_KBC3"); pins[8].pinNo= QL_PINNAME_KBC3; Ql_sprintf(pins[9].pinName, "QL_PINNAME_KBC4"); pins[9].pinNo= QL_PINNAME_KBC4; // Query the status of all multifunction pins for (i = 0; i < (sizeof(pins) / sizeof(pins[0])); i++) { Ql_pinQueryMode(pins[i].pinNo, &subscribe, &wrkMode, &pinParam); Ql_sprintf(notes, "%s: subscribe:%d, pinMode:%d\r\n", pins[i].pinName, subscribe, wrkMode); Ql_SendToUart(ql_uart_port1, (u8*)notes, Ql_strlen(notes)); } }
void ql_entry(void) { bool keepGoing = TRUE; s32 ret; s32 i; char notes[50]; OUT_DEBUG(debug_buffer,"sms: ql_entry\r\n"); Ql_SetDebugMode(ADVANCE_MODE); Ql_OpenModemPort(ql_md_port1); Ql_SMS_Callback cb_func={CallBack_NewSMS,CallBack_SendSMS,CallBack_DeleteSMS, //public CallBack_ReadPDUSMS,CallBack_NewFlashPDUSMS,CallBack_PDUStatusReport, //pdu CallBack_ReadTextSMS,CallBack_NewFlashTextSMS,CallBack_TextStatusReport}; //text ret=Ql_SMSInitialize(&cb_func); OUT_DEBUG(debug_buffer,"\r\nQl_SMSInitialize=%d\r\n",ret); //OUT_DEBUG(debug_buffer,"CallBack_ReadPDUSMS=%X\r\n",CallBack_ReadPDUSMS); while(keepGoing) { Ql_GetEvent(&g_event); switch(g_event.eventType) { case EVENT_MODEMDATA: { //TODO: receive and hanle data from CORE through virtual modem port PortData_Event* pPortEvt = (PortData_Event*)&g_event.eventData.modemdata_evt; OUT_DEBUG(debug_buffer,"%s", pPortEvt->data); break; } case EVENT_UARTDATA: { char* pChar=NULL; char* pChar2=NULL; PortData_Event* pDataEvt = (PortData_Event*)&g_event.eventData.uartdata_evt; //Ql_SetSMSStorage=(0-3) Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_SetSMSStorage="); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { u8 storage; pChar+=17; storage=Ql_atoi(pChar); ret=Ql_SetSMSStorage(storage); OUT_DEBUG(debug_buffer,"\r\nQl_SetSMSStorage(storage=%d)=%d\r\n",storage,ret); break; } //Ql_GetSMSStorageInfo Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_GetSMSStorageInfo"); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { u8 current_mem,used,total; ret=Ql_GetSMSStorageInfo(¤t_mem, &used, &total); OUT_DEBUG(debug_buffer,"\r\nQl_GetSMSStorageInfo(current_mem=%d,used=%d,total=%d)=%d\r\n", current_mem,used,total,ret); break; } //Ql_SetInfoCentreNum="<sca number>" eg:Ql_SetInfoCentreNum="+8613800551500" Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_SetInfoCentreNum=\""); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { pChar+=21; pChar2 = Ql_strstr(pChar,"\""); *pChar2=0; ret=Ql_SetInfoCentreNum((u8*)pChar); OUT_DEBUG(debug_buffer,"\r\nQl_SetInfoCentreNum(sca_num=%s)=%d\r\n", pChar,ret); break; } //Ql_GetInfoCentreNum Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_GetInfoCentreNum"); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { u8 sca_number[40]; u8 type; ret=Ql_GetInfoCentreNum(sca_number,&type); OUT_DEBUG(debug_buffer,"\r\nQl_GetInfoCentreNum(sca_number=\"%s\",type=%d)=%d\r\n", sca_number,type,ret); break; } //Ql_SetNewSMSDirectToTE=(0,1) Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_SetNewSMSDirectToTE="); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { u8 op; pChar+=23; op=Ql_atoi(pChar); ret=Ql_SetNewSMSDirectToTE(op); OUT_DEBUG(debug_buffer,"\r\nQl_SetNewSMSDirectToTE(op=%d)=%d\r\n",op,ret); break; } //Ql_SetSMSFormat=(0,1) Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_SetSMSFormat="); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { u8 format; pChar+=16; format=Ql_atoi(pChar); ret=Ql_SetSMSFormat(format); OUT_DEBUG(debug_buffer,"\r\nQl_SetSMSFormat(format=%d)=%d\r\n",format,ret); break; } //Ql_ReadSMS=(1,300),(0,1) Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_ReadSMS="); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { u16 index; u8 mode; pChar+=11; index=Ql_atoi(pChar); pChar=Ql_strstr(pChar, ","); pChar++; mode=Ql_atoi(pChar); ret=Ql_ReadSMS(index,mode); OUT_DEBUG(debug_buffer,"\r\nQl_ReadSMS(index=%d,mode=%d)=%d\r\n",index,mode,ret); break; } //Ql_DeleteSMS=(1,300),(0,4) Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_DeleteSMS="); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { u16 index; u8 flag; pChar+=13; index=Ql_atoi(pChar); pChar=Ql_strstr(pChar, ","); pChar++; flag=Ql_atoi(pChar); ret=Ql_DeleteSMS(index,flag); OUT_DEBUG(debug_buffer,"\r\nQl_DeleteSMS(index=%d,flag=%d)=%d\r\n",index,flag,ret); break; } //Ql_ListSMS=(0,4) Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_ListSMS="); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { u8 by_status; u16 sms_count=0; QlSMSListNode sms_list[MAX_LIST_NODE_COUNT]; //MAX_LIST_NODE_COUNT should be set large enough pChar+=11; by_status=Ql_atoi(pChar); ret=Ql_ListSMS(sms_list, MAX_LIST_NODE_COUNT, by_status, &sms_count); OUT_DEBUG(debug_buffer,"\r\nQl_ListSMS(by_status=%d,node_count=%d,sms_count=%d)=%d\r\n", by_status,MAX_LIST_NODE_COUNT,sms_count,ret); if(0==ret) { for(i=0;i<sms_count;i++) { OUT_DEBUG(debug_buffer,"index=%d,status=%d\r\n",sms_list[i].index,sms_list[i].status); } } break; } //Ql_GetUnReadSMS=(0,1) Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_GetUnReadSMS="); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { u8 mode; pChar+=16; mode=Ql_atoi(pChar); ret=Ql_GetUnReadSMS(mode); OUT_DEBUG(debug_buffer,"\r\nQl_GetUnReadSMS(mode=%d)=%d\r\n",mode,ret); break; } //Ql_SendPDUSMS Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_SendPDUSMS"); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { u8 pdu_len; u8 pdu_string[]={0x00, //Set aside for SCA 0x31, //FO 0xff, //Set aside for MR /* 0x05, //DA Length 0x81, //DA type 0x01, 0x80, 0xf6, //DA:10086 */ 0x0b, //DA Length 0x81, //DA type 0x31, 0x58, 0x15, 0x64, 0x79, 0xf3, //DA:13855146973 0x00, //PID 0x00, //DCS 0x47, //VP 0x07, //UDH 0xd1, 0x7a, 0x79, 0x4c, 0x2f, 0xb3, 0x01 //UD:Quectel, GSM 7-bit coding }; pdu_len=sizeof(pdu_string); ret=Ql_SendPDUSMS(pdu_string,pdu_len); OUT_DEBUG(debug_buffer,"\r\nQl_SendPDUSMS(pdu_len=%d)=%d\r\n",pdu_len,ret); if(0==ret) { for(i=0;i<pdu_len;i++) { OUT_DEBUG(debug_buffer,"%02X",pdu_string[i]); } OUT_DEBUG(debug_buffer,"\r\n"); } break; } //Ql_SetTextSMSPara=(0-2),(0,1),(0,1) Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_SetTextSMSPara="); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { u8 chset,isflashsms,status_report; pChar+=18; chset=Ql_atoi(pChar); pChar=Ql_strstr(pChar, ","); pChar++; isflashsms=Ql_atoi(pChar); pChar=Ql_strstr(pChar, ","); pChar++; status_report=Ql_atoi(pChar); ret=Ql_SetTextSMSPara(chset, isflashsms, status_report); OUT_DEBUG(debug_buffer, "\r\nQl_SetTextSMSPara(chset=%d,isflashsms=%d,status_report=%d)=%d\r\n",chset,isflashsms,status_report,ret); break; } //Ql_SendTextSMS="<phone number>" Ql_memset(notes, 0x0, sizeof(notes)); Ql_sprintf(notes, "Ql_SendTextSMS=\""); pChar = Ql_strstr((char*)pDataEvt->data, notes); if (NULL != pChar) { pChar+=16; pChar2 = Ql_strstr(pChar,"\""); *pChar2=0; ret=Ql_SendTextSMS((u8*)pChar,(u8*)"Welcome to use Quectel module!", Ql_strlen((u8*)"Welcome to use Quectel module!")); OUT_DEBUG(debug_buffer, "\r\nQl_SendTextSMS(phone_num=\"%s\")=%d\r\n",pChar,ret); break; } Ql_SendToModem(ql_md_port1, (u8*)pDataEvt->data, pDataEvt->len); break; } default: break; } } }
static void proc_handle(char *pData,s32 len) { char *p = NULL; char parambuf[100]; //command: Reset=<type> p = Ql_strstr(pData,"Reset="); if (p) { Ql_memset(parambuf, 0, 100); if (Analyse_Command(pData, 1, '>', parambuf)) { APP_DEBUG("<--Parameter Error.-->\r\n"); return; } if (Ql_atoi(parambuf) != 0)//must be 0 { APP_DEBUG("<--Parameter Error.-->\r\n"); return; } APP_DEBUG("<--Set Reset Parameter Successfully<%d>.-->\r\n",Ql_atoi(parambuf)); Ql_Sleep(100); Ql_Reset(Ql_atoi(parambuf)); return; } //command: Sleep=<msec> p = Ql_strstr(pData,"Sleep="); if (p) { s32 ret; ST_Time time,*tm; Ql_memset(parambuf, 0, 100); if (Analyse_Command(pData, 1, '>', parambuf)) { APP_DEBUG("<--Parameter Error.-->\r\n"); return; } APP_DEBUG("<--Set Sleep Parameter Successfully<%d>.-->\r\n",Ql_atoi(parambuf)); APP_DEBUG("<--Start sleeping-->\r\n"); Ql_Sleep(Ql_atoi(parambuf)); APP_DEBUG("<--sleeping over-->\r\n"); return; } //command: Read Module UID p = Ql_strstr(pData,"Read Module UID"); if (p) { s32 i, uidLen; u8 moduleUID[100]; u8 tmpbuf[100]; Ql_memset(moduleUID, 0, sizeof(moduleUID)); Ql_memset(tmpbuf, 0, sizeof(tmpbuf)); uidLen = Ql_GetUID(moduleUID, sizeof(moduleUID)); for (i = 0; i < uidLen; i++) { Ql_sprintf(tmpbuf + i*2, "%02X", moduleUID[i]); } APP_DEBUG("<--Module UID=0x%s,len=%d-->\r\n", tmpbuf, uidLen); return; } //command: Get Core Version p = Ql_strstr(pData,"Get Core Version"); if (p) { s32 ret; u8 tmpbuf[100]; Ql_memset(tmpbuf, 0, sizeof(tmpbuf)); ret = Ql_GetCoreVer((u8*)tmpbuf, sizeof(tmpbuf)); if(ret > 0) { APP_DEBUG("<--Core Version:%s-->\r\n", tmpbuf); } else { APP_DEBUG("<--Get Core Version Failure.-->\r\n"); } return; } //command: Get SDK Version p = Ql_strstr(pData,"Get SDK Version"); if (p) { s32 ret; u8 tmpbuf[100]; Ql_memset(tmpbuf, 0, sizeof(tmpbuf)); ret = Ql_GetSDKVer((u8*)tmpbuf, sizeof(tmpbuf)); if(ret > 0) { APP_DEBUG("<--SDK Version:%s.-->\r\n", tmpbuf); } else { APP_DEBUG("<--Get SDK Version Failure.-->\r\n"); } return; } //command: Get Ms Since PwrOn p = Ql_strstr(pData,"Get Ms Since PwrOn"); if (p) { u64 totalMS; totalMS = Ql_GetMsSincePwrOn(); APP_DEBUG("<--Get Ms Since PwrOn:=%lld.-->\r\n", totalMS); return; } //command: Ql_SleepEnable set the module into sleep mod p= Ql_strstr(pData,"Ql_SleepEnable"); if(p) { s32 ret; APP_DEBUG("<-- Ql_SleepEnable=%d -->\r\n", ret); ret = Ql_SleepEnable(); return; } // p= Ql_strstr(pData,"Ql_SleepDisable"); if(p) { s32 ret; APP_DEBUG("<-- Ql_SleepDisable=%d -->\r\n", ret); ret = Ql_SleepDisable(); return; } //command:Ql_SecureData_Store=<n> , n=1~13. p= Ql_strstr(pData,"Ql_SecureData_Store="); if(p) { s32 ret; u8 index; Ql_memset(parambuf, 0, 100); if (Analyse_Command(pData, 1, '>', parambuf)) { APP_DEBUG("<--Parameter Error.-->\r\n"); return; } index = Ql_atoi(parambuf); if(index <1 || index >13) { APP_DEBUG("<--Parameter n Error.-->\r\n"); return; } ret = Ql_SecureData_Store(index, (u8*)&test,sizeof(test)); APP_DEBUG("<-- Ql_SecureData_Store(index=%d, value=%d, data size=%d)=%d -->\r\n", index,test.reset.Period,sizeof(Global_SYS_Cfg),ret); return; } //command:Ql_SecureData_Read=<n> , n=1~13. p= Ql_strstr(pData,"Ql_SecureData_Read="); if(p) { s32 ret; u8 index; Ql_memset(parambuf, 0, 100); if (Analyse_Command(pData, 1, '>', parambuf)) { APP_DEBUG("<--Parameter Error.-->\r\n"); return; } index = Ql_atoi(parambuf); if(index <1 || index >13) { APP_DEBUG("<--Parameter n Error.-->\r\n"); return; } ret = Ql_SecureData_Read(index, (u8*)&tempTest,sizeof(Global_SYS_Cfg)); APP_DEBUG("<-- Ql_SecureData_Read =%d \r\n test.version:%s test.data=%s test.reset.timeDelay =%d-->\r\n",ret, tempTest.version,tempTest.data,tempTest.reset.timeDelay); return; } return; }
void get_rebot_page(void){ Ql_sprintf(__data_buf,__reboot_page,__str_loc_ip_addr); }
void page_response(HttpHeader *header){ bool reset=FALSE; bool prepare=TRUE; char* action=header->action; OUTD("action=%s",action); Ql_memset(__data_buf,0,4096); Ql_memset(__s_buf,0,10240); if (Ql_strstr(header->action, "/")) { get_main_page( __est_connection ? "System state is start":"System state stop"); OUTD("main page",NULL); } else if (Ql_strstr(action,"reboot")) { get_rebot_page(); reset=TRUE; } else if (Ql_strstr(action,"settings?")) { char* pch=NULL; char* last=NULL; //OUTD("parse setting action:%s",pch); pch=strtok_r(action+9,"&",&last); //OUTD("parse command:%s",pch); while (pch!=NULL) { setCommand(pch); pch=strtok_r(NULL,"&",&last); //OUTD("parse command:%s",pch); } WriteSettings(); ReadSettings(); get_main_page("Save settings controller is OK"); } else if (Ql_strstr(action,"date?")) { bool sdt=SetLocDate(action+5); get_main_page(sdt ? "Set date and time is OK":"Error set date and time"); } else if (Ql_strstr(action,"stop")) { StopEstConnection(); get_main_page("Recive command Stop"); } else if (Ql_strstr(action,"run")) { nSTATE=STATE_EST_SOCKET_CREATE; get_main_page("Recive command Start"); } else if (Ql_strstr(action,"log")) { u16 size=0; ReadLogFile(&size); Ql_sprintf(__s_buf,__download_page,size); //Ql_strcpy(&__s_buf[Ql_strlen(__s_buf)],__buf_log); Ql_memcpy(&__s_buf[Ql_strlen(__s_buf)],__buf_log,size); OUTD("__download_page:%d file size:%d buffer-len:%d",Ql_strlen(__download_page),size,Ql_strlen(__s_buf)); prepare=FALSE; } else if (Ql_strstr(action, "autorize")) { Ql_sprintf(__s_buf,__autorize,0); prepare=FALSE; OUTD("set autorize",NULL); } else { get_error_page(); Ql_sprintf(__s_buf,__error_page,0); prepare=FALSE; } if (prepare) { //if (header->set_cookie) { // Ql_sprintf(__s_buf, __ok_page, Ql_strlen(__data_buf),"\r\nSet-Cookie: __ztp=987654321\r\n"); //} Ql_sprintf(__s_buf, __ok_page, Ql_strlen(__data_buf)); Ql_strcpy(&__s_buf[Ql_strlen(__s_buf)],__data_buf); OUTD("sbuf:%d dbuf:%d",Ql_strlen(__s_buf),Ql_strlen(__data_buf)); } if (reset) { Ql_Sleep(10000); Ql_Reset(0); } }