yocto_network.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_network.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindNetwork(), the high-level API for Network functions
6  *
7  * - - - - - - - - - License information: - - - - - - - - -
8  *
9  * Copyright (C) 2011 and beyond by Yoctopuce Sarl, Switzerland.
10  *
11  * Yoctopuce Sarl (hereafter Licensor) grants to you a perpetual
12  * non-exclusive license to use, modify, copy and integrate this
13  * file into your software for the sole purpose of interfacing
14  * with Yoctopuce products.
15  *
16  * You may reproduce and distribute copies of this file in
17  * source or object form, as long as the sole purpose of this
18  * code is to interface with Yoctopuce products. You must retain
19  * this notice in the distributed source file.
20  *
21  * You should refer to Yoctopuce General Terms and Conditions
22  * for additional information regarding your rights and
23  * obligations.
24  *
25  * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED 'AS IS' WITHOUT
26  * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
27  * WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS
28  * FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO
29  * EVENT SHALL LICENSOR BE LIABLE FOR ANY INCIDENTAL, SPECIAL,
30  * INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
31  * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR
32  * SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT
33  * LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
34  * CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON THE
35  * BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF
36  * WARRANTY, OR OTHERWISE.
37  *
38  *********************************************************************/
39 
40 
41 #ifndef YOCTO_NETWORK_H
42 #define YOCTO_NETWORK_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YNetwork return codes)
50 //--- (end of YNetwork return codes)
51 //--- (YNetwork definitions)
52 class YNetwork; // forward declaration
53 
54 typedef void (*YNetworkValueCallback)(YNetwork *func, const string& functionValue);
55 #ifndef _Y_READINESS_ENUM
56 #define _Y_READINESS_ENUM
57 typedef enum {
65 #endif
66 #ifndef _Y_DISCOVERABLE_ENUM
67 #define _Y_DISCOVERABLE_ENUM
68 typedef enum {
73 #endif
74 #ifndef _Y_CALLBACKMETHOD_ENUM
75 #define _Y_CALLBACKMETHOD_ENUM
76 typedef enum {
82 #endif
83 #ifndef _Y_CALLBACKENCODING_ENUM
84 #define _Y_CALLBACKENCODING_ENUM
85 typedef enum {
99 #endif
100 #define Y_MACADDRESS_INVALID (YAPI_INVALID_STRING)
101 #define Y_IPADDRESS_INVALID (YAPI_INVALID_STRING)
102 #define Y_SUBNETMASK_INVALID (YAPI_INVALID_STRING)
103 #define Y_ROUTER_INVALID (YAPI_INVALID_STRING)
104 #define Y_IPCONFIG_INVALID (YAPI_INVALID_STRING)
105 #define Y_PRIMARYDNS_INVALID (YAPI_INVALID_STRING)
106 #define Y_SECONDARYDNS_INVALID (YAPI_INVALID_STRING)
107 #define Y_NTPSERVER_INVALID (YAPI_INVALID_STRING)
108 #define Y_USERPASSWORD_INVALID (YAPI_INVALID_STRING)
109 #define Y_ADMINPASSWORD_INVALID (YAPI_INVALID_STRING)
110 #define Y_HTTPPORT_INVALID (YAPI_INVALID_UINT)
111 #define Y_DEFAULTPAGE_INVALID (YAPI_INVALID_STRING)
112 #define Y_WWWWATCHDOGDELAY_INVALID (YAPI_INVALID_UINT)
113 #define Y_CALLBACKURL_INVALID (YAPI_INVALID_STRING)
114 #define Y_CALLBACKCREDENTIALS_INVALID (YAPI_INVALID_STRING)
115 #define Y_CALLBACKINITIALDELAY_INVALID (YAPI_INVALID_UINT)
116 #define Y_CALLBACKSCHEDULE_INVALID (YAPI_INVALID_STRING)
117 #define Y_CALLBACKMINDELAY_INVALID (YAPI_INVALID_UINT)
118 #define Y_CALLBACKMAXDELAY_INVALID (YAPI_INVALID_UINT)
119 #define Y_POECURRENT_INVALID (YAPI_INVALID_UINT)
120 //--- (end of YNetwork definitions)
121 
122 //--- (YNetwork declaration)
130 #ifdef __BORLANDC__
131 #pragma option push -w-8022
132 #endif
133 //--- (end of YNetwork declaration)
134 protected:
135  //--- (YNetwork attributes)
136  // Attributes (function value cache)
138  string _macAddress;
139  string _ipAddress;
140  string _subnetMask;
141  string _router;
142  string _ipConfig;
143  string _primaryDNS;
145  string _ntpServer;
149  string _defaultPage;
152  string _callbackUrl;
162 
163  friend YNetwork *yFindNetwork(const string& func);
164  friend YNetwork *yFirstNetwork(void);
165 
166  // Function-specific method for parsing of JSON output and caching result
167  virtual int _parseAttr(YJSONObject* json_val);
168 
169  // Constructor is protected, use yFindNetwork factory function to instantiate
170  YNetwork(const string& func);
171  //--- (end of YNetwork attributes)
172 
173 public:
174  ~YNetwork();
175  //--- (YNetwork accessors declaration)
176 
177  static const Y_READINESS_enum READINESS_DOWN = Y_READINESS_DOWN;
178  static const Y_READINESS_enum READINESS_EXISTS = Y_READINESS_EXISTS;
179  static const Y_READINESS_enum READINESS_LINKED = Y_READINESS_LINKED;
180  static const Y_READINESS_enum READINESS_LAN_OK = Y_READINESS_LAN_OK;
181  static const Y_READINESS_enum READINESS_WWW_OK = Y_READINESS_WWW_OK;
182  static const Y_READINESS_enum READINESS_INVALID = Y_READINESS_INVALID;
183  static const string MACADDRESS_INVALID;
184  static const string IPADDRESS_INVALID;
185  static const string SUBNETMASK_INVALID;
186  static const string ROUTER_INVALID;
187  static const string IPCONFIG_INVALID;
188  static const string PRIMARYDNS_INVALID;
189  static const string SECONDARYDNS_INVALID;
190  static const string NTPSERVER_INVALID;
191  static const string USERPASSWORD_INVALID;
192  static const string ADMINPASSWORD_INVALID;
193  static const int HTTPPORT_INVALID = YAPI_INVALID_UINT;
194  static const string DEFAULTPAGE_INVALID;
195  static const Y_DISCOVERABLE_enum DISCOVERABLE_FALSE = Y_DISCOVERABLE_FALSE;
196  static const Y_DISCOVERABLE_enum DISCOVERABLE_TRUE = Y_DISCOVERABLE_TRUE;
197  static const Y_DISCOVERABLE_enum DISCOVERABLE_INVALID = Y_DISCOVERABLE_INVALID;
198  static const int WWWWATCHDOGDELAY_INVALID = YAPI_INVALID_UINT;
199  static const string CALLBACKURL_INVALID;
200  static const Y_CALLBACKMETHOD_enum CALLBACKMETHOD_POST = Y_CALLBACKMETHOD_POST;
201  static const Y_CALLBACKMETHOD_enum CALLBACKMETHOD_GET = Y_CALLBACKMETHOD_GET;
202  static const Y_CALLBACKMETHOD_enum CALLBACKMETHOD_PUT = Y_CALLBACKMETHOD_PUT;
203  static const Y_CALLBACKMETHOD_enum CALLBACKMETHOD_INVALID = Y_CALLBACKMETHOD_INVALID;
204  static const Y_CALLBACKENCODING_enum CALLBACKENCODING_FORM = Y_CALLBACKENCODING_FORM;
205  static const Y_CALLBACKENCODING_enum CALLBACKENCODING_JSON = Y_CALLBACKENCODING_JSON;
206  static const Y_CALLBACKENCODING_enum CALLBACKENCODING_JSON_ARRAY = Y_CALLBACKENCODING_JSON_ARRAY;
207  static const Y_CALLBACKENCODING_enum CALLBACKENCODING_CSV = Y_CALLBACKENCODING_CSV;
208  static const Y_CALLBACKENCODING_enum CALLBACKENCODING_YOCTO_API = Y_CALLBACKENCODING_YOCTO_API;
209  static const Y_CALLBACKENCODING_enum CALLBACKENCODING_JSON_NUM = Y_CALLBACKENCODING_JSON_NUM;
210  static const Y_CALLBACKENCODING_enum CALLBACKENCODING_EMONCMS = Y_CALLBACKENCODING_EMONCMS;
211  static const Y_CALLBACKENCODING_enum CALLBACKENCODING_AZURE = Y_CALLBACKENCODING_AZURE;
212  static const Y_CALLBACKENCODING_enum CALLBACKENCODING_INFLUXDB = Y_CALLBACKENCODING_INFLUXDB;
213  static const Y_CALLBACKENCODING_enum CALLBACKENCODING_MQTT = Y_CALLBACKENCODING_MQTT;
214  static const Y_CALLBACKENCODING_enum CALLBACKENCODING_YOCTO_API_JZON = Y_CALLBACKENCODING_YOCTO_API_JZON;
215  static const Y_CALLBACKENCODING_enum CALLBACKENCODING_INVALID = Y_CALLBACKENCODING_INVALID;
216  static const string CALLBACKCREDENTIALS_INVALID;
217  static const int CALLBACKINITIALDELAY_INVALID = YAPI_INVALID_UINT;
218  static const string CALLBACKSCHEDULE_INVALID;
219  static const int CALLBACKMINDELAY_INVALID = YAPI_INVALID_UINT;
220  static const int CALLBACKMAXDELAY_INVALID = YAPI_INVALID_UINT;
221  static const int POECURRENT_INVALID = YAPI_INVALID_UINT;
222 
244  Y_READINESS_enum get_readiness(void);
245 
247  { return this->get_readiness(); }
248 
257  string get_macAddress(void);
258 
259  inline string macAddress(void)
260  { return this->get_macAddress(); }
261 
270  string get_ipAddress(void);
271 
272  inline string ipAddress(void)
273  { return this->get_ipAddress(); }
274 
282  string get_subnetMask(void);
283 
284  inline string subnetMask(void)
285  { return this->get_subnetMask(); }
286 
294  string get_router(void);
295 
296  inline string router(void)
297  { return this->get_router(); }
298 
318  string get_ipConfig(void);
319 
320  inline string ipConfig(void)
321  { return this->get_ipConfig(); }
322 
323  int set_ipConfig(const string& newval);
324  inline int setIpConfig(const string& newval)
325  { return this->set_ipConfig(newval); }
326 
334  string get_primaryDNS(void);
335 
336  inline string primaryDNS(void)
337  { return this->get_primaryDNS(); }
338 
350  int set_primaryDNS(const string& newval);
351  inline int setPrimaryDNS(const string& newval)
352  { return this->set_primaryDNS(newval); }
353 
361  string get_secondaryDNS(void);
362 
363  inline string secondaryDNS(void)
364  { return this->get_secondaryDNS(); }
365 
377  int set_secondaryDNS(const string& newval);
378  inline int setSecondaryDNS(const string& newval)
379  { return this->set_secondaryDNS(newval); }
380 
388  string get_ntpServer(void);
389 
390  inline string ntpServer(void)
391  { return this->get_ntpServer(); }
392 
403  int set_ntpServer(const string& newval);
404  inline int setNtpServer(const string& newval)
405  { return this->set_ntpServer(newval); }
406 
416  string get_userPassword(void);
417 
418  inline string userPassword(void)
419  { return this->get_userPassword(); }
420 
434  int set_userPassword(const string& newval);
435  inline int setUserPassword(const string& newval)
436  { return this->set_userPassword(newval); }
437 
447  string get_adminPassword(void);
448 
449  inline string adminPassword(void)
450  { return this->get_adminPassword(); }
451 
465  int set_adminPassword(const string& newval);
466  inline int setAdminPassword(const string& newval)
467  { return this->set_adminPassword(newval); }
468 
476  int get_httpPort(void);
477 
478  inline int httpPort(void)
479  { return this->get_httpPort(); }
480 
492  int set_httpPort(int newval);
493  inline int setHttpPort(int newval)
494  { return this->set_httpPort(newval); }
495 
503  string get_defaultPage(void);
504 
505  inline string defaultPage(void)
506  { return this->get_defaultPage(); }
507 
519  int set_defaultPage(const string& newval);
520  inline int setDefaultPage(const string& newval)
521  { return this->set_defaultPage(newval); }
522 
533  Y_DISCOVERABLE_enum get_discoverable(void);
534 
536  { return this->get_discoverable(); }
537 
550  int set_discoverable(Y_DISCOVERABLE_enum newval);
552  { return this->set_discoverable(newval); }
553 
565  int get_wwwWatchdogDelay(void);
566 
567  inline int wwwWatchdogDelay(void)
568  { return this->get_wwwWatchdogDelay(); }
569 
584  int set_wwwWatchdogDelay(int newval);
585  inline int setWwwWatchdogDelay(int newval)
586  { return this->set_wwwWatchdogDelay(newval); }
587 
595  string get_callbackUrl(void);
596 
597  inline string callbackUrl(void)
598  { return this->get_callbackUrl(); }
599 
610  int set_callbackUrl(const string& newval);
611  inline int setCallbackUrl(const string& newval)
612  { return this->set_callbackUrl(newval); }
613 
622  Y_CALLBACKMETHOD_enum get_callbackMethod(void);
623 
625  { return this->get_callbackMethod(); }
626 
637  int set_callbackMethod(Y_CALLBACKMETHOD_enum newval);
639  { return this->set_callbackMethod(newval); }
640 
652  Y_CALLBACKENCODING_enum get_callbackEncoding(void);
653 
655  { return this->get_callbackEncoding(); }
656 
670  int set_callbackEncoding(Y_CALLBACKENCODING_enum newval);
672  { return this->set_callbackEncoding(newval); }
673 
683  string get_callbackCredentials(void);
684 
685  inline string callbackCredentials(void)
686  { return this->get_callbackCredentials(); }
687 
705  int set_callbackCredentials(const string& newval);
706  inline int setCallbackCredentials(const string& newval)
707  { return this->set_callbackCredentials(newval); }
708 
722  int callbackLogin(string username,string password);
723 
731  int get_callbackInitialDelay(void);
732 
733  inline int callbackInitialDelay(void)
734  { return this->get_callbackInitialDelay(); }
735 
746  int set_callbackInitialDelay(int newval);
747  inline int setCallbackInitialDelay(int newval)
748  { return this->set_callbackInitialDelay(newval); }
749 
757  string get_callbackSchedule(void);
758 
759  inline string callbackSchedule(void)
760  { return this->get_callbackSchedule(); }
761 
771  int set_callbackSchedule(const string& newval);
772  inline int setCallbackSchedule(const string& newval)
773  { return this->set_callbackSchedule(newval); }
774 
782  int get_callbackMinDelay(void);
783 
784  inline int callbackMinDelay(void)
785  { return this->get_callbackMinDelay(); }
786 
796  int set_callbackMinDelay(int newval);
797  inline int setCallbackMinDelay(int newval)
798  { return this->set_callbackMinDelay(newval); }
799 
807  int get_callbackMaxDelay(void);
808 
809  inline int callbackMaxDelay(void)
810  { return this->get_callbackMaxDelay(); }
811 
822  int set_callbackMaxDelay(int newval);
823  inline int setCallbackMaxDelay(int newval)
824  { return this->set_callbackMaxDelay(newval); }
825 
836  int get_poeCurrent(void);
837 
838  inline int poeCurrent(void)
839  { return this->get_poeCurrent(); }
840 
868  static YNetwork* FindNetwork(string func);
869 
881  virtual int registerValueCallback(YNetworkValueCallback callback);
883 
884  virtual int _invokeValueCallback(string value);
885 
901  virtual int useDHCP(string fallbackIpAddr,int fallbackSubnetMaskLen,string fallbackRouter);
902 
913  virtual int useDHCPauto(void);
914 
927  virtual int useStaticIP(string ipAddress,int subnetMaskLen,string router);
928 
938  virtual string ping(string host);
939 
950  virtual int triggerCallback(void);
951 
965  virtual int set_periodicCallbackSchedule(string interval,int offset);
966 
967 
968  inline static YNetwork* Find(string func)
969  { return YNetwork::FindNetwork(func); }
970 
978  YNetwork *nextNetwork(void);
979  inline YNetwork *next(void)
980  { return this->nextNetwork();}
981 
991  static YNetwork* FirstNetwork(void);
992  inline static YNetwork* First(void)
993  { return YNetwork::FirstNetwork();}
994 #ifdef __BORLANDC__
995 #pragma option pop
996 #endif
997  //--- (end of YNetwork accessors declaration)
998 };
999 
1000 //--- (YNetwork functions declaration)
1001 
1029 inline YNetwork* yFindNetwork(const string& func)
1030 { return YNetwork::FindNetwork(func);}
1041 { return YNetwork::FirstNetwork();}
1042 
1043 //--- (end of YNetwork functions declaration)
1044 
1045 #endif
string secondaryDNS(void)
Y_CALLBACKMETHOD_enum
Definition: yocto_network.h:76
YNetwork * yFirstNetwork(void)
string _callbackSchedule
string _userPassword
static const string SUBNETMASK_INVALID
int _callbackInitialDelay
int setCallbackMaxDelay(int newval)
int setCallbackUrl(const string &newval)
string _macAddress
Y_DISCOVERABLE_enum _discoverable
int setHttpPort(int newval)
int setCallbackSchedule(const string &newval)
int _wwwWatchdogDelay
int _callbackMaxDelay
string macAddress(void)
Y_DISCOVERABLE_enum
Definition: yocto_network.h:68
static const string CALLBACKCREDENTIALS_INVALID
static YNetwork * Find(string func)
static const string DEFAULTPAGE_INVALID
string _ntpServer
string ipConfig(void)
YNetwork * next(void)
Y_CALLBACKENCODING_enum
Definition: yocto_network.h:85
int setUserPassword(const string &newval)
string callbackSchedule(void)
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
Y_CALLBACKENCODING_enum callbackEncoding(void)
int setSecondaryDNS(const string &newval)
string _adminPassword
static const string PRIMARYDNS_INVALID
string callbackCredentials(void)
static YNetwork * FindNetwork(string func)
int setIpConfig(const string &newval)
string _router
int poeCurrent(void)
static const string MACADDRESS_INVALID
string defaultPage(void)
int setCallbackCredentials(const string &newval)
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
Y_CALLBACKMETHOD_enum callbackMethod(void)
string ntpServer(void)
string router(void)
static const string CALLBACKSCHEDULE_INVALID
string subnetMask(void)
int callbackInitialDelay(void)
int _poeCurrent
string _ipAddress
static YNetwork * FirstNetwork(void)
static const string IPCONFIG_INVALID
static const string ROUTER_INVALID
Y_DISCOVERABLE_enum discoverable(void)
static const string IPADDRESS_INVALID
YNetworkValueCallback _valueCallbackNetwork
string ipAddress(void)
string _callbackUrl
int wwwWatchdogDelay(void)
string _defaultPage
int httpPort(void)
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
Y_CALLBACKENCODING_enum _callbackEncoding
void(* YNetworkValueCallback)(YNetwork *func, const string &functionValue)
Definition: yocto_network.h:54
int callbackMaxDelay(void)
static YNetwork * First(void)
static const string USERPASSWORD_INVALID
static const string SECONDARYDNS_INVALID
string _subnetMask
int setCallbackMinDelay(int newval)
int setCallbackMethod(Y_CALLBACKMETHOD_enum newval)
int _callbackMinDelay
string adminPassword(void)
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
static const string CALLBACKURL_INVALID
Y_READINESS_enum readiness(void)
int callbackMinDelay(void)
int setDiscoverable(Y_DISCOVERABLE_enum newval)
static const string ADMINPASSWORD_INVALID
int setCallbackInitialDelay(int newval)
string userPassword(void)
int setNtpServer(const string &newval)
int setDefaultPage(const string &newval)
int setPrimaryDNS(const string &newval)
Y_READINESS_enum
Definition: yocto_network.h:57
Y_READINESS_enum _readiness
int setCallbackEncoding(Y_CALLBACKENCODING_enum newval)
int setWwwWatchdogDelay(int newval)
string _ipConfig
string _primaryDNS
YNetwork * yFindNetwork(const string &func)
string _secondaryDNS
static const string NTPSERVER_INVALID
Y_CALLBACKMETHOD_enum _callbackMethod
int setAdminPassword(const string &newval)
string callbackUrl(void)
string _callbackCredentials
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:2563
string primaryDNS(void)


yoctopuce_altimeter
Author(s): Anja Sheppard
autogenerated on Mon Jun 10 2019 15:49:11