Closed nopnop2002 closed 3 years ago
Could the buffer be too small?
<< dc e0 11 2 f 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 20 d 37 35 33 30 63 34 38 37 32 62 19
The buffer should be ok, the messages can be of (almost) any length. But 'Bad CRC' could show bad SPI connection. I am not sure if you need 5V/3V3 convertor, but I'd try to put it in the SPI bus. And I'd try to slow down the SPI speed in case of any interference.
I'm sorry, I made a mistake on the UNO side.
wrong: char ssid[] = "aterm-d5a4ee-g "; // your network SSID (name)
correct: char ssid[] = "aterm-d5a4ee-g"; // your network SSID (name)
But I can't connect. esp12 is correctly receiving the ssid and passphrase. ssid: [aterm-d5a4ee-g]passphrase: [7530c4872b4f2] -> 7
WiFi.mode(WIFI_OFF);
WiFi.mode(WIFI_STA);
#if defined(ESPSPI_MONITOR)
Serial.printf("ssid: [%s]", ssid);
Serial.printf("passphrase: [%s]", passphrase);
#endif
uint8_t status = WiFi.begin(ssid, passphrase);
Serial.printf(" -> %d\n", status);
replyStart(cmd, 1);
replyParam(&status, 1);
replyEnd();
SPI SLAVE ver. 0.2.5 Protocol ver. 0.2.5 << df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 << df e0 50 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7e df e0 d0 1 5 30 2e 32 2e 35 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 << dc e0 11 2 e 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 d 37 35 33 30 63 34 38 37 32 62 34 b8 << df 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cc Conn: aterm-d5a4ee-gmode : sta(cc:50:e3:08:1c:d6) add if0 ssid: [aterm-d5a4ee-g]passphrase: [7530c4872b4f2] -> 7 df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 << df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 10 cnt
connected with aterm-d5a4ee-g, channel 1 dhcp client start... ip:192.168.10.133,mask:255.255.255.0,gw:192.168.10.1 Heap: 49880 << df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
df e0 a0 1 1 3 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 << df e0 50 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7e df e0 d0 1 5 30 2e 32 2e 35 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 << dc e0 11 2 e 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 d 37 35 33 30 63 34 38 37 32 62 34 b8 << df 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cc Conn: aterm-d5a4ee-gstate: 5 -> 0 (0) rm 0 Disconnect status=7 del if0 usl mode : null mode : sta(cc:50:e3:08:1c:d6) add if0 ssid: [aterm-d5a4ee-g]passphrase: [7530c4872b4f2] -> 7 df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 << df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 10 cnt
connected with aterm-d5a4ee-g, channel 1 dhcp client start... ip:192.168.10.133,mask:255.255.255.0,gw:192.168.10.1
I hope I understand the 'state' value well, then you are losing the connection. The 'state: x->y' should write values from the following enum:
typedef enum {
WL_NO_SHIELD = 255, // for compatibility with WiFi Shield library
WL_IDLE_STATUS = 0,
WL_NO_SSID_AVAIL = 1,
WL_SCAN_COMPLETED = 2,
WL_CONNECTED = 3,
WL_CONNECT_FAILED = 4,
WL_CONNECTION_LOST = 5,
WL_DISCONNECTED = 6
} wl_status_t;
Please try a sketch from Arduino/ESP8266 examples first in order to be sure there are no problems with your ESP8266 and it can connecti to the AP. Also I'd recommend to turn off the ESPSPI_MONITOR debugging when you urgently don't need it as it may break the SPI communication. From what I've seen, I can tell the communication between the Arduino and the ESP is ok.
I have changed some code in ConnectWithWAP:
// attempt to connect to Wifi network:
#if 0
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network:
status = WiFiSpi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
#else
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network:
status = WiFiSpi.begin(ssid, pass);
while(1) {
if ( WiFiSpi.status() == WL_CONNECTED) break;
// wait 1 seconds for connection:
delay(1000);
}
#endif
It connected.
Attempting to connect to WPA SSID: aterm-d5a4ee-g
You're connected to the networkSSID: aterm-d5a4ee-g
BSSID: 52:DE:36:97:B7:F8
signal strength (RSSI):-62
IP Address: 192.168.10.133
MAC address: D6:1C:8:E3:50:CC
SSID: aterm-d5a4ee-g
BSSID: 52:DE:36:97:B7:F8
signal strength (RSSI):-63
SSID: aterm-d5a4ee-g
BSSID: 52:DE:36:97:B7:F8
signal strength (RSSI):-64
I pressed the UNO reset button several times. I get this error sometime.
Since all GPIOs of ESP8266 are 5V tolerant, we don't need 5V/3V3 convertor. It may be a problem with SPI Speed.
[espspi_proxy.h:300] W: Slave rx is not ready, status 15
[espspi_proxy.h:300] W: Slave rx is not ready, status 15
[espspi_proxy.h:329] W: Slave tx is not ready, status 15
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[wifispi_drv.cpp:262] W: Error waitResponse
WiFi module not present
aterm-d5a4ee-g
BSSID: 52:DE:36:97:B7:F8
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
signal strength (RSSI):-64
[espspi_proxy.h:300] W: Slave rx is not ready, status 0
[espspi_proxy.h:300] W: Slave rx is not ready, status 0
[espspi_proxy.h:329] W: Slave tx is not ready, status 0
[wifispi_drv.cpp:262] W: Error waitResponse
WiFi module not presen
Hi, I tested ConnectWithWPA sketch on my device (STM32F103 + ESP8266) and got correct results (run several times to be sure it gives the same result for each run). I admit, I am not using the recent version of Arduino/ESP8266, I fixed the commit c61b70de865531f62218541fa0f32715c153a449 (14 months old) but it should not matter.
SDK:2.2.2-dev(a58da79)/Core:unspecified=0/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-30-g92add50/BearSSL:5c771be
SPI SLAVE ver. 0.2.5
Protocol ver. 0.2.5
Conn: BILNetmode : sta(a0:20:a6:04:a5:8b)
add if0
-> 6
scandone
state: 0 -> 2 (b0)
Heap: 40808
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
cnt
connected with BILNet, channel 5
dhcp client start...
ip:192.168.1.183,mask:255.255.255.0,gw:192.168.1.254
Heap: 40000
pm open,type:2 0
Heap: 39480
Heap: 39480
I want to see your logs with _DEBUG_MESSAGES enabled.
It’s mine: SDK:2.2.2-dev(38a443e)/Core:unix-3.0.0-dev=-300000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:c0b69df
I want to see your logs with _DEBUG_MESSAGES enabled.
Edit: My SPI bus speed is 4 MHz.
SDK:2.2.2-dev(a58da79)/Core:unspecified=0/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-30-g92add50/BearSSL:5c771be
SPI SLAVE ver. 0.2.5
Protocol ver. 0.2.5
Heap: 41960
Heap: 41960
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 11 2 6 42 49 4c 4e 65 74 a -- -- -- -- -- -- -- -- -- -- ee 0 0 0 0 0 0 0 0 13
Conn: BILNetmode : sta(a0:20:a6:04:a5:8b)
add if0
-> 6
>> df e0 91 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
scandone
state: 0 -> 2 (b0)
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 5
cnt
connected with BILNet, channel 5
dhcp client start...
ip:192.168.1.183,mask:255.255.255.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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 36
>> df e0 a4 1 6 cc 32 e5 df c6 62 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 25 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 19
>> df e0 a5 1 4 c8 ff ff ff ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Heap: 39464
Edit: My SPI bus speed is 4 MHz.
Where is SPI SPEED defined in the header file?
Maybe in my environment the last a0 message cannot be received by UNO.
connected with aterm-d5a4ee-g, channel 1
dhcp client start...
ip:192.168.10.133,mask:255.255.255.0,gw:192.168.10.1
Heap: 49880
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 3 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
So UNO demands a reconnection.
<< df e0 50 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7e
>> df e0 d0 1 5 30 2e 32 2e 35 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< dc e0 11 2 e 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 d 37 35 33 30 63 34 38 37 32 62 34 b8
<< df 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cc
And I have one more question.
Why are so many GET_CONN_STATUS_CMD issued?
SPI SLAVE ver. 0.2.5
Protocol ver. 0.2.5
Heap: 41960
Heap: 41960
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 11 2 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
scandone
state: 0 -> 2 (b0)
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 6 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 5
cnt
connected with BILNet, channel 5
dhcp client start...
ip:192.168.1.183,mask:255.255.255.0,gw:192.168.1.254
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 3 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
This is UNO. GET_CONN_STATUS_CMD has been issued only 3 times
SPI SLAVE ver. 0.2.5
Protocol ver. 0.2.5
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 50 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7e
>> df e0 d0 1 5 30 2e 32 2e 35 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< dc e0 11 2 e 61 74 65 72 6d 2d 64 35 61 34 65 65 2d 67 d 37 35 33 30 63 34 38 37 32 62 34 b8
<< df 66 32 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 cc
Conn: aterm-d5a4ee-gmode : sta(cc:50:e3:08:1c:d6)
add if0
ssid: [aterm-d5a4ee-g]passphrase: [7530c4872b4f2] -> 7
>> df e0 91 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 7 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 10
cnt
connected with aterm-d5a4ee-g, channel 1
dhcp client start...
ip:192.168.10.133,mask:255.255.255.0,gw:192.168.10.1
Heap: 49880
<< df e0 20 0 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8a
>> df e0 a0 1 1 3 ee 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The function WiFiSpi.init();
has parameter max_speed
.
Edit: Connecting to my AP takes a time, so that more GET_CONN_STATUS_CMD commands are not unusual.
The waiting loop for connecting is here:
uint8_t WiFiSpiClass::begin(const char* ssid)
{
uint8_t status = WL_IDLE_STATUS;
uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION;
if (WiFiSpiDrv::wifiSetNetwork(ssid, strlen(ssid)) != WL_FAILURE)
{
do
{
delay(WL_DELAY_START_CONNECTION);
status = WiFiSpiDrv::getConnectionStatus();
}
while (((status == WL_IDLE_STATUS) || (status == WL_SCAN_COMPLETED) || (status == WL_DISCONNECTED)) && (--attempts > 0));
} else
status = WL_CONNECT_FAILED;
return status;
}
If max_speed is not specified, UNO's SPI speed is probably 8Mhz.
If max_speed is specified, SPI.beginTransaction is executed. But there is no SPI.endTransaction.
void WiFiSpiDrv::wifiDriverInit(uint8_t pin, uint32_t max_speed, SPIClass *in_spi)
{
spi_obj = in_spi;
spi_obj->begin();
if (max_speed != 0)
spi_obj->beginTransaction(SPISettings(max_speed, MSBFIRST, SPI_MODE0));
espSpiProxy.begin(pin, spi_obj);
}
It's rather old code of mine, I can't remember all details, but AFAIK the endTransaction is not that important, try to slow down the bus. IMHO, the Arduino bus is 4 MHz as well, see:
class SPISettings {
public:
SPISettings(uint32_t clock, uint8_t bitOrder, uint8_t dataMode) {
if (__builtin_constant_p(clock)) {
init_AlwaysInline(clock, bitOrder, dataMode);
} else {
init_MightInline(clock, bitOrder, dataMode);
}
}
SPISettings() {
init_AlwaysInline(4000000, MSBFIRST, SPI_MODE0);
}
For libraries that support SPI with transactions, SPI.begin() defines SPI_HAS_TRANSACTION.
{
spi_obj = in_spi;
spi_obj->begin();
#if defined(SPI_HAS_TRANSACTION)
spi_obj->beginTransaction(SPISettings(max_speed, MSBFIRST, SPI_MODE0));
#endif
#if 0
if (max_speed != 0)
spi_obj->beginTransaction(SPISettings(max_speed, MSBFIRST, SPI_MODE0));
#endif
espSpiProxy.begin(pin, spi_obj);
}
Perhaps STM32's SPI LIBRARY may automatically issue endTransaction ().
I believe, beginTransaction is for us useful only in the two lines (AVR):
SPCR = settings.spcr;
SPSR = settings.spsr;
The SPI transaction in an Arduino construction, there no such term in SPI bus definition.
IMHO, the Arduino bus is 4 MHz as well, see:
I don't know why don't work with 4Mhz.
Thank you for your many support.
@nopnop2002 , I have just checked out the newest Arduino/ESP8266 libraries ~based on SDK 3.0.0.~ and it is failing here, too!!
So I assume the SDK:2.2.2-dev(38a443e)/Core:unix-3.0.0-dev=-300000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:c0b69df
introduced a bug in my app. I will look at it as the time allows, but for now, please check out an older version of Arduino/ESP8266 github project and give it a try.
Edit: and don't worry about SPI transactions, as long as we are the only one who uses the SPI bus (and we are), the beginTransaction is used only to setup the SPI bus clock. Yes, it is dirty in terms of Arduino transactions but totally irrelevant.
please check out an older version of Arduino/ESP8266 github project and give it a try.
Thank you for your help.
EDIT) I found that Legacy SPI code works on STM32 without using setClockDivider().
The problem is on ESP8266 side, described here: https://github.com/esp8266/Arduino/issues/7432 Closing here and opening in the other repository (https://github.com/JiriBilek/WiFiSpiESP/issues/19)
The situation seems to be much easier :)
There was an inconsistency in wl_status_t
type between this library and the esp8266/Arduino version causing bad detection of status values. I made a fix and it is working for me at last.
Please get the branch https://github.com/JiriBilek/WiFiSpi/tree/Fix_%2332 and give it a try.
Edit: to my big surprise, the change was introduced somewhere in 2020 in esp8266/Arduino repo, where they added a new item in enum in between the old values :(
Edit: it is this commit: https://github.com/esp8266/Arduino/pull/7652
I tried new branch. I got this error on Arduino UNO side. Probably SPI communication is not established.
[espspi_proxy.h:300] W: Slave rx is not ready, status 15
[espspi_proxy.h:300] W: Slave rx is not ready, status 15
[espspi_proxy.h:329] W: Slave tx is not ready, status 15
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[espspi_proxy.h:261] W: Bad CRC, request repeated
[wifispi_drv.cpp:262] W: Error waitResponse
WiFi module not present
This is my compile option using WeMos D1 Mini.
Are you sure there is no issue with the SPI bus? My fix doesn't rely with the SPI bus at all.
I am not sure we are heading the right way now. The latest release in esp8266/Arduino repo does not contain the changed wl_definitions.h
file.
So I'd suggest using the latest official esp8266/Arduino release for compiling and the issue would be gone. In future, when they make a new release, I'll update the library. Otherwise I am stuck in the problem of incompatibility.
I downgrade esp8266 core library from git version to release version.
git version SDK:2.2.2-dev(38a443e)/Core:unix-3.0.0-dev=-300000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:c0b69df
release version(install using board manager) SDK:2.2.2-dev(38a443e)/Core:2.7.3-3-g2843a5ac=20703003/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-30-g92add50/BearSSL:5c771be
But error don't fixed.
I'm give up to use. Thank you for many help.
Closing as the source of the problem lies outside this repo. I will update the library when the wl_status_t
type is changed in the release of esp8266/Arduino repository. For now, this library works with last release of esp8266/Arduino lib, not with the git head.
Thank you again.
I flashed WiFiSpiESP BearSSL branch to WeMos D1 Mini(ESP12).
And I opened https://github.com/JiriBilek/WiFiSpi/tree/BearSSL/examples/ConnectWithWPA, edit ssid & pass, flashed to Arduino Uno.
And I connected D1 and UNO, Reset Uno.
But connection fail.
Do you have any help.
This is UNO side.
This is ESP12 side.