Giter Club home page Giter Club logo

esp-coap's Introduction

thingTronics ESP8266 12E Arduino Library

This is a Arduino Library for the ESP8266 12E.

ESP-CoAP server/client library for Arduino

This repo contains CoAP protocol for operationg ESP-12E as CoAP server and as CoAp client.

IETF CoAP RFC 7252

RFC 7252 simple server library for Arduino.

Repository Contents

  • /examples - Example sketches for the library (.ino). Run these from the Arduino IDE.
  • /src - Source files for the library (.cpp, .h).
  • library.properties - General library properties for the Arduino package manager.
  • library.json - General library properties for the Arduino package manager in JSON format
  • keywords.txt - Contains the keywords for Arduino IDE.

This lightweight library source code have only 4 files. coapServer.cpp, coapServer.h, coapClient.cpp, coapClient.h .

Example

Some sample sketches for Arduino included(/examples/).

  • coapserver.ino: simple server endpoint url callback sample.
  • coapclient.ino: simple client response callback sample.

How to use

Download this source code branch zip file and extract to the Arduino libraries directory or checkout repository. Here is checkout on Ubuntu.

cd $HOME/Downloads/Arduino/libraries/
git clone https://github.com/automote/ESP-CoAP
# restart Arduino IDE, you can find ESP-CoAP examples.

working with CoAP server

  • Upload the server example code to ESP-12E and open Serial Monitor to get the IPaddress of ESP-12E(server)
  • Run the coap client(web browser) with following URI coap://IPaddress:default port number/resource, to connect to ESP-12E server.

working with CoAP client

  • Upload the client example cose to ESP-12E, check the working by taking ETH Zurich as server.

For more information about this library please vist here.

Where to Buy

You can buy the ESP-CoAP compatible modules from us by going to this URL here.

Features

  • Server Side Working:

    • Methods
      • GET
      • PUT
      • POST (update working,creation not working)
      • DELETE (not working)
    • Ping
    • Observe (only 1 resource; only 10 observers)
    • Resource Discovery
    • Block Transfer (WIP)
  • Client Side Working:

    • Methods
      • GET
      • PUT
      • POST
      • DELETE
    • Observe
    • Ping

Maintainers

The ESP-CoAP is maintained by thingTronics Innovations.

Main contributor:

esp-coap's People

Contributors

efriede avatar ka0o0 avatar lovelesh avatar per1234 avatar pravallikanagesh avatar srihariash999 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp-coap's Issues

Memory leakage with packet having a Token in it

Reproducibility:

Hardware: ESP8266
Software : Firefox version 45.02 + Copper extension

Set arduino sketch as server using this library.
Printing 'ESP.getFreeHeap();' when a coap request is received to check memory usage.

Sending a request from Copper in debug mode (up right checkbox) with and without a token.

Behaviour:
Not setting a token the ESP free memory doesn't change... while setting a token memory goes down on each request over time (8 byte each request).

Checking RFC7252 specs... a token should take exactly 8 byte

EDIT: removing the ESP coap server response to an external request with a token, the leakage still be there... so it seems that the ESP Coap server doesn't release the memory used to store the token when it receives a request with it

Compile errors

I wish I could be more descriptive but I don't know enough yet. I get the following line highlighted.

static int handle_put_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

I'm using Arduino 1.6.13 and the current Git version of ESP8266


