void read_provision_status(void)
{
    char psm_val[65];
    psm_handle_t handle;
    int ret;

    if ((ret = psm_open(&handle, "network")) != 0) {
        wmprintf("open psm network error\r\n");
        return;
    }
    if (psm_get(&handle, "configured", psm_val, sizeof(psm_val)) != 0) {
        psm_close(&handle);
        return;
    }
    if (0 == strcmp(psm_val, "1"))
        g_provisioned.state = APP_NETWORK_PROVISIONED;
    else
        g_provisioned.state = APP_NETWORK_NOT_PROVISIONED;

    psm_close(&handle);
}
示例#2
0
void test_1(tls_handle_t h)
{
	char reply[11];
	tls_session_t *s = (tls_session_t *) h;
	int total_bytes;

	int input = SSL_read(s->ssl, reply, sizeof(reply) - 1);
	if (input > 0) {
		total_bytes += input;
		reply[input] = 0;
		tls_d("Server response: %s", reply);

		while (1) {
			input = SSL_read(s->ssl, reply, sizeof(reply) - 1);
			if (input > 0) {
				reply[input] = 0;
				wmprintf("%s\n\r", reply);
			} else
				break;
		}
	}
}
示例#3
0
void cmd_wlan_deepsleep(int argc, char **argv)
{
	unsigned int status = 0;
	unsigned int duration = 0;
	int action = 0;

	if (argc == 2) {
		get_uint(argv[1], &status, strlen(argv[1]));
		action = (status == 1) ? EN_AUTO_PS : DIS_AUTO_PS;
	} else if (argc == 3) {
		get_uint(argv[1], &status, strlen(argv[1]));
		get_uint(argv[2], &duration, strlen(argv[2]));
		wmprintf("Entering Deep Sleep for %u milliseconds\r\n",
					duration);
		action = (status == 1) ? EN_AUTO_PS : DIS_AUTO_PS;
	} else {
		action = GET_PS;
	}

	wifi_send_power_save_command(action, BITMAP_AUTO_DS,
					(void *) &duration);
}
示例#4
0
int wpa2_ent_connect(struct wlan_network *wpa2_network)
{
	struct wpa2_command *wpa2_cmd = NULL;

	wpa2_cmd = (struct wpa2_command *)
			wps_mem_malloc(sizeof(struct wpa2_command));

	if (wpa2_cmd == NULL) {
		wmprintf("Failed to allocated memory for wpa2 command\r\n");
		return -WM_FAIL;
	}

	memset(wpa2_cmd, 0, sizeof(struct wpa2_command));

	memcpy(&wpa2_cmd->wpa2_network, wpa2_network,
			sizeof(struct wlan_network));

	if (os_queue_send(&wps.cmd_queue, &wpa2_cmd, OS_NO_WAIT) != WM_SUCCESS)
		return -WM_FAIL;
	return WM_SUCCESS;

}
示例#5
0
/* create shadow yield thread */
static int create_test_thread()
{
	int ret;
	ret = os_thread_create(
		/* thread handle */
		&test_thread,
		/* thread name */
		"test",
		/* entry function */
		test,
		/* argument */
		0,
		/* stack */
		&test_stack,
		/* priority */
		OS_PRIO_3);
	if (ret != WM_SUCCESS) {
		wmprintf("Failed to create shadow yield thread: %d\r\n", ret);
		return -WM_FAIL;
	}
	return WM_SUCCESS;
}
示例#6
0
void sem_debug_delete(const xSemaphoreHandle handle)
{
	int temp, i;
	if (sem_mutex) {
		temp = os_mutex_get(&sem_mutex, OS_WAIT_FOREVER);
		if (temp == -WM_FAIL) {
			wmprintf("[sem-dbg] Failed to get sem-mutex\r\n");
			return;
		}
	}
	for (i = 0; i < MAX_SEM_INFO_BUF; i++) {
		if (semdbg[i].x_queue == handle) {
			semdbg[i].x_queue  = 0;
			os_mem_free(semdbg[i].q_name);
			semdbg[i].q_name = NULL;
			semcnt--;
			break;
		}
	}
	if (sem_mutex)
		os_mutex_put(&sem_mutex);
	return;
}
示例#7
0
int wps_connect(enum wps_session_command pbc, uint32_t pin,
			struct wlan_scan_result *res)
{
	struct wps_command *wps_cmd = NULL;

	wps_cmd = (struct wps_command *)
			wps_mem_malloc(sizeof(struct wps_command));

	if (wps_cmd == NULL) {
		wmprintf("Failed to allocated memory for wps command\r\n");
		return -WM_FAIL;
	}

	memset(wps_cmd, 0, sizeof(struct wps_command));

	wps_cmd->command = pbc;
	wps_cmd->wps_pin = pin;
	memcpy(&wps_cmd->res, res, sizeof(struct wlan_scan_result));

