software/drivers/sd8887/src/wlan/mapp/uaputl/uaputl.c
/**
 *  @brief Creates deepsleep  request and send to driver
 *
 *
 *  @param argc     Number of arguments
 *  @param argv     Pointer to the arguments
 *  @return         UAP_SUCCESS/UAP_FAILURE
 */
@brief Creates deepsleep  request and send to driver
@param argc     Number of arguments
@param argv     Pointer to the arguments
@return         UAP_SUCCESS/UAP_FAILURE
@brief Creates deepsleep request and send to driver @param argc Number of arguments @param argv Pointer to the arguments @return UAP_SUCCESS / UAP_FAILURE
int
apcmd_deepsleep(int argc, char *argv[])
{
	int opt;
	deep_sleep_para param;
	struct ifreq ifr;
	t_s32 sockfd;
	while ((opt = getopt_long(argc, argv, "+", cmd_options, NULL)) != -1) {
		switch (opt) {
		default:
			print_deepsleep_usage();
			return UAP_SUCCESS;
		}
	}
	argc -= optind;
	argv += optind;
	memset(&param, 0, sizeof(param));
	if (argc > 2) {
		printf("ERR:wrong arguments. Only support 2 arguments\n");
		print_deepsleep_usage();
		return UAP_FAILURE;
	}
	param.subcmd = UAP_DEEP_SLEEP;
	if (argc) {
		if (argc >= 1) {
			if ((IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE) ||
			    ((atoi(argv[0]) < 0) || (atoi(argv[0]) > 1))) {
				printf("ERR: Only Number values are allowed\n");
				print_deepsleep_usage();
				return UAP_FAILURE;
			}
		}
		param.action = 1;
		param.deep_sleep = (t_u16)A2HEXDECIMAL(argv[0]);
		param.idle_time = 0;
		if (argc == 2) {
			if (IS_HEX_OR_DIGIT(argv[0]) == UAP_FAILURE) {
				printf("ERR: Only Number values are allowed\n");
				print_deepsleep_usage();
				return UAP_FAILURE;
			}
			param.idle_time = (t_u16)A2HEXDECIMAL(argv[1]);
		}
	} else {
		param.action = 0;
	}
	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
		printf("ERR:Cannot open socket\n");
		return UAP_FAILURE;
	}
	memset(&ifr, 0, sizeof(ifr));
	strncpy(ifr.ifr_ifrn.ifrn_name, dev_name, IFNAMSIZ - 1);
	ifr.ifr_ifru.ifru_data = (void *)&param;
	errno = 0;
	if (ioctl(sockfd, UAP_IOCTL_CMD, &ifr)) {
		if (argc)
			printf("ERR: deep sleep must be disabled before changing idle time\n");
		else {
			perror("");
			printf("ERR:deep sleep failed\n");
		}
		close(sockfd);
		return UAP_FAILURE;
	}
	if (!argc) {
		if (param.deep_sleep == 1) {
			printf("deep sleep mode: enabled\n");
			printf("idle time = %dms\n", param.idle_time);
		} else {
			printf("deep sleep mode: disabled\n");
		}
	}
	close(sockfd);
	return UAP_SUCCESS;
}
int apcmd_deepsleep ( int argc , char * argv [ ] ) { int opt ; deep_sleep_para param ; struct ifreq ifr ; t_s32 sockfd ; while ( ( opt = getopt_long ( argc , argv , " " , cmd_options , NULL ) ) != -1 ) { switch ( opt ) { default : print_deepsleep_usage ( ) ; return UAP_SUCCESS ; } } argc -= optind ; argv += optind ; memset ( & param , 0 , sizeof ( param ) ) ; if ( argc > 2 ) { printf ( " \n " ) ; print_deepsleep_usage ( ) ; return UAP_FAILURE ; } param . subcmd = UAP_DEEP_SLEEP ; if ( argc ) { if ( argc >= 1 ) { if ( ( IS_HEX_OR_DIGIT ( argv [ 0 ] ) == UAP_FAILURE ) || ( ( atoi ( argv [ 0 ] ) < 0 ) || ( atoi ( argv [ 0 ] ) > 1 ) ) ) { printf ( " \n " ) ; print_deepsleep_usage ( ) ; return UAP_FAILURE ; } } param . action = 1 ; param . deep_sleep = ( t_u16 ) A2HEXDECIMAL ( argv [ 0 ] ) ; param . idle_time = 0 ; if ( argc == 2 ) { if ( IS_HEX_OR_DIGIT ( argv [ 0 ] ) == UAP_FAILURE ) { printf ( " \n " ) ; print_deepsleep_usage ( ) ; return UAP_FAILURE ; } param . idle_time = ( t_u16 ) A2HEXDECIMAL ( argv [ 1 ] ) ; } } else { param . action = 0 ; } if ( ( sockfd = socket ( AF_INET , SOCK_STREAM , 0 ) ) < 0 ) { printf ( " \n " ) ; return UAP_FAILURE ; } memset ( & ifr , 0 , sizeof ( ifr ) ) ; strncpy ( ifr . ifr_ifrn . ifrn_name , dev_name , IFNAMSIZ - 1 ) ; ifr . ifr_ifru . ifru_data = ( void * ) & param ; errno = 0 ; if ( ioctl ( sockfd , UAP_IOCTL_CMD , & ifr ) ) { if ( argc ) printf ( " \n " ) ; else { perror ( " " ) ; printf ( " \n " ) ; } close ( sockfd ) ; return UAP_FAILURE ; } if ( ! argc ) { if ( param . deep_sleep == 1 ) { printf ( " \n " ) ; printf ( " \n " , param . idle_time ) ; } else { printf ( " \n " ) ; } } close ( sockfd ) ; return UAP_SUCCESS ; }
@brief Creates deepsleep  request and send to driver
  @param argc     Number of arguments
  @param argv     Pointer to the arguments
  @return         UAP_SUCCESS/UAP_FAILURE
@brief Creates deepsleep request and send to driver @param argc Number of arguments @param argv Pointer to the arguments @return UAP_SUCCESS / UAP_FAILURE
/* Check arguments */ /* Open socket */ /* Initialize the ifr structure */ /* Perform ioctl */ /* Close socket */