This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Httpd.cpp Source File

Httpd.cpp

00001 #include "Httpd.h"
00002 #include "HttpdConnection.h"
00003 #include "mbed.h"
00004 namespace MiMic
00005 {
00006     char Httpd::_shared_buf[SIZE_OF_HTTP_BUF];
00007 
00008     void Httpd::onRequestHandler(NyLPC_TcHttpdConnection_t* i_connection)
00009     {
00010         HttpdConnection c(i_connection);
00011         ((struct Httpd2*)(i_connection->_parent_httpd))->_parent->onRequest(c);
00012     }
00013     Httpd::Httpd(int i_port_number)
00014     {
00015         if(!NyLPC_cHttpd_initialize((NyLPC_TcHttpd_t*)(&this->_inst),(NyLPC_TUInt16)i_port_number)){
00016             mbed_die();
00017         }
00018         this->_inst._parent=this;
00019         this->_inst.super.function.onRequest=onRequestHandler;
00020     }
00021     Httpd::~Httpd()
00022     {
00023         NyLPC_cHttpd_finalize((NyLPC_TcHttpd_t*)(&this->_inst));
00024     }
00025     void Httpd::loop()
00026     {
00027         NyLPC_cHttpd_loop((NyLPC_TcHttpd_t*)(&this->_inst));
00028     }    
00029     void Httpd::lock()
00030     {
00031         NyLPC_cHttpd_lock((NyLPC_TcHttpd_t*)(&this->_inst));
00032     }
00033     void Httpd::unlock()
00034     {
00035         NyLPC_cHttpd_unlock((NyLPC_TcHttpd_t*)(&this->_inst));
00036     }
00037     void Httpd::loopTask()
00038     {
00039         NyLPC_TcThread_t* th=(NyLPC_TcThread_t*)malloc(sizeof(NyLPC_TcThread_t));
00040         NyLPC_cThread_initialize(th,256,NyLPC_TcThread_PRIORITY_IDLE);
00041         NyLPC_cThread_start(th,Httpd::taskHandler,&(this->_inst));
00042     }
00043     int Httpd::taskHandler(void* i_param)
00044     {
00045         NyLPC_cHttpd_loop((NyLPC_TcHttpd_t*)i_param);
00046         return 0;
00047     }
00048     
00049 }