software/drivers/sd8887/src/wlan/mapp/uaputl/uaputl.c
/**
 *  @brief Creates power mode request and send to driver
 *   and sends to the driver
 *
 *
 *  @param argc     Number of arguments
 *  @param argv     Pointer to the arguments
 *  @return         UAP_SUCCESS/UAP_FAILURE
 */
@brief Creates power mode request and send to driver
and sends to the driver

@param argc     Number of arguments
@param argv     Pointer to the arguments
@return         UAP_SUCCESS/UAP_FAILURE
@brief Creates power mode request and send to driver and sends to the driver @param argc Number of arguments @param argv Pointer to the arguments @return UAP_SUCCESS / UAP_FAILURE
int
apcmd_pscfg(int argc, char *argv[])
{
	int opt;
	ps_mgmt pm;
	int ret = UAP_SUCCESS;
	while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
		switch (opt) {
		default:
			print_pscfg_usage();
			return UAP_SUCCESS;
		}
	}
	argc -= optind;
	argv += optind;
	memset(&pm, 0, sizeof(ps_mgmt));
	if ((argc > 7) ||
	    ((argc != 0) && (argc != 1) && (argc != 5) && (argc != 7))) {
		printf("ERR:wrong arguments.\n");
		print_pscfg_usage();
		return UAP_FAILURE;
	}
	if (argc) {
		if (send_power_mode_ioctl(&pm, 1) == UAP_FAILURE)
			return UAP_FAILURE;
		if ((ISDIGIT(argv[0]) == 0) || (atoi(argv[0]) < 0) ||
		    (atoi(argv[0]) > 2)) {
			printf("ERR:Illegal power mode %s. Must be either '0' '1' or '2'.\n", argv[0]);
			print_pscfg_usage();
			return UAP_FAILURE;
		}
		pm.flags = PS_FLAG_PS_MODE;
		pm.ps_mode = atoi(argv[0]);
		if ((pm.ps_mode == PS_MODE_DISABLE) && (argc > 1)) {
			printf("ERR: Illegal parameter for disable power mode\n");
			print_pscfg_usage();
			return UAP_FAILURE;
		}
		if ((pm.ps_mode != PS_MODE_INACTIVITY) && (argc > 5)) {
			printf("ERR:Min awake period and Max awake period are valid only for inactivity based power save mode\n");
			print_pscfg_usage();
			return UAP_FAILURE;
		}
		if (argc >= 5) {
			if ((ISDIGIT(argv[1]) == 0) || (atoi(argv[1]) < 0) ||
			    (atoi(argv[1]) > 1)) {
				printf("ERR:Illegal ctrl bitmap = %s. Must be either '0' or '1'.\n", argv[1]);
				print_pscfg_usage();
				return UAP_FAILURE;
			}
			pm.flags |=
				PS_FLAG_SLEEP_PARAM | PS_FLAG_INACT_SLEEP_PARAM;
			pm.sleep_param.ctrl_bitmap = atoi(argv[1]);
			if ((ISDIGIT(argv[2]) == 0) || (ISDIGIT(argv[3]) == 0)
			    || (ISDIGIT(argv[4]) == 0)) {
				printf("ERR:Illegal parameter\n");
				print_pscfg_usage();
				return UAP_FAILURE;
			}
			pm.inact_param.inactivity_to = atoi(argv[2]);
			pm.sleep_param.min_sleep = atoi(argv[3]);
			pm.sleep_param.max_sleep = atoi(argv[4]);
			if (pm.sleep_param.min_sleep > pm.sleep_param.max_sleep) {
				printf("ERR: MIN_SLEEP value should be less than or equal to MAX_SLEEP\n");
				return UAP_FAILURE;
			}
			if (pm.sleep_param.min_sleep < PS_SLEEP_PARAM_MIN ||
			    ((pm.sleep_param.max_sleep > PS_SLEEP_PARAM_MAX) &&
			     pm.sleep_param.ctrl_bitmap)) {
				printf("ERR: Incorrect value of sleep period. Please check README\n");
				return UAP_FAILURE;
			}
			if (argc == 7) {
				if ((ISDIGIT(argv[5]) == 0) ||
				    (ISDIGIT(argv[6]) == 0)) {
					printf("ERR:Illegal parameter\n");
					print_pscfg_usage();
					return UAP_FAILURE;
				}
				pm.inact_param.min_awake = atoi(argv[5]);
				pm.inact_param.max_awake = atoi(argv[6]);
				if (pm.inact_param.min_awake >
				    pm.inact_param.max_awake) {
					printf("ERR: MIN_AWAKE value should be less than or equal to MAX_AWAKE\n");
					return UAP_FAILURE;
				}
				if (pm.inact_param.min_awake <
				    PS_AWAKE_PERIOD_MIN) {
					printf("ERR: Incorrect value of MIN_AWAKE period.\n");
					return UAP_FAILURE;
				}
			}
		}
	}
	ret = send_power_mode_ioctl(&pm, 0);
	return ret;
}
int apcmd_pscfg ( int argc , char * argv [ ] ) { int opt ; ps_mgmt pm ; int ret = UAP_SUCCESS ; while ( ( opt = getopt_long ( argc , argv , " " , cmd_options , NULL ) ) != -1 ) { switch ( opt ) { default : print_pscfg_usage ( ) ; return UAP_SUCCESS ; } } argc -= optind ; argv += optind ; memset ( & pm , 0 , sizeof ( ps_mgmt ) ) ; if ( ( argc > 7 ) || ( ( argc != 0 ) && ( argc != 1 ) && ( argc != 5 ) && ( argc != 7 ) ) ) { printf ( " \n " ) ; print_pscfg_usage ( ) ; return UAP_FAILURE ; } if ( argc ) { if ( send_power_mode_ioctl ( & pm , 1 ) == UAP_FAILURE ) return UAP_FAILURE ; if ( ( ISDIGIT ( argv [ 0 ] ) == 0 ) || ( atoi ( argv [ 0 ] ) < 0 ) || ( atoi ( argv [ 0 ] ) > 2 ) ) { printf ( " \n " , argv [ 0 ] ) ; print_pscfg_usage ( ) ; return UAP_FAILURE ; } pm . flags = PS_FLAG_PS_MODE ; pm . ps_mode = atoi ( argv [ 0 ] ) ; if ( ( pm . ps_mode == PS_MODE_DISABLE ) && ( argc > 1 ) ) { printf ( " \n " ) ; print_pscfg_usage ( ) ; return UAP_FAILURE ; } if ( ( pm . ps_mode != PS_MODE_INACTIVITY ) && ( argc > 5 ) ) { printf ( " \n " ) ; print_pscfg_usage ( ) ; return UAP_FAILURE ; } if ( argc >= 5 ) { if ( ( ISDIGIT ( argv [ 1 ] ) == 0 ) || ( atoi ( argv [ 1 ] ) < 0 ) || ( atoi ( argv [ 1 ] ) > 1 ) ) { printf ( " \n " , argv [ 1 ] ) ; print_pscfg_usage ( ) ; return UAP_FAILURE ; } pm . flags |= PS_FLAG_SLEEP_PARAM | PS_FLAG_INACT_SLEEP_PARAM ; pm . sleep_param . ctrl_bitmap = atoi ( argv [ 1 ] ) ; if ( ( ISDIGIT ( argv [ 2 ] ) == 0 ) || ( ISDIGIT ( argv [ 3 ] ) == 0 ) || ( ISDIGIT ( argv [ 4 ] ) == 0 ) ) { printf ( " \n " ) ; print_pscfg_usage ( ) ; return UAP_FAILURE ; } pm . inact_param . inactivity_to = atoi ( argv [ 2 ] ) ; pm . sleep_param . min_sleep = atoi ( argv [ 3 ] ) ; pm . sleep_param . max_sleep = atoi ( argv [ 4 ] ) ; if ( pm . sleep_param . min_sleep > pm . sleep_param . max_sleep ) { printf ( " \n " ) ; return UAP_FAILURE ; } if ( pm . sleep_param . min_sleep < PS_SLEEP_PARAM_MIN || ( ( pm . sleep_param . max_sleep > PS_SLEEP_PARAM_MAX ) && pm . sleep_param . ctrl_bitmap ) ) { printf ( " \n " ) ; return UAP_FAILURE ; } if ( argc == 7 ) { if ( ( ISDIGIT ( argv [ 5 ] ) == 0 ) || ( ISDIGIT ( argv [ 6 ] ) == 0 ) ) { printf ( " \n " ) ; print_pscfg_usage ( ) ; return UAP_FAILURE ; } pm . inact_param . min_awake = atoi ( argv [ 5 ] ) ; pm . inact_param . max_awake = atoi ( argv [ 6 ] ) ; if ( pm . inact_param . min_awake > pm . inact_param . max_awake ) { printf ( " \n " ) ; return UAP_FAILURE ; } if ( pm . inact_param . min_awake < PS_AWAKE_PERIOD_MIN ) { printf ( " \n " ) ; return UAP_FAILURE ; } } } } ret = send_power_mode_ioctl ( & pm , 0 ) ; return ret ; }
@brief Creates power mode request and send to driver
   and sends to the driver
@brief Creates power mode request and send to driver and sends to the driver
/* Check arguments */