	if (os_queue_send(&wps.cmd_queue, &wps_cmd, OS_NO_WAIT) != WM_SUCCESS)
		return -WM_FAIL;
	return WM_SUCCESS;

}
示例#8
0
/* Ticker function for polling the UART for character input. */
static void console_tick(void)
{
	int ret;

	if (cli.inbuf == NULL) {
		ret = cli_get_cmd_buffer(&cli.inbuf);
		if (ret != WM_SUCCESS) {
			return;
		}
		cli.bp = 0;
	}

	if (cli.input_enabled && get_input(cli.inbuf, &cli.bp)) {
		cli.input_enabled = 0;
		ret = cli_submit_cmd_buffer(&cli.inbuf);
		cli.inbuf = NULL;
		if (ret != WM_SUCCESS) {
			wmprintf("Error: problem sending cli message"
				       "\r\n");
		}
		cli.input_enabled = 1;
	}

}
示例#9
0
static void test_wlan_get_mac_address(int argc, char **argv)
{
	uint8_t mac[6];

	wmprintf("MAC address\r\n");
	if (wlan_get_mac_address(mac))
		wmprintf("Error: unable to retrieve MAC address\r\n");
	else
		wmprintf("%02X:%02X:%02X:%02X:%02X:%02X\r\n",
			       mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
#ifdef CONFIG_P2P
	wmprintf("P2P MAC address\r\n");
	if (wlan_get_wfd_mac_address(mac))
		wmprintf("Error: unable to retrieve P2P MAC address\r\n");
	else
		wmprintf("%02X:%02X:%02X:%02X:%02X:%02X\r\n",
			       mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
#endif
}
示例#10
0
static void print_address(struct wlan_ip_config *addr)
{
	struct in_addr ip, gw, nm, dns1, dns2;
	char addr_type[10];
	ip.s_addr = addr->ip;
	gw.s_addr = addr->gw;
	nm.s_addr = addr->netmask;
	dns1.s_addr = addr->dns1;
	dns2.s_addr = addr->dns2;
	if (addr->addr_type == ADDR_TYPE_STATIC)
		strncpy(addr_type, "STATIC", sizeof(addr_type));
	else if (addr->addr_type == ADDR_TYPE_STATIC)
		strncpy(addr_type, "AUTO IP", sizeof(addr_type));
	else
		strncpy(addr_type, "DHCP", sizeof(addr_type));

	wmprintf("\taddress: %s", addr_type);
	wmprintf("\r\n\t\tIP:\t\t%s", inet_ntoa(ip));
	wmprintf("\r\n\t\tgateway:\t%s", inet_ntoa(gw));
	wmprintf("\r\n\t\tnetmask:\t%s", inet_ntoa(nm));
	wmprintf("\r\n\t\tdns1:\t\t%s", inet_ntoa(dns1));
	wmprintf("\r\n\t\tdns2:\t\t%s", inet_ntoa(dns2));
	wmprintf("\r\n");
}
示例#11
0
static void test_wlan_info(int argc, char **argv)
{
	enum wlan_connection_state state;
	struct wlan_network sta_network;
	struct wlan_network uap_network;
	int sta_found = 0;

	if (wlan_get_connection_state(&state)) {
		wmprintf("Error: unable to get STA connection"
						" state\r\n");
	} else {
		switch (state) {
		case WLAN_CONNECTED:
			if (!wlan_get_current_network(&sta_network)) {
				wmprintf("Station connected to:\r\n");
				print_network(&sta_network);
				sta_found = 1;
			} else
				wmprintf("Station not connected\r\n");
			break;
		default:
			wmprintf("Station not connected\r\n");
			break;
		}
	}

	if (wlan_get_current_uap_network(&uap_network))
		wmprintf("uAP not started\r\n");
	else {
		/* Since uAP automatically changes the channel to the one that
		 * STA is on */
		if (sta_found == 1)
			uap_network.channel = sta_network.channel;

		if (uap_network.role == WLAN_BSS_ROLE_UAP)
			wmprintf("uAP started as:\r\n");

		print_network(&uap_network);
	}
}
示例#12
0
static void action_led_callback(const char* json_str, size_t size)
{
    jobj_t json;
    int err = json_parse_start(&json, (char*)json_str, size);
    if (err != WM_SUCCESS) 
    {
        wmprintf("Wrong json string\n\r");
        return;
    }

    output_gpio_cfg_t led;

	char type[32];
	if (json_get_val_str(&json, "type", type, sizeof(type)) != WM_SUCCESS) 
    {
		wmprintf("type doesn't exist\r\n");
        goto callback_exit;
	}

    if (strcmp(type, "_led1") == 0) 
    {
        led = led_1;
    }
    else if (strcmp(type, "_led2") == 0) 
    {
        led = led_2;
    }
    else
    {
		wmprintf("not expected type value\r\n");
        goto callback_exit;
    }

    if (json_get_composite_object(&json, "customFields") != WM_SUCCESS) 
    {
        wmprintf("Custom fields doesn't exist\n\r");
        goto callback_exit;
    }

    char status[16];
    if (json_get_val_str(&json, "status", status, sizeof(status)) != WM_SUCCESS) 
    {
        wmprintf("Status doesn't exist\n\r");
        goto callback_exit;
    }

    json_release_composite_object(&json);

    wmprintf("Received action: type = \"%s\", status = \"%s\"\n\r", type, status);

    if (strcmp(status, "0") == 0) 
    {
        led_off(led);
    } 
    else if (strcmp(status, "1") == 0) 
    {
        led_on(led);
    }

callback_exit:
    json_parse_stop(&json);
}
示例#13
0
static void set_device_time()
{
	http_session_t handle;
	http_resp_t *resp = NULL;
	char buf[MAX_DOWNLOAD_DATA];
	int64_t timestamp, offset;
	int size = 0;
	int status = 0;
	char url_name[MAX_URL_LEN];

	memset(url_name, 0, sizeof(url_name));
	strncpy(url_name, EVRYTHNG_GET_TIME_URL, strlen(EVRYTHNG_GET_TIME_URL));

	wmprintf("Get time from : %s\r\n", url_name);
	status = httpc_get(url_name, &handle, &resp, NULL);
	if (status != WM_SUCCESS) {
		wmprintf("Getting URL failed");
		return;
	}
	size = http_read_content(handle, buf, MAX_DOWNLOAD_DATA);
	if (size <= 0) {
		wmprintf("Reading time failed\r\n");
		goto out_time;
	}
	/*
	  If timezone is present in PSM
	  Get on http://api.evrythng.com/time?tz=<timezone>
	  The data will look like this
	  {
	  "timestamp":1429514751927,
	  "offset":-18000000,
	  "localTime":"2015-04-20T02:25:51.927-05:00",
	  "nextChange":1446361200000
	  }
	  If timezone is not presentin PSM
	  Get on http://api.evrythng.com/time
	  The data will look like this
	  {
	  "timestamp":1429514751927
	  }
	*/
	jobj_t json_obj;
	if (json_parse_start(&json_obj, buf, size) != WM_SUCCESS) {
		wmprintf("Wrong json string\r\n");
		goto out_time;
	}

	if (json_get_val_int64(&json_obj, "timestamp", &timestamp) == WM_SUCCESS) {
		if (json_get_val_int64(&json_obj, "offset", &offset)
		    != WM_SUCCESS) {
			offset = 0;
		}
		timestamp = timestamp + offset;
	}
	wmtime_time_set_posix(timestamp/1000);

    json_parse_stop(&json_obj);

out_time:
	http_close_session(&handle);
	return;
}
示例#14
0
static void cmd_httpc_post(int argc, char **argv)
{
	if (argc < 3) {
		dbg("\nUsage: %s\n", httpc_test_cmds[0].help);
		return;
	}

	const char *url = argv[1];
	const char *data = argv[2];
	int len = strlen(data);
	int count = 1;		/* Default value */

	/* Check if user has given count */
	if (argc > 3) {
		count = strtol(argv[3], NULL, 0);
	}

	http_session_t hnd;
	int rv = http_open_session(&hnd, url, 0, NULL, 0);
	if (rv != 0) {
		dbg("Open session failed: %s (%d)", url, rv);
		return;
	}

	while (count--) {
		http_req_t req = {
			.type = HTTP_POST,
			.resource = url,
			.version = HTTP_VER_1_1,
			.content = data,
			.content_len = len,
		};

		rv = http_prepare_req(hnd, &req,
				      STANDARD_HDR_FLAGS |
				      HDR_ADD_CONN_KEEP_ALIVE);
		if (rv != 0) {
			dbg("Prepare request failed: %d", rv);
			break;
		}

		rv = http_send_request(hnd, &req);
		if (rv != 0) {
			dbg("Send request failed: %d", rv);
			break;
		}

		http_resp_t *resp;
		rv = http_get_response_hdr(hnd, &resp);
		if (rv != 0) {
			dbg("Get resp header failed: %d", rv);
			break;
		}

		dbg("Content length: %d", resp->content_length);
		if (resp->content_length == 0) {
			continue;
		}

		dbg("------------Content------------");
		while (1) {
			char buf[32];
			rv = http_read_content(hnd, buf, sizeof(buf));
			if (rv == 0 || rv < 0) {
				break;
			}
			wmprintf("%s", buf);
		}

		if (rv < 0) {
			/* Error condition */
			break;
		}
	}
}
示例#15
0
/* Parse input line and locate arguments (if any), keeping count of the number
 * of arguments and their locations.  Look up and call the corresponding cli
 * function if one is found and pass it the argv array.
 *
 * Returns: 0 on success: the input line contained at least a function name and
 *          that function exists and was called.
 *          1 on lookup failure: there is no corresponding function for the
 *          input line.
 *          2 on invalid syntax: the arguments list couldn't be parsed
 */
static int handle_input(char *inbuf)
{
	struct {
		unsigned inArg:1;
		unsigned inQuote:1;
		unsigned done:1;
	} stat;
	static char *argv[16];
	int argc = 0;
	int i = 0;
	const struct cli_command *command = NULL;
	const char *p;

	memset((void *)&argv, 0, sizeof(argv));
	memset(&stat, 0, sizeof(stat));

	do {
		switch (inbuf[i]) {
		case '\0':
			if (stat.inQuote)
				return 2;
			stat.done = 1;
			break;

		case '"':
			if (i > 0 && inbuf[i - 1] == '\\' && stat.inArg) {
				memcpy(&inbuf[i - 1], &inbuf[i],
				       strlen(&inbuf[i]) + 1);
				--i;
				break;
			}
			if (!stat.inQuote && stat.inArg)
				break;
			if (stat.inQuote && !stat.inArg)
				return 2;

			if (!stat.inQuote && !stat.inArg) {
				stat.inArg = 1;
				stat.inQuote = 1;
				argc++;
				argv[argc - 1] = &inbuf[i + 1];
			} else if (stat.inQuote && stat.inArg) {
				stat.inArg = 0;
				stat.inQuote = 0;
				inbuf[i] = '\0';
			}
			break;

		case ' ':
			if (i > 0 && inbuf[i - 1] == '\\' && stat.inArg) {
				memcpy(&inbuf[i - 1], &inbuf[i],
				       strlen(&inbuf[i]) + 1);
				--i;
				break;
			}
			if (!stat.inQuote && stat.inArg) {
				stat.inArg = 0;
				inbuf[i] = '\0';
			}
			break;

		default:
			if (!stat.inArg) {
				stat.inArg = 1;
				argc++;
				argv[argc - 1] = &inbuf[i];
			}
			break;
		}
	} while (!stat.done && ++i < INBUF_SIZE);

	if (stat.inQuote)
		return 2;

	if (argc < 1)
		return 0;

	wmprintf("\r\n");

	/*
	 * Some comamands can allow extensions like foo.a, foo.b and hence
	 * compare commands before first dot.
	 */
	i = ((p = strchr(argv[0], '.')) == NULL) ? 0 :
					(p - argv[0]);
	command = lookup_command(argv[0], i);
	if (command == NULL)
		return 1;

	command->function(argc, argv);

	return 0;
}
示例#16
0
int __scan_cb(unsigned int count)
{
	struct wlan_scan_result res;
	int i;
	int err;

	if (count == 0) {
		wmprintf("no networks found\r\n");
		return 0;
	}

	wmprintf("%d network%s found:\r\n", count, count == 1 ? "" : "s");

	for (i = 0; i < count; i++) {
		err = wlan_get_scan_result(i, &res);
		if (err) {
			wmprintf("Error: can't get scan res %d\r\n", i);
			continue;
		}

		print_mac(res.bssid);

		if (res.ssid[0])
			wmprintf(" \"%s\" %s\r\n", res.ssid,
				       print_role(res.role));
		else
			wmprintf(" (hidden) %s\r\n",
				       print_role(res.role));

		wmprintf("\tchannel: %d\r\n", res.channel);
		wmprintf("\trssi: -%d dBm\r\n", res.rssi);
		wmprintf("\tsecurity: ");
		if (res.wep)
			wmprintf("WEP ");
		if (res.wpa && res.wpa2)
			wmprintf("WPA/WPA2 Mixed ");
		else {
			if (res.wpa)
				wmprintf("WPA ");
			if (res.wpa2)
				wmprintf("WPA2 ");
#ifdef CONFIG_WPA2_ENTP
			if (res.wpa2_entp)
				wmprintf("WPA2(EAP-TLS)");
#endif
		}
		if (!(res.wep || res.wpa || res.wpa2
#ifdef CONFIG_WPA2_ENTP
|| res.wpa2_entp
#endif
		))
			wmprintf("OPEN ");
		wmprintf("\r\n");

		wmprintf("\tWMM: %s\r\n", res.wmm ? "YES" : "NO");
#ifdef CONFIG_WPS2
		if (res.wps) {
			if (res.wps_session == WPS_SESSION_PBC)
				wmprintf("\tWPS: %s, Session: %s\r\n", "YES", "Push Button");
			else if (res.wps_session == WPS_SESSION_PIN)
				wmprintf("\tWPS: %s, Session: %s\r\n", "YES", "PIN");
			else
				wmprintf("\tWPS: %s, Session: %s\r\n", "YES", "Not active");
		}
		else
			wmprintf("\tWPS: %s \r\n", "NO");
#endif
	}

	return 0;
}
示例#17
0
void json_test(int argc, char **argv)
{
	int num;
	int fmt;
	char text[] =
	    "{\n     \"precision\": \"zip\",\n       \"Latitude\":  37668,\n       \"Longitude\": -12259,\n     \"Address\":   \"\",\n  \"City\":      \"SAN FRANCISCO\",\n     \"State\":     \"CA\",\n        \"Zip\":       \"94107\",\n     \"Country\":   \"US\"\n                                                                                                    }";
	char complex_obj[] =
	    "{ \"glossary\": { \"title\": \"example glossary\", \"GlossDiv\": { \"title\": \"S\", 		\"GlossList\": { \"GlossEntry\": { \"ID\": \"SGML\", \"SortAs\": \"SGML\",\"GlossTerm\": \"Standard Generalized Markup Language\", \"Acronym\": \"SGML\", 	\"Abbrev\": \"ISO 8879:1986\", 	\"GlossDef\": { \"para\": \"language\",	\"GlossSeeAlso\": \"XML\" },	\"GlossSee\": \"markup\"  } } } } }";

	debug("#### json_parser ####\n");

	json_object_init(&tmp, text);

	if (!json_get_val_str(&tmp, "Country", str, MAX_JSON_STR_LEN)) {
		if (!strcmp(str, "US")) {
			debug("***Json_parser ---str_get match\n");
		} else {
			debug("***Err ---str_get mismatch\n");
			goto ERROR;
		}
	} else {
		debug("***Err ---str_get failed\n");
		goto ERROR;
	}

	if (!json_get_val_int(&tmp, "Longitude", &num)) {
		if (num == -12259) {
			debug("***Json_parser ---int_get match\n");
		} else {
			debug("***Err ---int_get mismatch\n");
			goto ERROR;
		}
	} else {
		debug("***Err ---int_get failed\n");
		goto ERROR;
	}

	fmt = 1;
	debug("***Json_parser ---Simple Set Example\n");
	json_str_init(&jstr, tmpstr, sizeof(tmpstr), fmt);
	json_start_object(&jstr);
	json_set_val_str(&jstr, "name", "John Galt");
	json_set_val_int(&jstr, "age", 29);
	json_set_val_str(&jstr, "numberstr", "123");
	json_close_object(&jstr);
	debug("The JSON String is :%s:\n", jstr.buff);

	debug("***Json_parser --- Complex object Set Example\n");
	json_str_init(&jstr_c, tmpstr, sizeof(tmpstr), fmt);
	json_start_object(&jstr_c);
	json_push_object(&jstr_c, "menu");
	json_set_val_str(&jstr_c, "pictures", "tmp");

	json_push_object(&jstr_c, "Image");
	json_set_val_str(&jstr_c, "name", "sun");
	json_set_val_int(&jstr_c, "length", 1000);
	json_set_val_str(&jstr_c, "size", "1600pi");

	json_pop_object(&jstr_c);	/* Close Image */

	json_push_object(&jstr_c, "text");
	json_set_val_str(&jstr_c, "style", "bold");
	json_set_val_str(&jstr_c, "alignment", "center");
	json_set_val_str(&jstr_c, "name", "text1");

	json_pop_object(&jstr_c);	/* Close text */
	json_set_val_str(&jstr_c, "object", "close");
	json_pop_object(&jstr_c);	/* Close menu */
	json_close_object(&jstr_c);	/* Close main */

	debug("The JSON String is *%s*\n", jstr_c.buff);

	struct json_object obj;
	json_object_init(&obj, jstr_c.buff);
	if (!json_get_composite_object(&obj, "text")) {
		if (!json_get_val_int(&obj, "length", &num))
			debug("val is %d \n", num);
		else
			debug("***Json_parser ---passed, no such member\n");

		if (!json_get_val_str(&obj, "style", str, MAX_JSON_STR_LEN)) {
			if (!strcmp(str, "bold")) {
				debug
				    ("***Json_parser ---composite_str_get match\n");
				debug("member->style:val->%s\n", str);
			} else {
				debug("***Err ---composite_str_get mismatch\n");
				goto ERROR;
			}
		} else {
			debug("***Err ---composite_str_get failed\n");
			goto ERROR;
		}

	} else {
		debug("***Err ---get_object_offsets failed\n");
		goto ERROR;
	}

	json_release_composite_object(&obj);

	json_object_init(&obj, complex_obj);
	if (!json_get_composite_object(&obj, "GlossEntry")) {
		if (!json_get_val_str(&obj, "GlossSee", str, 64)) {
			if (!strcmp(str, "markup")) {
				debug
				    ("***Json_parser ---composite_str_get match\n");
				debug("member->GlossEntry:val->%s\n", str);
			} else {
				debug("***Err ---composite_str_get mismatch\n");
				goto ERROR;
			}
		} else {
			debug("***Err ---composite_str_get failed\n");
			goto ERROR;
		}
	} else {
		debug("***Err ---get_object_offsets failed\n");
		goto ERROR;
	}

	json_release_composite_object(&obj);
	goto SUCCESS;
ERROR:
	wmprintf("Error");
SUCCESS:
	wmprintf("Success");
}
示例#18
0
/*
 * MTF Shell Commands
 */
static void dump_wlan_add_usage()
{
	wmprintf("Usage:\r\n");
	wmprintf("For Station interface\r\n");
	wmprintf("  For DHCP IP Address assignment:\r\n");
	wmprintf("    wlan-add <profile_name> ssid <ssid> [wpa2 <secret>]"
		"\r\n");
	wmprintf("  For static IP address assignment:\r\n");
	wmprintf("    wlan-add <profile_name> ssid <ssid>\r\n"
		 "    ip:<ip_addr>,<gateway_ip>,<netmask>\r\n");
	wmprintf("    [bssid <bssid>] [channel <channel number>]\r\n"
		 "    [wpa2 <secret>]\r\n");

	wmprintf("For Micro-AP interface\r\n");
	wmprintf("    wlan-add <profile_name> ssid <ssid>\r\n"
		 "    ip:<ip_addr>,<gateway_ip>,<netmask>\r\n");
	wmprintf("    role uap [bssid <bssid>]\r\n"
		 "    [channel <channelnumber>]\r\n");
	wmprintf("    [wpa2 <secret>]\r\n");

}
示例#19
0
static void on_connection_restored()
{
    wmprintf("connection to cloud restored\n\r");
}
示例#20
0
static void dump_wlan_set_regioncode_usage()
{
	wmprintf("Usage:\r\n");
	wmprintf("wlan-set-regioncode <region-code>\r\n");
	wmprintf("where, region code =\r\n");
	wmprintf("0x10 : US FCC, Singapore\r\n");
	wmprintf("0x20 : IC Canada\r\n");
	wmprintf("0x30 : ETSI, Australia, Republic of Korea\r\n");
	wmprintf("0x32 : France\r\n");
	wmprintf("0x40 : Japan\r\n");
	wmprintf("0x41 : Japan\r\n");
	wmprintf("0x50 : China\r\n");
	wmprintf("0xFE : Japan\r\n");
	wmprintf("0xFF : Special\r\n");
}
示例#21
0
static void wlan_ieeeps_usage_help()
{
	wmprintf("Usage:\r\n");
	wmprintf("pm-ieeeps-hs-cfg <enabled> "
		 "<wakeup condition>\r\n");
	wmprintf("enabled: 1 to enable\r\n");
	wmprintf("\t 0 to disable\r\n");
	wmprintf("wakeup conditions :");
	wmprintf("host wakeup conditions\r\n");
	wmprintf("\tbit0=1: broadcast data\r\n");
	wmprintf("\tbit1=1: unicast data\r\n");
	wmprintf("\tbit2=1: mac events\r\n");
	wmprintf("\tbit3=1: multicast data\r\n");
	wmprintf("\tbit4=1: arp broadcast data\r\n");
}
示例#22
0
void test_wlan_add(int argc, char **argv)
{
	struct wlan_network network;
	int ret = 0;
	int arg = 1;
	struct {
		unsigned ssid:1;
		unsigned bssid:1;
		unsigned channel:1;
		unsigned address:2;
		unsigned security:1;
		unsigned role:1;
	} info;

	memset(&info, 0, sizeof(info));
	memset(&network, 0, sizeof(struct wlan_network));

	if (argc < 4) {
		dump_wlan_add_usage();
		wmprintf("Error: invalid number of arguments\r\n");
		return;
	}

	if (strlen(argv[arg]) >= WLAN_NETWORK_NAME_MAX_LENGTH) {
		wmprintf("Error: network name too long\r\n");
		return;
	}

	memcpy(network.name, argv[arg], strlen(argv[arg]));
	arg++;
	info.address = ADDR_TYPE_DHCP;
	do {
		if (!info.ssid && string_equal("ssid", argv[arg])) {
			if (strlen(argv[arg + 1]) > IEEEtypes_SSID_SIZE) {
				wmprintf("Error: SSID is too long\r\n");
				return;
			}
			memcpy(network.ssid, argv[arg + 1],
			       strlen(argv[arg + 1]));
			arg += 2;
			info.ssid = 1;
		} else if (!info.bssid && string_equal("bssid", argv[arg])) {
			ret = get_mac(argv[arg + 1], network.bssid, ':');
			if (ret) {
				wmprintf("Error: invalid BSSID argument"
					"\r\n");
				return;
			}
			arg += 2;
			info.bssid = 1;
		} else if (!info.channel && string_equal("channel", argv[arg])) {
			if (arg + 1 >= argc ||
			    get_uint(argv[arg + 1], &network.channel,
				     strlen(argv[arg + 1]))) {
				wmprintf("Error: invalid channel"
					" argument\n");
				return;
			}
			arg += 2;
			info.channel = 1;
		} else if (!strncmp(argv[arg], "ip:", 3)) {
			ret = get_address(argv[arg], &network.address);
			if (ret) {
				wmprintf("Error: invalid address"
					" argument\n");
				return;
			}
			arg++;
			info.address = ADDR_TYPE_STATIC;
		} else if (!info.security && string_equal("wep", argv[arg])) {
			ret =
				get_security(argc - arg - 1,
					     (char **)(argv + arg + 1),
					     WLAN_SECURITY_WEP_OPEN,
					     &network.security);
			if (ret) {
				wmprintf("Error: invalid WEP security"
					" argument\r\n");
				return;
			}
			arg += 3;
			info.security++;
		} else if (!info.security && string_equal("wpa", argv[arg])) {
			ret =
			    get_security(argc - arg - 1, argv + arg + 1,
					 WLAN_SECURITY_WPA, &network.security);
			if (ret) {
				wmprintf("Error: invalid WPA security"
					" argument\r\n");
				return;
			}
			arg += 2;
			info.security++;
		} else if (!info.security && string_equal("wpa2", argv[arg])) {
			ret =
			    get_security(argc - arg - 1, argv + arg + 1,
					 WLAN_SECURITY_WPA2, &network.security);
			if (ret) {
				wmprintf("Error: invalid WPA2 security"
					" argument\r\n");
				return;
			}
			arg += 2;
			info.security++;
		} else if (!info.role && string_equal("role", argv[arg])) {
			if (arg + 1 >= argc ||
			    get_role(argv[arg + 1], &network.role)) {
				wmprintf("Error: invalid wireless"
					" network role\r\n");
				return;
			}
			arg += 2;
			info.role++;
		} else if (!strncmp(argv[arg], "autoip", 6)) {
			info.address = ADDR_TYPE_LLA;
			arg++;
		} else {
			dump_wlan_add_usage();
			wmprintf("Error: argument %d is invalid\r\n", arg);
			return;
		}
	} while (arg < argc);

	if (!info.ssid && !info.bssid) {
		dump_wlan_add_usage();
		wmprintf("Error: specify at least the SSID or BSSID\r\n");
		return;
	}

	network.address.addr_type = info.address;

	ret = wlan_add_network(&network);
	switch (ret) {
	case WLAN_ERROR_NONE:
		wmprintf("Added \"%s\"\r\n", network.name);
		break;
	case WLAN_ERROR_PARAM:
		wmprintf("Error: that network already exists\r\n");
		break;
	case WLAN_ERROR_NOMEM:
		wmprintf("Error: network list is full\r\n");
		break;
	case WLAN_ERROR_STATE:
		wmprintf("Error: can't add networks in this state\r\n");
		break;
	default:
		wmprintf("Error: unable to add network for unknown"
			" reason\r\n");
		break;
	}
}
示例#23
0
static void test_wlan_stat(int argc, char **argv)
{
	enum wlan_connection_state state;
	enum wlan_ps_mode ps_mode;
	enum wlan_uap_ps_mode ps_mode_uap;
	char ps_mode_str[12];

	if (wlan_get_ps_mode(&ps_mode)) {
		wmprintf("Error: unable to get power save"
				" mode\r\n");
		return;
	}

	switch (ps_mode) {
	case WLAN_IEEE:
		strcpy(ps_mode_str, "IEEE ps");
		break;
	case WLAN_DEEP_SLEEP:
		strcpy(ps_mode_str, "Deep sleep");
		break;
	case WLAN_PDN:
		strcpy(ps_mode_str, "Power down");
		break;
	case WLAN_ACTIVE:
	default:
		strcpy(ps_mode_str, "Active");
		break;
	}

	if (wlan_get_connection_state(&state)) {
		wmprintf("Error: unable to get STA connection"
						" state\r\n");
	} else {
		if (ps_mode != WLAN_PDN) {
			switch (state) {
			case WLAN_DISCONNECTED:
				wmprintf("Station disconnected (%s)\r\n",
					 ps_mode_str);
				break;
			case WLAN_SCANNING:
				wmprintf("Station scanning (%s)\r\n",
					ps_mode_str);
				break;
			case WLAN_ASSOCIATING:
				wmprintf("Station associating (%s)\r\n",
					ps_mode_str);
				break;
			case WLAN_ASSOCIATED:
				wmprintf("Station associated (%s)\r\n",
					 ps_mode_str);
				break;
			case WLAN_CONNECTING:
				wmprintf("Station connecting (%s)\r\n",
					ps_mode_str);
				break;
			case WLAN_CONNECTED:
				wmprintf("Station connected (%s)\r\n",
					ps_mode_str);
				break;
			default:
				wmprintf("Error: invalid STA state"
						" %d\r\n", state);
			}
		} else {
			wmprintf
			("Wireless card is in power down mode\r\n");
		}
	}
	if (wlan_get_uap_connection_state(&state)) {
		wmprintf("Error: unable to get uAP connection"
						" state\r\n");
	} else {
		if (ps_mode != WLAN_PDN) {
			switch (state) {
			case WLAN_UAP_STARTED:
				wlan_get_uap_ps_mode(&ps_mode_uap);
				switch (ps_mode_uap) {
				case WLAN_UAP_INACTIVITY_SLEEP:
					strcpy(ps_mode_str, "Inactivity PS");
					break;
				case WLAN_UAP_ACTIVE:
				default:
					strcpy(ps_mode_str, "Active");
					break;
				}
				wmprintf("uAP started (%s)\r\n",
					       ps_mode_str);
				break;
			case WLAN_UAP_STOPPED:
				wmprintf("uAP stopped\r\n");
				break;
			default:
				wmprintf("Error: invalid uAP state"
						" %d\r\n", state);
			}
		}
	}
}
示例#24
0
void test_wlan_disconnect(int argc, char **argv)
{
	if (wlan_disconnect() != WLAN_ERROR_NONE)
		wmprintf("Error: unable to disconnect\r\n");
}
示例#25
0
/* This task configures Evrythng client and connects to the Evrythng cloud  */
static void evrythng_task()
{
    psm_handle_t handle;
    int rc;

    if ((rc = psm_open(&handle, "evrythng")) != 0)
    {
        wmprintf("psm_open failed with: %d (Is the module name registered?)\n\r", rc);
        goto exit;
    }

    char api_key[128];
    if (psm_get(&handle, "api_key", api_key, 128) == 0)
    {
        wmprintf("api_key: %s\n\r", api_key);
    }
    else
    {
        wmprintf("api_key doesn't exist\n\r");
        goto exit;
    }

    char thng_id_buf[64];
    if (psm_get(&handle, "thng_id", thng_id_buf, 64) == 0)
    {
        if (thng_id != NULL)
        {
            os_mem_free(thng_id);
        }
        thng_id = (char*)os_mem_alloc((strlen(thng_id_buf)+1)*sizeof(char));
        strcpy(thng_id, thng_id_buf);
        wmprintf("thng_id: %s\n\r", thng_id);
    }
    else
    {
        wmprintf("thng_id doesn't exist\n\r");
        goto exit;
    }

    char url_buf[64];
    if (psm_get(&handle, "url", url_buf, 64) == 0)
    {
        wmprintf("Evrythng URL: %s\n\r", url_buf);
    }
    else
    {
        wmprintf("Evrythng URL doesn't exist\n\r");
        goto exit;
    }
    psm_close(&handle);

    EvrythngInitHandle(&evt_handle);
    EvrythngSetUrl(evt_handle, url_buf);
    EvrythngSetKey(evt_handle, api_key);
    EvrythngSetLogCallback(evt_handle, log_callback);
    EvrythngSetConnectionCallbacks(evt_handle, on_connection_lost, on_connection_restored);

    while (EvrythngConnect(evt_handle) != EVRYTHNG_SUCCESS)
    {
        wmprintf("Retry\n\r");
        os_thread_sleep(os_msec_to_ticks(5000));
    }
    wmprintf("Connected\n\r");

    os_semaphore_create_counting(&button1_sem, "button1_sem", 1000, 0);
    os_semaphore_create_counting(&button2_sem, "button1_sem", 1000, 0);

    EvrythngSubThngAction(evt_handle, thng_id, "_led1", 0, action_led_callback);
    EvrythngSubThngAction(evt_handle, thng_id, "_led2", 0, action_led_callback);

    os_thread_create(&button1_thread, "button1_task", button_task, (void*)button_1, &button_stack, OS_PRIO_3);
    os_thread_create(&button2_thread, "button2_task", button_task, (void*)button_2, &button_stack, OS_PRIO_3);

exit:
    os_thread_self_complete(0);
}
示例#26
0
文件: main.c 项目: caoguanqiu/midir
static void modules_init()
{
    int ret;
    struct partition_entry *p;
    flash_desc_t fl;

    /*
     * Initialize wmstdio prints
     */
    ret = wmstdio_init(UART0_ID, 115200);
    if (ret != WM_SUCCESS) {
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    /* Initialize time subsystem.
     *
     * Initializes time to 1/1/1970 epoch 0.
     */
    ret = wmtime_init();
    if (ret != WM_SUCCESS) {
        wmprintf("Error: wmtime_init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    /*
     * Initialize CLI Commands
     */
    ret = cli_init();
    if (ret != WM_SUCCESS) {
        LOG_ERROR("Error: cli_init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    /* Initialize the partition module */
    ret = part_init();
    if (ret != 0) {
        LOG_ERROR("Failed to initialize partition\r\n");
        appln_critical_error_handler((void *) -WM_FAIL);
    }
    p = part_get_layout_by_id(FC_COMP_PSM, NULL);
    if (!p) {
        LOG_ERROR("Error: no psm partition found");
        appln_critical_error_handler((void *) -WM_FAIL);
    }
    part_to_flash_desc(p, &fl);

#if defined CONFIG_CPU_MC200 && defined CONFIG_WiFi_8801
    //check psm _format
    psm_format_check(&fl);
#endif
    /* Initilize psm module */
    ret = app_psm_init();
    if (ret != 0) {
        LOG_ERROR("Failed to initialize psm module\r\n");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    wmprintf("\n\r");
    wmprintf("_|      _|  _|_|_|  _|_|_|    _|_|  \n\r");
    wmprintf("_|_|  _|_|    _|      _|    _|    _|\n\r");
    wmprintf("_|  _|  _|    _|      _|    _|    _|\n\r");
    wmprintf("_|      _|    _|      _|    _|    _|\n\r");
    wmprintf("_|      _|  _|_|_|  _|_|_|    _|_|  \n\r");
    print_versions();

    read_provision_status();

#ifndef RELEASE
    /* Initilize cli for psm module */
    ret = psm_cli_init();
    if (ret != 0) {
        LOG_ERROR("Failed to register psm-cli commands\r\n");
        appln_critical_error_handler((void *) -WM_FAIL);
    }
#endif

    ret = gpio_drv_init();
    if (ret != WM_SUCCESS) {
        LOG_ERROR("Error: gpio_drv_init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    ret = aes_drv_init();
    if (ret != WM_SUCCESS) {
        LOG_ERROR("Error: aes drv init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    ret = factory_cli_init();
    if (ret != 0) {
        LOG_ERROR("Error: factory_cli_init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

    ret = miio_chip_rpc_init();
    if (ret != 0) {
        LOG_ERROR("Error: miio_chip_rpc_cli_init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

#ifndef RELEASE
    ret = appln_cli_init();
    if (ret != 0) {
        LOG_ERROR("Error: appln init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }
#endif

    /* init add on interface */
    init_addon_interface();

    ret = ota_init();
    if (ret != 0) {
        LOG_ERROR("Error: ota init failed");
        appln_critical_error_handler((void *) -WM_FAIL);
    }

#ifdef MIIO_COMMANDS
    ret = mcmd_create(UART1_ID);
    if (ret < 0) {
        LOG_ERROR("Error: miio command init failed(%d)\r\n", ret);
        appln_critical_error_handler((void *) -WM_FAIL);
    }
#endif

    /*
	* Initialize Power Management Subsystem
	*/
	ret = pm_init();
	if (ret != WM_SUCCESS) {
		LOG_ERROR("Error: pm_init failed");
		appln_critical_error_handler((void *) -WM_FAIL);
	}

}
示例#27
0
static void on_connection_lost()
{
    wmprintf("connection to cloud lost\n\r");
}
示例#28
0
static void print_network(struct wlan_network *network)
{
	wmprintf("\"%s\"\r\n\tSSID: %s\r\n\tBSSID: ", network->name,
		 network->ssid[0] ? network->ssid : "(hidden)");
	print_mac(network->bssid);
	if (network->channel)
		wmprintf("\r\n\tchannel: %d", network->channel);
	else
		wmprintf("\r\n\tchannel: %s", "(Auto)");
	wmprintf("\r\n\trole: %s\r\n", print_role(network->role));

	char *sec_tag = "\tsecurity";
	if (!network->security_specific) {
		sec_tag = "\tsecurity [Wildcard]";
	}
	switch (network->security.type) {
	case WLAN_SECURITY_NONE:
		wmprintf("%s: none\r\n", sec_tag);
		break;
	case WLAN_SECURITY_WEP_OPEN:
		wmprintf("%s: WEP (open)\r\n", sec_tag);
		break;
	case WLAN_SECURITY_WEP_SHARED:
		wmprintf("%s: WEP (shared)\r\n", sec_tag);
		break;
	case WLAN_SECURITY_WPA:
		wmprintf("%s: WPA\r\n", sec_tag);
		break;
	case WLAN_SECURITY_WPA2:
		wmprintf("%s: WPA2\r\n", sec_tag);
		break;
	case WLAN_SECURITY_WPA_WPA2_MIXED:
		wmprintf("%s: WPA/WPA2 Mixed\r\n", sec_tag);
		break;
	case WLAN_SECURITY_EAP_TLS:
		wmprintf("%s: (WPA2)EAP-TLS\r\n", sec_tag);
		break;
	default:
		break;
	}

	print_address(&network->address);
}
示例#29
0
/**
 *   @brief This function processes the received buffer
 *     
 *   @param adapter A pointer to mlan_adapter
 *   @param pmbuf     A pointer to the received buffer
 *
 *   @return        MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
 */
mlan_status
wlan_ops_sta_process_rx_packet(IN t_void * adapter, IN pmlan_buffer pmbuf)
{
    pmlan_adapter pmadapter = (pmlan_adapter) adapter;
    mlan_status ret = MLAN_STATUS_SUCCESS;
    RxPD *prx_pd;
    RxPacketHdr_t *prx_pkt;
    pmlan_private priv = pmadapter->priv[pmbuf->bss_index];
    t_u8 ta[MLAN_MAC_ADDR_LENGTH];
    t_u16 rx_pkt_type = 0;
    /* wlan_mgmt_pkt *pmgmt_pkt_hdr = MNULL; */
    ENTER();

    prx_pd = (RxPD *) (pmbuf->pbuf + pmbuf->data_offset);
    /* Endian conversion */
    endian_convert_RxPD(prx_pd);
    rx_pkt_type = prx_pd->rx_pkt_type;
    
    /* Note: We do not have data @ some offset of pbuf. pbuf only has RxPD */
    /* prx_pkt = (RxPacketHdr_t *) ((t_u8 *) prx_pd + prx_pd->rx_pkt_offset); */
    prx_pkt = (RxPacketHdr_t *) pmbuf->pdesc;

    /* wmprintf("%p + %d: O: %d PL: %d DL: %d\n\r", */
    /* 	     pmbuf->pbuf, pmbuf->data_offset, */
    /* 	     prx_pd->rx_pkt_offset, prx_pd->rx_pkt_length, pmbuf->data_len); */

    if ((prx_pd->rx_pkt_offset + prx_pd->rx_pkt_length) >
        (t_u16) pmbuf->data_len) {
        PRINTM(MERROR,
               "Wrong rx packet: len=%d,rx_pkt_offset=%d,"
               " rx_pkt_length=%d\n", pmbuf->data_len, prx_pd->rx_pkt_offset,
               prx_pd->rx_pkt_length);
        pmbuf->status_code = MLAN_ERROR_PKT_SIZE_INVALID;
        ret = MLAN_STATUS_FAILURE;
        wlan_free_mlan_buffer(pmadapter, pmbuf);
        goto done;
    }
    pmbuf->data_len = prx_pd->rx_pkt_offset + prx_pd->rx_pkt_length;

    if (pmadapter->priv[pmbuf->bss_index]->mgmt_frame_passthru_mask &&
        prx_pd->rx_pkt_type == PKT_TYPE_MGMT_FRAME) {
        /* Check if this is mgmt packet and needs to forwarded to app as an
           event */

	    /* fixme */
	    wmprintf("Is a management packet expected here?\n\r");
	    os_enter_critical_section();
	    while(1){}
#ifndef CONFIG_MLAN_WMSDK
    /* Note: We do not have data @ some offset of pbuf. pbuf only has RxPD */
        /* pmgmt_pkt_hdr = */
        /*     (wlan_mgmt_pkt *) ((t_u8 *) prx_pd + prx_pd->rx_pkt_offset); */
	pmgmt_pkt_hdr = (wlan_mgmt_pkt *)pmbuf->pdesc;

        pmgmt_pkt_hdr->frm_len = wlan_le16_to_cpu(pmgmt_pkt_hdr->frm_len);

        if ((pmgmt_pkt_hdr->wlan_header.frm_ctl
             & IEEE80211_FC_MGMT_FRAME_TYPE_MASK) == 0)
            wlan_process_802dot11_mgmt_pkt(pmadapter->priv[pmbuf->bss_index],
                                           (t_u8 *) & pmgmt_pkt_hdr->
                                           wlan_header,
                                           pmgmt_pkt_hdr->frm_len +
                                           sizeof(wlan_mgmt_pkt)
                                           - sizeof(pmgmt_pkt_hdr->frm_len));
        wlan_free_mlan_buffer(pmadapter, pmbuf);
        goto done;
#endif /* CONFIG_MLAN_WMSDK */
    }

#ifdef DUMP_PACKET_MAC
    dump_mac_addr("Own: ", priv->curr_addr);
    dump_mac_addr("Dest: ", prx_pkt->eth803_hdr.dest_addr);
#endif /* DUMP_PACKET_MAC */

    /* 
     * If the packet is not an unicast packet then send the packet
     * directly to os. Don't pass thru rx reordering
     */
    if (!IS_11N_ENABLED(priv) ||
        memcmp(priv->adapter, priv->curr_addr, prx_pkt->eth803_hdr.dest_addr,
               MLAN_MAC_ADDR_LENGTH)) {
        wlan_process_rx_packet(pmadapter, pmbuf);
        goto done;
    }

    if (queuing_ra_based(priv)) {
        memcpy(pmadapter, ta, prx_pkt->eth803_hdr.src_addr,
               MLAN_MAC_ADDR_LENGTH);
    } else {
        if ((rx_pkt_type != PKT_TYPE_BAR) && (prx_pd->priority < MAX_NUM_TID))
            priv->rx_seq[prx_pd->priority] = prx_pd->seq_num;
        memcpy(pmadapter, ta,
               priv->curr_bss_params.bss_descriptor.mac_address,
               MLAN_MAC_ADDR_LENGTH);
    }

    /* Reorder and send to OS */
    if ((ret = mlan_11n_rxreorder_pkt(priv, prx_pd->seq_num,
                                      prx_pd->priority, ta,
                                      (t_u8) prx_pd->rx_pkt_type,
                                      (void *) pmbuf)) ||
        (rx_pkt_type == PKT_TYPE_BAR)
        ) {
        wlan_free_mlan_buffer(pmadapter, pmbuf);
    }

  done:

    LEAVE();
    return (ret);
}
示例#30
0
void dump_rf_channel_info(const wifi_rf_channel_t *prf_channel)
{
	wmprintf("Channel: %d\n\r", prf_channel->current_channel);

	int rf_type = prf_channel->rf_type;
	wmprintf("RF type: %p\n\r", rf_type);
	int band = rf_type & 0x3;
	int channel_width = rf_type & 0xC >> 2;
	int sec_channel_offset = rf_type & 0x30 >> 4;
	wmprintf("Band: ");
	switch (band) {
	case 0:
		wmprintf("2.4 GHz\n\r");
		break;
	case 1:
		wmprintf("5 GHz\n\r");
		break;
	case 2:
		wmprintf("2 GHz\n\r");
		break;
	case 3:
		wmprintf("Reserved\n\r");
		break;
	}

	wmprintf("Channel width: ");
	switch (channel_width) {
	case 0:
		wmprintf("20 MHz\n\r");
		break;
	case 1:
		wmprintf("40 MHz\n\r");
		break;
	default:
		wmprintf("Reserved\n\r");
		break;
	}

	wmprintf("Secondary channel offset:");
	switch (sec_channel_offset) {
	case 0:
		wmprintf("No offset\n\r");
		break;
	case 1:
		wmprintf("Sec. channel above primary\n\r");
		break;
	case 3:
		wmprintf("Reserved\n\r");
		break;
	case 4:
		wmprintf("Sec. channel below primary\n\r");
		break;
	}
}