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