Setting up a network bridge connection for mbed on your laptop
Here is an initial attempt at instructions on how to use a Wi Fi connection on a laptop that is connected to the Internet to setup a bridged network connection to the hardwired network jack on the laptop. Mbed can then access the Internet using it's Ethernet hardware by plugging into the laptop's network jack, if you have a network breakout board. This is handy for schools and anyone working with mbed network applications on a laptop with Wi Fi. Instructions are included for Windows PCs, Macs, and Linux.
Student using mbed on a laptop with Wi Fi
Windows 7 & 8 Network Sharing and Bridge Ethernet to Wi-Fi Instructions
First connect to the Internet using Wi-Fi. To setup a bridge on a laptop using an existing Wi-Fi connection to the Internet, right click on the Wi-Fi or signal strength status icon (lower right corner on desktop bar) left click -> “Open network and sharing center “ then -> “Change adapter settings,” and the new window that opens should show icons for the Wi-Fi and the laptop’s hardwired Ethernet connector.
Right click on the WiFi icon, select properties, click on the "sharing" tab in the window that pops up. Next check the box that says “Allow other network users to connect through this computers Internet connection” and click "OK" to enable sharing. This seems to work on more network setups than the next alternative of setting up a network bridge (especially in Windows 8.1). The Ethernet connector on your laptop can now access the Internet for use by mbed applications whenever an mbed Ethernet network cable is plugged into your laptop.
The alternative to sharing is to use the bridge setup approach. In the network and sharing center -> “Change adapter settings” window highlight both of the WiFi and ethernet icons and then right click the Wi-Fi icon. Select “Bridge Connections” in the pop up box that appears. After several seconds, a new bridge icon appears when the bridge is setup.
On some laptops, a small delay might need to be added to the default 15000ms mbed ethernet.connection(timeout_ms) network timeouts or an extra wait at startup or reset, if DHCP does not work. An mbed reset seems to cycle the Windows network cable detection and they seem to take a bit too long to detect a new network cable connection and provide the IP address via DHCP.
Note: Some corporate IT Windows enterprise versions are configured with sharing and the network bridging features disabled for security reasons - they will not allow a bridge to be setup. It is also possible that the Wi-Fi server has network security settings that keep it from working with an unknown MAC address (without a new login for each device). This seems to be more common in the hotels that charge for Wi-Fi.
In Windows 8.1, if DHCP service does not provide mbed an IP address, try a static IP assignment. This will require changing the TCP/IP properties on the network bridge and adding the static IP address to the Ethernet init call in the mbed program.
Click to view a PDF of Instructions for other common Operating Systems
Windows 10
There is a tutorial on setting this up in the new Windows 10 (also says it works for 8.1). Should be an easier way to do it than in this tutorial using the command line! At the end of the tutorial, they have an app you can download that sets up the ugly part of it, but even after that some manual GUI steps are still required - so read carefully! There are a few free and low cost apps that are available to setup a hotspot in Windows 10, but most seem to just display the instructions for you to follow.
If you need a hotspot for Wi Fi there is a new easier procedure.
Using Laptops without an Ethernet Jack
USB to Ethernet Adapter Cable
If the laptop does not have a built-in Ethernet jack, a USB to Ethernet Adapter Cable can be used. These are available for around US $20. A USB driver may also be needed. USB to Wi Fi adapters could also be added to a laptop.
Getting your mbed's MAC address
If you wind up needing the mbed's MAC address to enable DHCP on a network, the code example below will print it out.
#include "mbed.h" extern "C" void mbed_mac_address(char *mac); int main() { char mac[6]; mbed_mac_address(mac); for(int i=0; i<6;i++) { printf("%02X ", mac[i]); } printf("\n"); }
Click import below to set up this code example in the compiler window
Import programmac
Example to get unique mbed mac address
If your code example already has the mbed Ethernet class, the .address() member function will also return the MAC address. It gets it using the same extern function. It is based on the unique serial number of your mbed. It is hidden as a substring in the long string of numbers (auth=) in the mbed.html file on the mbed's flash drive that is setup by the mbed's USB microcontroller's firmware (magic USB chip on back of LPC1768 board). It is harder to find there, so just use the program. The MAC address can also be changed, if needed. If you change this function to assign a different MAC address, make certain that you do not have two active devices on the network at the same time with the same MAC address!
Wi Fi Hotspot
If your mbed project uses Wi Fi and not a hardwired connection, many PCs with just Wi Fi can setup a PC mobile Wi Fi hotspot or a hotspot using a Mac.
154 comments on Setting up a network bridge connection for mbed on your laptop:
Please log in to post comments.
Thanks, I was just starting to look a bit at ethernet and this was exactly what I was planning to do :)