Skip to content
This repository was archived by the owner on Sep 20, 2022. It is now read-only.

add microcoap example application#2

Merged
miri64 merged 1 commit intoRIOT-OS:masterfrom
Lotterleben:microcoap_example
Mar 4, 2015
Merged

add microcoap example application#2
miri64 merged 1 commit intoRIOT-OS:masterfrom
Lotterleben:microcoap_example

Conversation

@Lotterleben
Copy link
Copy Markdown
Member

Add a small microcoap example server along with instructions on how to test it using marz and the Copper Firefox Plugin. Depends on RIOT-OS/RIOT#2383.

@jnohlgard
Copy link
Copy Markdown
Member

I can't build this example:

applications/microcoap/endpoints.c:10:13: error: variably modified ‘response’ at file scope
 static char response[response_len] = "";
             ^

arm-none-eabi-gcc (Gentoo 4.8.3 p1.1, pie-0.5.9) 4.8.3

When I change the size to numeric constant 1500 I get the program to build correctly.

@Lotterleben
Copy link
Copy Markdown
Member Author

Yup, that has been fixed, but on the wrong branch it seems. 1 sec.

@Lotterleben
Copy link
Copy Markdown
Member Author

Should build now :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the out-commented flag

@Lotterleben
Copy link
Copy Markdown
Member Author

@LudwigOrtmann @authmillenon
I'm sorry, but I'm gong to have to ask again– I re-implemented get_hw_addr() now as suggested, but I'm still not content with the way it is now– the user may not have to constantly adjust the hwaddr in marz.config if they use -i, but they'll have to do it once (because I have no idea for which -i get_hw_addr() will return 1, which is the default hwaddr i marz.config).
And I just don't get what's wrong with just returning sysconfig.id and telling the user to start the native instance which they want to be connected to marz with-i 1?

@Lotterleben
Copy link
Copy Markdown
Member Author

Aaaah, because it will break other things -.- sighs

@miri64
Copy link
Copy Markdown
Member

miri64 commented Mar 4, 2015

Looks good, please squash.

@Lotterleben
Copy link
Copy Markdown
Member Author

Done :)

@miri64
Copy link
Copy Markdown
Member

miri64 commented Mar 4, 2015

"make" -C /home/martine/Repositories/RIOT-OS/RIOT/pkg/microcoap/microcoap
/home/martine/Repositories/RIOT-OS/applications/microcoap/endpoints.c:10:13: error: variably modified ‘response’ at file scope
 static char response[response_len] = "";

with gcc

"make" -C /home/martine/Repositories/RIOT-OS/RIOT/pkg/microcoap/microcoap
/home/martine/Repositories/RIOT-OS/applications/microcoap/endpoints.c:10:13: error: variable length array declaration not
      allowed at file scope
static char response[response_len] = "";
            ^        ~~~~~~~~~~~~
/home/martine/Repositories/RIOT-OS/applications/microcoap/endpoints.c:20:80: warning: unused parameter 'inpkt'
      [-Wunused-parameter]
static int handle_get_response(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id...
                                                                               ^
/home/martine/Repositories/RIOT-OS/applications/microcoap/endpoints.c:20:118: warning: unused parameter 'id_hi'
      [-Wunused-parameter]
  ...handle_get_response(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_...
                                                                                                               ^
/home/martine/Repositories/RIOT-OS/applications/microcoap/endpoints.c:20:133: warning: unused parameter 'id_lo'
      [-Wunused-parameter]
  ...*scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)
                                                                                         ^
3 warnings and 1 error generated.

with clang

edit: same error as reported in #2 (comment)

@miri64
Copy link
Copy Markdown
Member

miri64 commented Mar 4, 2015

diff --git a/microcoap/endpoints.c b/microcoap/endpoints.c
index 0c8869e..f6b6967 100644
--- a/microcoap/endpoints.c
+++ b/microcoap/endpoints.c
@@ -6,14 +6,14 @@
 #define ENABLE_DEBUG    (0)
 #include "debug.h"

-uint16_t response_len = 1500;
-static char response[response_len] = "";
+#define RESPONSE_LEN   (1500)
+static char response[RESPONSE_LEN] = "";

 static const coap_endpoint_path_t path = {2, {"foo", "bar"}};

 void create_response(void)
 {
-    strncat(response, "1337", response_len-5);
+    strncat(response, "1337", RESPONSE_LEN-5);
 }

 /* The handler which handles the path /foo/bar */

fixes it.

@Lotterleben
Copy link
Copy Markdown
Member Author

That one seems to haunt me :D This was already fixed, but I must've lost it in the rebase... Sorry. 1sec.

@Lotterleben
Copy link
Copy Markdown
Member Author

Wait.. How did you get that? I can't seem to find the offending line(s) in the current code.

@miri64
Copy link
Copy Markdown
Member

miri64 commented Mar 4, 2015

Arghs checked out wrong branch 😊

@miri64
Copy link
Copy Markdown
Member

miri64 commented Mar 4, 2015

All is fine: ACK

miri64 added a commit that referenced this pull request Mar 4, 2015
add microcoap example application
@miri64 miri64 merged commit efb0740 into RIOT-OS:master Mar 4, 2015
@Lotterleben
Copy link
Copy Markdown
Member Author

✨ Thanks for reviewing! :)

chrysn pushed a commit to chrysn-pull-requests/RIOT that referenced this pull request Sep 20, 2022
…example

add microcoap example application
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants