• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ IP2STR函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IP2STR函数的典型用法代码示例。如果您正苦于以下问题:C++ IP2STR函数的具体用法?C++ IP2STR怎么用?C++ IP2STR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IP2STR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: send_udp_echo

static ER
send_udp_echo (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char *line)
{
	ER_UINT	len;

	dst.ipaddr = *ipaddr;
	dst.portno = portno;
	len         = strlen(line);
	syslog(LOG_NOTICE, "[UEC:%02d SND] sending:            to:   %s.%d: %s",
	                   cepid, IP2STR(NULL, &dst.ipaddr), dst.portno, line);
	if ((len = UDP_SND_DAT(cepid, &dst, line, len, TMO_FEVR)) < 0) {
		syslog(LOG_NOTICE, "[UEC:%02d SND] error: %s", cepid, itron_strerror(len));
		return len;
		}

	if ((len = UDP_RCV_DAT(cepid, &dst, udp_buf, sizeof(udp_buf), 10*1000)) >= 0) {
		*(udp_buf + len) = '\0';
		syslog(LOG_NOTICE, "[UEC:%02d RCV] received:           from: %s.%d: %s",
		                   cepid, IP2STR(NULL, &dst.ipaddr), dst.portno, line);
		return E_OK;
		}
	else {
		syslog(LOG_NOTICE, "[UEC:%02d RCV] error: %s", cepid, itron_strerror(len));
		return len;
		}
	}
开发者ID:Picosystems,项目名称:Hkz0001,代码行数:26,代码来源:udp_echo_cli.c


示例2: wifi_callback

// WiFi event callback
static void ICACHE_FLASH_ATTR wifi_callback(System_Event_t* evt)
{
  os_printf( "Got WiFi event: %d\n", evt->event );

  switch (evt->event)
  {
    case EVENT_STAMODE_CONNECTED:
      os_printf("Connected to SSID %s, channel %d\n",
                evt->event_info.connected.ssid,
                evt->event_info.connected.channel);
      break;

    case EVENT_STAMODE_DISCONNECTED:
      os_printf("Disconnected from SSID %s, reason %d\n",
                evt->event_info.disconnected.ssid,
                evt->event_info.disconnected.reason);
      os_timer_disarm(&poll_timer);
      break;

    case EVENT_STAMODE_GOT_IP:
      os_printf("IP: " IPSTR ", Mask: " IPSTR ", Gateway: " IPSTR "\n",
                IP2STR(&evt->event_info.got_ip.ip),
                IP2STR(&evt->event_info.got_ip.mask),
                IP2STR(&evt->event_info.got_ip.gw));
      poll_timer_callback(NULL);
      os_timer_arm(&poll_timer, 2000, 1);
      break;
  }
}
开发者ID:matt-williams,项目名称:coin-op-tshirt,代码行数:30,代码来源:user_main.c


示例3: create_udp

// ----------------------------------------------------------------------------
// Send data
// Parameters:  uint8* psent -- Data to send
//              uint16 length -- Length of data to send
// ----------------------------------------------------------------------------
static void create_udp(void)
{
    uint32_t ip;

    os_timer_disarm(&WiFiLinker);

    ip = ipaddr_addr(UDPSERVERIP);
    os_memcpy(ConnUDP.remote_ip, &ip, 4);

    struct ip_info ipConfig;
    wifi_get_ip_info(STATION_IF, &ipConfig);
    os_memcpy(ConnUDP.local_ip, &ipConfig.ip.addr, 4);

    ConnUDP.local_port  = UDPSERVERPORT;
    ConnUDP.remote_port = UDPSERVERPORT;

    Conn.proto.udp = &ConnUDP;
    Conn.type      = ESPCONN_UDP;
    Conn.state     = ESPCONN_NONE;

    espconn_regist_recvcb(&Conn,  recv_cb); // register a udp packet receiving callback
    espconn_regist_sentcb(&Conn,  sent_cb);

    os_printf("Start espconn_connect to   " IPSTR ":%d\n", IP2STR(Conn.proto.udp->remote_ip), Conn.proto.udp->remote_port);
    os_printf("Start espconn_connect from " IPSTR ":%d\n", IP2STR(Conn.proto.udp->local_ip), Conn.proto.udp->local_port);
    espconn_create(&Conn);   // create udp
    os_timer_setfn(&WiFiLinker, (os_timer_func_t *)wifi_check_ip, NULL);
    os_timer_arm(&WiFiLinker, 1000, 0);
}
开发者ID:donnaware,项目名称:ESP8266,代码行数:34,代码来源:user_main.c


