Connection to Tesla Powerwall not possible anymore after Powerwall update
- Dominant language
- C++
- Stars
- 16.7k
- Forks
- 13.1k
- PR merge metrics
- No merged PRs in 30d
Description
Hey, any updates on this? I'm getting an `_wait_for_handshake: failed` unfortunately, too. Please look at this:
### Basic Infos
- [x] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [x] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [x] I have tested that the issue is present in current master branch (aka latest git).
- [x] I have searched the issue tracker for a similar issue.
- [x] If there is a stack dump, I have decoded it.
- [x] I have filled out all fields below.
#### Platform
- Hardware: ESP-12F
- Core Version: SDK:2.2.2-dev(38a443e)/Core:3.0.1=30001000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:c0b69df
- Development Env: Platformio
- Operating System: Windows
### Settings in IDE
- Module: Wemos D1 mini r2
- Flash Mode: qio
- Flash Size: 4MB
- lwip Variant: v2 Lower Memory
- Reset Method: ck
- Flash Frequency: [40Mhz]
- CPU Frequency: 80Mhz
- Upload Using: SERIAL
- Upload Speed: 115200
### Problem Description
So I got problems to do the handshake with my tesla powerwall (solar battery storage system) which I'm doing a [project](https://github.com/MoritzLerch/pv_display) with. The powerwall did an update and unfortunately as described I can not connect to it anymore. I'm getting the `_wait_for_handshake: failed` error. However, if I try that request with curl on my PC it works just fine. Raspberry Pi also works. So problem has to have to do with the BearSSL-WifiClientSecure library.
### Getting stuck here:
(In my project in [`lib/Powerwall/Powerwall.h:54`](https://github.com/MoritzLerch/pv_display/blob/db5a520d18739716266433ea8cda33937ffd9b02/lib/Powerwall/Powerwall.h#L54-L67))
```cpp
powerwall_ip = "192.168.178.38"
WiFiClientSecure httpsClient;
httpsClient.setInsecure();
httpsClient.setTimeout(10000);
int retry = 0;
while ((!httpsClient.connect(powerwall_ip, 443)) && (retry < 15)) {
delay(100);
Serial.print(".");
retry++;
}
if (retry >= 15) {
return ("CONN-FAIL");
}
```
### Debug Messages
```
(DEV: doing GET-request to 192.168.178.38/api/system_status/soe)
:ref 1
BSSL:_connectSSL: start connection
_iobuf_in: 0x3fff1744
_iobuf_out: 0x3fffb2a4
_iobuf_in_size: 16709
_iobuf_out_size: 597
:wr 137 0
:wrc 137 137 0
:ack 137
:rcl pb=0 sz=-1
:abort
BSSL:_wait_for_handshake: failed
BSSL:Couldn't connect. Error = 'Unknown error code.'
.:ur 1
:dsrcv 0
:del
```
### Debugging
I did some debugging with a friend and from the `_wait_for_handshake` function (bool) in the WifiClientSecure-class we got to the `_run_until` function and searched for the `-1`. We found out the connection is crashing here:
```cpp
if (!(_client->state() == ESTABLISHED) && !WiFiClient::available()) {
return (state & target) ? 0 : -1;
}
```
After this we just outputted the values of `state` and `target` via `DEBUG_BSSL` and found out they were `4` and `8`. So they are not matching with the binary-and (&) so this has to be the problem.
These would be the two values:
```cpp
/** \brief SSL engine state: engine may receive records from the peer. */
#define BR_SSL_RECVREC 0x0004
/** \brief SSL engine state: engine may accept application data to send. */
#define BR_SSL_SENDAPP 0x0008
```
Probably someone can help.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.