Closed heartinstaller closed 1 year ago
Someone please throw some light on this issue. Dont know what is happening
this is what i got on serial monitor, how to solve this issue?
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset load 0x4010f000, len 3424, room 16 tail 0 chksum 0x2e load 0x3fff20b8, len 40, room 8 tail 0 chksum 0x2b csum 0x2b v00044410 ~ld
@gaurav3015 If you okay, please show your source code.
@hirotakaster Thanks, Im sharing here the code im using. File location: this git/examples/esp8266.esp8266.ino Board: esp8266(esp12e)
Please throw some light. Thnkx
const char ssid = "MY SSID"; const char password = "MY PASSWORD";
// CoAP client response callback void callback_response(CoapPacket &packet, IPAddress ip, int port);
// CoAP server endpoint url callback void callback_light(CoapPacket &packet, IPAddress ip, int port);
// UDP and CoAP class // other initialize is "Coap coap(Udp, 512);" // 2nd default parameter is COAP_BUF_MAX_SIZE(defaulit:128) // For UDP fragmentation, it is good to set the maximum under // 1280byte when using the internet connection. WiFiUDP udp; Coap coap(udp);
// LED STATE bool LEDSTATE;
// CoAP server endpoint URL void callback_light(CoapPacket &packet, IPAddress ip, int port) { Serial.println("[Light] ON/OFF");
// send response char p[packet.payloadlen + 1]; memcpy(p, packet.payload, packet.payloadlen); p[packet.payloadlen] = NULL;
String message(p);
if (message.equals("0")) LEDSTATE = false; else if(message.equals("1")) LEDSTATE = true;
if (LEDSTATE) { digitalWrite(9, HIGH) ; coap.sendResponse(ip, port, packet.messageid, "1"); } else { digitalWrite(9, LOW) ; coap.sendResponse(ip, port, packet.messageid, "0"); } }
// CoAP client response callback void callback_response(CoapPacket &packet, IPAddress ip, int port) { Serial.println("[Coap Response got]");
char p[packet.payloadlen + 1]; memcpy(p, packet.payload, packet.payloadlen); p[packet.payloadlen] = NULL;
Serial.println(p); }
void setup() { Serial.begin(9600);
WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
Serial.println(""); Serial.println("WiFi connected"); Serial.println("IP address: "); Serial.println(WiFi.localIP());
// LED State pinMode(9, OUTPUT); digitalWrite(9, HIGH); LEDSTATE = true;
// add server url endpoints. // can add multiple endpoint urls. // exp) coap.server(callback_switch, "switch"); // coap.server(callback_env, "env/temp"); // coap.server(callback_env, "env/humidity"); Serial.println("Setup Callback Light"); coap.server(callback_light, "light");
// client response callback. // this endpoint is single callback. Serial.println("Setup Response Callback"); coap.response(callback_response);
// start coap server/client coap.start(); }
void loop() { delay(1000); coap.loop(); } / if you change LED, req/res test with coap-client(libcoap), run following. coap-client -m get coap://(arduino ip addr)/light coap-client -e "1" -m put coap://(arduino ip addr)/light coap-client -e "0" -m put coap://(arduino ip addr)/light /
@gaurav3015
I think your wifi networks maybe not works well. Can you try the Arduino ESP8266 sample code connect to WiFi and communicate properly via UDP.
Thanks @hirotakaster, I tried this 8266server code and got the ping on terminal. Please help me to work COAP p.s- i did not understand your the assignment you gave me to "communicate properly via UDP" but i tried this. If it's not what you wanted to see please let me know.
@gaurav3015
Your sample code(WebSocket) is use the TCP. so, Not a TCP, check the UDP socket work or not.
And the CoAP is use a UDP packet, so you should test with this ESP8266 sample code UDP socket on your environments. https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/udp-examples.html
If this UDP socket test is work well on your ESP8266 environments, something bug or problem on this library.
Thanks @hirotakaster, It worked!!!
But what next? still coap get same error. Please help me
@gaurav3015 okay, then you update following, use other port,
pinMode(9, OUTPUT);
digitalWrite(9, HIGH);
to other port (like a 5 or others). You might check this site for the cause of your error.
@hirotakaster Tried to change the pin to 5 and got this following reply:
00:36:03.974 -> IP address: 192.168.1.29 00:36:11.531 -> ?)���e�@`�9�����h�Z�............. 00:36:18.939 -> WiFi connected 00:36:18.939 -> IP address: 192.168.1.29 00:36:26.380 -> ?)�J 00:36:26.413 -> ��9�� �A�K a�............ 00:36:33.329 -> WiFi connected 00:36:33.329 -> IP address: 192.168.1.29 00:36:41.258 -> �Q)�����@H��0ε�K$jB�............. 00:36:48.697 -> WiFi connected 00:36:48.697 -> IP address: 192.168.1.29 00:36:56.118 -> �������@H�����jGI|�d............. 00:37:03.558 -> WiFi connected 00:37:03.558 -> IP address: 192.168.1.29 00:37:11.010 -> ����!9�DŇ����h0��............. 00:37:18.430 -> WiFi connected 00:37:18.430 -> IP address: 192.168.1.29 00:37:25.882 -> ��FJ 00:37:25.882 -> ���@H��h0�8�............. 00:37:33.298 -> WiFi connected 00:37:33.298 -> IP address: 192.168.1.29 00:37:40.745 -> H!��) 00:37:40.745 -> �!H�h$hSˠ............. 00:37:48.159 -> WiFi connected 00:37:48.159 -> IP address: 192.168.1.29
@gaurav3015
Not only 'pinMode(9, OUTPUT);' update all port? What’s this? Adjust the serial speed and output logs for debugging. From your logs alone, I don't know what you are doing. (show your code and operation)
@hirotakaster Yes it did worked. I got the ping(on terminal). Huge thanks to you. Response on serial monitor: 19:07:49.025 -> �HQȸ>dIY�4C,l�4h R`�.�KC@�............. 19:08:16.459 -> WiFi connected 19:08:16.459 -> IP address: 192.168.1.29 19:08:16.492 -> Setup Callback Light 19:08:16.525 -> Setup Response Callback
I hope i'll be able do to the next. Thanks again.
@gaurav3015 close this issue.
Running code on esp12E and example is ESP8266 following is the response i'm getting on loop.
WiFi connected IP address: 192.168.1.28 ��bL����@H��90��.�JC�............. WiFi connected IP address: 192.168.1.28 ?)���9�`�9����jGI|�d............. WiFi connected IP address: 192.168.1.28 ���Ԏ���@H����!K$hbC............. WiFi connected IP address: 192.168.1.28 F)�����@Hʪ0ε�KG���d.............
while on terminal following is the response: $ping
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
Request timeout for icmp_seq 8
Request timeout for icmp_seq 9
Request timeout for icmp_seq 10
Request timeout for icmp_seq 11
Request timeout for icmp_seq 12
64 bytes from 192.168.1.28: icmp_seq=13 ttl=255 time=28.324 ms
Request timeout for icmp_seq 14
Request timeout for icmp_seq 15
Request timeout for icmp_seq 16
Request timeout for icmp_seq 17
Request timeout for icmp_seq 18