int BWC::modem_speed_profile_set( BWC::MODEM_SPEED_PROFILE profile )
{
    
#ifdef FLAG_SUPPORT_MODEM_SCALE


    switch( profile )
    {
    case MSP_NORMAL:
        BWC_INFO("ifc_set_throttle: %d %d (Normal)\n", -1, -1 );
        ifc_set_throttle( "ccmni0", -1, -1 );       //UnLimit
        break;

    case MSP_SCALE_DOWN:
        BWC_INFO("ifc_set_throttle: %d %d (Scale Down)\n", (int)21*1024, (int)5.7*1024 );
        ifc_set_throttle( "ccmni0", 21*1024, 5.7*1024 );  //Limit downlink to 21Mbps/uplink 5.7Mbps
        break;

    default:
        BWC_ERROR("Unknown modem speed profile:%d\n", profile );
        return -1;
    }



#endif
    
    return 0;
}
예제 #2
0
static void set_wifi_throttle(int level)
{
	int i = 0;
	for ( i=0; i<IFC_NUM; i++) {
		TM_DBG_LOG("checking %s", IFC_PATH[i]);
		if (0 == access(IFC_PATH[i], R_OK)) {
			char buf[80];
			int fd = open(IFC_PATH[i], O_RDONLY);
			if (fd < 0) {
				TM_INFO_LOG("Can't open %s: %s", IFC_PATH[i], strerror(errno));
				continue;
			}

			int len = read(fd, buf, sizeof(buf) - 1);
			if (len < 0) {
				TM_INFO_LOG("Can't read %s: %s", IFC_PATH[i], strerror(errno));
				continue;
			}
			close(fd);
			if(!strncmp (buf, "up", 2)) {
				ifc_set_throttle(IFC_NAME[i], level * ONE_MBITS_PER_SEC, level * ONE_MBITS_PER_SEC);

				#ifdef NEVER
			 	exe_cmd(i, level);
				#endif /* NEVER */
			} else
				TM_DBG_LOG("%s is down!", IFC_NAME[i]);
		}
	}
}
예제 #3
0
static void set_md_ul_throttle(int level)
{
	int i = 0;

	TM_DBG_LOG("set_md_ul_throttle %d\n", level);
	
	for ( i=0; i<MD_IFC_NUM; i++) {
		TM_DBG_LOG("checking %s", MD_IFC_PATH[i]);
		if (0 == access(MD_IFC_PATH[i], R_OK)) {
			char buf[80];
			int fd = open(MD_IFC_PATH[i], O_RDONLY);
			if (fd < 0) {
				TM_INFO_LOG("Can't open %s: %s", MD_IFC_PATH[i], strerror(errno));
				continue;
			}

			int len = read(fd, buf, sizeof(buf) - 1);
			if (len < 0) {
				TM_INFO_LOG("Can't read %s: %s", MD_IFC_PATH[i], strerror(errno));
				continue;
			}
			close(fd);
#if 0
			if(!strncmp (buf, "up", 2)) {
				ifc_set_throttle(MD_IFC_NAME[i], -1, level);

				#ifdef NEVER
			 	exe_cmd(i, level);
				#endif /* NEVER */
			} else
				TM_DBG_LOG("%s is down!", MD_IFC_NAME[i]);
#else
			if(!strncmp (buf, "down", 4)) {
			    TM_DBG_LOG("%s is down!", MD_IFC_NAME[i]);
			} else {
                ifc_set_throttle(MD_IFC_NAME[i], -1, level);

				#ifdef NEVER
			 	exe_cmd(i, level);
				#endif /* NEVER */
			}
#endif
		}
	}
}