26 #include <MD5Builder.h> 29 #include <ESP8266WiFi.h> 30 #include <ESP8266HTTPClient.h> 34 #include <HTTPClient.h> 44 TR064_CODE_UNKNOWNACTION = 401,
45 TR064_CODE_FALSEARGUMENTS = 402,
46 TR064_CODE_ACTIONNOTAUTHORIZED = 606,
47 TR064_CODE_SECONDFACTORAUTHREQUIRED = 866,
48 TR064_CODE_SECONDFACTORAUTHBLOCKED = 867,
49 TR064_CODE_SECONDFACTORAUTHBUSY = 868,
54 #define arr_len( x ) ( sizeof( x ) / sizeof( *x ) ) 57 #define TR064_NO_SERVICES -1 58 #define TR064_SERVICES_LOADED 0 61 #define TR064_NO_SERVICES -1 62 #define TR064_SERVICES_LOADED 0 65 #define TR064_NO_SERVICES -1 66 #define TR064_SERVICES_LOADED 0 85 enum LoggingLevels {DEBUG_NONE, DEBUG_ERROR, DEBUG_WARNING, DEBUG_INFO, DEBUG_VERBOSE};
91 TR064_CODE_UNKNOWNACTION = 401,
92 TR064_CODE_FALSEARGUMENTS = 402,
93 TR064_CODE_AUTHFAILED = 503,
94 TR064_CODE_ARGUMENTVALUEINVALIDE = 600,
95 TR064_CODE_ACTIONNOTAUTHORIZED = 606,
96 TR064_CODE_ARRAYINDEXINVALID = 713,
97 TR064_CODE_NOSUCHENTRY = 714,
98 TR064_CODE_INTERNALERROR = 820,
99 TR064_CODE_SECONDFACTORAUTHREQUIRED = 866,
100 TR064_CODE_SECONDFACTORAUTHBLOCKED = 867,
101 TR064_CODE_SECONDFACTORAUTHBUSY = 868,
105 TR064(uint16_t port,
const String& ip,
const String& user,
const String& pass);
107 TR064&
setServer(uint16_t port,
const String& ip,
const String& user,
const String& pass);
111 bool action(
const String& service,
const String& act, String params[][2] = {},
int nParam = 0,
const String& url =
"");
113 bool action(
const String& service,
const String& act, String params[][2],
int nParam, String (*req)[2],
int nReq,
const String& url =
"");
120 WiFiClient tr064client;
125 void initServiceURLs();
126 void deb_print(
const String& message,
int level);
127 void deb_println(
const String& message,
int level);
128 bool action_raw(
const String& service,
const String& act, String params[][2],
int nParam,
const String& url =
"");
129 bool httpRequest(
const String& url,
const String& xml,
const String& action,
bool retry);
130 String generateAuthToken();
131 String generateAuthXML();
132 String findServiceURL(
const String& service);
133 String cleanOldServiceName(
const String& service);
134 bool xmlTakeParam(String (*params)[2],
int nParam);
135 bool xmlTakeParam(String& value,
const String& needParam);
136 static String errorToString(
int error);
148 const char*
const _requestStart =
"<?xml version=\"1.0\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">";
149 const char*
const _detectPage =
"/tr64desc.xml";
150 const char*
const _servicePrefix =
"urn:dslforum-org:service:";
151 unsigned long lastOutActivity;
152 unsigned long lastInActivity;
158 String _services[100][2];
Class to easily make TR-064 calls. This is the main class of this library. An object of this class ke...
Definition: tr064.h:76
String md5String(const String &s)
Translates a string into its MD5 hash.
Definition: tr064.cpp:534
bool action(const String &service, const String &act, String params[][2]={}, int nParam=0, const String &url="")
This function will call an action on the service of the device with certain parameters and return val...
Definition: tr064.cpp:205
TR064()
Library/Class to easily make TR-064 calls. Do not construct this unless you have a working connection...
Definition: tr064.cpp:66
tr064_codes
HTTP codes see RFC7231.
Definition: tr064.h:88
TR064 & setServer(uint16_t port, const String &ip, const String &user, const String &pass)
Set the server parameters, needed if the empty constructor was used.
Definition: tr064.cpp:100
t_tr064_codes
HTTP codes see RFC7231.
Definition: tr064.h:41
LoggingLevels
Definition: tr064.h:85
int debug_level
Available levels are DEBUG_NONE, DEBUG_ERROR, DEBUG_WARNING, DEBUG_INFO, and DEBUG_VERBOSE.
Definition: tr064.h:117
String byte2hex(byte number)
Translates a byte number into a hex number.
Definition: tr064.cpp:554
void init()
Initializes the library. Needs to be explicitly called. There should already be a working connection ...
Definition: tr064.cpp:78
int state()
Returns the State of Service Load.
Definition: tr064.cpp:350