Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major cleanup - c_whatever is finally history. #2838

Merged
merged 3 commits into from
Jul 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,31 +90,33 @@ COMPONENTS_eagle.app.v6 = \
# only those) modules are pulled in.
SELECTED_MODULE_SYMS=$(filter %_module_selected %module_selected1,$(shell $(NM) modules/.output/$(TARGET)/$(FLAVOR)/lib/libmodules.a))

LINKFLAGS_eagle.app.v6 = \
-Wl,--gc-sections \
-Wl,-Map=mapfile \
LINKFLAGS_eagle.app.v6 = \
-Wl,--gc-sections \
-Wl,-Map=mapfile \
-nostdlib \
-T$(LD_FILE) \
-Wl,@../ld/defsym.rom \
-Wl,--no-check-sections \
-Wl,-static \
-T$(LD_FILE) \
-Wl,@../ld/defsym.rom \
-Wl,--no-check-sections \
-Wl,-static \
$(addprefix -u , $(SELECTED_MODULE_SYMS)) \
-Wl,--start-group \
-Wl,--start-group \
-lmain \
-lc \
$(DEP_LIBS_eagle.app.v6)\
-Wl,--end-group \
-Wl,--start-group \
-lgcc \
-lhal \
-lphy \
-lpp \
-lnet80211 \
-lsmartconfig \
-lwpa \
-lwpa2 \
-lsmartconfig \
-lcrypto \
-lwps \
$(DEP_LIBS_eagle.app.v6) \
-Wl,--end-group \
-lm
-lc \
-lm \
-Wl,--end-group
# -Wl,--cref
# -Wl,--wrap=_xtos_set_exception_handler

Expand Down
50 changes: 25 additions & 25 deletions app/coap/coap.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "user_config.h"
#include "c_stdio.h"
#include "c_string.h"
#include <stdio.h>
#include <string.h>
#include "coap.h"
#include "uri.h"

Expand All @@ -10,27 +10,27 @@ extern const coap_endpoint_t endpoints[];
#ifdef COAP_DEBUG
void coap_dumpHeader(coap_header_t *hdr)
{
c_printf("Header:\n");
c_printf(" ver 0x%02X\n", hdr->ver);
c_printf(" t 0x%02X\n", hdr->ver);
c_printf(" tkl 0x%02X\n", hdr->tkl);
c_printf(" code 0x%02X\n", hdr->code);
c_printf(" id 0x%02X%02X\n", hdr->id[0], hdr->id[1]);
printf("Header:\n");
printf(" ver 0x%02X\n", hdr->ver);
printf(" t 0x%02X\n", hdr->ver);
printf(" tkl 0x%02X\n", hdr->tkl);
printf(" code 0x%02X\n", hdr->code);
printf(" id 0x%02X%02X\n", hdr->id[0], hdr->id[1]);
}