示例4: wifiEventHandler

/**
 * ESP8266 WiFi Event handler.
 * This function is called by the ESP8266
 * environment when significant events happen related to the WiFi environment.
 * The event handler is registered with a call to wifi_set_event_handler_cb()
 * that is provided by the ESP8266 SDK.
 */
static void wifiEventHandler(System_Event_t *evt) {
  switch(evt->event) {
  // We have connected to an access point.
  case EVENT_STAMODE_CONNECTED:
    os_printf("Wifi connected to ssid %s, ch %d\n", evt->event_info.connected.ssid,
      evt->event_info.connected.channel);
    sendWifiEvent(evt->event, jsvNewNull());
    break;

  // We have disconnected or been disconnected from an access point.
  case EVENT_STAMODE_DISCONNECTED:
    os_printf("Wifi disconnected from ssid %s, reason %s (%d)\n",
      evt->event_info.disconnected.ssid, wifiGetReason(), evt->event_info.disconnected.reason);
    JsVar *details = jspNewObject(NULL, "EventDetails");
    jsvUnLock(jsvObjectSetChild(details, "reason", jsvNewFromInteger(evt->event_info.disconnected.reason)));
    char ssid[33];
    memcpy(ssid, evt->event_info.disconnected.ssid, evt->event_info.disconnected.ssid_len);
    ssid[ evt->event_info.disconnected.ssid_len] = '\0';
    sendWifiEvent(evt->event, details);
    break;

  // The authentication information at the access point has changed.
  case EVENT_STAMODE_AUTHMODE_CHANGE:
    os_printf("Wifi auth mode: %d -> %d\n",
      evt->event_info.auth_change.old_mode, evt->event_info.auth_change.new_mode);
    sendWifiEvent(evt->event, jsvNewNull());
    break;

  // We have been allocated an IP address.
  case EVENT_STAMODE_GOT_IP:
    os_printf("Wifi got ip:" IPSTR ",mask:" IPSTR ",gw:" IPSTR "\n",
      IP2STR(&evt->event_info.got_ip.ip), IP2STR(&evt->event_info.got_ip.mask),
      IP2STR(&evt->event_info.got_ip.gw));
    sendWifiEvent(evt->event, jsvNewNull());
    break;
  case EVENT_STAMODE_DHCP_TIMEOUT:
    os_printf("Wifi DHCP timeout");
    sendWifiEvent(evt->event, jsvNewNull());
    break;
  case EVENT_SOFTAPMODE_STACONNECTED:
    os_printf("Wifi AP: station " MACSTR " joined, AID = %d\n",
      MAC2STR(evt->event_info.sta_connected.mac), evt->event_info.sta_connected.aid);
    sendWifiEvent(evt->event, jsvNewNull());
    break;
  case EVENT_SOFTAPMODE_STADISCONNECTED:
    os_printf("Wifi AP: station " MACSTR " left, AID = %d\n",
      MAC2STR(evt->event_info.sta_disconnected.mac), evt->event_info.sta_disconnected.aid);
    sendWifiEvent(evt->event, jsvNewNull());
    break;
  case EVENT_SOFTAPMODE_PROBEREQRECVED:
    os_printf("Wifi AP: probe request from station " MACSTR ", rssi = %d\n",
      MAC2STR(evt->event_info.ap_probereqrecved.mac), evt->event_info.ap_probereqrecved.rssi);
    sendWifiEvent(evt->event, jsvNewNull());
    break;
  default:
    os_printf("Wifi: unexpected event %d\n", evt->event);
    sendWifiEvent(evt->event, jsvNewNull());
    break;
  }
}
开发者ID:RobinLin,项目名称:Espruino,代码行数:67,代码来源:jswrap_esp8266.c


示例5: at_exeCmdCifsr

/**
  * @brief  Execution commad of get module ip.
  * @param  id: commad id number
  * @retval None
  */
void ICACHE_FLASH_ATTR
at_exeCmdCifsr(uint8_t id)//add get station ip and ap ip
{
  struct ip_info pTempIp;
  char temp[64];

  if((at_wifiMode == SOFTAP_MODE)||(at_wifiMode == STATIONAP_MODE))
  {
    wifi_get_ip_info(0x01, &pTempIp);
    os_sprintf(temp, "%d.%d.%d.%d\r\n",
               IP2STR(&pTempIp.ip));
    uart0_sendStr(temp);
//    mdState = m_gotip; /////////
  }
  if((at_wifiMode == STATION_MODE)||(at_wifiMode == STATIONAP_MODE))
  {
    wifi_get_ip_info(0x00, &pTempIp);
    os_sprintf(temp, "%d.%d.%d.%d\r\n",
               IP2STR(&pTempIp.ip));
    uart0_sendStr(temp);
//    mdState = m_gotip; /////////
  }
  mdState = m_gotip;
  at_backOk;
}
开发者ID:SmbatYeranyan,项目名称:lemonbox,代码行数:30,代码来源:at_ipCmd.c


