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@0:31292d956e92, 2015-02-01 (annotated)
- Committer:
- ansond
- Date:
- Sun Feb 01 18:24:03 2015 +0000
- Revision:
- 0:31292d956e92
- Child:
- 1:cb681dfa1678
revamped
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:31292d956e92 | 28 | void net_stubs_plumb_network(bool canActAsRouterNode) |
ansond | 0:31292d956e92 | 29 | { |
ansond | 0:31292d956e92 | 30 | // ethernet initialize |
ansond | 0:31292d956e92 | 31 | ethernet.init(); // DHCP |
ansond | 0:31292d956e92 | 32 | ethernet.connect(); // connect |
ansond | 0:31292d956e92 | 33 | |
ansond | 0:31292d956e92 | 34 | // our IP address |
ansond | 0:31292d956e92 | 35 | DBG("Ethernet Address: %s\r\n",ethernet.getIPAddress()); |
ansond | 0:31292d956e92 | 36 | |
ansond | 0:31292d956e92 | 37 | // initialize NSDL |
ansond | 0:31292d956e92 | 38 | registration_update_thread(NULL); |
ansond | 0:31292d956e92 | 39 | } |
ansond | 0:31292d956e92 | 40 | |
ansond | 0:31292d956e92 | 41 | // create a suitable main event loop for this specific network |
ansond | 0:31292d956e92 | 42 | void net_stubs_create_main_loop(void) |
ansond | 0:31292d956e92 | 43 | { |
ansond | 0:31292d956e92 | 44 | // not used for EthernetInterface... |
ansond | 0:31292d956e92 | 45 | ; |
ansond | 0:31292d956e92 | 46 | } |
ansond | 0:31292d956e92 | 47 | |
ansond | 0:31292d956e92 | 48 | // register the endpoint |
ansond | 0:31292d956e92 | 49 | void net_stubs_register_endpoint(void) |
ansond | 0:31292d956e92 | 50 | { |
ansond | 0:31292d956e92 | 51 | register_endpoint(true); |
ansond | 0:31292d956e92 | 52 | } |
ansond | 0:31292d956e92 | 53 | |
ansond | 0:31292d956e92 | 54 | // begin the main loop for processing network events |
ansond | 0:31292d956e92 | 55 | void net_stubs_begin_main_loop(void) |
ansond | 0:31292d956e92 | 56 | { |
ansond | 0:31292d956e92 | 57 | // NDSL main loop |
ansond | 0:31292d956e92 | 58 | nsdl_event_loop(); |
ansond | 0:31292d956e92 | 59 | } |
ansond | 0:31292d956e92 | 60 | |
ansond | 0:31292d956e92 | 61 | } |