41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "network" 53 ,_readiness(READINESS_INVALID)
54 ,_macAddress(MACADDRESS_INVALID)
55 ,_ipAddress(IPADDRESS_INVALID)
56 ,_subnetMask(SUBNETMASK_INVALID)
57 ,_router(ROUTER_INVALID)
58 ,_ipConfig(IPCONFIG_INVALID)
59 ,_primaryDNS(PRIMARYDNS_INVALID)
60 ,_secondaryDNS(SECONDARYDNS_INVALID)
61 ,_ntpServer(NTPSERVER_INVALID)
62 ,_userPassword(USERPASSWORD_INVALID)
63 ,_adminPassword(ADMINPASSWORD_INVALID)
64 ,_httpPort(HTTPPORT_INVALID)
65 ,_defaultPage(DEFAULTPAGE_INVALID)
66 ,_discoverable(DISCOVERABLE_INVALID)
67 ,_wwwWatchdogDelay(WWWWATCHDOGDELAY_INVALID)
68 ,_callbackUrl(CALLBACKURL_INVALID)
69 ,_callbackMethod(CALLBACKMETHOD_INVALID)
70 ,_callbackEncoding(CALLBACKENCODING_INVALID)
71 ,_callbackCredentials(CALLBACKCREDENTIALS_INVALID)
72 ,_callbackInitialDelay(CALLBACKINITIALDELAY_INVALID)
73 ,_callbackSchedule(CALLBACKSCHEDULE_INVALID)
74 ,_callbackMinDelay(CALLBACKMINDELAY_INVALID)
75 ,_callbackMaxDelay(CALLBACKMAXDELAY_INVALID)
76 ,_poeCurrent(POECURRENT_INVALID)
77 ,_valueCallbackNetwork(NULL)
107 if(json_val->
has(
"readiness")) {
110 if(json_val->
has(
"macAddress")) {
113 if(json_val->
has(
"ipAddress")) {
116 if(json_val->
has(
"subnetMask")) {
119 if(json_val->
has(
"router")) {
122 if(json_val->
has(
"ipConfig")) {
125 if(json_val->
has(
"primaryDNS")) {
128 if(json_val->
has(
"secondaryDNS")) {
131 if(json_val->
has(
"ntpServer")) {
134 if(json_val->
has(
"userPassword")) {
137 if(json_val->
has(
"adminPassword")) {
140 if(json_val->
has(
"httpPort")) {
143 if(json_val->
has(
"defaultPage")) {
146 if(json_val->
has(
"discoverable")) {
149 if(json_val->
has(
"wwwWatchdogDelay")) {
152 if(json_val->
has(
"callbackUrl")) {
155 if(json_val->
has(
"callbackMethod")) {
158 if(json_val->
has(
"callbackEncoding")) {
161 if(json_val->
has(
"callbackCredentials")) {
164 if(json_val->
has(
"callbackInitialDelay")) {
167 if(json_val->
has(
"callbackSchedule")) {
170 if(json_val->
has(
"callbackMinDelay")) {
173 if(json_val->
has(
"callbackMaxDelay")) {
176 if(json_val->
has(
"poeCurrent")) {
218 }
catch (std::exception) {
248 }
catch (std::exception) {
278 }
catch (std::exception) {
307 }
catch (std::exception) {
336 }
catch (std::exception) {
377 }
catch (std::exception) {
392 res =
_setAttr(
"ipConfig", rest_val);
393 }
catch (std::exception) {
422 }
catch (std::exception) {
448 res =
_setAttr(
"primaryDNS", rest_val);
449 }
catch (std::exception) {
478 }
catch (std::exception) {
504 res =
_setAttr(
"secondaryDNS", rest_val);
505 }
catch (std::exception) {
534 }
catch (std::exception) {
559 res =
_setAttr(
"ntpServer", rest_val);
560 }
catch (std::exception) {
591 }
catch (std::exception) {
623 res =
_setAttr(
"userPassword", rest_val);
624 }
catch (std::exception) {
655 }
catch (std::exception) {
687 res =
_setAttr(
"adminPassword", rest_val);
688 }
catch (std::exception) {
717 }
catch (std::exception) {
742 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
743 res =
_setAttr(
"httpPort", rest_val);
744 }
catch (std::exception) {
773 }
catch (std::exception) {
799 res =
_setAttr(
"defaultPage", rest_val);
800 }
catch (std::exception) {
832 }
catch (std::exception) {
858 rest_val = (newval>0 ?
"1" :
"0");
859 res =
_setAttr(
"discoverable", rest_val);
860 }
catch (std::exception) {
893 }
catch (std::exception) {
921 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
922 res =
_setAttr(
"wwwWatchdogDelay", rest_val);
923 }
catch (std::exception) {
952 }
catch (std::exception) {
977 res =
_setAttr(
"callbackUrl", rest_val);
978 }
catch (std::exception) {
1008 }
catch (std::exception) {
1032 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
1033 res =
_setAttr(
"callbackMethod", rest_val);
1034 }
catch (std::exception) {
1067 }
catch (std::exception) {
1094 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
1095 res =
_setAttr(
"callbackEncoding", rest_val);
1096 }
catch (std::exception) {
1127 }
catch (std::exception) {
1159 res =
_setAttr(
"callbackCredentials", rest_val);
1160 }
catch (std::exception) {
1184 rest_val = string(username)+string(
":")+string(password);
1185 return _setAttr(
"callbackCredentials", rest_val);
1209 }
catch (std::exception) {
1233 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
1234 res =
_setAttr(
"callbackInitialDelay", rest_val);
1235 }
catch (std::exception) {
1264 }
catch (std::exception) {
1288 res =
_setAttr(
"callbackSchedule", rest_val);
1289 }
catch (std::exception) {
1318 }
catch (std::exception) {
1341 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
1342 res =
_setAttr(
"callbackMinDelay", rest_val);
1343 }
catch (std::exception) {
1372 }
catch (std::exception) {
1396 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
1397 res =
_setAttr(
"callbackMaxDelay", rest_val);
1398 }
catch (std::exception) {
1430 }
catch (std::exception) {
1478 }
catch (std::exception) {
1500 if (callback != NULL) {
1507 if (callback != NULL && this->
isOnline()) {
1640 vector<YFUN_DESCR> v_fundescr;
1642 string serial, funcId, funcName, funcVal, errmsg;
1645 v_fundescr.size() == 0 ||
string get_adminPassword(void)
int set_callbackMethod(Y_CALLBACKMETHOD_enum newval)
static const string SUBNETMASK_INVALID
yCRITICAL_SECTION _this_cs
int _callbackInitialDelay
static const int CALLBACKMAXDELAY_INVALID
Y_DISCOVERABLE_enum get_discoverable(void)
int set_callbackInitialDelay(int newval)
Y_DISCOVERABLE_enum _discoverable
string get_primaryDNS(void)
YRETCODE _load_unsafe(int msValidity)
static const int POECURRENT_INVALID
string get_subnetMask(void)
static const string CALLBACKCREDENTIALS_INVALID
static const string DEFAULTPAGE_INVALID
string get_userPassword(void)
int set_callbackMinDelay(int newval)
int set_userPassword(const string &newval)
int set_primaryDNS(const string &newval)
YNetwork * nextNetwork(void)
static int DefaultCacheValidity
int set_callbackUrl(const string &newval)
string getString(const string &key)
virtual int registerValueCallback(YNetworkValueCallback callback)
int set_callbackSchedule(const string &newval)
virtual int triggerCallback(void)
int set_ipConfig(const string &newval)
void _throw(YRETCODE errType, string errMsg)
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
string _download(const string &url)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
static const string PRIMARYDNS_INVALID
static YNetwork * FindNetwork(string func)
static const Y_READINESS_enum READINESS_INVALID
int get_callbackMinDelay(void)
string get_callbackUrl(void)
#define YAPI_INVALID_STRING
static const string MACADDRESS_INVALID
virtual int _parseAttr(YJSONObject *json_val)
virtual int _invokeValueCallback(string value)
virtual int useDHCPauto(void)
string get_ipAddress(void)
int set_defaultPage(const string &newval)
static const string CALLBACKSCHEDULE_INVALID
int getInt(const string &key)
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
YNetwork(const string &func)
Y_READINESS_enum get_readiness(void)
int set_adminPassword(const string &newval)
int get_callbackInitialDelay(void)
static YNetwork * FirstNetwork(void)
string get_macAddress(void)
Y_CALLBACKMETHOD_enum get_callbackMethod(void)
static const string IPCONFIG_INVALID
string get_secondaryDNS(void)
static const string ROUTER_INVALID
static const int HTTPPORT_INVALID
string get_ipConfig(void)
static const string IPADDRESS_INVALID
YNetworkValueCallback _valueCallbackNetwork
static YFunction * _FindFromCache(const string &classname, const string &func)
static string ysprintf(const char *fmt,...)
int set_secondaryDNS(const string &newval)
virtual int useStaticIP(string ipAddress, int subnetMaskLen, string router)
static const int CALLBACKMINDELAY_INVALID
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
static yCRITICAL_SECTION _global_cs
virtual int _parseAttr(YJSONObject *json_val)
int get_wwwWatchdogDelay(void)
Y_CALLBACKENCODING_enum _callbackEncoding
string get_ntpServer(void)
static const Y_DISCOVERABLE_enum DISCOVERABLE_INVALID
void(* YNetworkValueCallback)(YNetwork *func, const string &functionValue)
#define YAPI_HASH_BUF_SIZE
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
int set_callbackMaxDelay(int newval)
static const string USERPASSWORD_INVALID
virtual int useDHCP(string fallbackIpAddr, int fallbackSubnetMaskLen, string fallbackRouter)
static const string SECONDARYDNS_INVALID
string get_callbackSchedule(void)
int set_callbackCredentials(const string &newval)
static const Y_CALLBACKMETHOD_enum CALLBACKMETHOD_INVALID
virtual string ping(string host)
static const string CALLBACKURL_INVALID
int callbackLogin(string username, string password)
int set_callbackEncoding(Y_CALLBACKENCODING_enum newval)
virtual int set_periodicCallbackSchedule(string interval, int offset)
static const string ADMINPASSWORD_INVALID
string get_callbackCredentials(void)
int get_callbackMaxDelay(void)
static bool _apiInitialized
Y_READINESS_enum _readiness
int set_wwwWatchdogDelay(int newval)
YRETCODE _nextFunction(string &hwId)
static void _UpdateValueCallbackList(YFunction *func, bool add)
static const int CALLBACKINITIALDELAY_INVALID
static const int WWWWATCHDOGDELAY_INVALID
static const Y_CALLBACKENCODING_enum CALLBACKENCODING_INVALID
string get_defaultPage(void)
static const string NTPSERVER_INVALID
bool has(const string &key)
Y_CALLBACKMETHOD_enum _callbackMethod
int set_discoverable(Y_DISCOVERABLE_enum newval)
YRETCODE _setAttr(string attrname, string newvalue)
Y_CALLBACKENCODING_enum get_callbackEncoding(void)
int set_httpPort(int newval)
string _callbackCredentials
virtual int _invokeValueCallback(string value)
int set_ntpServer(const string &newval)