What’s up guys, today it is time to run a web server on Windows … CE.
I’m going to use Mongoose Networking Library. The benefit of this is that this example can be easily shaped into a CoAP server, an MQTT broker or any other server (or client) for protocols supported by Mongoose.
Windows CE was extremely popular about 15 years ago. Its heyday has probably been and gone, but this platform is still well-known and performs well for specific projects. At some point it got new name “Windows Mobile 6.0”, I’m going to refer it as WinCE.
For the test project I will use a SBC8018 development board running Windows CE 6.0. Saying that, this project should still work without any problems on any device with WinCE 6.0 and with minimal changes on any device running WinCE 5.0 and higher.
For this project you’ll need:
- Microsoft Visual Studio 2005 or 2008
- Windows Mobile 6.0 SDK
- Device running WinCE
Building the example
Open mongoose/examples/WinCE/http_server/http_server.vcproj in Visual Studio. Press “Build”. If the SDK is installed correctly the project should be built successfully.
Running the example
There are several ways to deploy this example on your device. You could connect your device directly from Visual Studio (Tools -> Connect to device). Another way would be to use ActiveSync. If your device supports an SD card (or similar) it is also way to go.
I believe that for testing purposes Visual Studio is the best and simplest way to deploy the application.
So, connect Visual Studio to device and press “F5” to run the application.
Time to test!
Testing the example
First of all, let’s test the web server locally, directly from the WinCE device (if you have a display attached, of course)
- Run Internet Explorer (on the device)
- Navigate it to http://localhost:8000/hello
- You’ll see a picture like this:
This greeting page is created by the Mongoose event handler.
The web server works!
Now, we’ll figure out your device IP. There are a lot of ways to do this (just google it). You can use ipconfig command (yes, WinCE has it), look to the registry (yes, it is still Windows) and visit your router statistic page. Or, just add the code to print the IP address, then start the program (I didn’t add it because the network API has changed a bit in WinCE 6.0 and doesn’t work on WinCE 5.0 (and visa versa), while I wanted to keep some kind of backward compatibility).
Anyway, if you navigate with your favorite browser to the real device IP and the network works correctly, you should see the picture like this one:
Congratulations, the world has one more web server instance.
Instead of the explanation
I won’t go into detail of how the background works. Simply because in the case of Windows CE you shouldn’t write any platform specific code. All you really need is to create a project in Visual Studio and follow this instruction. Or even copy & paste the code from the appropriate example.
It’s that simple. Nothing to add.