Blame view

RIOT/pkg/microcoap/patches/0001-Remove-unneeded-.c-files.patch 8.52 KB
a752c7ab   elopes   add first test an...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
  From 335f83548f4a4a13b556800bcc354d77db8c3434 Mon Sep 17 00:00:00 2001
  From: Patrick Grosse <patrick.grosse@uni-muenster.de>
  Date: Sat, 25 Mar 2017 10:32:27 +0100
  Subject: [PATCH 1/6] Remove unneeded *.c files
  
  ---
   endpoints.c   | 113 ----------------------------------------------------------
   main-posix.c  |  85 -------------------------------------------
   microcoap.ino |  99 --------------------------------------------------
   3 files changed, 297 deletions(-)
   delete mode 100644 endpoints.c
   delete mode 100644 main-posix.c
   delete mode 100644 microcoap.ino
  
  diff --git a/endpoints.c b/endpoints.c
  deleted file mode 100644
  index ccc961b..0000000
  --- a/endpoints.c
  +++ /dev/null
  @@ -1,113 +0,0 @@
  -#include <stdbool.h>
  -#include <string.h>
  -#include "coap.h"
  -
  -static char light = '0';
  -
  -const uint16_t rsplen = 1500;
  -static char rsp[1500] = "";
  -void build_rsp(void);
  -
  -#ifdef ARDUINO
  -#include "Arduino.h"
  -static int led = 6;
  -void endpoint_setup(void)
  -{                
  -    pinMode(led, OUTPUT);     
  -    build_rsp();
  -}
  -#else
  -#include <stdio.h>
  -void endpoint_setup(void)
  -{
  -    build_rsp();
  -}
  -#endif
  -
  -static const coap_endpoint_path_t path_well_known_core = {2, {".well-known", "core"}};
  -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)
  -{
  -    return coap_make_response(scratch, outpkt, (const uint8_t *)rsp, strlen(rsp), id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_APPLICATION_LINKFORMAT);
  -}
  -
  -static const coap_endpoint_path_t path_light = {1, {"light"}};
  -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)
  -{
  -    return coap_make_response(scratch, outpkt, (const uint8_t *)&light, 1, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_TEXT_PLAIN);
  -}
  -
  -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)
  -{
  -    if (inpkt->payload.len == 0)
  -        return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_BAD_REQUEST, COAP_CONTENTTYPE_TEXT_PLAIN);
  -    if (inpkt->payload.p[0] == '1')
  -    {
  -        light = '1';
  -#ifdef ARDUINO
  -        digitalWrite(led, HIGH);
  -#else
  -        printf("ON\n");
  -#endif
  -        return coap_make_response(scratch, outpkt, (const uint8_t *)&light, 1, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CHANGED, COAP_CONTENTTYPE_TEXT_PLAIN);
  -    }
  -    else
  -    {
  -        light = '0';
  -#ifdef ARDUINO
  -        digitalWrite(led, LOW);
  -#else
  -        printf("OFF\n");
  -#endif
  -        return coap_make_response(scratch, outpkt, (const uint8_t *)&light, 1, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CHANGED, COAP_CONTENTTYPE_TEXT_PLAIN);
  -    }
  -}
  -
  -const coap_endpoint_t endpoints[] =
  -{
  -    {COAP_METHOD_GET, handle_get_well_known_core, &path_well_known_core, "ct=40"},
  -    {COAP_METHOD_GET, handle_get_light, &path_light, "ct=0"},
  -    {COAP_METHOD_PUT, handle_put_light, &path_light, NULL},
  -    {(coap_method_t)0, NULL, NULL, NULL}
  -};
  -
  -void build_rsp(void)
  -{
  -    uint16_t len = rsplen;
  -    const coap_endpoint_t *ep = endpoints;
  -    int i;
  -
  -    len--; // Null-terminated string
  -
  -    while(NULL != ep->handler)
  -    {
  -        if (NULL == ep->core_attr) {
  -            ep++;
  -            continue;
  -        }
  -
  -        if (0 < strlen(rsp)) {
  -            strncat(rsp, ",", len);
  -            len--;
  -        }
  -
  -        strncat(rsp, "<", len);
  -        len--;
  -
  -        for (i = 0; i < ep->path->count; i++) {
  -            strncat(rsp, "/", len);
  -            len--;
  -
  -            strncat(rsp, ep->path->elems[i], len);
  -            len -= strlen(ep->path->elems[i]);
  -        }
  -
  -        strncat(rsp, ">;", len);
  -        len -= 2;
  -
  -        strncat(rsp, ep->core_attr, len);
  -        len -= strlen(ep->core_attr);
  -
  -        ep++;
  -    }
  -}
  -
  diff --git a/main-posix.c b/main-posix.c
  deleted file mode 100644
  index 3711b02..0000000
  --- a/main-posix.c
  +++ /dev/null
  @@ -1,85 +0,0 @@
  -#include <sys/socket.h>
  -#include <netinet/in.h>
  -#include <stdio.h>
  -#include <stdbool.h>
  -#include <strings.h>
  -
  -#include "coap.h"
  -
  -#define PORT 5683
  -
  -int main(int argc, char **argv)
  -{
  -    int fd;
  -#ifdef IPV6
  -    struct sockaddr_in6 servaddr, cliaddr;
  -#else /* IPV6 */
  -    struct sockaddr_in servaddr, cliaddr;
  -#endif /* IPV6 */
  -    uint8_t buf[4096];
  -    uint8_t scratch_raw[4096];
  -    coap_rw_buffer_t scratch_buf = {scratch_raw, sizeof(scratch_raw)};
  -
  -#ifdef IPV6
  -    fd = socket(AF_INET6,SOCK_DGRAM,0);
  -#else /* IPV6 */
  -    fd = socket(AF_INET,SOCK_DGRAM,0);
  -#endif /* IPV6 */
  -
  -    bzero(&servaddr,sizeof(servaddr));
  -#ifdef IPV6
  -    servaddr.sin6_family = AF_INET6;
  -    servaddr.sin6_addr = in6addr_any;
  -    servaddr.sin6_port = htons(PORT);
  -#else /* IPV6 */
  -    servaddr.sin_family = AF_INET;
  -    servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
  -    servaddr.sin_port = htons(PORT);
  -#endif /* IPV6 */
  -    bind(fd,(struct sockaddr *)&servaddr, sizeof(servaddr));
  -
  -    endpoint_setup();
  -
  -    while(1)
  -    {
  -        int n, rc;
  -        socklen_t len = sizeof(cliaddr);
  -        coap_packet_t pkt;
  -
  -        n = recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *)&cliaddr, &len);
  -#ifdef DEBUG
  -        printf("Received: ");
  -        coap_dump(buf, n, true);
  -        printf("\n");
  -#endif
  -
  -        if (0 != (rc = coap_parse(&pkt, buf, n)))
  -            printf("Bad packet rc=%d\n", rc);
  -        else
  -        {
  -            size_t rsplen = sizeof(buf);
  -            coap_packet_t rsppkt;
  -#ifdef DEBUG
  -            coap_dumpPacket(&pkt);
  -#endif
  -            coap_handle_req(&scratch_buf, &pkt, &rsppkt);
  -
  -            if (0 != (rc = coap_build(buf, &rsplen, &rsppkt)))
  -                printf("coap_build failed rc=%d\n", rc);
  -            else
  -            {
  -#ifdef DEBUG
  -                printf("Sending: ");
  -                coap_dump(buf, rsplen, true);
  -                printf("\n");
  -#endif
  -#ifdef DEBUG
  -                coap_dumpPacket(&rsppkt);
  -#endif
  -
  -                sendto(fd, buf, rsplen, 0, (struct sockaddr *)&cliaddr, sizeof(cliaddr));
  -            }
  -        }
  -    }
  -}
  -
  diff --git a/microcoap.ino b/microcoap.ino
  deleted file mode 100644
  index 148b6ce..0000000
  --- a/microcoap.ino
  +++ /dev/null
  @@ -1,99 +0,0 @@
  -/*
  -* WARNING - UDP_TX_PACKET_MAX_SIZE is hardcoded by Arduino to 24 bytes
  -* This limits the size of possible outbound UDP packets
  -*/
  -
  -#include <SPI.h>
  -#include <Ethernet.h>
  -#include <stdint.h>
  -#include <EthernetUdp.h>
  -#include "coap.h"
  -
  -#define PORT 5683
  -static uint8_t mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02};
  -
  -EthernetClient client;
  -EthernetUDP udp;
  -uint8_t packetbuf[256];
  -static uint8_t scratch_raw[32];
  -static coap_rw_buffer_t scratch_buf = {scratch_raw, sizeof(scratch_raw)};
  -
  -void setup()
  -{
  -    int i;
  -    Serial.begin(9600);
  -    while (!Serial) 
  -    {
  -        ; // wait for serial port to connect. Needed for Leonardo only
  -    }
  -
  -    // start the Ethernet connection:
  -    if (Ethernet.begin(mac) == 0)
  -    {
  -        Serial.println("Failed to configure Ethernet using DHCP");
  -        while(1);
  -    }
  -    Serial.print("My IP address: ");
  -    for (i=0;i<4;i++)
  -    {
  -        Serial.print(Ethernet.localIP()[i], DEC);
  -        Serial.print("."); 
  -    }
  -    Serial.println();
  -    udp.begin(PORT);
  -
  -    coap_setup();
  -    endpoint_setup();
  -}
  -
  -void udp_send(const uint8_t *buf, int buflen)
  -{
  -    udp.beginPacket(udp.remoteIP(), udp.remotePort());
  -    while(buflen--)
  -        udp.write(*buf++);
  -    udp.endPacket();
  -}
  -
  -void loop()
  -{
  -    int sz;
  -    int rc;
  -    coap_packet_t pkt;
  -    int i;
  -    
  -    if ((sz = udp.parsePacket()) > 0)
  -    {
  -        udp.read(packetbuf, sizeof(packetbuf));
  -
  -        for (i=0;i<sz;i++)
  -        {
  -            Serial.print(packetbuf[i], HEX);
  -            Serial.print(" ");
  -        }
  -        Serial.println("");
  -
  -        if (0 != (rc = coap_parse(&pkt, packetbuf, sz)))
  -        {
  -            Serial.print("Bad packet rc=");
  -            Serial.println(rc, DEC);
  -        }
  -        else
  -        {
  -            size_t rsplen = sizeof(packetbuf);
  -            coap_packet_t rsppkt;
  -            coap_handle_req(&scratch_buf, &pkt, &rsppkt);
  -
  -            memset(packetbuf, 0, UDP_TX_PACKET_MAX_SIZE);
  -            if (0 != (rc = coap_build(packetbuf, &rsplen, &rsppkt)))
  -            {
  -                Serial.print("coap_build failed rc=");
  -                Serial.println(rc, DEC);
  -            }
  -            else
  -            {
  -                udp_send(packetbuf, rsplen);
  -            }
  -        }
  -    }
  -}
  -
  -- 
  2.7.4