`Arduino: 1.6.13 (Windows 10), Board: "Generic ESP8266 Module, 160 MHz, 40MHz, QIO, 115200, 4M (3M SPIFFS), ck, Disabled, None"

In file included from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Print.h:27:0,

             from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Stream.h:26,

             from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Udp.h:38,

             from C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:27,

             from sketch\endpoints.c:3:

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Printable.h:25:1: error: unknown type name 'class'

class Print;

^

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Printable.h:33:1: error: unknown type name 'class'

class Printable {

^

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Printable.h:33:17: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token

class Printable {

             ^

In file included from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Stream.h:26:0,

             from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Udp.h:38,

             from C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:27,

             from sketch\endpoints.c:3:

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Print.h:34:1: error: unknown type name 'class'

class Print {

^

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Print.h:34:13: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token

class Print {

         ^

In file included from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Udp.h:38:0,

             from C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:27,

             from sketch\endpoints.c:3:

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Stream.h:38:1: error: unknown type name 'class'

class Stream: public Print {

^

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Stream.h:38:13: error: expected '=', ',', ';', 'asm' or 'attribute' before ':' token

class Stream: public Print {

         ^

In file included from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Udp.h:39:0,

             from C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:27,

             from sketch\endpoints.c:3:

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/IPAddress.h:29:1: error: unknown type name 'class'

class IPAddress: public Printable {

^

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/IPAddress.h:29:16: error: expected '=', ',', ';', 'asm' or 'attribute' before ':' token

class IPAddress: public Printable {

            ^

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/IPAddress.h:90:1: error: unknown type name 'IPAddress'

extern const IPAddress INADDR_NONE;

^

In file included from C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:27:0,

             from sketch\endpoints.c:3:

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Udp.h:41:1: error: unknown type name 'class'

class UDP: public Stream {

^

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Udp.h:41:10: error: expected '=', ',', ';', 'asm' or 'attribute' before ':' token

class UDP: public Stream {

      ^

In file included from sketch\endpoints.c:3:0:

C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:114:1: error: unknown type name 'class'

class CoapOption {

^

C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:114:18: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token

class CoapOption {

              ^

C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:121:1: error: unknown type name 'class'

class CoapPacket {

^

C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:121:18: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token

class CoapPacket {

              ^

C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:134:37: error: expected ')' before '&' token

typedef void (*callback)(CoapPacket &, IPAddress, int);

                                 ^

C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:137:1: error: unknown type name 'class'

class CoapUri {

^

C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:137:15: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token

class CoapUri {

           ^

C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:169:1: error: unknown type name 'class'

class Coap {

^

C:\Users\Rudy\Documents\Arduino\libraries\CoAP_simple_library/coap.h:169:12: error: expected '=', ',', ';', 'asm' or 'attribute' before '{' token

class Coap {

        ^

endpoints.c:32: error: unknown type name 'coap_rw_buffer_t'

static int handle_get_well_known_core(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                                   ^

endpoints.c:32: error: unknown type name 'coap_packet_t'

endpoints.c:32: error: unknown type name 'coap_packet_t'

static int handle_get_well_known_core(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                                                                                          ^

endpoints.c:33: error: unknown type name 'coap_rw_buffer_t'

static int handle_get_light_blink(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                               ^

endpoints.c:33: error: unknown type name 'coap_packet_t'

endpoints.c:33: error: unknown type name 'coap_packet_t'

static int handle_get_light_blink(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                                                                                      ^

endpoints.c:34: error: unknown type name 'coap_rw_buffer_t'

static int handle_put_light_blink(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                               ^

endpoints.c:34: error: unknown type name 'coap_packet_t'

endpoints.c:34: error: unknown type name 'coap_packet_t'

static int handle_put_light_blink(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                                                                                      ^

endpoints.c:35: error: unknown type name 'coap_rw_buffer_t'

static int handle_get_request(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                           ^

endpoints.c:35: error: unknown type name 'coap_packet_t'

endpoints.c:35: error: unknown type name 'coap_packet_t'

static int handle_get_request(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                                                                                  ^

endpoints.c:36: error: unknown type name 'coap_rw_buffer_t'

static int handle_put_request(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                           ^

endpoints.c:36: error: unknown type name 'coap_packet_t'

endpoints.c:36: error: unknown type name 'coap_packet_t'

static int handle_put_request(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                                                                                  ^

endpoints.c:37: error: unknown type name 'coap_rw_buffer_t'

static int handle_get_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                         ^

endpoints.c:37: error: unknown type name 'coap_packet_t'

endpoints.c:37: error: unknown type name 'coap_packet_t'

static int handle_get_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                                                                                ^

endpoints.c:38: error: unknown type name 'coap_rw_buffer_t'

static int handle_put_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                         ^

endpoints.c:38: error: unknown type name 'coap_packet_t'

endpoints.c:38: error: unknown type name 'coap_packet_t'

static int handle_put_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                                                                                ^

endpoints.c:39: error: unknown type name 'coap_rw_buffer_t'

static int handle_get_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                         ^

endpoints.c:39: error: unknown type name 'coap_packet_t'

endpoints.c:39: error: unknown type name 'coap_packet_t'

static int handle_get_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                                                                                ^

endpoints.c:40: error: unknown type name 'coap_rw_buffer_t'

static int handle_put_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                         ^

endpoints.c:40: error: unknown type name 'coap_packet_t'

endpoints.c:40: error: unknown type name 'coap_packet_t'

static int handle_put_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo);

                                                                                ^

endpoints.c:65: error: unknown type name 'coap_endpoint_path_t'

static const coap_endpoint_path_t path_well_known_core = {2, {".well-known", "core"}};

^

sketch\endpoints.c:65:1: warning: braces around scalar initializer [enabled by default]

sketch\endpoints.c:65:1: warning: (near initialization for 'path_well_known_core') [enabled by default]

sketch\endpoints.c:65:1: warning: initialization makes integer from pointer without a cast [enabled by default]

sketch\endpoints.c:65:1: warning: (near initialization for 'path_well_known_core') [enabled by default]

sketch\endpoints.c:65:1: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:65:1: warning: (near initialization for 'path_well_known_core') [enabled by default]

sketch\endpoints.c:65:1: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:65:1: warning: (near initialization for 'path_well_known_core') [enabled by default]

endpoints.c:66: error: unknown type name 'coap_endpoint_path_t'

static const coap_endpoint_path_t path_light_blink = {1, {"light_blink"}};

^

sketch\endpoints.c:66:1: warning: braces around scalar initializer [enabled by default]

sketch\endpoints.c:66:1: warning: (near initialization for 'path_light_blink') [enabled by default]

sketch\endpoints.c:66:1: warning: initialization makes integer from pointer without a cast [enabled by default]

sketch\endpoints.c:66:1: warning: (near initialization for 'path_light_blink') [enabled by default]

sketch\endpoints.c:66:1: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:66:1: warning: (near initialization for 'path_light_blink') [enabled by default]

endpoints.c:67: error: unknown type name 'coap_endpoint_path_t'

static const coap_endpoint_path_t path_request = {1, {"request"}};

^

sketch\endpoints.c:67:1: warning: braces around scalar initializer [enabled by default]

sketch\endpoints.c:67:1: warning: (near initialization for 'path_request') [enabled by default]

sketch\endpoints.c:67:1: warning: initialization makes integer from pointer without a cast [enabled by default]

sketch\endpoints.c:67:1: warning: (near initialization for 'path_request') [enabled by default]

sketch\endpoints.c:67:1: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:67:1: warning: (near initialization for 'path_request') [enabled by default]

endpoints.c:68: error: unknown type name 'coap_endpoint_path_t'

static const coap_endpoint_path_t path_light = {1, {"light"}};

^

sketch\endpoints.c:68:1: warning: braces around scalar initializer [enabled by default]

sketch\endpoints.c:68:1: warning: (near initialization for 'path_light') [enabled by default]

sketch\endpoints.c:68:1: warning: initialization makes integer from pointer without a cast [enabled by default]

sketch\endpoints.c:68:1: warning: (near initialization for 'path_light') [enabled by default]

sketch\endpoints.c:68:1: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:68:1: warning: (near initialization for 'path_light') [enabled by default]

endpoints.c:73: error: unknown type name 'coap_endpoint_t'

const coap_endpoint_t endpoints[] =

^

sketch\endpoints.c:75:5: warning: braces around scalar initializer [enabled by default]

 {COAP_METHOD_GET, handle_get_well_known_core, &path_well_known_core, "ct=40"},

 ^

sketch\endpoints.c:75:5: warning: (near initialization for 'endpoints[0]') [enabled by default]

endpoints.c:75: error: 'COAP_METHOD_GET' undeclared here (not in a function)

 {COAP_METHOD_GET, handle_get_well_known_core, &path_well_known_core, "ct=40"},

  ^

endpoints.c:75: error: 'handle_get_well_known_core' undeclared here (not in a function)

 {COAP_METHOD_GET, handle_get_well_known_core, &path_well_known_core, "ct=40"},

                   ^

sketch\endpoints.c:75:5: warning: excess elements in scalar initializer [enabled by default]

 {COAP_METHOD_GET, handle_get_well_known_core, &path_well_known_core, "ct=40"},

 ^

sketch\endpoints.c:75:5: warning: (near initialization for 'endpoints[0]') [enabled by default]

sketch\endpoints.c:75:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:75:5: warning: (near initialization for 'endpoints[0]') [enabled by default]

sketch\endpoints.c:75:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:75:5: warning: (near initialization for 'endpoints[0]') [enabled by default]

sketch\endpoints.c:76:5: warning: braces around scalar initializer [enabled by default]

 {COAP_METHOD_GET, handle_get_light, &path_light, "ct=0"},

 ^

sketch\endpoints.c:76:5: warning: (near initialization for 'endpoints[1]') [enabled by default]

endpoints.c:76: error: 'handle_get_light' undeclared here (not in a function)

 {COAP_METHOD_GET, handle_get_light, &path_light, "ct=0"},

                   ^

sketch\endpoints.c:76:5: warning: excess elements in scalar initializer [enabled by default]

 {COAP_METHOD_GET, handle_get_light, &path_light, "ct=0"},

 ^

sketch\endpoints.c:76:5: warning: (near initialization for 'endpoints[1]') [enabled by default]

sketch\endpoints.c:76:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:76:5: warning: (near initialization for 'endpoints[1]') [enabled by default]

sketch\endpoints.c:76:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:76:5: warning: (near initialization for 'endpoints[1]') [enabled by default]

sketch\endpoints.c:77:5: warning: braces around scalar initializer [enabled by default]

 {COAP_METHOD_GET, handle_get_light_blink, &path_light_blink, "ct=0"},

 ^

sketch\endpoints.c:77:5: warning: (near initialization for 'endpoints[2]') [enabled by default]

endpoints.c:77: error: 'handle_get_light_blink' undeclared here (not in a function)

 {COAP_METHOD_GET, handle_get_light_blink, &path_light_blink, "ct=0"},

                   ^

sketch\endpoints.c:77:5: warning: excess elements in scalar initializer [enabled by default]

 {COAP_METHOD_GET, handle_get_light_blink, &path_light_blink, "ct=0"},

 ^

sketch\endpoints.c:77:5: warning: (near initialization for 'endpoints[2]') [enabled by default]

sketch\endpoints.c:77:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:77:5: warning: (near initialization for 'endpoints[2]') [enabled by default]

sketch\endpoints.c:77:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:77:5: warning: (near initialization for 'endpoints[2]') [enabled by default]

sketch\endpoints.c:78:5: warning: braces around scalar initializer [enabled by default]

 {COAP_METHOD_GET, handle_get_request, &path_request, "ct=0"},

 ^

sketch\endpoints.c:78:5: warning: (near initialization for 'endpoints[3]') [enabled by default]

endpoints.c:78: error: 'handle_get_request' undeclared here (not in a function)

 {COAP_METHOD_GET, handle_get_request, &path_request, "ct=0"},

                   ^

sketch\endpoints.c:78:5: warning: excess elements in scalar initializer [enabled by default]

 {COAP_METHOD_GET, handle_get_request, &path_request, "ct=0"},

 ^

sketch\endpoints.c:78:5: warning: (near initialization for 'endpoints[3]') [enabled by default]

sketch\endpoints.c:78:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:78:5: warning: (near initialization for 'endpoints[3]') [enabled by default]

sketch\endpoints.c:78:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:78:5: warning: (near initialization for 'endpoints[3]') [enabled by default]

sketch\endpoints.c:79:5: warning: braces around scalar initializer [enabled by default]

 {COAP_METHOD_PUT, handle_put_request, &path_request, NULL},

 ^

sketch\endpoints.c:79:5: warning: (near initialization for 'endpoints[4]') [enabled by default]

endpoints.c:79: error: 'COAP_METHOD_PUT' undeclared here (not in a function)

 {COAP_METHOD_PUT, handle_put_request, &path_request, NULL},

  ^

endpoints.c:79: error: 'handle_put_request' undeclared here (not in a function)

 {COAP_METHOD_PUT, handle_put_request, &path_request, NULL},

                   ^

sketch\endpoints.c:79:5: warning: excess elements in scalar initializer [enabled by default]

 {COAP_METHOD_PUT, handle_put_request, &path_request, NULL},

 ^

sketch\endpoints.c:79:5: warning: (near initialization for 'endpoints[4]') [enabled by default]

sketch\endpoints.c:79:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:79:5: warning: (near initialization for 'endpoints[4]') [enabled by default]

sketch\endpoints.c:79:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:79:5: warning: (near initialization for 'endpoints[4]') [enabled by default]

sketch\endpoints.c:80:5: warning: braces around scalar initializer [enabled by default]

 {COAP_METHOD_PUT, handle_put_light, &path_light, NULL},

 ^

sketch\endpoints.c:80:5: warning: (near initialization for 'endpoints[5]') [enabled by default]

endpoints.c:80: error: 'handle_put_light' undeclared here (not in a function)

 {COAP_METHOD_PUT, handle_put_light, &path_light, NULL},

                   ^

sketch\endpoints.c:80:5: warning: excess elements in scalar initializer [enabled by default]

 {COAP_METHOD_PUT, handle_put_light, &path_light, NULL},

 ^

sketch\endpoints.c:80:5: warning: (near initialization for 'endpoints[5]') [enabled by default]

sketch\endpoints.c:80:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:80:5: warning: (near initialization for 'endpoints[5]') [enabled by default]

sketch\endpoints.c:80:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:80:5: warning: (near initialization for 'endpoints[5]') [enabled by default]

sketch\endpoints.c:81:5: warning: braces around scalar initializer [enabled by default]

 {COAP_METHOD_PUT, handle_put_light_blink, &path_light_blink, NULL},

 ^

sketch\endpoints.c:81:5: warning: (near initialization for 'endpoints[6]') [enabled by default]

endpoints.c:81: error: 'handle_put_light_blink' undeclared here (not in a function)

 {COAP_METHOD_PUT, handle_put_light_blink, &path_light_blink, NULL},

                   ^

sketch\endpoints.c:81:5: warning: excess elements in scalar initializer [enabled by default]

 {COAP_METHOD_PUT, handle_put_light_blink, &path_light_blink, NULL},

 ^

sketch\endpoints.c:81:5: warning: (near initialization for 'endpoints[6]') [enabled by default]

sketch\endpoints.c:81:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:81:5: warning: (near initialization for 'endpoints[6]') [enabled by default]

sketch\endpoints.c:81:5: warning: excess elements in scalar initializer [enabled by default]

sketch\endpoints.c:81:5: warning: (near initialization for 'endpoints[6]') [enabled by default]

sketch\endpoints.c:82:5: warning: braces around scalar initializer [enabled by default]

 {(coap_method_t)0, NULL, NULL, NULL}

 ^

sketch\endpoints.c:82:5: warning: (near initialization for 'endpoints[7]') [enabled by default]

endpoints.c:82: error: 'coap_method_t' undeclared here (not in a function)

 {(coap_method_t)0, NULL, NULL, NULL}

   ^

endpoints.c:82: error: expected '}' before numeric constant

 {(coap_method_t)0, NULL, NULL, NULL}

                 ^

endpoints.c:88: error: unknown type name 'coap_rw_buffer_t'

static int handle_get_well_known_core(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                                   ^

endpoints.c:88: error: unknown type name 'coap_packet_t'

endpoints.c:88: error: unknown type name 'coap_packet_t'

static int handle_get_well_known_core(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                                                                                          ^

endpoints.c:96: error: unknown type name 'coap_rw_buffer_t'

static int handle_get_light_blink(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                               ^

endpoints.c:96: error: unknown type name 'coap_packet_t'

endpoints.c:96: error: unknown type name 'coap_packet_t'

static int handle_get_light_blink(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                                                                                      ^

endpoints.c:104: error: unknown type name 'coap_rw_buffer_t'

static int handle_put_light_blink(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                               ^

endpoints.c:104: error: unknown type name 'coap_packet_t'

endpoints.c:104: error: unknown type name 'coap_packet_t'

static int handle_put_light_blink(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                                                                                      ^

endpoints.c:125: error: unknown type name 'coap_rw_buffer_t'

static int handle_get_request(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                           ^

endpoints.c:125: error: unknown type name 'coap_packet_t'

endpoints.c:125: error: unknown type name 'coap_packet_t'

static int handle_get_request(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                                                                                  ^

endpoints.c:133: error: unknown type name 'coap_rw_buffer_t'

static int handle_put_request(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                           ^

endpoints.c:133: error: unknown type name 'coap_packet_t'

endpoints.c:133: error: unknown type name 'coap_packet_t'

static int handle_put_request(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                                                                                  ^

endpoints.c:149: error: unknown type name 'coap_rw_buffer_t'

static int handle_get_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                         ^

endpoints.c:149: error: unknown type name 'coap_packet_t'

endpoints.c:149: error: unknown type name 'coap_packet_t'

static int handle_get_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                                                                                ^

endpoints.c:157: error: unknown type name 'coap_rw_buffer_t'

static int handle_put_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                         ^

endpoints.c:157: error: unknown type name 'coap_packet_t'

endpoints.c:157: error: unknown type name 'coap_packet_t'

static int handle_put_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)

                                                                                ^

sketch\endpoints.c: In function 'build_rsp':

endpoints.c:182: error: unknown type name 'coap_endpoint_t'

 const coap_endpoint_t *ep = endpoints;

 ^

endpoints.c:187: error: request for member 'handler' in something not a structure or union

 while(NULL != ep->handler)

                 ^

endpoints.c:189: error: request for member 'core_attr' in something not a structure or union

     if (NULL == ep->core_attr) {

                   ^

endpoints.c:202: error: request for member 'path' in something not a structure or union

     for (i = 0; i < ep->path->count; i++) {

                       ^

endpoints.c:202: error: request for member 'count' in something not a structure or union

     for (i = 0; i < ep->path->count; i++) {

                             ^

sketch\endpoints.c:202:23: warning: comparison between pointer and integer [enabled by default]

     for (i = 0; i < ep->path->count; i++) {

                   ^

endpoints.c:206: error: request for member 'path' in something not a structure or union

         strncat(rsp, ep->path->elems[i], len);

                        ^

endpoints.c:206: error: request for member 'elems' in something not a structure or union

         strncat(rsp, ep->path->elems[i], len);

                              ^

sketch\endpoints.c:206:13: warning: passing argument 2 of 'strncat' makes pointer from integer without a cast [enabled by default]

         strncat(rsp, ep->path->elems[i], len);

         ^

In file included from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/include/string.h:10:0,

             from sketch\endpoints.c:2:

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/include/string.h:34:15: note: expected 'const char * restrict' but argument is of type 'int'

char *_EXFUN(strncat,(char *__restrict, const char *__restrict, size_t));

           ^

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/include/_ansi.h:65:30: note: in definition of macro '_EXFUN'

#define _EXFUN(name, proto) name proto

                          ^

endpoints.c:207: error: request for member 'path' in something not a structure or union

         len -= strlen(ep->path->elems[i]);

                         ^

endpoints.c:207: error: request for member 'elems' in something not a structure or union

         len -= strlen(ep->path->elems[i]);

                               ^

sketch\endpoints.c:207:13: warning: passing argument 1 of 'strlen' makes pointer from integer without a cast [enabled by default]

         len -= strlen(ep->path->elems[i]);

         ^

In file included from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/include/string.h:10:0,

             from sketch\endpoints.c:2:

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/include/string.h:33:16: note: expected 'const char *' but argument is of type 'int'

size_t _EXFUN(strlen,(const char *));

            ^

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/include/_ansi.h:65:30: note: in definition of macro '_EXFUN'

#define _EXFUN(name, proto) name proto

                          ^

endpoints.c:213: error: request for member 'core_attr' in something not a structure or union

     strncat(rsp, ep->core_attr, len);

                    ^

sketch\endpoints.c:213:9: warning: passing argument 2 of 'strncat' from incompatible pointer type [enabled by default]

     strncat(rsp, ep->core_attr, len);

     ^

In file included from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/include/string.h:10:0,

             from sketch\endpoints.c:2:

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/include/string.h:34:15: note: expected 'const char * restrict' but argument is of type 'const int *'

char *_EXFUN(strncat,(char *__restrict, const char *__restrict, size_t));

           ^

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/include/_ansi.h:65:30: note: in definition of macro '_EXFUN'

#define _EXFUN(name, proto) name proto

                          ^

endpoints.c:214: error: request for member 'core_attr' in something not a structure or union

     len -= strlen(ep->core_attr);

                     ^

sketch\endpoints.c:214:9: warning: passing argument 1 of 'strlen' from incompatible pointer type [enabled by default]

     len -= strlen(ep->core_attr);

     ^

In file included from C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/include/string.h:10:0,

             from sketch\endpoints.c:2:

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/include/string.h:33:16: note: expected 'const char *' but argument is of type 'const int *'

size_t _EXFUN(strlen,(const char *));

            ^

C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/sdk/libc/xtensa-lx106-elf/include/_ansi.h:65:30: note: in definition of macro '_EXFUN'

#define _EXFUN(name, proto) name proto

                          ^

exit status 1
unknown type name 'coap_rw_buffer_t'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
`