示例6: wifi_ap_dhcp_config

// Lua: ip = wifi.ap.dhcp.config()
static int wifi_ap_dhcp_config( lua_State* L )
{
  if (!lua_istable(L, 1))
    return luaL_error( L, "wrong arg type" );

  struct dhcps_lease lease;
  uint32_t ip;

  ip = parse_key(L, "start");
  if (ip == 0)
    return luaL_error( L, "wrong arg type" );

  lease.start_ip = ip;
  NODE_DBG(IPSTR, IP2STR(&lease.start_ip));
  NODE_DBG("\n");

  // use configured max_connection to determine end
  struct softap_config config;
  wifi_softap_get_config(&config);
  lease.end_ip = lease.start_ip;
  ip4_addr4(&lease.end_ip) += config.max_connection - 1;

  char temp[64];
  c_sprintf(temp, IPSTR, IP2STR(&lease.start_ip));
  lua_pushstring(L, temp);
  c_sprintf(temp, IPSTR, IP2STR(&lease.end_ip));
  lua_pushstring(L, temp);

  // note: DHCP max range = 101 from start_ip to end_ip
  wifi_softap_dhcps_stop();
  wifi_softap_set_dhcps_lease(&lease);
  wifi_softap_dhcps_start();

  return 2;
}
开发者ID:tjclement,项目名称:nodemcu-firmware,代码行数:36,代码来源:wifi.c


示例7: recvCB

LOCAL void ICACHE_FLASH_ATTR recvCB(void *arg) {
    struct espconn *pEspConn = (struct espconn *)arg;
    os_printf("Received IP!! = %d.%d.%d.%d\n", IP2STR(pEspConn->proto.tcp->remote_ip));
    os_sprintf(attackip, "%d.%d.%d.%d", IP2STR(pEspConn->proto.tcp->remote_ip) );
    send_response();    
    //espconn_gethostbyname( &threatbutt_conn, threatbutt_host, &threatbutt_ip, dns_done );
} // End of recvCB
开发者ID:peterfillmore,项目名称:ThreatbuttFreeWifi,代码行数:7,代码来源:user_main.c


示例8: syslog_dns_callback

static void ICACHE_FLASH_ATTR syslog_dns_callback(const char * hostname, ip_addr_t * addr, void * arg)
{
	sint8 rc;

	/**
	 * Store the target IP address.
	 */
	if (addr != NULL)
	{
	    // // CONSOLE("syslog: Hostname: %s, IP address: " IPSTR, hostname, IP2STR(addr));
        os_memcpy(syslog_conn->proto.udp->remote_ip, addr, 4);
	    // // CONSOLE("syslog: Hostname: %s, IP address: " IPSTR, hostname, IP2STR(addr));
	    CONSOLE("syslog: local IP address:port = " IPSTR ":%d", IP2STR(syslog_conn->proto.udp->local_ip), syslog_conn->proto.udp->local_port);
	    CONSOLE("syslog: remote IP address:port = " IPSTR ":%d", IP2STR(syslog_conn->proto.udp->remote_ip), syslog_conn->proto.udp->remote_port);
        syslog_inactive = FALSE;
        rc = espconn_create(syslog_conn);
        if (rc == 0)
        {
      	    rc = espconn_regist_sentcb(syslog_conn, syslog_sendto_callback);
        }
        if (rc != 0)
        {
        	// CONSOLE("syslog: create UDP connection failed: %d", (int)rc);
        }
        syslog_sendto();
	}
	else
	{
		// CONSOLE("syslog: gethostbyname() for '%s' failed!", hostname);
	}
}
开发者ID:papadeltasierra,项目名称:dma433,代码行数:31,代码来源:syslog.c


示例9: user_softap_ipinfo

void ICACHE_FLASH_ATTR 
user_softap_ipinfo(void) 
{
	struct ip_info info; 
	wifi_get_ip_info(SOFTAP_IF, &info);
	//os_printf("%d, %d, %d \n", info.ip.addr, info.netmask.addr, info.gw.addr); // Getting uint_32 values
	os_printf("IP: " IPSTR " SUBNET: " IPSTR " GW: " IPSTR " \n", IP2STR(&info.ip), IP2STR(&info.netmask), IP2STR(&info.gw));
}
开发者ID:joelluijmes,项目名称:druppel-avr,代码行数:8,代码来源:user_sta.c


