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);
75 * Stop the CoAP client or server processing
77 * @return 0 - success, else - TBD error
79 OCStackResult OCStopCoAP();
82 * Called in main loop of CoAP client or server. Allows low-level CoAP processing of
83 * send, receive, timeout, discovery, callbacks, etc.
85 * @return 0 - success, else - TBD error
87 OCStackResult OCProcessCoAP();
90 * This method is called to generate a token of MAX_TOKEN_LENGTH.
91 * This token is used to co-relate client requests with server responses.
94 void OCGenerateCoAPToken(OCCoAPToken * token);
97 * Initiate sending of CoAP messages. Example: server uses it to send observe messages
99 * @return 0 - success, else - TBD error
101 OCStackResult OCSendCoAPNotification (unsigned char * uri, OCDevAddr *dstAddr,
102 OCQualityOfService qos, OCCoAPToken * token,
103 unsigned char *payload, OCResource *resPtr, uint32_t maxAge);
105 #endif /* OCCOAP_H_ */