UDP6EndpointAddress when observing

I'm using coapserver..ino to observe led. The problem is that if I observe the resource light and change it from 1 to 0, inside Copper no change is reflected. If I try to observe the resource in the comand line I receive the following error:
`WARNING:coap:Received Type.ACK from <UDP6EndpointAddress [::ffff:192.168.2.121]:5683 with local address>, but could not match it to a running exchange.

How to make a resource observable?

Hello.

I have an analog sensor connected and I want to make the resource observable, when the reading change or with a periodic time update.

Thanks.

Error compiling on ESP-12E

I am facing a problem when i compile the coapserver.ino. These are the errors. Appreciate if anyone can guide me the direction

C:\Users\user\Documents\Arduino\libraries\ESP-CoAP-master\coap_server.cpp: In member function 'bool coapServer::loop()':
C:\Users\user\Documents\Arduino\libraries\ESP-CoAP-master\coap_server.cpp:186:11: error: no match for 'operator+=' (operand types are 'String' and 'char [(((int)request->coapPacket::options[i].coapOption::length) + 1)]')
186 | url += urlname;
| ~~~~^~~~~~~~~~
In file included from C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266/Arduino.h:286,
from C:\Users\user\Documents\Arduino\libraries\ESP-CoAP-master\coap_server.h:14,
from C:\Users\user\Documents\Arduino\libraries\ESP-CoAP-master\coap_server.cpp:11:
C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266/WString.h:133:17: note: candidate: 'template String& String::operator+=(const T&)'
133 | String &operator +=(const T &rhs) {
| ^~~~~~~~
C:\Users\user\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.1\cores\esp8266/WString.h:133:17: note: template argument deduction/substitution failed:
C:\Users\user\Documents\Arduino\libraries\ESP-CoAP-master\coap_server.cpp:186:14: note: variable-sized array type 'char [(((int)request->coapPacket::options[i].coapOption::length) + 1)]' is not a valid template argument
186 | url += urlname;
| ^~~~~~~
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

How to add options in the packet?

I'm trying to use options in the standard packet format and the server that I'm using, need resource path as options. I couldn't figure out how to set it in the client programme.

Redfinition of password in coapclient.ino

There is a redefinition of the "const char* password " in the coapclient.ino file.

It is declared twice in two lines. An oversight maybe?
Ofcourse you can delete one after entering password. But some people who doesn't understand much programming might think the program doesn't work.

Packet splitting if payload bigger than 250 bytes

Hi. I am using this library to test CoAP performance for various situations. When I use Get method to get data bigger than 250 bytes from a server this library splits packets.

I opened an issue about BUF_MAX_SIZE here #15 . And O solved my problem for the POST, PUT and Delete methods.

ISSUE
But for the get methods or more correctly when I am getting an acknowledgement(ACKN) packet it makes them split, getting them multiple time longer. This cause more, energy consumption, requires more time for a packet to deliver etc.

Expected behavior
A CoAP library should receive an ACK packet with 0 to 1024 byte payload at once, as a hole packet.

I don't know what to do. I think the problem is in the bool coapClient::loop() method. I tried to change some of those codes. But I couldn't solve it.

Thanks for any help.

Compile error

` <<<<<<< HEAD