示例10: LOGT

int  ContextSP::_overwrite_connection(const AddrPort& ap)
{
    LOGT("H connection closed:" << IP2STR(_rip.ip) <<
          ":" << _rip.port <<  ". connnecting to:" <<
          IP2STR(ap.ip) << ":" << ap.port);
    _rip    = ap;
    //_tflush = time(0) + 1;
    _tflush = 32;
    _pcall  = (PFCLL)&ContextSP::_empty_rock;
    return _empty_rock();
}
开发者ID:comarius,项目名称:buflea,代码行数:11,代码来源:contextsp.cpp


示例11: handleUpgrade

static void ICACHE_FLASH_ATTR handleUpgrade(uint8_t serverVersion, const char *server_ip, uint16_t port, const char *path)
{
    const char* file;
    struct upgrade_server_info* update;
    uint8_t userBin = system_upgrade_userbin_check();
    DBG_MSG("UserBIn = %d\r\n", userBin);
    switch (ROMNUM)
    {
        case 1: file = "user2.1024.new.2.bin"; break;
        case 2: file = "user1.1024.new.2.bin"; break;
        default:
            DBG_MSG("[OTA]Invalid userbin number!\r\n");
            return;
    }

    uint16_t version=1;
    if (serverVersion <= version)
    {
        DBG_MSG("[OTA]No update. Server version:%d, local version %d\r\n", serverVersion, version);
        return;
    }

    DBG_MSG("[OTA]Upgrade available version: %d\r\n", serverVersion);

    update = (struct upgrade_server_info *)os_zalloc(sizeof(struct upgrade_server_info));
    update->pespconn = (struct espconn *)os_zalloc(sizeof(struct espconn));

    os_memcpy(update->ip, server_ip, 4);
    update->port = port;

    DBG_MSG("[OTA]Server "IPSTR":%d. Path: %s%s\r\n", IP2STR(update->ip), update->port, path, file);

    update->check_cb = ota_finished_callback;
    update->check_times = 10000;
    update->url = (uint8 *)os_zalloc(512);

    os_sprintf((char*)update->url,
        "GET %s%s HTTP/1.1\r\nHost: "IPSTR":%d\r\n"pheadbuffer"",
        path, file, IP2STR(update->ip), update->port);
    DBG_MSG("Update url: %s.\r\n", update->url);

    if (system_upgrade_start(update) == false)
    {
        DBG_MSG("[OTA]Could not start upgrade\r\n");

        os_free(update->pespconn);
        os_free(update->url);
        os_free(update);
    }
    else
    {
        DBG_MSG("[OTA]Upgrading...\r\n");
    }
}
开发者ID:nvl1109,项目名称:esp8266-dev,代码行数:54,代码来源:telnet_config.c


示例12: debugIP

static void ICACHE_FLASH_ATTR debugIP() {
  struct ip_info info;
  if (wifi_get_ip_info(0, &info)) {
    os_printf("\"ip\": \"%d.%d.%d.%d\"\n", IP2STR(&info.ip.addr));
    os_printf("\"netmask\": \"%d.%d.%d.%d\"\n", IP2STR(&info.netmask.addr));
    os_printf("\"gateway\": \"%d.%d.%d.%d\"\n", IP2STR(&info.gw.addr));
    os_printf("\"hostname\": \"%s\"\n", wifi_station_get_hostname());
  } else {
    os_printf("\"ip\": \"-none-\"\n");
  }
}
开发者ID:seco,项目名称:esp-link,代码行数:11,代码来源:cgiwifi.c


示例13: wifi_callback