void coap_dump(const uint8_t *buf, size_t buflen, bool bare)
{
if (bare)
{
while(buflen--)
c_printf("%02X%s", *buf++, (buflen > 0) ? " " : "");
printf("%02X%s", *buf++, (buflen > 0) ? " " : "");
}
else
{
c_printf("Dump: ");
printf("Dump: ");
while(buflen--)
c_printf("%02X%s", *buf++, (buflen > 0) ? " " : "");
c_printf("\n");
printf("%02X%s", *buf++, (buflen > 0) ? " " : "");
printf("\n");
}
}
#endif
Expand Down Expand Up @@ -100,7 +100,7 @@ int coap_buildToken(const coap_buffer_t *tokbuf, const coap_header_t *hdr, uint8
return COAP_ERR_UNSUPPORTED;

if (hdr->tkl > 0)
c_memcpy(p, tokbuf->p, hdr->tkl);
memcpy(p, tokbuf->p, hdr->tkl);

// http://tools.ietf.org/html/rfc7252#section-3.1
// inject options
Expand Down Expand Up @@ -260,22 +260,22 @@ int coap_buildOptionHeader(uint32_t optDelta, size_t length, uint8_t *buf, size_
void coap_dumpOptions(coap_option_t *opts, size_t numopt)
{
size_t i;
c_printf(" Options:\n");
printf(" Options:\n");
for (i=0;i<numopt;i++)
{
c_printf(" 0x%02X [ ", opts[i].num);
printf(" 0x%02X [ ", opts[i].num);
coap_dump(opts[i].buf.p, opts[i].buf.len, true);
c_printf(" ]\n");
printf(" ]\n");
}
}

void coap_dumpPacket(coap_packet_t *pkt)
{
coap_dumpHeader(&pkt->hdr);
coap_dumpOptions(pkt->opts, pkt->numopts);
c_printf("Payload: ");
printf("Payload: ");
coap_dump(pkt->payload.p, pkt->payload.len, true);
c_printf("\n");
printf("\n");
}
#endif

Expand Down Expand Up @@ -325,7 +325,7 @@ int coap_buffer_to_string(char *strbuf, size_t strbuflen, const coap_buffer_t *b
{
if (buf->len+1 > strbuflen)
return COAP_ERR_BUFFER_TOO_SMALL;
c_memcpy(strbuf, buf->p, buf->len);
memcpy(strbuf, buf->p, buf->len);
strbuf[buf->len] = 0;
return 0;
}
Expand Down Expand Up @@ -360,7 +360,7 @@ int coap_build(uint8_t *buf, size_t *buflen, const coap_packet_t *pkt)
p += rc;
left -= rc;

c_memcpy(p, pkt->opts[i].buf.p, pkt->opts[i].buf.len);
memcpy(p, pkt->opts[i].buf.p, pkt->opts[i].buf.len);
p += pkt->opts[i].buf.len;
left -= pkt->opts[i].buf.len;
running_delta = pkt->opts[i].num;
Expand All @@ -373,7 +373,7 @@ int coap_build(uint8_t *buf, size_t *buflen, const coap_packet_t *pkt)
if (*buflen < 4 + 1 + pkt->payload.len + opts_len)
return COAP_ERR_BUFFER_TOO_SMALL;
buf[4 + opts_len] = 0xFF; // payload marker
c_memcpy(buf+5 + opts_len, pkt->payload.p, pkt->payload.len);
memcpy(buf+5 + opts_len, pkt->payload.p, pkt->payload.len);
*buflen = opts_len + 5 + pkt->payload.len;
}
else
Expand Down Expand Up @@ -471,7 +471,7 @@ int coap_make_request(coap_rw_buffer_t *scratch, coap_packet_t *pkt, coap_msgtyp

/* split arg into Uri-* options */
// const char *addr = uri->host.s;
// if(uri->host.length && (c_strlen(addr) != uri->host.length || c_memcmp(addr, uri->host.s, uri->host.length) != 0)){
// if(uri->host.length && (strlen(addr) != uri->host.length || memcmp(addr, uri->host.s, uri->host.length) != 0)){
if(uri->host.length){
/* add Uri-Host */
// addr is destination address
Expand Down Expand Up @@ -525,9 +525,9 @@ int coap_handle_req(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_
goto next;
for (i=0;i<ep->path->count;i++)
{
if (opt[i].buf.len != c_strlen(ep->path->elems[i]))
if (opt[i].buf.len != strlen(ep->path->elems[i]))
goto next;
if (0 != c_memcmp(ep->path->elems[i], opt[i].buf.p, opt[i].buf.len))
if (0 != memcmp(ep->path->elems[i], opt[i].buf.p, opt[i].buf.len))
goto next;
}
// pre-path match!
Expand All @@ -551,5 +551,5 @@ void coap_setup(void)

int
check_token(coap_packet_t *pkt) {
return pkt->tok.len == the_token.len && c_memcmp(pkt->tok.p, the_token.p, the_token.len) == 0;
return pkt->tok.len == the_token.len && memcmp(pkt->tok.p, the_token.p, the_token.len) == 0;
}
4 changes: 2 additions & 2 deletions app/coap/coap.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
extern "C" {
#endif

#include "c_stdint.h"
#include "c_stddef.h"
#include <stdint.h>
#include <stddef.h>
#include "lualib.h"
#include "lauxlib.h"

Expand Down
6 changes: 3 additions & 3 deletions app/coap/coap_io.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "c_string.h"
#include <string.h>
#include "coap_io.h"
#include "node.h"
#include "espconn.h"
Expand All @@ -16,10 +16,10 @@ coap_tid_t coap_send(struct espconn *pesp_conn, coap_pdu_t *pdu) {
espconn_sent(pesp_conn, (unsigned char *)(pdu->msg.p), pdu->msg.len);

if(pesp_conn->type == ESPCONN_TCP){
c_memcpy(&ip, pesp_conn->proto.tcp->remote_ip, sizeof(ip));
memcpy(&ip, pesp_conn->proto.tcp->remote_ip, sizeof(ip));
port = pesp_conn->proto.tcp->remote_port;
}else{
c_memcpy(&ip, pesp_conn->proto.udp->remote_ip, sizeof(ip));
memcpy(&ip, pesp_conn->proto.udp->remote_ip, sizeof(ip));
port = pesp_conn->proto.udp->remote_port;
}
coap_transaction_id(ip, port, pdu->pkt, &id);
Expand Down
4 changes: 2 additions & 2 deletions app/coap/coap_server.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "user_config.h"
#include "c_types.h"
#include "c_stdlib.h"
#include <stdlib.h>

#include "coap.h"

Expand Down Expand Up @@ -51,7 +51,7 @@ size_t coap_server_respond(char *req, unsigned short reqlen, char *rsp, unsigned
#endif
}
if(rsppkt.content.p){
c_free(rsppkt.content.p);
free(rsppkt.content.p);
rsppkt.content.p = NULL;
rsppkt.content.len = 0;
}
Expand Down
1 change: 1 addition & 0 deletions app/coap/coap_timer.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "node.h"
#include "coap_timer.h"
#include "os_type.h"
#include "osapi.h"
#include "pm/swtimer.h"

static os_timer_t coap_timer;
Expand Down
Loading