Ethernet-based network support for mbedConnectorInterface.

Dependencies:   libnsdl EthernetInterface mbed-rtos

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

network_stubs/network_stubs.cpp

Committer:
ansond
Date:
2015-02-01
Revision:
0:31292d956e92
Child:
1:cb681dfa1678

File content as of revision 0:31292d956e92:

/**
 * @file    network_stubs.cpp
 * @brief   mbed Endpoint network stubs implementation (Ethernet)
 * @author  Doug Anson
 * @version 1.0
 * @see     
 *
 * Copyright (c) 2014
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
#include "network_stubs.h"

extern "C" {
    
// plumb out the network
void net_stubs_plumb_network(bool canActAsRouterNode) 
{
     // ethernet initialize
     ethernet.init();       // DHCP
     ethernet.connect();    // connect
     
     // our IP address
     DBG("Ethernet Address: %s\r\n",ethernet.getIPAddress());
     
     // initialize NSDL
     registration_update_thread(NULL);
}

// create a suitable main event loop for this specific network
void net_stubs_create_main_loop(void)
{
    // not used for EthernetInterface...
    ;
}

// register the endpoint
void net_stubs_register_endpoint(void)
{
    register_endpoint(true);
}

// begin the main loop for processing network events
void net_stubs_begin_main_loop(void) 
{
    // NDSL main loop
    nsdl_event_loop();
}

}