^

coapclient:14: error: expected unqualified-id before '==' token

=======

^

coapclient:16: error: expected unqualified-id before '>>' token

observe`

How to get uri.path from observed packets arriving from 8266 CoAp Server?

Dear friend, I set an experiment to see the workings of CoAp and for that I used your code at Github.

I set a 8266 Coap Server running one /led resource
The second is an ESP12 running CoAp Client and it is set to observe the resource /led in the 8266 CoAp Server.

When /led changes at the CoAp Server ( I am using a browser with CoAp for that) the ESP12 is notified. It works ok.

The problem is that, in case I am observing more than one resource at the server I must find a way to identify what resource is generating the packet when it arrives at the following function:

`// coap client response callback
void callback_response(coapPacket &packet, IPAddress ip, int port) {
char p[packet.payloadlen + 1];
memcpy(p, packet.payload, packet.payloadlen);
p[packet.payloadlen] = NULL;

char t[packet.tokenlen + 1];
memcpy(t, packet.token, packet.tokenlen);
t[packet.tokenlen] = NULL;    

//response from coap server
if(packet.type==3 && packet.code==0){
  Serial.println("ping ok");
}

Serial.print("type: ");
Serial.print(packet.type);
Serial.print(" - code: ");
Serial.print(packet.code);
Serial.print(" - messageid: ");
Serial.print(packet.messageid);    
Serial.print(" - optionnum: ");
Serial.print(packet.optionnum); 
Serial.print(" - token: ");
Serial.println(t);     

Serial.println(p);

}`

I tried to print all variables I could find but had no success with uri.path.

So, my question is:
How to get the "/led" resource name so I can patch the payload value to the correct variable?

Thanks in advance for your time.
And Congrats for the excellent work!

Paulo Borges

#Define BUF MAX SIZE 250

Hi. I am using this library to test CoAP performance for various situations. But I can't send CoAP packets if their payload length bigger than 250 characters.

Edit: Using this library on Client side.

I think the problem is on that lines

coap_client.h
#define BUF_MAX_SIZE 250

coap_client.cpp inside the coapClient::sendPacket method

`
// make payload
if (packet.payloadlen > 0) {

	if ((packetsize + 1 + packet.payloadlen) >= buf_max_size) {
		return 0;
	}
	*p++ = 0xFF;
	memcpy(p, packet.payload, packet.payloadlen);
	packetSize += 1 + packet.payloadlen;
}

`

What can I do to make this library support more than 250 length of payload since -as much as I know- CoAP supports 1024 bytes of payload.

Thanks.

Using ESP8266 as Server and trying to communicate with another server

Hi,
I am trying to use ESP8266 as a server and to connect it to another server for M2M event based communication. But while including both libraries of coap_server.h and coap_client.h it is not compiling and showing the following error -
"ESP01_COAP_SERVER:9: error: 'coapClient' does not name a type

coapClient coap_Client;

^

exit status 1
'coapClient' does not name a type"

Is it possible for coap_server instance to generate GET, POST requests

Resource not available in Copper

Hello,
Thanks a lot for the CoAP implementation. I am running into issues when trying to connect to the CoAP server. My copper extension does not show the resources "light" and "lightled". I tried adding a print statement in the callback to see what the IP is for the server and the output is (IP unset). I do get an IP after I am connected to a WiFi network. Can you please help me with this?
I am running the script on a NodeMCU Lolin v3.

Payload length not set to 0 when there is no payload

Problem,

the packet.payloadlen will not be initialized in coapClient::loop(). When there is a payload it will be set, but it will be a random number else. This might causes problems on developer side when using the client.

Solution:
Place packet.payloadlen = 0 somewhere around line 205 in coap_client.cpp.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.