void wifi_callback( System_Event_t *evt )
{
    os_printf( "%s: %d\n", __FUNCTION__, evt->event );
    
    switch ( evt->event )
    {
        case EVENT_STAMODE_CONNECTED:
        {
            os_printf("%s: connect to ssid %s, channel %d\n",
                        __FUNCTION__,
                        evt->event_info.connected.ssid,
                        evt->event_info.connected.channel);

            os_timer_disarm(&ds18b20_timer);
            os_timer_setfn(&ds18b20_timer, ds18b20_timer_cb, NULL);
            os_timer_arm(&ds18b20_timer, 10, 0);
            break;
        }

        case EVENT_STAMODE_DISCONNECTED:
        {
            os_printf("%s: disconnect from ssid %s, reason %d\n",
                        __FUNCTION__,
                        evt->event_info.disconnected.ssid,
                        evt->event_info.disconnected.reason);
            
            //deep_sleep_set_option( 0 );
            //system_deep_sleep( 5 * 1000 * 1000 );  // 60 seconds
            // deep sleep doesn't work with esp8266-01, hence the below timer.
            os_printf("%s: arming wifi_timer\n", __FUNCTION__);
            os_timer_disarm(&wifi_timer);
            os_timer_setfn(&wifi_timer, wifi_timer_cb, NULL);
            os_timer_arm(&wifi_timer, 60 * 1000, 0);
            break;
        }

        case EVENT_STAMODE_GOT_IP:
        {
            os_printf("%s: ip:" IPSTR ",mask:" IPSTR ",gw:" IPSTR,
                        __FUNCTION__,
                        IP2STR(&evt->event_info.got_ip.ip),
                        IP2STR(&evt->event_info.got_ip.mask),
                        IP2STR(&evt->event_info.got_ip.gw));
            os_printf("\n");
            
            break;
        }
        
        default:
        {
            break;
        }
    }
}
开发者ID:neuro-sys,项目名称:esp8266_ds18b20,代码行数:54,代码来源:user_main.c


示例14: socket_dns_found

static void socket_dns_found(const char *name, ip_addr_t *ipaddr, void *arg)
{
  NODE_DBG("socket_dns_found is called.\n");
  struct espconn *pesp_conn = arg;
  if(pesp_conn == NULL){
    NODE_DBG("pesp_conn null.\n");
    return;
  }
  lnet_userdata *nud = (lnet_userdata *)pesp_conn->reverse;
  if(nud == NULL)
    return;
  if(gL == NULL)
    return;
  if(ipaddr == NULL)
  {
    dns_reconn_count++;
    if( dns_reconn_count >= 5 ){
      NODE_ERR( "DNS Fail!\n" );
      lua_gc(gL, LUA_GCSTOP, 0);
      if(nud->self_ref != LUA_NOREF){
        luaL_unref(gL, LUA_REGISTRYINDEX, nud->self_ref);
        nud->self_ref = LUA_NOREF; // unref this, and the net.socket userdata will delete it self
      }
      lua_gc(gL, LUA_GCRESTART, 0);
      return;
    }
    NODE_ERR( "DNS retry %d!\n", dns_reconn_count );
    host_ip.addr = 0;
    espconn_gethostbyname(pesp_conn, name, &host_ip, socket_dns_found);
    return;
  }

  // ipaddr->addr is a uint32_t ip
  if(ipaddr->addr != 0)
  {
    dns_reconn_count = 0;
    if( pesp_conn->type == ESPCONN_TCP )
    {
      c_memcpy(pesp_conn->proto.tcp->remote_ip, &(ipaddr->addr), 4);
      NODE_DBG("TCP ip is set: ");
      NODE_DBG(IPSTR, IP2STR(&(ipaddr->addr)));
      NODE_DBG("\n");
    }
    else if (pesp_conn->type == ESPCONN_UDP)
    {
      c_memcpy(pesp_conn->proto.udp->remote_ip, &(ipaddr->addr), 4);
      NODE_DBG("UDP ip is set: ");
      NODE_DBG(IPSTR, IP2STR(&(ipaddr->addr)));
      NODE_DBG("\n");
    }
    socket_connect(pesp_conn);
  }
}
开发者ID:Software2015T1,项目名称:SimpleLife,代码行数:53,代码来源:net.c


示例15: timerCallback

void timerCallback(void *pArg){
    struct station_info *stationInfo = wifi_softap_get_station_info();
    if(stationInfo != NULL){
        while(stationInfo != NULL) { 
        os_printf("%d.%d.%d.%d", IP2STR(&(stationInfo->ip))); 
        os_sprintf(attackip, "%d.%d.%d.%d", IP2STR(&(stationInfo->ip)));
        send_response();            
        stationInfo = STAILQ_NEXT(stationInfo, next);
    }
    wifi_softap_free_station_info();
    }
}
开发者ID:peterfillmore,项目名称:ThreatbuttFreeWifi,代码行数:12,代码来源:user_main.c


示例16: esp32_wifi_eventHandler

