Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: NyFileSystems libMiMic mbed-rtos mbed
Fork of MiMicSimpleHttpd by
Revision 7:8d030ae8ddc3, committed 2013-07-11
- Comitter:
- nyatla
- Date:
- Thu Jul 11 01:11:26 2013 +0000
- Parent:
- 6:bcf3fe4d0ba1
- Child:
- 8:384c8fb9f401
- Commit message:
- update libMiMic
Changed in this revision
| libMiMic.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/libMiMic.lib Thu May 16 16:11:48 2013 +0000 +++ b/libMiMic.lib Thu Jul 11 01:11:26 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/nyatla/code/libMiMic/#f02596009a02 +http://mbed.org/users/nyatla/code/libMiMic/#74390edbe66c
--- a/main.cpp Thu May 16 16:11:48 2013 +0000
+++ b/main.cpp Thu Jul 11 01:11:26 2013 +0000
@@ -1,30 +1,27 @@
#include "mimic.h"
-
+ LocalFileSystem2 lf("local");
/**
- * MiMic RemoteMCU httpd.<br/>
- * <p>Service list</p>
- * <pre>
- * /rom/ - romfs
- * /setup/ - MiMic configulation REST API.
- * /local/ - mbed LocalFileSystem
- * /mvm/ - MiMicVM REST API
- * </pre>
+ *
*/
-
-class MiMicRemoteMcu:public MiMic::Httpd
+class SimpleHttpd:public MiMic::Httpd
{
private:
ModUrl modurl; //basic URL parser
public:
- MiMicRemoteMcu():Httpd(80)
+ SimpleHttpd(NetConfig& i_cfg):Httpd(i_cfg._inst.services.http_port)
{
}
virtual void onRequest(HttpdConnection& i_connection)
{
char url[32];
int method;
+
+ //
+ //write Http handler(s) here!
+ //
+
//call ModUrl module.
if(this->modurl.execute(i_connection,url,32,&method)){
//send 200 OK and requested URL
@@ -32,15 +29,21 @@
i_connection.sendBodyF("<html><body>Your Request path is %s.</body></html>",url);
return;
}
+
return;
}
};
-
+
+NetConfig cfg; //create network configulation
int main()
{
- NetConfig cfg; //create network configulation
- Net net(cfg); //create a net instance.
- MiMicRemoteMcu httpd; //create a httpd instance.
+ Net net; //create a net instance.
+
+ //try to override setting by local file.
+ cfg.loadFromFile("/local/mimic.cfg");
+
+ SimpleHttpd httpd(cfg); //create a httpd instance.
+ net.start(cfg);
httpd.loop(); //start httpd loop.
return 0;
}
