Jun Furutani / libMiMic

Fork of libMiMic by Ryo Iizuka

Revision:
50:35e765380772
Parent:
48:00d211aac2ec
--- a/mbed/mod/ModUPnPDevice.cpp	Wed Aug 07 16:43:32 2013 +0000
+++ b/mbed/mod/ModUPnPDevice.cpp	Thu Aug 08 15:21:43 2013 +0000
@@ -2,34 +2,33 @@
 #include <NyLPC_net.h>
 #include <stdio.h>
 #include "mbed.h"
-   
+   #include "../NyLPC_cHttpdConnection_protected.h"
    
 namespace MiMic
 {  
-    ModUPnPDevice::ModUPnPDevice(const Net& i_ref_net)
+    ModUPnPDevice::ModUPnPDevice():ModBaseClass(Net::UPNP_ROOT_PATH)
     {
-        setParam(i_ref_net);
-    }
-    ModUPnPDevice::ModUPnPDevice()
-    {
+        this->_ref_net=NULL;
     }
     ModUPnPDevice::~ModUPnPDevice()
     {
     }
     void ModUPnPDevice::setParam(const Net& i_ref_net)
     {
-        ModBaseClass::setParam(i_ref_net.refUPnPInstance()!=NULL?i_ref_net.refUPnPInstance()->_ref_root_path:NULL);
-        this->_ref_upnp_inst=i_ref_net.refUPnPInstance();
-    }
+        this->_ref_net=&i_ref_net;
+        ModBaseClass::setParam(Net::UPNP_ROOT_PATH);
+    }    
     bool ModUPnPDevice::execute(HttpdConnection& i_connection)
     {
         NyLPC_TcModUPnPDevice_t mod;
 
-        //check parametor
-        if(this->_path==NULL){
+        //check Net has UPnP Instance
+        const NyLPC_TcUPnP_t* upnp=this->_ref_net->refUPnPInstance();
+        if(upnp==NULL || this->_path==NULL){
             return false;
         }
-        NyLPC_cModUPnPDevice_initialize(&mod,this->_ref_upnp_inst);
+        //
+        NyLPC_cModUPnPDevice_initialize(&mod,upnp);
         if(NyLPC_cModUPnPDevice_canHandle(&mod,i_connection._ref_inst)){
             NyLPC_cModUPnPDevice_execute(&mod,i_connection._ref_inst);
             NyLPC_cModUPnPDevice_finalize(&mod);