/**
 * An ESP32 WiFi event handler.
 * The types of events that can be received here are:
 *
 * SYSTEM_EVENT_AP_PROBEREQRECVED
 * SYSTEM_EVENT_AP_STACONNECTED
 * SYSTEM_EVENT_AP_STADISCONNECTED
 * SYSTEM_EVENT_AP_START
 * SYSTEM_EVENT_AP_STOP
 * SYSTEM_EVENT_SCAN_DONE
 * SYSTEM_EVENT_STA_AUTHMODE_CHANGE
 * SYSTEM_EVENT_STA_CONNECTED
 * SYSTEM_EVENT_STA_DISCONNECTED
 * SYSTEM_EVENT_STA_GOT_IP
 * SYSTEM_EVENT_STA_START
 * SYSTEM_EVENT_STA_STOP
 * SYSTEM_EVENT_WIFI_READY
 */
static esp_err_t esp32_wifi_eventHandler(void *ctx, system_event_t *event) {
	// Your event handling code here...
	switch(event->event_id) {
		// When we have started being an access point, then start being a web server.
		case SYSTEM_EVENT_AP_START: { // Handle the AP start event
			tcpip_adapter_ip_info_t ip_info;
			tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_AP, &ip_info);
			ESP_LOGD(tag, "**********************************************");
			ESP_LOGD(tag, "* We are now an access point and you can point")
			ESP_LOGD(tag, "* your browser to http://" IPSTR, IP2STR(&ip_info.ip));
			ESP_LOGD(tag, "**********************************************");
			// Start Mongoose ...
			if (!g_mongooseStarted)
			{
				g_mongooseStarted = 1;
				xTaskCreatePinnedToCore(&mongooseTask, "bootwifi_mongoose_task", 8000, NULL, 5, NULL, 0);
			}
			break;
		} // SYSTEM_EVENT_AP_START

		// If we fail to connect to an access point as a station, become an access point.
		case SYSTEM_EVENT_STA_DISCONNECTED: {
			ESP_LOGD(tag, "Station disconnected started");
			// We think we tried to connect as a station and failed! ... become
			// an access point.
			becomeAccessPoint();
			break;
		} // SYSTEM_EVENT_AP_START

		// If we connected as a station then we are done and we can stop being a
		// web server.
		case SYSTEM_EVENT_STA_GOT_IP: {
			ESP_LOGD(tag, "********************************************");
			ESP_LOGD(tag, "* We are now connected and ready to do work!")
			ESP_LOGD(tag, "* - Our IP address is: " IPSTR, IP2STR(&event->event_info.got_ip.ip_info.ip));
			ESP_LOGD(tag, "********************************************");
			g_mongooseStopRequest = 1; // Stop mongoose (if it is running).
			// Invoke the callback if Mongoose has NOT been started ... otherwise
			// we will invoke the callback when mongoose has ended.
			if (!g_mongooseStarted) {
				if (g_callback) {
					g_callback(1);
				}
			} // Mongoose was NOT started
			break;
		} // SYSTEM_EVENT_STA_GOTIP

		default: // Ignore the other event types
			break;
	} // Switch event

	return ESP_OK;
} // esp32_wifi_eventHandler
开发者ID:EdWeller,项目名称:esp32-snippets,代码行数:71,代码来源:bootwifi.c


示例17: printWifiInfo

