Adapted to LoRa Semtech + Nucleo
Dependents: LoRaWAN-lmic-app LoRaWAN-lmic-app LoRaWAN-test-10secs LoRaPersonalizedDeviceForEverynet ... more
Fork of cantcoap by
Diff: cantcoap.h
- Revision:
- 1:5eec2844ad47
- Parent:
- 0:3d62a105fd34
- Child:
- 2:d0d57af6c9df
diff -r 3d62a105fd34 -r 5eec2844ad47 cantcoap.h --- a/cantcoap.h Tue Oct 08 14:36:01 2013 +0000 +++ b/cantcoap.h Thu Jan 30 14:07:56 2014 +0000 @@ -1,25 +1,31 @@ -/// Copyright (c) 2013, Ashley Mills. -#define MBED -#ifndef MBED -#include <unistd.h> -#endif -#include <stdint.h> +/** +Copyright (c) 2013, Ashley Mills. +All rights reserved. -#define INFO(...) printf(__VA_ARGS__); printf("\r\n"); -#define INFOX(...); printf(__VA_ARGS__); -#define ERR(...) printf(__VA_ARGS__); printf("\r\n"); +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. -#ifdef DEBUG - #define DBG(...) fprintf(stderr,"%s:%d ",__FILE__,__LINE__); fprintf(stderr,__VA_ARGS__); fprintf(stderr,"\r\n"); - #define DBGX(...) fprintf(stderr,__VA_ARGS__); - #define DBGLX(...) fprintf(stderr,"%s:%d ",__FILE__,__LINE__); fprintf(stderr,__VA_ARGS__); - #define DBG_PDU() printBin(); -#else - #define DBG(...) {}; - #define DBGX(...) {}; - #define DBGLX(...) {}; - #define DBG_PDU() {}; -#endif +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#pragma once + +#include <stdint.h> #define COAP_HDR_SIZE 4 #define COAP_OPTION_HDR_BYTE 1 @@ -77,7 +83,8 @@ COAP_BAD_GATEWAY, COAP_SERVICE_UNAVAILABLE, COAP_GATEWAY_TIMEOUT, - COAP_PROXYING_NOT_SUPPORTED + COAP_PROXYING_NOT_SUPPORTED, + COAP_UNDEFINED_CODE=0xFF }; /// CoAP option numbers. @@ -148,6 +155,7 @@ // message code void setCode(CoapPDU::Code code); CoapPDU::Code getCode(); + CoapPDU::Code httpStatusToCode(int httpStatus); // message ID int setMessageID(uint16_t messageID); @@ -159,8 +167,10 @@ CoapOption* getOptions(); int getNumOptions(); // shorthand helpers + int setURI(char *uri); int setURI(char *uri, int urilen); int getURI(char *dst, int dstlen, int *outLen); + int addURIQuery(char *query); // content format helper int setContentFormat(CoapPDU::ContentFormat format); @@ -251,4 +261,4 @@ #define COAP_CODE_SERVICE_UNAVAILABLE 0xA3 #define COAP_CODE_GATEWAY_TIMEOUT 0xA4 #define COAP_CODE_PROXYING_NOT_SUPPORTED 0xA5 -*/ +*/ \ No newline at end of file