|
|
@@ -561,10 +561,8 @@ static int nl_get_signal(ap_stat_t *stat)
|
|
|
nl_cb_set(h->cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &err);
|
|
|
nl_cb_set(h->cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &err);
|
|
|
r = nl_cb_set(h->cb, NL_CB_VALID, NL_CB_CUSTOM, callback_stat, stat);
|
|
|
- printf("_______________stat 111, %d\n", r);
|
|
|
|
|
|
- r = genlmsg_put(h->msg, NL_AUTO_PORT, NL_AUTO_SEQ, h->nl_id, 0, NLM_F_DUMP, NL80211_CMD_GET_STATION, 0); // Setup which command to run.
|
|
|
- printf("_______________stat 222, %d\n", r);
|
|
|
+ genlmsg_put(h->msg, NL_AUTO_PORT, NL_AUTO_SEQ, h->nl_id, 0, NLM_F_DUMP, NL80211_CMD_GET_STATION, 0); // Setup which command to run.
|
|
|
|
|
|
nla_put_u32(h->msg, NL80211_ATTR_IFINDEX, h->ifindex); // Add message attribute, which interface to use.
|
|
|
r = nl_send_auto(h->sock, h->msg);
|
|
|
@@ -687,12 +685,12 @@ static int nl_disconn(void)
|
|
|
|
|
|
return r;
|
|
|
}
|
|
|
-static int nl_set_link(int on)
|
|
|
+static int nl_link(int on)
|
|
|
{
|
|
|
int r,fd;
|
|
|
struct ifreq ifr;
|
|
|
|
|
|
- fd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
|
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
|
|
|
if (fd>=0) {
|
|
|
strcpy(ifr.ifr_name, WLAN_IFNAME);
|
|
|
r = ioctl(fd, SIOCGIFFLAGS, &ifr);
|
|
|
@@ -755,12 +753,14 @@ int wifi_set(WIFIManager *wm)
|
|
|
wifi_handle_t *h=&wfHandle;
|
|
|
|
|
|
#ifdef USE_WIFI
|
|
|
- r = nl_set_link(wm->mode);
|
|
|
+ r = nl_link(wm->mode);
|
|
|
if(wm->mode) {
|
|
|
memset(&info, 0, sizeof(info));
|
|
|
|
|
|
strcpy(info.ssid, wm->WIFI_name);
|
|
|
strcpy(info.password, wm->WIFI_code);
|
|
|
+
|
|
|
+ sta_start(&info, 0);
|
|
|
r = sta_start(&info, 1);
|
|
|
}
|
|
|
else {
|
|
|
@@ -801,7 +801,7 @@ int wifi_sta_stat(ap_stat_t *stat)
|
|
|
if(r==0) {
|
|
|
stat->link = 1; //不知道何原因导致获取信号强度的回调函数触发不了,暂时绕过
|
|
|
}
|
|
|
- //printf("______ link: %d, signal: %d, ip: %s\n", stat->link, stat->signal, stat->ipaddr);
|
|
|
+ printf("______ link: %d, signal: %d, ip: %s\n", stat->link, stat->signal, stat->ipaddr);
|
|
|
#endif
|
|
|
|
|
|
return r;
|