feat(IOT): LibAPI #21
@ -27,10 +27,9 @@ bool API::wifiBegin(String wifiId, String wifiPass, Stream* espSerial){
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool API::connect(){
|
||||||
JSONVar* API::connect(){
|
|
||||||
this->client->stop();
|
this->client->stop();
|
||||||
JSONVar* sortie =nullptr;
|
bool sortie = false;
|
||||||
|
|
||||||
JSONVar data;
|
JSONVar data;
|
||||||
|
|
||||||
@ -69,14 +68,16 @@ JSONVar* API::connect(){
|
|||||||
|
|
||||||
String str = responce.substring(responce.indexOf("{"),responce.lastIndexOf("}")+1);
|
String str = responce.substring(responce.indexOf("{"),responce.lastIndexOf("}")+1);
|
||||||
|
|
||||||
sortie = new JSONVar(JSONVar::parse(str));
|
JSONVar jsonRes = new JSONVar(JSONVar::parse(str));
|
||||||
|
|
||||||
this->token = JSONVar::stringify((*sortie)["token"]);
|
this->token = JSONVar::stringify(jsonRes["token"]);
|
||||||
|
|
||||||
this->token = this->token.substring(1,this->token.length()-1);
|
this->token = this->token.substring(1,this->token.length()-1);
|
||||||
|
|
||||||
this->client->stop();
|
this->client->stop();
|
||||||
|
|
||||||
|
sortie = true;
|
||||||
|
|
||||||
return sortie;
|
return sortie;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +91,8 @@ bool API::sendValute(String val, String poubelleID, String valUnit, bool full){
|
|||||||
String strData = JSONVar::stringify(data);
|
String strData = JSONVar::stringify(data);
|
||||||
|
|
||||||
if(this->token == ""){
|
if(this->token == ""){
|
||||||
this->connect();
|
bool connected = this->connect();
|
||||||
|
if(!connected)return false;
|
||||||
}
|
}
|
||||||
if(this->https){
|
if(this->https){
|
||||||
if (!this->client->connectSSL(("https://" + this->serveurHost).c_str(), 443)) {
|
if (!this->client->connectSSL(("https://" + this->serveurHost).c_str(), 443)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user