Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DebugLib EthernetInterface cantcoap mbed-rtos
Fork of yeswecancoap by
Diff: request.h
- Revision:
- 25:7adc1d174b74
- Parent:
- 24:8319d71d6749
--- a/request.h Wed Oct 21 15:41:11 2015 +0000
+++ b/request.h Wed Oct 21 16:43:59 2015 +0000
@@ -23,8 +23,8 @@
*
* CoAP version defaults to 1.
*
- * \sa CoapPDU::CoapPDU(uint8_t *pdu, int pduLength), CoapPDU::CoapPDU::(uint8_t *buffer, int bufferLength, int pduLength),
- * CoapPDU:CoapPDU()~
+ * \sa Request::Request(uint8_t *pdu, int pduLength), Request::Request::(uint8_t *buffer, int bufferLength, int pduLength),
+ * Request:Request()~
*
*/
Request();
@@ -43,19 +43,19 @@
*
* CoAP version defaults to 1.
*
- * \sa CoapPDU::CoapPDU(uint8_t *pdu, int pduLength), CoapPDU::CoapPDU::(uint8_t *buffer, int bufferLength, int pduLength),
- * CoapPDU:CoapPDU()~
+ * \sa Request::Request(uint8_t *pdu, int pduLength), Request::Request::(uint8_t *buffer, int bufferLength, int pduLength),
+ * Request:Request()~
*
*/
Request(uint8_t *pdu, int pduLength);
/** Construct a PDU using an external buffer. No copy of the buffer is made.
- * This constructor is normally used where a PDU has been received over the network, and it's length is known.
- * In this case the CoapPDU object is probably going to be used as a temporary container to access member values.
- *
- * It is assumed that \b pduLength is the length of the actual CoAP PDU, and consequently the buffer will also be this size,
- * contrast this with CoapPDU::CoapPDU(uint8_t *buffer, int bufferLength, int pduLength) which allows the buffer to
- * be larger than the PDU.
+ * This differs from CoapPDU::CoapPDU(uint8_t *pdu, int pduLength) in that the buffer may be larger
+ * than the actual CoAP PDU contained int the buffer. This is typically used when a large buffer is reused
+ * multiple times. Note that \b pduLength can be 0.
+ *
+ * If an actual CoAP PDU is passed in the buffer, \b pduLength should match its length. CoapPDU::validate() must
+ * be called to initiate the object before member functions can be used.
*
* A PDU constructed in this manner must be validated with CoapPDU::validate() before the member variables will be accessible.
*
@@ -67,10 +67,11 @@
*
* Deleting this object will only delete the Object container and will not delete the PDU buffer.
*
- * @param pdu A pointer to an array of bytes which comprise the CoAP PDU
- * @param pduLength The length of the CoAP PDU pointed to by \b pdu
-
- * \sa CoapPDU::CoapPDU(), CoapPDU::CoapPDU(uint8_t *buffer, int bufferLength, int pduLength)
+ * \param buffer A buffer which either contains a CoAP PDU or is intended to be used to construct one.
+ * \param bufferLength The length of the buffer
+ * \param pduLength If the buffer contains a CoAP PDU, this specifies the length of the PDU within the buffer.
+ *
+ * \sa Request::Request(), Request::Request(uint8_t *pdu, int pduLength)
*/
Request(uint8_t *buffer, int bufferLength, int pduLength);
@@ -86,6 +87,14 @@
char* getContent();
/** Get the lenght of the content
+ * @code
+ * void get_hello(Request* req, Response* res)
+ * {
+ * if(req->hasContent()){
+ * printf("Content: %s\r\n", req->getContent());
+ * }
+ * }
+ * @endcode
* @return integer containing the length of the content
*/
int getContentLength();
