Mongoose embedded networking library on NXP Kinetis
This example shows you how to use Mongoose, the most popular open-source embedded web server and networking library with NXP Kinetis K-series MCUs.
The K series MCUs come with built-in Ethernet MAC. This is what we will focus on. We will assume that you have a FRDM-K64F development board and have already been working with it or at least followed the Getting Started tutorial (have your Kinetis Design Studio installed, downloaded the SDK, etc). With that, you will need to:
- Download Mongoose source code from here.
- In the Mongoose source directory, navigate to the examples/NXP_K64 and copy the Kinetis SDK there. Make sure you copy the whole thing, the entire SDK_2.0_FRDM-K64F folder there (alternatively, you can manually adjust the SDK_PATH variable after you import the example project).
- Open Kinetis Design Studio
- Choose Project of Projects -> Existing Project Sets
- On the next screen, click Browse…, navigate to theexamples/NXP_K64/kds directory and select theMongoose_FRDMK64F_BM.wsd file.
- Build the project. You may see a couple warnings.
- Connect a terminal to the console port (see step 2.3 in the "Getting Started" tutorial).
- Connect the Ethernet cable. By default, the example is configured to use DHCP to obtain the IP address. If you’d like to configure a static IP address, set USE_DHCP to 0 at the top of source/main.c, adjust STATIC_IP settings below and rebuild.
- Run the project. You should see the following output:
- This should be accompanied by the on-board LED changing from red to amber to green.
- Use your browser to navigate to the given URL. You should see a simple greeting page, created by the MG_EV_HTTP_REQUEST handler and the corresponding messages on the console:
0x20000878: Connection from 192.168.1.15:38548
0x20000708: GET /
0x20000708: Connection closed
- Congratulations, you now have a fully functioning web server on your board! But Mongoose is much more than a web server - it can act as an HTTP client, MQTT client or broker and much more. Read more about it here.