@@ -114,7 +114,7 @@ void MicroGear::initEndpoint(Client *client, char* endpoint) {
114114 char pstr[100 ];
115115 int port = this ->securemode ?GEARAUTHSECUREPORT:GEARAUTHPORT;
116116
117- if (client->connect (GEARAUTHHOST ,port)){
117+ if (client->connect (gearauth ,port)){
118118 sprintf (pstr," GET /api/endpoint/%s HTTP/1.1\r\n\r\n " ,this ->gearkey );
119119 client->write ((const uint8_t *)pstr,strlen (pstr));
120120
@@ -137,7 +137,7 @@ void MicroGear::syncTime(Client *client, unsigned long *bts) {
137137 int port = (this ->securemode )?GEARAUTHSECUREPORT:GEARAUTHPORT;
138138
139139 *bts = 0 ;
140- if (client->connect (GEARAUTHHOST ,port)){
140+ if (client->connect (gearauth ,port)){
141141
142142 if (this ->securemode ) {
143143 WiFiClientSecure *clientsecure = (WiFiClientSecure *)(client);
@@ -148,7 +148,7 @@ void MicroGear::syncTime(Client *client, unsigned long *bts) {
148148 Serial.print (" fingerprint loaded from eeprom : " );
149149 Serial.println (tstr);
150150 #endif
151- if (clientsecure->verify (tstr, GEARAUTHHOST )) {
151+ if (clientsecure->verify (tstr, gearauth )) {
152152 #ifdef DEBUG_H
153153 Serial.println (" fingerprint matched" );
154154 #endif
@@ -209,6 +209,9 @@ MicroGear::MicroGear(Client& netclient ) {
209209 this ->backoff = 10 ;
210210 this ->retry = RETRY;
211211
212+ strcpy (this ->gearauth ,GEARAUTHHOST);
213+ this ->gearauth [MAXGEARAUTHSIZE] = ' \0 ' ;
214+
212215 this ->eepromoffset = 0 ;
213216 cb_message = NULL ;
214217 cb_connected = NULL ;
@@ -283,7 +286,7 @@ void MicroGear::resetToken() {
283286 char revokecode[REVOKECODESIZE+1 ];
284287 int port = this ->securemode ?GEARAUTHSECUREPORT:GEARAUTHPORT;
285288
286- if (sockclient->connect (GEARAUTHHOST ,port)){
289+ if (sockclient->connect (gearauth ,port)){
287290 readEEPROM (token,EEPROM_TOKENOFFSET,TOKENSIZE);
288291 readEEPROM (revokecode,EEPROM_REVOKECODEOFFSET,REVOKECODESIZE);
289292 sprintf (pstr," GET /api/revoke/%s/%s HTTP/1.1\r\n\r\n " ,token,revokecode);
@@ -514,7 +517,7 @@ int MicroGear::connectBroker(char* appid) {
514517
515518 if (authclient) delete (authclient);
516519 authclient = new AuthClient (*sockclient);
517- authclient->init (appid,scope,bootts);
520+ authclient->init (gearauth, appid,scope,bootts);
518521
519522 tokenOK = getToken (this ->gearkey ,this ->gearalias ,token,tokensecret,endpoint);
520523 delete (authclient);
@@ -821,3 +824,13 @@ int MicroGear::state() {
821824 if (!mqttclient) return -9 ;
822825 else return this ->mqttclient ->state ();
823826}
827+
828+ int MicroGear::setConfig (char * key, char * value) {
829+ if (strcmp (key," GEARAUTH" )==0 ) {
830+ strncpy (gearauth,value,MAXGEARAUTHSIZE);
831+ return 1 ;
832+ }
833+ else {
834+ return 0 ;
835+ }
836+ }
0 commit comments