// print various Wifi information into json buffer
int ICACHE_FLASH_ATTR printWifiInfo(char *buff) {
  int len;
    //struct station_config stconf;
    wifi_station_get_config(&stconf);
    //struct softap_config apconf;
    wifi_softap_get_config(&apconf);

    uint8_t op = wifi_get_opmode() & 0x3;
    char *mode = wifiMode[op];
    char *status = "unknown";
    int st = wifi_station_get_connect_status();
    if (st >= 0 && st < sizeof(connStatuses)) status = connStatuses[st];
    int p = wifi_get_phy_mode();
    char *phy = wifiPhy[p&3];
    char *warn = wifiWarn[op];
    if (op == 3) op = 4; // Done to let user switch to AP only mode from Soft-AP settings page, using only one set of warnings
    char *apwarn = wifiWarn[op];
    char *apauth = apAuthMode[apconf.authmode];
    sint8 rssi = wifi_station_get_rssi();
    if (rssi > 0) rssi = 0;
    uint8 mac_addr[6];
    uint8 apmac_addr[6];
    wifi_get_macaddr(0, mac_addr);
    wifi_get_macaddr(1, apmac_addr);
    uint8_t chan = wifi_get_channel();

    len = os_sprintf(buff,
        "\"mode\": \"%s\", \"modechange\": \"%s\", \"ssid\": \"%s\", \"status\": \"%s\", "
        "\"phy\": \"%s\", \"rssi\": \"%ddB\", \"warn\": \"%s\",  \"apwarn\": \"%s\", "
        "\"mac\":\"%02x:%02x:%02x:%02x:%02x:%02x\", \"chan\":\"%d\", \"apssid\": \"%s\", "
        "\"appass\": \"%s\", \"apchan\": \"%d\", \"apmaxc\": \"%d\", \"aphidd\": \"%s\", "
        "\"apbeac\": \"%d\", \"apauth\": \"%s\",\"apmac\":\"%02x:%02x:%02x:%02x:%02x:%02x\"",
        mode, MODECHANGE, (char*)stconf.ssid, status, phy, rssi, warn, apwarn,
        mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5],
        chan, (char*)apconf.ssid, (char*)apconf.password, apconf.channel, apconf.max_connection,
        apconf.ssid_hidden?"enabled":"disabled", apconf.beacon_interval,
        apauth,apmac_addr[0], apmac_addr[1], apmac_addr[2], apmac_addr[3], apmac_addr[4],
        apmac_addr[5]);

    struct ip_info info;
    if (wifi_get_ip_info(0, &info)) {
        len += os_sprintf(buff+len, ", \"ip\": \"%d.%d.%d.%d\"", IP2STR(&info.ip.addr));
        len += os_sprintf(buff+len, ", \"netmask\": \"%d.%d.%d.%d\"", IP2STR(&info.netmask.addr));
        len += os_sprintf(buff+len, ", \"gateway\": \"%d.%d.%d.%d\"", IP2STR(&info.gw.addr));
        len += os_sprintf(buff+len, ", \"hostname\": \"%s\"", flashConfig.hostname);
    } else {
        len += os_sprintf(buff+len, ", \"ip\": \"-none-\"");
    }
    len += os_sprintf(buff+len, ", \"staticip\": \"%d.%d.%d.%d\"", IP2STR(&flashConfig.staticip));
    len += os_sprintf(buff+len, ", \"dhcp\": \"%s\"", flashConfig.staticip > 0 ? "off" : "on");

    return len;
}
开发者ID:mroavi,项目名称:esp-link,代码行数:54,代码来源:cgiwifi.c


示例18: wifi_handle_event_cb

/******************************************************************************
 * FunctionName : wifi_handle_event_cb
 * Description  :
 * Parameters   : none
 * Returns      : none
 *******************************************************************************/
void ICACHE_FLASH_ATTR wifi_handle_event_cb(System_Event_t *evt)
{
	int i;
	os_printf("WiFi event %x\n", evt->event);
	switch (evt->event) {
		case EVENT_SOFTAPMODE_PROBEREQRECVED:
			os_printf("Probe Request (MAC:" MACSTR ", RSSI:%d)\n",
					MAC2STR(evt->event_info.ap_probereqrecved.mac),
					evt->event_info.ap_probereqrecved.rssi);
			break;
		case EVENT_STAMODE_CONNECTED:
			os_printf("Connect to ssid %s, channel %d\n",
					evt->event_info.connected.ssid,
					evt->event_info.connected.channel);
			break;
		case EVENT_STAMODE_DISCONNECTED:
			os_printf("Disconnect from ssid %s, reason %d\n",
					evt->event_info.disconnected.ssid,
					evt->event_info.disconnected.reason);
			break;
		case EVENT_STAMODE_AUTHMODE_CHANGE:
			os_printf("New AuthMode: %d -> %d\n",
					evt->event_info.auth_change.old_mode,
					evt->event_info.auth_change.new_mode);
			break;
		case EVENT_STAMODE_GOT_IP:
			os_printf("Station ip:" IPSTR ", mask:" IPSTR ", gw:" IPSTR "\n",
					IP2STR(&evt->event_info.got_ip.ip),
					IP2STR(&evt->event_info.got_ip.mask),
					IP2STR(&evt->event_info.got_ip.gw));
			break;
		case EVENT_SOFTAPMODE_STACONNECTED:
			i = wifi_softap_get_station_num(); // Number count of stations which connected to ESP8266 soft-AP
			os_printf("Station[%u]: " MACSTR " join, AID = %d\n",
					i,
					MAC2STR(evt->event_info.sta_connected.mac),
					evt->event_info.sta_connected.aid);
			break;
		case EVENT_SOFTAPMODE_STADISCONNECTED:
			i = wifi_softap_get_station_num();
			os_printf("Station[%u]: " MACSTR " leave, AID = %d\n",
					i,
					MAC2STR(evt->event_info.sta_disconnected.mac),
					evt->event_info.sta_disconnected.aid);
			break;
		case EVENT_STAMODE_DHCP_TIMEOUT:
			os_printf("DHCP timeot\n");
			break;
/*		default:
			break; */
		}
}
开发者ID:UncleRus,项目名称:MinEspSDKLib,代码行数:58,代码来源:user_main.c


