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


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

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


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

示例1: mbed_mac_address

void
tcpClient_main(intptr_t exinf) {

	EthernetInterface network;
	TCPSocketConnection socket;

	/* syslogの設定 */
    SVC_PERROR(syslog_msk_log(LOG_UPTO(LOG_INFO), LOG_UPTO(LOG_EMERG)));

	syslog(LOG_NOTICE, "tcpClient:");
    syslog(LOG_NOTICE, "Sample program starts (exinf = %d).", (int_t) exinf);
    syslog(LOG_NOTICE, "LOG_NOTICE: Network Setting up...");

#if (USE_DHCP == 1)
    if (network.init() != 0) {                             //for DHCP Server
#else
    if (network.init(IP_ADDRESS, SUBNET_MASK, DEFAULT_GATEWAY) != 0) { //for Static IP Address (IPAddress, NetMasks, Gateway)
#endif
		syslog(LOG_NOTICE, "Network Initialize Error");
        return;
    }
    syslog(LOG_NOTICE, "Network was initialized successfully");
    while (network.connect(5000) != 0) {
        syslog(LOG_NOTICE, "LOG_NOTICE: Network Connect Error");
    }

    syslog(LOG_NOTICE, "MAC Address is %s", network.getMACAddress());
    syslog(LOG_NOTICE, "IP Address is %s", network.getIPAddress());
    syslog(LOG_NOTICE, "NetMask is %s", network.getNetworkMask());
    syslog(LOG_NOTICE, "Gateway Address is %s", network.getGateway());
    syslog(LOG_NOTICE, "Network Setup OK...");
	
    while (socket.connect(SERVER, HTTP_PORT) < 0) {
        syslog(LOG_EMERG, "Unable to connect to (%s) on port (%d)", SERVER, HTTP_PORT);
        wait(1.0);
    }
    ClientGreet(&socket);
    socket.close();
    syslog(LOG_NOTICE, "program end");
}

// set mac address
void mbed_mac_address(char *mac) {
	// PEACH1
    mac[0] = 0x00;
    mac[1] = 0x02;
    mac[2] = 0xF7;
    mac[3] = 0xF0;
    mac[4] = 0x00;
    mac[5] = 0x00;
}
开发者ID:ncesnagoya,项目名称:asp-gr_peach_gcc-mbed,代码行数:51,代码来源:tcpClient.cpp

示例2: HTTPAPI_Init

HTTPAPI_RESULT HTTPAPI_Init(void)
{
    LogInfo("HTTPAPI_Init::Start\r\n");
    time_t ctTime;
    ctTime = time(NULL);
    HTTPAPI_RESULT result;
    LogInfo("HTTAPI_Init::Time is now (UTC) %s\r\n", ctime(&ctTime));
    if (eth.init())
    {
        LogInfo("HTTPAPI_Init::Error with initing the Ethernet Interface\r\n");
        result = HTTPAPI_INIT_FAILED;
    }
    else
    {
        LogInfo("HTTPAPI_Init::Ethernet interface was inited!\r\n");
        if (eth.connect(30000))
        {
            LogError("HTTPAPI_Init::Error with connecting.\r\n");
            result = HTTPAPI_INIT_FAILED;
        }
        else
        {
            LogInfo("HTTAPI_Init::Ethernet interface was connected (brought up)!\r\n");
            LogInfo("HTTAPI_Init::MAC address %s\r\n", eth.getMACAddress());
            LogInfo("HTTAPI_Init::IP address %s\r\n", eth.getIPAddress());
            if (ntp.setTime("0.pool.ntp.org") == 0)
            {
                LogInfo("HTTAPI_Init:: Successfully set time\r\n");
                LogInfo("HTTAPI_Init::Time is now (UTC) %s\r\n", ctime(&ctTime));
                result = HTTPAPI_OK;
            }
            else
            {
                LogError("HTTPAPI_INIT::Unable to set time.  Init failed");
                result = HTTPAPI_INIT_FAILED;
            }
        }
    }
    LogInfo("HTTPAPI_Init::End\r\n");
    return result;
}
开发者ID:rturnage,项目名称:azure-event-hubs,代码行数:41,代码来源:httpapi_mbed.cpp

示例3: app_start

void app_start(int /*argc*/, char* /*argv*/[]) {

    //Sets the console baud-rate
    output.baud(115200);

    // start the accelerometer
    acc.enable();

    // print device name for easy reference
    output.printf("Device Name is '%s'\r\n\r\n",MBED_ENDPOINT_NAME);

    // This sets up the network interface configuration which will be used
    // by LWM2M Client API to communicate with mbed Device server.
    eth.init(); //Use DHCP
    eth.connect();
    output.printf("%s\n", eth.getMACAddress());
    char *ip = eth.getIPAddress();
    if (ip) {
        output.printf("IP Address is: %s\n", ip);
    } else {
        error("Failed to aquire IP address\n");
    }

    lwipv4_socket_init();

    // On press of SW3 button on K64F board, example application
    // will call unregister API towards mbed Device Server
    // unreg_button.fall(&mbed_client,&MbedClient::test_unregister);

    // Create LWM2M Client API interface to manage register and unregister
    mbed_client.create_interface();

    // Create LWM2M server object specifying mbed device server
    // information.
    M2MSecurity* register_object = mbed_client.create_register_object();

    // Create LWM2M device object specifying device resources
    // as per OMA LWM2M specification.
    M2MDevice* device_object = mbed_client.create_device_object();

    // Create Generic object specifying custom resources
    M2MObject* sdw_object = mbed_client.create_sdw_object();
    
    // Create Generic object specifying custom resources
    M2MObject* led_object = mbed_client.create_led_object();

    // Add all the objects that you would like to register
    // into the list and pass the list for register API.
    M2MObjectList object_list;
    object_list.push_back(device_object);
    object_list.push_back(sdw_object);
    object_list.push_back(led_object);

    mbed_client.set_register_object(register_object);

    // Issue register command.
    FunctionPointer2<void, M2MSecurity*, M2MObjectList> fp(&mbed_client, &MbedClient::test_register);
    minar::Scheduler::postCallback(fp.bind(register_object, object_list));
    minar::Scheduler::postCallback(&mbed_client, &MbedClient::update_sdw_resource).period(minar::milliseconds(1000));
    minar::Scheduler::postCallback(&mbed_client, &MbedClient::test_update_register).period(minar::milliseconds(25000));
}
开发者ID:sg-,项目名称:sdw-workshop,代码行数:61,代码来源:app.cpp


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