1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 #include "occoaptoken.h"
29 #include "ocstackinternal.h"
30 #include "occoaphelper.h"
33 //-----------------------------------------------------------------------------
34 // Function Prototypes
35 //-----------------------------------------------------------------------------
37 uint32_t GetTime(float afterSeconds);
40 * Initialize the CoAP client or server with the its IPv4 address and CoAP port
43 * IP Address of host device
47 * Host device is client, server, or client-server
53 OCStackResult OCInitCoAP(const char *address, uint16_t port, OCMode mode);
56 * Discover OC resources
58 * @param method - method to perform on the resource
59 * @param qos - CON or NON requests
60 * @param token - pointer to the token data structure
61 * @param Uri - URI of the resource to interact with
62 * @param payload - CoAP PDU payload
63 * @param options - The address of an array containing the vendor specific
64 * header options to be sent with the request
65 * @param numOptions - The number of header options to be included
70 OCStackResult OCDoCoAPResource(OCMethod method, OCQualityOfService qos, OCCoAPToken * token,
71 const char *Uri, const char *payload, OCHeaderOption * options, uint8_t numOptions);
74 * Send a response to a request.
76 * @param response - pointer to OCServerProtocolResponse that contains all request and
77 * response info necessary to send the response to the client
79 * OC_STACK_OK - No errors; Success
80 * OC_STACK_ERROR - Error sending response
82 OCStackResult OCDoCoAPResponse(OCServerProtocolResponse *response);
85 * Stop the CoAP client or server processing
87 * @return 0 - success, else - TBD error
89 OCStackResult OCStopCoAP();
92 * Called in main loop of CoAP client or server. Allows low-level CoAP processing of
93 * send, receive, timeout, discovery, callbacks, etc.
95 * @return 0 - success, else - TBD error
97 OCStackResult OCProcessCoAP();
100 * This method is called to generate a token of MAX_TOKEN_LENGTH.
101 * This token is used to co-relate client requests with server responses.
104 void OCGenerateCoAPToken(OCCoAPToken * token);
107 * Retrieve the end-point info where resource is being hosted.
108 * Currently, this method only provides the IP port with which the socket
109 * is bound. This internal method may be extended in future to retrieve
110 * more info (such as IP address, transport technology) about the hosting end-point.
112 * @param resPtr - pointer to the resource
113 * @param info - pointer to 16-bit integer to hold port number
114 * @return 0 - success, else - TBD error
116 OCStackResult OCGetResourceEndPointInfo (OCResource *resPtr, void *info);
118 #endif /* OCCOAP_H_ */