Simplest UPnP basic device example. This program to run UPnP basic device on the mbed.
Dependencies: NyFileSystems libMiMic mbed-rtos mbed
Fork of MbedFileServer by
This is UPnP BasicDevice by MiMicSDK. BasicDevice is most simplest UPnP device.
How To Use
- Write firmware to your mbed.
- Reset mbed and update firmware.
- Check your "network computer" folder by Exproler. (in case of windows.)
- You can find UPnPBasicDevice hosted by mbed. (If you can not find device then reflesh exploler information.)
- If you double-click UPnPBasicDevice, the presentation page on device is opened.
Function
- AutoIP
- SSDP
- DeviceDescription hosting (Httpd)
- SOAP (not implemented)
- GENA (not implemented)
Source Code
It is simple and short!
/** * @file * Simplest UPnP basic device.<br/> * This program is upnp:BasicDeveice:1 template. * * <p> * After starting program, check "network" by Exproler. * MiMic basic device will be appeared. * </p> */ #include "mbed.h" #include "rtos.h" #include "SDFileSystem.h" #include "mimic.h" #include "utils/PlatformInfo.h" #include "fsdata.h" Net* net; /** * Httpd for UPnPService and presentation. */ class UPnPBasicDeviceHttpd:public MiMic::Httpd { private: ModUPnPDevice modupnp; ModRomFiles modromfs; //ROM file module public: UPnPBasicDeviceHttpd(NetConfig& i_cfg):Httpd(i_cfg.getHttpPort()) { //prepare fs data (presentation.html,icon,image.) this->modromfs.setParam("rom",FSDATA,3); //bind upnp service to module. this->modupnp.setParam(*net); } virtual void onRequest(HttpdConnection& i_connection) { //try to ModRomFS module. for icon,images. if(this->modromfs.execute(i_connection)){ return; } //try to UPnP service. for descriptions. if(this->modupnp.execute(i_connection)){ return; } //Otherwise, Send the redirect response to /rom/index.html i_connection.sendHeader(302, "text/html", "Status: 302:Moved Temporarily\r\n" "Location: /rom/index.html\r\n"); } }; NetConfig cfg; //create network configulation int main() { net=new Net();//Net constructor must be created after started RTOS //Prepare configulation. cfg.setUPnPIcon(64,64,8,"image/png","/rom/icon.png");//set upnp icon address cfg.setUPnPUdn(0xe29f7103,0x4ba2,0x01e0,0); //set application timebase-uuid time and sequence field. cfg.setFriendlyName("UPnPBasicDevice(LPC176x)"); //set friendly name cfg.setUPnPPresentationURL("/rom/index.html"); //set presentationURL cfg.setZeroconf(true);//AutoIP enable UPnPBasicDeviceHttpd httpd(cfg); //create a httpd instance. net->start(cfg); httpd.loop(); //start httpd loop. return 0; }
I think that this code helps to make Web connection to your application easily.
History
update libmimic
2015-09-15, by nyatla [Tue, 15 Sep 2015 12:03:36 +0000] rev 28
update libmimic
update libMiMic
2014-10-28, by nyatla [Tue, 28 Oct 2014 15:12:26 +0000] rev 27
update libMiMic
update library; fix stack overflow
2014-10-27, by nyatla [Mon, 27 Oct 2014 15:03:05 +0000] rev 26
update library; fix stack overflow
Update libMiMic
2013-11-12, by nyatla [Tue, 12 Nov 2013 03:53:27 +0000] rev 25
Update libMiMic
update libMiMic
2013-10-23, by nyatla [Wed, 23 Oct 2013 05:13:03 +0000] rev 24
update libMiMic
update libMiMic
2013-10-03, by nyatla [Thu, 03 Oct 2013 05:02:11 +0000] rev 23
update libMiMic
update libMiMic
2013-08-10, by nyatla [Sat, 10 Aug 2013 02:53:46 +0000] rev 22
update libMiMic
add issue comment
2013-08-09, by nyatla [Fri, 09 Aug 2013 14:23:08 +0000] rev 21
add issue comment
First release; simplest UPnP Basicdevice
2013-08-09, by nyatla [Fri, 09 Aug 2013 10:45:36 +0000] rev 20
First release; simplest UPnP Basicdevice
update libMiMic; support UPnP function.
2013-08-09, by nyatla [Fri, 09 Aug 2013 09:06:09 +0000] rev 19
update libMiMic; support UPnP function.