示例19: wifi_handle_event_cb

void wifi_handle_event_cb(System_Event_t *evt) {
    printf("event %x\n", evt->event_id);
    switch (evt->event_id) {
        case EVENT_STAMODE_CONNECTED:
            printf("connect to ssid %s, channel %d\n",
                   evt->event_info.connected.ssid,
                   evt->event_info.connected.channel);
            break;
        case EVENT_STAMODE_DISCONNECTED:
            printf("disconnect from ssid %s, reason %d\n",
                   evt->event_info.disconnected.ssid,
                   evt->event_info.disconnected.reason);

            if (connected) {
                connected = false;
                on_disconnect();
            }

            break;
        case EVENT_STAMODE_AUTHMODE_CHANGE:
            printf("mode: %d -> %d\n",
                   evt->event_info.auth_change.old_mode,
                   evt->event_info.auth_change.new_mode);
            break;
        case EVENT_STAMODE_GOT_IP:
            printf("ip:" IPSTR ",mask:" IPSTR ",gw:" IPSTR,
                   IP2STR(&evt->event_info.got_ip.ip),
                   IP2STR(&evt->event_info.got_ip.mask),
                   IP2STR(&evt->event_info.got_ip.gw));
            printf("\n");

            first_connect = false;
            connected = true;

            on_connect();

            break;
        case EVENT_SOFTAPMODE_STACONNECTED:
            printf("station: " MACSTR "join, AID = %d\n",
                   MAC2STR(evt->event_info.sta_connected.mac),
                   evt->event_info.sta_connected.aid);
            break;
        case EVENT_SOFTAPMODE_STADISCONNECTED:
            printf("station: " MACSTR "leave, AID = %d\n", MAC2STR(evt->event_info.sta_disconnected.mac),
                   evt->event_info.sta_disconnected.aid);
            break;
        default:
            break;
    }
}
开发者ID:FerdinandvHagen,项目名称:hackzurich15,代码行数:50,代码来源:user_wifi.c


示例20: wifi_handle_event_cb

/*
 * 函数:wifi_handle_event_cb
 * 参数:System_Event_t *evt
 * 说明:WiFi事件回调
 */
void ICACHE_FLASH_ATTR
wifi_handle_event_cb(System_Event_t *evt)
{
  os_printf("event %x\n", evt->event);

  switch (evt->event) {
      case EVENT_STAMODE_CONNECTED:
        os_printf("connect to ssid %s, channel %d\n",
          evt->event_info.connected.ssid,
          evt->event_info.connected.channel);
        break;
      case EVENT_STAMODE_DISCONNECTED:
        os_printf("disconnect from ssid %s, reason %d\n",
          evt->event_info.disconnected.ssid,
          evt->event_info.disconnected.reason);
        break;
      case EVENT_STAMODE_AUTHMODE_CHANGE:
          os_printf("mode: %d -> %d\n",
          evt->event_info.auth_change.old_mode,
          evt->event_info.auth_change.new_mode);
          break;
      case EVENT_STAMODE_GOT_IP:
        os_printf("ip:" IPSTR ",mask:" IPSTR ",gw:" IPSTR,
                IP2STR(&evt->event_info.got_ip.ip),
                IP2STR(&evt->event_info.got_ip.mask),
                IP2STR(&evt->event_info.got_ip.gw));
        os_printf("\n");

        // TODO:
        // WiFi连接后并获取IP后建立TCP连接
        tcp_client_init(HOST, PORT);


        break;
      case EVENT_SOFTAPMODE_STACONNECTED:
          os_printf("station: " MACSTR "join, AID = %d\n",
        MAC2STR(evt->event_info.sta_connected.mac),
        evt->event_info.sta_connected.aid);
          break;
      case EVENT_SOFTAPMODE_STADISCONNECTED:
          os_printf("station: " MACSTR "leave, AID = %d\n",
        MAC2STR(evt->event_info.sta_disconnected.mac),
        evt->event_info.sta_disconnected.aid);
          break;
      default:
        break;
  }
}
开发者ID:zouchuan1991,项目名称:ESP8266-Demos,代码行数:53,代码来源:user_wifi.c



注:本文中的IP2STR函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IP6CB函数代码示例发布时间:2022-05-30
下一篇:
C++ IOobject函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap