This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088
Dependents: MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more
NetConfig.h
00001 #pragma once 00002 //////////////////////////////////////////////////////////////////////////////// 00003 // NetConfig.h 00004 //////////////////////////////////////////////////////////////////////////////// 00005 00006 #include "NyLPC_net.h" 00007 #include "IpAddr.h" 00008 00009 00010 namespace MiMic 00011 { 00012 class IpAddr; 00013 /** 00014 * Network configulation class. 00015 * The class is used by Net constructor. 00016 */ 00017 class NetConfig 00018 { 00019 private: 00020 /**service record*/ 00021 NyLPC_TcNetConfig_t _inst; 00022 struct NyLPC_TMDnsServiceRecord _srv_record; 00023 void _syncServiceInfo(); 00024 struct NyLPC_TDnsRecord _dns_record; 00025 struct NyLPC_TUPnPDevDescDevice _upnp_desc; 00026 struct NyLPC_TUPnPDevDescIcon _upnp_icon; 00027 const struct NyLPC_TDnsRecord* _ref_custom_dns_record; 00028 const struct NyLPC_TUPnPDevDescDevice* _ref_custom_upnp_desc; 00029 char _udn[42];//uuid:00000000-0000-0000-0000-000000000000+'\0' 00030 public: 00031 /** wrapped base LPC class.*/ 00032 NyLPC_TcNetConfig_t* refBaseInstance(){return &this->_inst;} 00033 /** internal UPnP description*/ 00034 const struct NyLPC_TUPnPDevDescDevice* refUPnPDevDesc()const; 00035 /** internal dns record*/ 00036 const struct NyLPC_TDnsRecord* refMdnsRecord()const; 00037 /** Thi sfunction returnes recommended HTTP service port number.*/ 00038 unsigned short getHttpPort()const{return this->_inst.services.http_port;} 00039 public: 00040 /** 00041 * The constructor. 00042 * This function initializes instance by onchip configulation data. 00043 * @param i_is_factory_default 00044 * Factory default flag. 00045 * <ul> 00046 * <li>true - The function sets factory default setting. 00047 * <li>false -The function sets onchip memory configulation (default) 00048 * </ul> 00049 */ 00050 NetConfig(bool i_is_factory_default=false); 00051 virtual ~NetConfig(); 00052 /** 00053 * Set IPv4 ip address to instance. 00054 */ 00055 void setIpAddr(unsigned char ip4,unsigned char ip3,unsigned char ip2,unsigned char ip1); 00056 void setIpAddr(const IpAddr& i_addr); 00057 /** 00058 * Set IPv4 network mask value to instance. 00059 */ 00060 void setNetMask(unsigned char ip4,unsigned char ip3,unsigned char ip2,unsigned char ip1); 00061 void setNetMask(const IpAddr& i_mask); 00062 /** 00063 * Set IPv4 default gateway address to instance. 00064 */ 00065 void setGateway(unsigned char ip4,unsigned char ip3,unsigned char ip2,unsigned char ip1); 00066 void setGateway(const IpAddr& i_addr); 00067 /** 00068 * Set Zero configuration enable flag. 00069 * @param v 00070 * True, Zero configuration mode. The mimic will try DHCP and AutoIP configuration. 00071 * ipaddress,netmask,gateway are ignored. 00072 * False, Manual mode. The mimic will set ip address from on chip data. 00073 */ 00074 void setZeroconf(bool v); 00075 /** 00076 * This function set a recommended HTTP port number to the application. 00077 */ 00078 void setSrvHttpPort(unsigned short port); 00079 /** 00080 * Set mDNS operation flag. 00081 * This function recommends to the application to provide mDNS service to network. 00082 */ 00083 void setSrvMdns(bool i_enable); 00084 /** 00085 * Set UPnP operation flag. 00086 * This function recommends to the application to provide UPnP service to network. 00087 */ 00088 void setSrvUPnP(bool i_enable); 00089 /** 00090 * This function sets host name for mDNS. 00091 * This value has effect to the mDNS a record. 00092 * @param i_hostname 00093 * host name. 00094 * NULL terminated string. 00095 */ 00096 void setHostName(const char* i_hostname); 00097 /** 00098 * This function sets host name for mDNS. 00099 * This is effective for mDNS a record. 00100 * @param i_hostname 00101 * host name. 00102 * @param i_len 00103 * length of host name. 00104 * maximum length is NyLPC_TcNetConfig_HOSTNAME_LEN-1 00105 */ 00106 void setHostName(const char* i_hostname,int len); 00107 const char* getHostName(); 00108 /** 00109 * Set ethernet mac address to instance. 00110 */ 00111 void setEmac(unsigned char ip6,unsigned char ip5,unsigned char ip4,unsigned char ip3,unsigned char ip2,unsigned char ip1); 00112 /** 00113 * Set FrendlyName to instance. 00114 * This value has effect to the mDNS name and UPnP frendlyName. 00115 */ 00116 void setFriendlyName(const char* i_name); 00117 void setUPnPManufactur(const char* i_name,const char* i_url); 00118 void setUPnPModel(const char* i_name,const char* i_number,const char* i_url,const char* i_description); 00119 void setUPnPSerialNumber(const char* i_number); 00120 void setUPnPPresentationURL(const char* i_url); 00121 00122 /** 00123 * Set Time base UDN value. 00124 * UDN is expressed as follows. 00125 * The value of the UDN, must be different for each device. 00126 * [i_time_l]-[i_time_m]-[i_time_h|0x80]-[i_sq&0x3F|0x80]-[MAC ADDRESS] 00127 */ 00128 void setUPnPUdn(unsigned long i_time_l,unsigned short i_time_m,unsigned short i_time_h,unsigned short i_sq); 00129 void setUPnPIcon(unsigned short i_width,unsigned short i_height,unsigned short i_depth,const char* i_mimetype,const char* i_url); 00130 /** 00131 * This function sets a custom UPnP device description to instance. 00132 * All UPnP description will be overwritten if set it. 00133 * @param i_ref_description 00134 * Perfect description structure. 00135 */ 00136 void setCustomUPnPDescription(const struct NyLPC_TUPnPDevDescDevice* i_ref_description); 00137 /** 00138 * This function sets a custom mDNS record to instance. 00139 * All mDNS record will be overwritten if set it. 00140 * @param i_ref_record 00141 * Perfect DNS record structure. 00142 */ 00143 void setCustomMdnsRecord(const struct NyLPC_TDnsRecord* i_ref_record); 00144 00145 00146 00147 /** 00148 * Load configulation from text file. 00149 * <p>File format example 00150 * <pre> 00151 * macaddr=00:00:00:00:00:00 00152 * host=MiMic01 00153 * ipaddr=192.168.0.1 00154 * netmask=255.255.255.0 00155 * gateway=192.168.0.254 00156 * srv_http_port=80 00157 * srv_mdns=yes 00158 * </pre> 00159 * <p>Keys 00160 * <ul> 00161 * <li>macaddr=[:macaddr:] - 48bit ethernet mac address that are separated by ':'</li> 00162 * <li>ipaddr=[:ip:] || AUTO 00163 * - 32 bit IP address or auto detection. AUTO will be to try DHCP and AUTOIP. 00164 * </li> 00165 * <li>netmask=[:ip:]- 32 bit network mask value.</li> 00166 * <li>gateway=[:ip:] - 32 bit default gateway address.</li> 00167 * <li>srv_http_port=[:UINT16:] - 16bit http service port number(not ZERO)</li> 00168 * <li>srv_mdns=[yes|no] - mDNS service flag.</li> 00169 * </ul> 00170 * </p> 00171 * <p>Default setting 00172 * <ul> 00173 * <li>macaddr=02:01:02:03:04:05 (In case of mbed it is preset value.) 00174 * <li>host=MiMic020102030405 00175 * <li>ipaddr =192.168.0.39 00176 * <li>netmask=255.255.255.0 00177 * <li>gateway=192.168.0.254 00178 * <li>srv_http_port=80 00179 * <li>srv_mdns=yes</li> 00180 * </ul> 00181 * </p> 00182 * Maximum line length is 31. 00183 * Specified values are override on-chip setting value. 00184 * If the same value appeared, then the last one is enabled. 00185 * In case of ipaddr=AUTO, gateway and netmask are ignored. 00186 * </p> 00187 * @return 00188 * true if file read. false is not read. 00189 */ 00190 bool loadFromFile(const char* i_file); 00191 }; 00192 }
Generated on Tue Jul 12 2022 15:46:15 by 1.7.2