Ethernet-based network support for mbedConnectorInterface.

Dependencies:   libnsdl EthernetInterface mbed-rtos

Dependents:   IoT_LED_demo ServoTest uWater_Project hackathon ... more

Committer:
ansond
Date:
Fri Feb 06 04:18:08 2015 +0000
Revision:
6:c8ac3efd53cf
Parent:
3:3e1ad8ab5071
updates for underlying re-org

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 0:31292d956e92 1 /**
ansond 0:31292d956e92 2 * @file network_stubs.cpp
ansond 0:31292d956e92 3 * @brief mbed Endpoint network stubs implementation (Ethernet)
ansond 0:31292d956e92 4 * @author Doug Anson
ansond 0:31292d956e92 5 * @version 1.0
ansond 0:31292d956e92 6 * @see
ansond 0:31292d956e92 7 *
ansond 0:31292d956e92 8 * Copyright (c) 2014
ansond 0:31292d956e92 9 *
ansond 0:31292d956e92 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 0:31292d956e92 11 * you may not use this file except in compliance with the License.
ansond 0:31292d956e92 12 * You may obtain a copy of the License at
ansond 0:31292d956e92 13 *
ansond 0:31292d956e92 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 0:31292d956e92 15 *
ansond 0:31292d956e92 16 * Unless required by applicable law or agreed to in writing, software
ansond 0:31292d956e92 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 0:31292d956e92 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 0:31292d956e92 19 * See the License for the specific language governing permissions and
ansond 0:31292d956e92 20 * limitations under the License.
ansond 0:31292d956e92 21 */
ansond 0:31292d956e92 22
ansond 0:31292d956e92 23 #include "network_stubs.h"
ansond 0:31292d956e92 24
ansond 0:31292d956e92 25 extern "C" {
ansond 0:31292d956e92 26
ansond 0:31292d956e92 27 // plumb out the network
ansond 6:c8ac3efd53cf 28 void net_stubs_pre_plumb_network(bool canActAsRouterNode)
ansond 6:c8ac3efd53cf 29 {
ansond 6:c8ac3efd53cf 30 // we have to defer all Ethernet until we are configured..
ansond 6:c8ac3efd53cf 31 ;
ansond 6:c8ac3efd53cf 32 }
ansond 6:c8ac3efd53cf 33
ansond 6:c8ac3efd53cf 34 // called after the endpoint is configured...
ansond 6:c8ac3efd53cf 35 void net_stubs_post_plumb_network(void)
ansond 0:31292d956e92 36 {
ansond 0:31292d956e92 37 // ethernet initialize
ansond 0:31292d956e92 38 ethernet.init(); // DHCP
ansond 0:31292d956e92 39 ethernet.connect(); // connect
ansond 0:31292d956e92 40
ansond 0:31292d956e92 41 // our IP address
ansond 6:c8ac3efd53cf 42 DBG("net_stubs_post_plumb_network: Ethernet Address: %s\r\n",ethernet.getIPAddress());
ansond 0:31292d956e92 43 }
ansond 0:31292d956e92 44
ansond 0:31292d956e92 45 // create a suitable main event loop for this specific network
ansond 0:31292d956e92 46 void net_stubs_create_main_loop(void)
ansond 0:31292d956e92 47 {
ansond 6:c8ac3efd53cf 48 // nothing to do for Ethernet endpoints - we are using the Threaded loop in nsdl_support.cpp
ansond 6:c8ac3efd53cf 49 ;
ansond 0:31292d956e92 50 }
ansond 0:31292d956e92 51
ansond 0:31292d956e92 52 // register the endpoint
ansond 0:31292d956e92 53 void net_stubs_register_endpoint(void)
ansond 0:31292d956e92 54 {
ansond 1:cb681dfa1678 55 // NSP registration
ansond 3:3e1ad8ab5071 56 DBG("net_stubs_register_endpoint: calling NSP registration...\r\n");
ansond 0:31292d956e92 57 register_endpoint(true);
ansond 3:3e1ad8ab5071 58 DBG("net_stubs_register_endpoint: NSP registration completed\r\n");
ansond 0:31292d956e92 59 }
ansond 0:31292d956e92 60
ansond 0:31292d956e92 61 // begin the main loop for processing network events
ansond 0:31292d956e92 62 void net_stubs_begin_main_loop(void)
ansond 0:31292d956e92 63 {
ansond 0:31292d956e92 64 // NDSL main loop
ansond 0:31292d956e92 65 nsdl_event_loop();
ansond 0:31292d956e92 66 }
ansond 0:31292d956e92 67
ansond 0:31292d956e92 68 }