Пример #1
0
INT32 APP_StandBy(void)
{
	UINT32 key;
	INT wakeup = 0;
	
	GUI_DisplayMessage(0, GUI_STR_STANDBY, NULL, GUI_MSG_FLAG_WAIT);
	
	if(AP_Support_LCD())
	{
		GUI_ClearScreen(NULL);//清全屏幕
		GUI_UpdateScreen(NULL);
		CloseBacklight();
	}
	ui_auto_update = FALSE;
	
	//APP_Sleep();
#ifdef XDL_35uA_POWEROFF//warkey 2.1  //进入超低电流关机
	rfd_XcvRegForceWrite32k();
#endif
	while(1)
	{
		key = MESSAGE_Wait();
		if(key == AP_MSG_RTC && GetBattery() >= 0)
		{
			if(tgt_GetKeyCode(0) == KEY_POWER)
			{
				app_trace(APP_MAIN_TRC, "APP_StandBy call DM_DeviceSwithOff");
				DM_DeviceSwithOff();
			}
			else // 如果power键长高,无法关机,进入睡眠
			{
				app_trace(APP_MAIN_TRC, "APP_StandBy call APP_Sleep");
				APP_Sleep();
			}
			continue;
		}
		if(key == (AP_KEY_POWER | AP_KEY_PRESS))
		{
			wakeup = 1;
		}
		if(key == (AP_KEY_PLAY | AP_KEY_HOLD))
			if(MESSAGE_IsHold())
			{
				wakeup = 1;
			}
		if((key & 0xffff) == AP_KEY_UP && wakeup)
		{
			key = RESULT_POWERON;
			break;
		}
		if(key == AP_MSG_ALARM)
		{
			key = RESULT_ALARM;
			break;
		}
	}
	APP_Wakeup();
	return key;
}
Пример #2
0
INT8 TM_GetDateAndTime(date_t *date, ap_time_t *time)
{
	TM_SYSTEMTIME systemTime;
	memset(&systemTime, 0, sizeof(TM_SYSTEMTIME));
	
	if (TM_GetSystemTime(&systemTime))
	{
		if(date != NULL)
		{
			date->year = systemTime.uYear;
			date->month = systemTime.uMonth;
			date->day  = systemTime.uDay;
		}
		if(time != NULL)
		{
			time->hour  = systemTime.uHour;
			time->minute = systemTime.uMinute;
			time->second = systemTime.uSecond;
		}
		//app_trace(APP_MAIN_TRC,"uHour:%d,uMinute:%d,uSecond:%d,uDayOfWeek:%d.",systemTime.uHour,systemTime.uMinute,systemTime.uSecond,systemTime.uDayOfWeek);
		return 0;
	}
	app_trace(APP_MAIN_TRC, "Fatal Error : TM_GetDateAndTime, Return -1!");
	return -1;
}
Пример #3
0
int app_destroy()
{
	app_trace(TRACE_INFO, "App. Destroing application");

	app_cfgDestroy();

	return 0;
}
Пример #4
0
int fax_sessionDestroy(session_t *session)
{
    app_trace(TRACE_INFO, "Session %04x. Destroy FAX", session->ses_id);

    fax_releaseGW(&session->fax_params);
    fax_paramsDestroy(&session->fax_params);

    return 0;
}
Пример #5
0
void sigint_handler(int sig) {
    if(sig == SIGINT ||
       sig == SIGHUP ||
       sig == SIGTERM)
    {
        app_trace(TRACE_INFO, "App. Signal %d received", sig);
        app_run = 0;
    }
}
Пример #6
0
/********************************************************************************
* Description : Get the selected location
*
* Arguments  :
*            location:    the buffer to store location
* Returns     :
*            TRUE: Successful
*            FALSE: Fail, detail information in fselError.
* Notes       :  None
*
********************************************************************************/
BOOL fselGetLocationC(file_location_t  *location)
{
#ifdef APP_SUPPORT_PLAYLIST
	UINT8     i;
	INT32    lEntry;
	location->disk = fselDiskLetter;
	
	for(i = 0; i < TOTALDIRLAYER; i++)
	{
		location->DirNo[i] = fselDirNo[i];
	}
	
	FS_GetCurDirEntry(&location->file_entry);
	
	location->dirLayer  = fselDirLayer;
	
	if (fselFileNo != 0 )
	{
		fselGetByNO(&lEntry, fselFileNo);
		if ( ERR_SUCCESS != FS_GetShortName(lEntry, location->file_name) )
		{
			location->file_name[0] = 0x00;
			location->dirLayer     = 0;
			return FALSE;
		}
	}
	else
	{
		location->file_name[0] = 0x00;
	}
	
	// 只有在fselDirNo[0] == 0时,当前目录是根目录.
	if ( fselDirLayer > (TOTALDIRLAYER - 1) || fselDirNo[0] == 0)
	{
		m_szTemp[0]  = FS_CD_ROOT;
		fselDirNo[0] = 0;
		fselDirLayer = 0;
	}
	else
	{
		FS_ChangeDir(FS_CD_PARENT);
		ToDirEntry(m_szTemp, fselDirNo[fselDirLayer]);
	}
	FS_ChangeDir(m_szTemp);
	FS_SetCurDirEntry(location->file_entry);
#else
	FS_GetCurDirEntry(&location->file_entry);
	FS_GetShortName(location->file_entry, location->file_name);
	FS_GetSubDirEntry(&location->subdir_entry);
	FS_GetShortName(location->subdir_entry, location->subdir_name);
	
	app_trace(APP_MAIN_TRC, "Select dir %s, file %s", location->subdir_name, location->file_name);
#endif
	return TRUE;
	
}
Пример #7
0
int app_init()
{
	int res = 0;
	int ret_val = 0;

	app_trace(TRACE_INFO, "App. Initializing application");

	signal(SIGINT, &sigint_handler);

	res = app_cfgInit();
	if(res)
	{
		app_trace(TRACE_INFO, "App. Failed to init config (%d)", res);
		ret_val = -1; goto _exit;
	}

_exit:
	return ret_val;
}
Пример #8
0
static void fax_spandspLog(int level, const char *msg)
{
	switch (level) {
		case SPAN_LOG_NONE:
			return;
		case SPAN_LOG_ERROR:
		case SPAN_LOG_PROTOCOL_ERROR:
			if(msg) app_trace(TRACE_INFO, "SPANDSP_LOG %s", msg);
			break;
		case SPAN_LOG_WARNING:
		case SPAN_LOG_PROTOCOL_WARNING:
			if(msg) app_trace(TRACE_INFO, "SPANDSP_LOG %s", msg);
			break;
		case SPAN_LOG_FLOW:
		case SPAN_LOG_FLOW_2:
		case SPAN_LOG_FLOW_3:
		default:	/* SPAN_LOG_DEBUG, SPAN_LOG_DEBUG_2, SPAN_LOG_DEBUG_3 */
			if(msg) app_trace(TRACE_INFO, "SPANDSP_LOG %s", msg);
			break;
	}
}
Пример #9
0
static int app_InitControlFD()
{
    int ret_val = 0;
    int res;
    session_t *session = NULL;
    cfg_t *cfg = app_getCfg();

    app_trace(TRACE_INFO, "App. Create control session: %s:%u",
              ip2str(cfg->local_ip, 0), cfg->local_port);

    session = session_create(FAX_SESSION_MODE_CTRL, FAX_CTRL_FD_IDX,
                             FAX_SESSION_DIR_IN);

    if(!session)
    {
        app_trace(TRACE_ERR, "App. Control session creating failed");
        ret_val = -1; goto _exit;
    }

    res = session_initCtrl(session);
    if(res)
    {
        app_trace(TRACE_ERR, "App. Control session init failed (%d)",
                  res);
        session_destroy(session);
        ret_val = -2; goto _exit;
    }

    cfg->pfds[FAX_CTRL_FD_IDX].fd = session->fds;
    cfg->pfds[FAX_CTRL_FD_IDX].events = POLLIN;
    cfg->session[FAX_CTRL_FD_IDX] = session;

    cfg->session_cnt = 1;

    app_trace(TRACE_INFO, "App. Control session created: Session %04x fd = %d",
              session->ses_id, session->fds);

_exit:
    return ret_val;
}
Пример #10
0
static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data,
								 const uint8_t *buf, int len, int count)
{
	fax_params_t *f_params;
	session_t *session;
	uint8_t pkt[LOCAL_FAX_MAX_DATAGRAM];
	int udptl_packtlen;
	int x;
	int ret_val = 0;
	int res = 0;

	(void)s;

	f_params = (fax_params_t *)user_data;
	session = f_params->session;

	if((udptl_packtlen = udptl_build_packet(f_params->pvt.udptl_state,
						pkt, buf, len)) > 0)
	{
		for(x = 0; x < count; x++)
		{
			res = f_params->send_cb(session, pkt, udptl_packtlen);

			if(res < 0)
			{
				app_trace(TRACE_ERR,"Fax %04x. send() failed (%d) %s",
						  session->ses_id, res,
						  res == -1 ? strerror(errno) : "");
				ret_val = -1;
				break;
			}
		}
	} else {
		app_trace(TRACE_ERR, "Fax %04x. Invalid UDPTL packet len: %d"
				  " PASSED: %d:%d", session->ses_id, udptl_packtlen,
				  len, count);
	}

	return ret_val;
}
Пример #11
0
static int app_cfgInit()
{
	int ret_val = 0, res;
	cfg_t *cfg = app_getCfg();

	app_trace(TRACE_INFO, "App. Init cfg");

	cfg->local_ip = app_getLocalIP(NET_IFACE);
	cfg->local_port = FAX_CONTROL_PORT;

	cfg->pfds = calloc(FAX_MAX_SESSIONS, sizeof(*(cfg->pfds)));
	if(!cfg->pfds)
	{
		app_trace(TRACE_ERR, "App. Memory allocation for file"
				  " descriptors failed");
		ret_val = -1; goto _exit;
	}

	cfg->session = calloc(FAX_MAX_SESSIONS, sizeof(*(cfg->session)));
	if(!cfg->session)
	{
		app_trace(TRACE_ERR, "App. Memory allocation for sessions failed");
		free(cfg->pfds);
		ret_val = -2; goto _exit;
	}

	res = app_InitControlFD();
	if(res)
	{
		app_trace(TRACE_ERR, "App. Creating of control fd failed (%d)",
				  res);
		free(cfg->pfds);
		free(cfg->session);
		ret_val = -3; goto _exit;
	}

_exit:
	return ret_val;
}
Пример #12
0
int main(int argc, char *argv[])
{
    (void)argc;
    (void)argv;
    int res;
    int ret_val = 0;

    app_trace(TRACE_INFO, " << FAX HANDLING APPLICATION BU!!! >>");

    res = app_init();
    if(res)
    {
        app_trace(TRACE_ERR, "App init failed (%d)", res);
        ret_val = -1; goto _exit;
    }

    app_start();

    app_destroy();

_exit:
    return ret_val;
}
Пример #13
0
void app_cfgDestroy()
{
	cfg_t *cfg = app_getCfg();
	int i;

	app_trace(TRACE_INFO, "App. Destroy cfg");

	for(i = 0; i < cfg->session_cnt; i++)
	{
		session_destroy(cfg->session[i]);
		cfg->session[i] = NULL;
		cfg->pfds[i].fd = -1;
	}

	free(cfg->pfds);
	free(cfg->session);
}
Пример #14
0
static int fax_releaseGW(fax_params_t *f_params)
{
	session_t *session = f_params->session;

	app_trace(TRACE_INFO, "Fax %04x. Release T.38-fax gateway", session->ses_id);

	if(f_params->pvt.t38_gw_state)
	{
		t38_gateway_release(f_params->pvt.t38_gw_state);
	}

	if(f_params->pvt.udptl_state)
	{
		udptl_release(f_params->pvt.udptl_state);
	}

	return 0;
}
Пример #15
0
int fax_sessionInit(session_t *session, t38_send_callback *send_cb)
{
    int ret_val = 0;
    fax_params_t *fax_params = &session->fax_params;

    app_trace(TRACE_INFO, "Session %04x. Init FAX", session->ses_id);

    fax_params->session = session;
    fax_params->send_cb = send_cb;

    fax_paramsInit(fax_params);
    fax_paramsSetDefault(fax_params);

    ret_val = fax_initGW(fax_params);

    if(!ret_val) configure_t38(fax_params);

    return ret_val;
}
Пример #16
0
int app_start()
{
	cfg_t *cfg = app_getCfg();
	int poll_res;

	app_trace(TRACE_INFO, "App. Starting application");

	while(app_run)
	{
		poll_res = poll(cfg->pfds, cfg->session_cnt, POLL_TIMEOUT);

		app_procSessions();

		if(poll_res > 0)
		{
			app_procCMD();
		}
	}

	return 0;
}
Пример #17
0
int fax_rxUDPTL(const session_t *session, const uint8_t *buf, int len)
{
    int ret_val = 0;
    int res = 0;

    if(!session || !buf)
    {
        ret_val = -1; goto _exit;
    }

    res = udptl_rx_packet(session->fax_params.pvt.udptl_state,
                          buf, len);
    if(res)
    {
        app_trace(TRACE_ERR, "Fax %04x. UDPTL RX failed (%d)",
                  session->ses_id, res);
        ret_val = -2;
    }

_exit:
    return ret_val;
}
Пример #18
0
int fax_rxAUDIO(const session_t *session, const uint8_t *buf, int len)
{
    int ret_val = 0;
    int res = 0;

    if(!session || !buf)
    {
        ret_val = -1; goto _exit;
    }

    res = t38_gateway_rx(session->fax_params.pvt.t38_gw_state,
                         (int16_t *)buf, len / 2);
    if(res)
    {
        app_trace(TRACE_ERR, "Fax %04x. AUDIO RX failed (%d)",
                  session->ses_id, res);
        ret_val = -2;
    }

_exit:
    return ret_val;
}
Пример #19
0
int fax_txAUDIO(const session_t *session, const uint8_t *buf, int *len)
{
    int ret_val = 0;
    int res = 0;

    if(!session || !buf)
    {
        ret_val = -1; goto _exit;
    }

    res = t38_gateway_tx(session->fax_params.pvt.t38_gw_state,
                         (int16_t *)buf, FRAMES_PER_CHUNK);
    if(res < 0)
    {
        app_trace(TRACE_ERR, "Fax %04x. AUDIO TX failed (%d)",
                  session->ses_id, res);
        ret_val = -2;
    }

    *len = res * 2;

_exit:
    return ret_val;
}
Пример #20
0
TASK_ENTRY BAL_MainTaskEntry(void *pData)
{
	INT8   IsUDisk = 0;
	BOOL   need_draw = TRUE;
	INT32  active = 0;   //当前活动的项目
	INT32  result = APP_DEFAULT_RESULT;
	INT32  ret    = RESULT_NULL;
	INT32  bt_active_ret = RESULT_NULL;
	TM_SYSTEMTIME systime;
	extern BOOL g_usb_connected;
	
	// dump version and date
	//hal_HstSendEvent(SYS_EVENT,0x11223344);
	//hal_HstSendEvent(SYS_EVENT,GetPlatformVersion());
	//hal_HstSendEvent(SYS_EVENT,GetPlatformRevision());
	//hal_HstSendEvent(SYS_EVENT,GetPlatformBuildDate());
	//hal_HstSendEvent(SYS_EVENT,AP_GetVersion());
	//hal_HstSendEvent(SYS_EVENT,AP_GetBuildDate());
	
	APP_ReadComPara();	//读取系统的全局变量。可以放在os初始化的过程中做
#if XDL_APP_SUPPORT_LOWBAT_DETECT==1//warkey 2.1
	StartBatTimer();
#endif
	gui_load_resource(g_comval->langid);
	
	LED_SetPattern(GUI_LED_POWERON, 1);
	
#if APP_SUPPORT_LCD==1
	if(AP_Support_LCD())
	{
		lcdd_Open();
		GUI_Initialise(g_displayconfig.lcd_width, g_displayconfig.lcd_heigth);
		GUI_SetTextColor(g_displayconfig.font_color);
		GUI_SetBackColor(g_displayconfig.back_color);
	}
#endif
	
	if(g_test_mode)
	{
		NVRAMWriteData();
		APP_Test_Mode();
	}
	
	APP_DisplaySysLogo(FALSE);
	AP_GetBuildDate();//force link date time functions.
	
	// check systemtime
	TM_GetSystemTime(&systime);
	if(systime.uHour >= 24 || systime.uDay == 0 || systime.uYear > 2050) // invalid date time
	{
		systime.uYear = 2012;
		systime.uMonth = 8;
		systime.uDay = 15;
		systime.uHour = 12;
		systime.uMinute = 30;
		TM_SetSystemTime(&systime);
	}
#if APP_SUPPORT_LCD==1
	TIMER_SetAlarm(1);
#endif
	
	hal_HstSendEvent(SYS_EVENT, 0x09250001);
	
	APP_InitialFunPtr(); //初始化各个模块的回调函数,最后通过宏定义来实现开关
	
	APP_Read_Sys_Config();
	LED_SetPattern(GUI_LED_NONE, 1);
	
	hal_HstSendEvent(BOOT_EVENT, 0x09558000);
	
#if APP_SUPPORT_LCD==0  //added for T_card update without LCD. Search TF card, if there is a file with the name "tflash_update.bin", then do the update.
#ifdef MCD_TFCARD_SUPPORT
	{
		INT32 file = -1, card_ok = -1;
		UINT32 cur_data = AP_GetBuildDate();
		UINT32 cur_time = AP_GetBuildTime();
		boolean needupdate = FALSE;
		
		hal_HstSendEvent(BOOT_EVENT, 0x98880001);
		hal_HstSendEvent(BOOT_EVENT, cur_data);
		hal_HstSendEvent(BOOT_EVENT, cur_time);
		hal_HstSendEvent(BOOT_EVENT, 0x98880001);
		
		
		card_ok = FS_MountDevice(FS_DEV_TYPE_TFLASH);
		hal_HstSendEvent(BOOT_EVENT, card_ok);
		if(card_ok == ERR_SUCCESS)
		{
			FS_FILE_ATTR file_attr;
			TM_FILETIME sFileTime;
			TM_SYSTEMTIME sSysTm;
			UINT32 bin_createDate = 0;
			UINT32 bin_createTime = 0;
			UINT32 offset = 0;
			
			file = FS_Open(UPDATE_TFLASH_BIN_NAME, FS_O_RDWR, 0);
			
			hal_HstSendEvent(BOOT_EVENT, 0x09550000);
			hal_HstSendEvent(BOOT_EVENT, file);
			hal_HstSendEvent(BOOT_EVENT, 0x09550000);
			
#if 1
			FS_Seek(file, 0xc, FS_SEEK_SET);
			FS_Read(file, &offset, 4);
			FS_Seek(file, ((offset & 0x00ffffff)) - 0x10, FS_SEEK_SET);
			FS_Read(file, &bin_createDate, 4);
			FS_Read(file, &bin_createTime, 4);
			
			hal_HstSendEvent(BOOT_EVENT, 0x98880002);
			hal_HstSendEvent(BOOT_EVENT, bin_createDate);
			hal_HstSendEvent(BOOT_EVENT, bin_createTime);
			hal_HstSendEvent(BOOT_EVENT, 0x98880002);
#else
			if(FS_GetFileAttrByHandle(file, &file_attr) == 0)
			{
				sFileTime.DateTime = file_attr.i_mtime;
			
				TM_FileTimeToSystemTime(sFileTime, &sSysTm);
				bin_createDate = ((sSysTm.uYear) * 10000 + ((sSysTm.uMonth) * 100) + sSysTm.uDay);
				bin_createTime = sSysTm.uHour * 10000 + sSysTm.uMinute * 100 + sSysTm.uSecond;
			
				hal_HstSendEvent(BOOT_EVENT, 0x98880002);
				hal_HstSendEvent(BOOT_EVENT, bin_createDate);
				hal_HstSendEvent(BOOT_EVENT, bin_createTime);
				hal_HstSendEvent(BOOT_EVENT, 0x98880002);
			}
#endif
			
			//if((cur_data<bin_createDate) ||
			//(cur_data==bin_createDate && cur_time<bin_createTime))
			if((cur_data != bin_createDate) || (cur_time != bin_createTime)) //只要不是同一软件就允许升级
			{
				needupdate = TRUE;
			}
			
			hal_HstSendEvent(BOOT_EVENT, needupdate);
			hal_HstSendEvent(BOOT_EVENT, 0x98880008);
			
			if(file >= 0 && needupdate)
			{
				Upgrade_Flash(file);
				
				RestartSystem();
			}
			else
			{
				FS_Close(file);
			}
		}
	}
#endif
#endif
	
	
	g_last_reslt = result;
	if(GetUsbCableStatus())
	{
		hal_HstSendEvent(APP_EVENT, 0x13113001);
		result = RESULT_UDISK;
	}
	if(gpio_detect_linein() == GPIO_DETECTED)
	{
		hal_HstSendEvent(APP_EVENT, 0x13113002);
		result = RESULT_LINE_IN;
	}
	//    IsUDisk = g_comval->Onlinedev;
	
#ifdef SUPPORT_POWERON_ENTER_CHARGE_AP//warkey 2.1 
	app_trace(APP_MAIN_TRC, "GetBattery:%d", GetBattery());
	if(-1 == GetBattery() && g_usb_connected == 0)
	{
		//                  hal_HstSendEvent(SYS_EVENT, 0x13062707);
		hal_HstSendEvent(APP_EVENT, 0x13113003);
		result = Charging_Entry();
	}
#endif
	while(1)
	{
		if(result==RESULT_STANDBY)
		{
			LED_SetPattern(GUI_LED_NONE, 0xde);
		}
		else
		{
			LED_SetPattern(GUI_LED_NONE, 1);
		}
		
		hal_HstSendEvent(SYS_EVENT, 0x09250002);
		hal_HstSendEvent(SYS_EVENT, result);
		
		if(result == RESULT_NULL || result == RESULT_MAIN)
		{
#if APP_SUPPORT_MENU==1
			if(AP_Support_MENU())
			{
				ui_auto_select = FALSE;
				result = GUI_Display_Menu(GUI_MENU_MAIN, main_menu_callback);
				
				g_last_reslt        = RESULT_NULL;
				if(result == RESULT_TIMEOUT || result == RESULT_IGNORE || result == RESULT_NULL)
				{
					result = RESULT_IDLE; // RESULT_CALENDAR;
				}
			}
			else
#endif
			{
				if(RESULT_STANDBY != result)
				{
					result = g_last_reslt;
				}
				switch(result)
				{
				case RESULT_STANDBY:
					break;
				case RESULT_BT:
#if APP_SUPPORT_MUSIC==1
					result = RESULT_MUSIC;
					break;
				case RESULT_MUSIC:
#endif
#if APP_SUPPORT_FM || APP_SUPPORT_LINEIN
					//没有Line in时才进入FM 2012-9-27
					if(gpio_detect_linein() == GPIO_DETECTED)
					{
				#if APP_SUPPORT_LINEIN ==1	
						result = RESULT_LINE_IN;
						break;
				#else
						result = RESULT_RADIO;
						break;						
				#endif
					}
					else
					{
				#if APP_SUPPORT_FM==1
						result = RESULT_RADIO;
						break;
				#endif
					}
				case RESULT_LINE_IN:
				case RESULT_RADIO:
#endif
				
#if APP_SUPPORT_RECORD
					if(AP_Support_RECORD())
					{
						result = RESULT_RECORD_NOSTART;
						break;
					}
				case RESULT_RECORD_NOSTART:
#endif
#if APP_SUPPORT_BLUETOOTH
					result = RESULT_BT;
					break;
#endif
				default:
					result = APP_DEFAULT_RESULT;
					break;
				}
			}
		}
		else if(result == RESULT_POWERON)
		{
			if(AP_Support_LCD())
			{
				GUI_ClearScreen(NULL);
				GUI_UpdateScreen(NULL);
			}
			LED_SetPattern(GUI_LED_POWERON, 1);
			
			APP_DisplaySysLogo(TRUE);
			LED_SetPattern(GUI_LED_NONE, 1);
			
			if (g_comval->LightTime == 0)            //每次开机判断一次!解决Bug Report:27
			{
				CloseBacklight();
			}
			else
			{
				OpenBacklight();
			}
			
			//APP_DUMP("g_last_reslt:", g_last_reslt);
			
			result = g_last_reslt;
			if(GetUsbCableStatus())
			{
				hal_HstSendEvent(APP_EVENT, 0x07021549);
				result = RESULT_UDISK;
			}
			if(gpio_detect_linein() == GPIO_DETECTED)
			{
				hal_HstSendEvent(APP_EVENT, 0x07021550);
				result = RESULT_LINE_IN;
			}
			need_draw = TRUE;
		}
		else        //boot with param or result != 0
		{
			switch( result)
			{
#if APP_SUPPORT_MUSIC==1
			case RESULT_MUSIC:
				hal_HstSendEvent(SYS_EVENT, 0x20120000);
				ret = APP_ModCall(FUN_MUSIC, 0);
				g_last_reslt = result;
				result = ret;
#if APP_SUPPORT_FADE_INOUT==1
				if(g_fade_volume_backup != -1)
				{
					//                    hal_HstSendEvent(SYS_EVENT, 0x13101701);
					//                    hal_HstSendEvent(SYS_EVENT, g_fade_volume_backup);
					SetPAVolume(g_fade_volume_backup);
					g_fade_volume_backup = -1;
				}
#endif
				if(g_usb_audio_tcard&&GetUsbCableStatus())//plug in tcard when usb audio is running
				{
					result = RESULT_UDISK;
				}
				hal_HstSendEvent(SYS_EVENT, 0x20124444);
				hal_HstSendEvent(SYS_EVENT, g_last_reslt);
				hal_HstSendEvent(SYS_EVENT, result);
				break;
#endif
			case RESULT_RADIO:
				hal_HstSendEvent(SYS_EVENT, 0x20120033);
				ret = APP_ModCall(FUN_FM, 0);
				hal_HstSendEvent(SYS_EVENT, 0x20120044);
				g_last_reslt = result;
				result = ret;
				hal_HstSendEvent(SYS_EVENT, 0x20123001);
				break;
				
			case RESULT_RECORD_START:    //进入录音
			case RESULT_RECORD_NOSTART:
			case RESULT_FMREC_START:
			case RESULT_FMREC_NOSTART:
				ret = APP_ModCall(FUN_RECORD, result); //传入result,以判断是否直接开始FM录音?
				g_last_reslt = result;
				result = ret;
				break;
				
			case RESULT_RECORD_SWITCH:
				if(g_last_reslt == RESULT_RECORD_START || g_last_reslt == RESULT_RECORD_NOSTART)
				{
					result = RESULT_FMREC_NOSTART;
				}
				else if(g_last_reslt == RESULT_FMREC_START || g_last_reslt == RESULT_FMREC_NOSTART)
				{
					result = RESULT_RECORD_NOSTART;
				}
				ret = APP_ModCall(FUN_RECORD, result); //传入result,以判断是否直接开始FM录音?
				g_last_reslt = result;
				result = ret;
				break;
			case RESULT_CHARGING:
				result = APP_ModCall(FUN_CHARGING, 0);
				break;
			case RESULT_IDLE:
				//APP_DUMP("g_last_reslt:", g_last_reslt);
				result = APP_ModCall(FUN_IDLE, 0);
				break;
			case RESULT_LINE_IN:
				hal_HstSendEvent(SYS_EVENT, 0x20128888);
				
				if(event_detected_displaying_log == RESULT_LINE_IN)
				{
					event_detected_displaying_log = 0;
				}
				
				result = APP_ModCall(FUN_LINEIN, 0);
				hal_HstSendEvent(SYS_EVENT, 0x20129999);
				hal_HstSendEvent(SYS_EVENT, g_last_reslt);
				hal_HstSendEvent(SYS_EVENT, result);
				//                if(result == RESULT_NULL || result == RESULT_MAIN)
				if(g_linein_out_event == 1)//line-in was removed
				{
					result = g_last_reslt;
					if(result == RESULT_LINE_IN)
					{
						result = APP_DEFAULT_RESULT;
					}
					g_linein_out_event = 0;
					
					if(g_usb_audio_linein&&GetUsbCableStatus())//plug in line-in when usb audio is running, so return usb audio again
					{
						result = RESULT_UDISK;
						hal_HstSendEvent(SYS_EVENT, 0x13071801);
					}
				}
				else
				{
					g_last_reslt = RESULT_LINE_IN;
				}
				break;
			case RESULT_STANDBY:
				{
					extern UINT8 g_light_time;
			#ifdef SUPPORT_POWERON_ENTER_CHARGE_AP//warkey 2.1
					if(-1 == GetBattery())
					{
						result = Charging_Entry();
					}
					else
			#endif
					{
						g_light_time = 0;
						result = APP_StandBy();
						
						if(g_comval->LightTime != 0)
						{
							g_light_time   = g_comval->LightTime * 2;
							OpenBacklight();
						}
					}
				}
				break;
#if APP_SUPPORT_CALIB_KEY==1
			case RESULT_KEYCALIB:
				result = APP_CalibKey();
				break;
#endif
			case RESULT_SYSTEM:
				ret = APP_ModCall(FUN_SYSTEM_SETTING, 0);
				g_last_reslt = result;
				result = ret;
				break;
			case RESULT_ALARM:
				ret = APP_ModCall(FUN_TIMER, 1);
				g_last_reslt = result;
				result = ret;
				break;
			case RESULT_TIMER:
				ret = APP_ModCall(FUN_TIMER, 0);
				g_last_reslt = result;
				result = ret;
				break;
			case RESULT_UDISK:
				//IsUDisk=1;
				//if(IsUDisk)
				{
					if(g_usb_active_after_bt != 0)
					{
						g_usb_active_after_bt = 0;
					}
					
					if(event_detected_displaying_log == RESULT_UDISK)
					{
						event_detected_displaying_log = 0;
					}
					hal_HstSendEvent(SYS_EVENT, 0x09250003);
					result = APP_ModCall(FUN_USB, 0);
					hal_HstSendEvent(SYS_EVENT, 0x09250004);
				}
				if(result == RESULT_NULL)
				{
					result = g_last_reslt;
					if(result == RESULT_UDISK)
					{
						result = APP_DEFAULT_RESULT;
					}
				}
				if(result == RESULT_BT_ACTIVE)
				{
					bt_active_ret = RESULT_UDISK;
				}
				//fix udisk return, drop key up
				//result = RESULT_MUSIC;
				hal_HstSendEvent(SYS_EVENT, result);
				break;
#if APP_SUPPORT_BLUETOOTH==1
			case RESULT_BT:
				hal_HstSendEvent(SYS_EVENT, 0x20120001);
				ret = APP_ModCall(FUN_BT, -1);
				g_last_reslt = result;
				result = ret;
				if(musicplay_timer)
				{
					COS_KillTimer(musicplay_timer);
					musicplay_timer = 0;
				}
				hal_HstSendEvent(SYS_EVENT, 0x20127777);
				hal_HstSendEvent(SYS_EVENT, g_last_reslt);
				hal_HstSendEvent(SYS_EVENT, result);
				break;
			case RESULT_BT_ACTIVE:
				hal_HstSendEvent(SYS_EVENT, 0x20120002);
				if(bt_active_ret != RESULT_NULL)
				{
					result = APP_ModCall(FUN_BT, bt_active_ret);
				}
				else
				{
					result = APP_ModCall(FUN_BT, g_last_reslt);
				}
				//add by wuxiang
				call_status = 0;
				g_bt_call_time = 0;
				bt_active_ret = RESULT_NULL;
				if(musicplay_timer)
				{
					COS_KillTimer(musicplay_timer);
					musicplay_timer = 0;
				}
				//add end
				hal_HstSendEvent(SYS_EVENT, 0x20126666);
				if(g_last_reslt == RESULT_ALARM)
				{
					result = RESULT_IDLE;
				}
				break;
#endif
			case RESULT_CALENDAR:
				ret = APP_ModCall(FUN_CALENDAR, 0);
				g_last_reslt = result;
				result = ret;
				break;
				
			default:
				//APP_DUMP("never run here: ", result);
				hal_HstSendEvent(SYS_EVENT, 0x20125555);
				hal_HstSendEvent(SYS_EVENT, result);
				result = RESULT_MAIN;
				break;
			}//switch(reault)
			
			//APP_ReadComPara();
			//IsUDisk = 1;      //更新Onlinedev
			need_draw = TRUE;
		}
	}//while never exit
	
}
Пример #21
0
BOOL APP_Read_Sys_Config(void)
{
#if 0
	//////////////////////Set Para Through File//////////////////////////
	INT32 config_file_handle = 0;
	UINT8 buf[READ_BUF_MAX];
	if(MountDisk(FS_DEV_TYPE_TFLASH))
	{
		config_file_handle = FS_Open(L"Config.txt", FS_O_RDONLY, 0);
	}
#if APP_SUPPORT_USB
	else if(MountDisk(FS_DEV_TYPE_USBDISK))
	{
		config_file_handle = FS_Open("Config.txt", FS_O_RDONLY, 0);
	}
#endif
	else
	{
		return FALSE;
	}
	
	if(config_file_handle < 0)
	{
		return FALSE;
	}
	
	///////Scan Param For  Setting/////
	memset(buf, 0, sizeof(buf));
	
	buf[READ_BUF_MAX - 1] = '\n';
	
	if(FS_Read(config_file_handle, buf, (sizeof(buf) - 1)))
	{
		//kval_t kval;
		UINT16 uYear, uMonth, uDay, uHour, uMinute, uSecond, position;
		
		/*First1:parse DATA*/
		{
			INT8 *str = "DATE:" ;
			position =  strstr(buf, str) - buf;
			position += strlen(str);
			uYear	= (buf[position] - '0') * 1000 + (buf[position + 1] - '0') * 100 + (buf[position + 2] - '0') * 10 + (buf[position + 3] - '0'); /*buf[0-3],Year... etc 2011 */
			uMonth	= (buf[position + 4] - '0') * 10 + (buf[position + 5] - '0'); /*buf[4-5],Month... etc 11 */
			uDay	    = (buf[position + 6] - '0') * 10 + (buf[position + 7] - '0'); /*buf[6-7],Day...	etc 11 */
			str = "TIME:" ;
			position =  strstr(buf, str) - buf;
			position += strlen(str);
			uHour	= (buf[position] - '0') * 10  + (buf[position + 1] - '0'); /*buf[8-9],uHour... etc 11 */
			uMinute = (buf[position + 2] - '0') * 10 + (buf[position + 3] - '0'); /*buf[10-11],uMinute... etc 11 */
			uSecond = (buf[position + 4] - '0') * 10 + (buf[position + 5] - '0'); /*buf[12-13],uSecond... etc 21 */
		}
		
		app_trace(APP_MAIN_TRC, "[APP_Read_Sys_Config]:%d,%d,%d,%d,%d,%d\r\n", uYear, uMonth, uDay, uHour, uMinute, uSecond);
		
		
		/*Get Band,FMFREQ*/
#if APP_SUPPORT_FM==1           /*Surport fm*/
		{
			INT8 *str = "BAND:" ;
			position =  strstr(buf, str) - buf;
			position += strlen(str);
			g_comval->fm_value.fm_band = (buf[position] - '0');
			str = "FMSEND:" ;
			position =  strstr(buf, str) - buf;
			position += strlen(str);
			g_comval->fm_value.fm_sendfreq = (buf[position] - '0') * 1000 + (buf[position + 1] - '0') * 100 + (buf[position + 2] - '0') * 10 + (buf[position + 3] - '0');
		}
#endif
		/*Get Loop,Eq*/
		{
			INT8 *str = "LOOP:" ;
			position =	strstr(buf, str) - buf;
			position += strlen(str);
			g_comval->music_cfg.loop_mode = (buf[position] - '0');
			str = "EQ:" ;
			position =	strstr(buf, str) - buf;
			position += strlen(str);
			g_comval->music_cfg.eq_mode   = (buf[position] - '0');
		}
		/*Get repeat ,times*/
		{
			INT8 *str = "REPEAT:" ;
			position =	strstr(buf, str) - buf;
			position += strlen(str);
			g_comval->music_cfg.repeat_count = (buf[position] - '0');
			str = "REPETIME:" ;
			position =	strstr(buf, str) - buf;
			position += strlen(str);
			g_comval->music_cfg.repeat_time	 = (buf[position] - '0') * 10 + (buf[position + 1] - '0');
		}
		
		//将systemtime 和 gwtime写回到VRAM中
		//NVRAMRead(&kval, VM_KERNEL, sizeof(kval_t));
		//kval.systemtime = ((uYear-2000)*365+uMonth*30+uDay)*24*60+uHour*60+uMinute;	 //全局变量
		//NVRAMWrite(&kval, VM_KERNEL, sizeof(kval_t));
		
	}
	
	FS_Close(config_file_handle);
#endif
	return TRUE;
}
Пример #22
0
static int fax_initGW(fax_params_t *f_params)
{
    t38_gateway_state_t *t38_gw;
    t38_core_state_t *t38_core;
    logging_state_t *logging;
    session_t *session;
    int log_level;
    int ret_val = 0;
    int fec_entries = DEFAULT_FEC_ENTRIES;
    int fec_span = DEFAULT_FEC_SPAN;
    int supported_modems;

    if(!f_params)
    {
        ret_val = -1; goto _exit;
    }

    session = f_params->session;

    app_trace(TRACE_INFO, "Fax %04x. Init T.38-fax gateway", session->ses_id);

    memset(f_params->pvt.t38_gw_state, 0, sizeof(t38_gateway_state_t));

    if(t38_gateway_init(f_params->pvt.t38_gw_state, t38_tx_packet_handler,
                         f_params) == NULL)
    {
        app_trace(TRACE_ERR, "Fax %04x. Cannot initialize T.38 structs",
                  session->ses_id);
        ret_val = -2; goto _exit;
    }

    t38_gw = f_params->pvt.t38_gw_state;

    t38_core = f_params->pvt.t38_core = t38_gateway_get_t38_core_state(t38_gw);

    t38_gateway_set_transmit_on_idle(t38_gw, TRANSMIT_ON_IDLE);
    t38_gateway_set_tep_mode(t38_gw, TEP_MODE);

    if(udptl_init(f_params->pvt.udptl_state, UDPTL_ERROR_CORRECTION_REDUNDANCY,
                  fec_span, fec_entries,
                  (udptl_rx_packet_handler_t *) t38_core_rx_ifp_packet,
                  (void *) f_params->pvt.t38_core) == NULL)
    {
        app_trace(TRACE_ERR, "Fax %04x. Cannot initialize UDPTL structs",
                  session->ses_id);
        ret_val = -3; goto _exit;
    }

    if(f_params->pvt.verbose)
    {
        log_level = SPAN_LOG_DEBUG | SPAN_LOG_SHOW_TAG |
                SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL |
                SPAN_LOG_FLOW;

        logging = t38_gateway_get_logging_state(t38_gw);
        span_log_set_message_handler(logging, fax_spandspLog);
        span_log_set_level(logging, log_level);
        span_log_set_tag(logging, f_params->log_tag);

        logging = t38_core_get_logging_state(t38_core);
        span_log_set_message_handler(logging, fax_spandspLog);
        span_log_set_level(logging, log_level);
        span_log_set_tag(logging, f_params->log_tag);
    }

	supported_modems = T30_SUPPORT_V29 | T30_SUPPORT_V27TER;
	if(!f_params->pvt.disable_v17) supported_modems |= T30_SUPPORT_V17;

	t38_gateway_set_supported_modems(t38_gw, supported_modems);
	t38_gateway_set_ecm_capability(t38_gw, f_params->pvt.use_ecm);

_exit:
	return ret_val;
}