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

Fork of libMiMic by Ryo Iizuka

Files at this revision

API Documentation at this revision

Comitter:
nyatla
Date:
Wed Nov 12 13:07:40 2014 +0000
Parent:
106:dc0d65dbde48
Child:
108:8dae2a2682e7
Commit message:
update mdns

Changed in this revision

core/NyLPC_cMiMicEnv.c Show annotated file Show diff for this revision Revisions of this file
core/net/mdns/NyLPC_cMDnsServer.c Show annotated file Show diff for this revision Revisions of this file
core/net/mdns/NyLPC_cMDnsServer.h Show annotated file Show diff for this revision Revisions of this file
--- a/core/NyLPC_cMiMicEnv.c	Tue Nov 11 13:23:54 2014 +0000
+++ b/core/NyLPC_cMiMicEnv.c	Wed Nov 12 13:07:40 2014 +0000
@@ -1,7 +1,7 @@
 #include "NyLPC_cMiMicEnv.h"
 #include "../uip/NyLPC_cUipService_protected.h"
 
-const static char* VERSION="MiMic/1.6.4";
+const static char* VERSION="MiMic/1.6.5";
 
 #if NyLPC_MCU==NyLPC_MCU_LPC4088
 const static char* MCU="LPC4088";
--- a/core/net/mdns/NyLPC_cMDnsServer.c	Tue Nov 11 13:23:54 2014 +0000
+++ b/core/net/mdns/NyLPC_cMDnsServer.c	Wed Nov 12 13:07:40 2014 +0000
@@ -772,7 +772,7 @@
         if(obuf==NULL){
             return;
         }
-        l=setResponseHeader(obuf,NULL,1+i_inst->_ref_record->num_of_srv,0,4);
+        l=setResponseHeader(obuf,NULL,1+i_inst->_ref_record->num_of_srv+4,0,0);
         //<Answer />
         //PTR
         l=writePtrRecord(i_inst->_ref_record,i2,obuf,l,obuflen);
@@ -1021,10 +1021,10 @@
 DROP:
     return;
 }
-#define CTRL_FLAG_INIT           0x00
-#define CTRL_FLAG_STARTED        0x80
-#define CTRL_FLAG_STOP_REQUESTED 0x40
-#define CTRL_FLAG_PROCESS_PACKET 0x20   //パケット処理中の間1
+#define ST_INIT 1       //初期QUERY送信(省略)
+#define ST_ANNOUNCE 2   //アナウンス
+#define ST_WAIT 3       //待機
+
 
 static NyLPC_TBool onPacket(NyLPC_TcUdpSocket_t* i_inst,const void* i_buf,const struct NyLPC_TIPv4RxInfo* i_info)
 {
@@ -1061,12 +1061,25 @@
 
 static void onPeriodic(NyLPC_TcUdpSocket_t* i_inst)
 {
-
-    if(NyLPC_cStopwatch_isExpired(&((NyLPC_TcMDnsServer_t*)i_inst)->_periodic_sw)){
-        //アナウンス
-        sendAnnounse(((NyLPC_TcMDnsServer_t*)i_inst));
-        //TTL(msec)*1000*60%
-        NyLPC_cStopwatch_startExpire((&((NyLPC_TcMDnsServer_t*)i_inst)->_periodic_sw),NyLPC_TcMDns_STD_TTL*1000*3/5);
+    NyLPC_TcMDnsServer_t* inst=(NyLPC_TcMDnsServer_t*)i_inst;
+    //Announce Timeout
+    if(NyLPC_cStopwatch_isExpired(&((NyLPC_TcMDnsServer_t*)inst)->_periodic_sw)){
+        switch(inst->_state){
+        case ST_WAIT:
+            inst->_state_val=0;
+            inst->_state=ST_ANNOUNCE;// set Announce status
+        case ST_ANNOUNCE:
+            //アナウンス
+            inst->_state_val++;
+            if(inst->_state_val<=3){
+                sendAnnounse(((NyLPC_TcMDnsServer_t*)inst));
+                NyLPC_cStopwatch_startExpire((&((NyLPC_TcMDnsServer_t*)inst)->_periodic_sw),1000);
+            }else{
+                inst->_state=ST_WAIT;
+                //TTL(msec)*1000*80%
+                NyLPC_cStopwatch_startExpire((&((NyLPC_TcMDnsServer_t*)inst)->_periodic_sw),NyLPC_TcMDns_STD_TTL*1000*4/5);
+            }
+        }
     }
 }
 
@@ -1079,6 +1092,8 @@
     NyLPC_cUdpSocket_setOnRxHandler(&(i_inst->_super),onPacket);
     NyLPC_cUdpSocket_setOnPeriodicHandler(&(i_inst->_super),onPeriodic);
     NyLPC_cUdpSocket_joinMulticast(&(i_inst->_super),&MDNS_MCAST_IPADDR);
+    i_inst->_state=ST_WAIT;
+    i_inst->_state_val=0;
     i_inst->_ref_record=i_ref_record;
     return NyLPC_TBool_TRUE;
 }
--- a/core/net/mdns/NyLPC_cMDnsServer.h	Tue Nov 11 13:23:54 2014 +0000
+++ b/core/net/mdns/NyLPC_cMDnsServer.h	Wed Nov 12 13:07:40 2014 +0000
@@ -71,6 +71,10 @@
     NyLPC_TcUdpSocket_t _super;
     /**周期実行タイマ*/
     NyLPC_TcStopwatch_t _periodic_sw;
+    /** 動作モード(private)*/
+    NyLPC_TUInt8 _state;
+    NyLPC_TUInt8 _state_val;
+    NyLPC_TUInt8 _padding[2];
     /** DNSレコードの参照情報*/
     const struct NyLPC_TDnsRecord* _ref_record;
 };