当前位置: 首页>>代码示例>>C++>>正文


C++ EthernetInterface::set_blocking方法代码示例

本文整理汇总了C++中EthernetInterface::set_blocking方法的典型用法代码示例。如果您正苦于以下问题:C++ EthernetInterface::set_blocking方法的具体用法?C++ EthernetInterface::set_blocking怎么用?C++ EthernetInterface::set_blocking使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EthernetInterface的用法示例。


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

示例1: easy_connect

/* \brief easy_connect     easy_connect() function to connect the pre-defined network bearer,
 *                         config done via mbed_app.json (see README.md for details).
 *
 * IN: bool  log_messages  print out diagnostics or not.
 */
NetworkInterface* easy_connect(bool log_messages) {
    NetworkInterface* network_interface = NULL;
    int connect_success = -1;

#if defined (EASY_CONNECT_WIFI)
    // We check if the _ssid and _password have already been set (via the easy_connect()
    // that takes thoses parameters or not.
    // If they have not been set, use the ones we can gain from mbed_app.json.
    if (_ssid == NULL) { 
        if(strlen(MBED_CONF_APP_WIFI_SSID) > WIFI_SSID_MAX_LEN) {
            printf("ERROR - MBED_CONF_APP_WIFI_SSID is too long %d vs. %d\n", 
                    strlen(MBED_CONF_APP_WIFI_SSID),
                    WIFI_SSID_MAX_LEN);
            return NULL;
        }
    }

    if (_password == NULL) {
        if(strlen(MBED_CONF_APP_WIFI_PASSWORD) > WIFI_PASSWORD_MAX_LEN) {
            printf("ERROR - MBED_CONF_APP_WIFI_PASSWORD is too long %d vs. %d\n", 
                    strlen(MBED_CONF_APP_WIFI_PASSWORD),
                    WIFI_PASSWORD_MAX_LEN);
            return NULL;
        }
    }
#endif // EASY_CONNECT_WIFI

    /// This should be removed once mbedOS supports proper dual-stack
    if (log_messages) {
#if defined (EASY_CONNECT_MESH) || (MBED_CONF_LWIP_IPV6_ENABLED==true)
        printf("[EasyConnect] IPv6 mode\n");
#else
        printf("[EasyConnect] IPv4 mode\n");
#endif
    }

#if defined (EASY_CONNECT_WIFI)
    if (log_messages) {
        printf("[EasyConnect] Using WiFi (%s) \n", EASY_CONNECT_WIFI_TYPE);
        printf("[EasyConnect] Connecting to WiFi %s\n", 
                ((_ssid == NULL) ? MBED_CONF_APP_WIFI_SSID : _ssid) );
    }
    network_interface = &wifi;
    if (_ssid == NULL) {
        connect_success = wifi.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD,
                          (strlen(MBED_CONF_APP_WIFI_PASSWORD) > 1) ? NSAPI_SECURITY_WPA_WPA2 : NSAPI_SECURITY_NONE);
    }
    else {
        connect_success = wifi.connect(_ssid, _password, (strlen(_password) > 1) ? NSAPI_SECURITY_WPA_WPA2 : NSAPI_SECURITY_NONE);
    }
#elif MBED_CONF_APP_NETWORK_INTERFACE == CELLULAR_ONBOARD || MBED_CONF_APP_NETWORK_INTERFACE == CELLULAR
#  ifdef MBED_CONF_APP_CELLULAR_SIM_PIN
    cellular.set_sim_pin(MBED_CONF_APP_CELLULAR_SIM_PIN);
#  endif
#  ifdef MBED_CONF_APP_CELLULAR_APN
#    ifndef MBED_CONF_APP_CELLULAR_USERNAME
#      define MBED_CONF_APP_CELLULAR_USERNAME 0
#    endif
#    ifndef MBED_CONF_APP_CELLULAR_PASSWORD
#      define MBED_CONF_APP_CELLULAR_PASSWORD 0
#    endif
    cellular.set_credentials(MBED_CONF_APP_CELLULAR_APN, MBED_CONF_APP_CELLULAR_USERNAME, MBED_CONF_APP_CELLULAR_PASSWORD);
    if (log_messages) {
        printf("[EasyConnect] Connecting using Cellular interface and APN %s\n", MBED_CONF_APP_CELLULAR_APN);
    }
#  else
    if (log_messages) {
        printf("[EasyConnect] Connecting using Cellular interface and default APN\n");
    }
#  endif
    connect_success = cellular.connect();
    network_interface = &cellular;

#elif MBED_CONF_APP_NETWORK_INTERFACE == CELLULAR_WNC14A2A
    if (log_messages) {
        printf("[EasyConnect] Using WNC14A2A\n");
    }
#   if MBED_CONF_APP_WNC_DEBUG == true
    printf("[EasyConnect] With WNC14A2A debug output set to 0x%02X\n",MBED_CONF_APP_WNC_DEBUG_SETTING);
    wnc.doDebug(MBED_CONF_APP_WNC_DEBUG_SETTING);
#   endif
    network_interface = &wnc;
    connect_success = wnc.connect();

#elif MBED_CONF_APP_NETWORK_INTERFACE == ETHERNET
    if (log_messages) {
        printf("[EasyConnect] Using Ethernet\n");
    }
    network_interface = ð
#if MBED_CONF_EVENTS_SHARED_DISPATCH_FROM_APPLICATION
    eth.set_blocking(false);
#endif
    connect_success = eth.connect();
#endif

//.........这里部分代码省略.........
开发者ID:ARMmbed,项目名称:easy-connect,代码行数:101,代码来源:easy-connect.cpp


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