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 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 #ifndef OCCLIENT_BASICOPS_H_
22 #define OCCLIENT_BASICOPS_H_
26 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
29 #define TAG "occlientslow"
30 #define DEFAULT_CONTEXT_VALUE 0x99
31 #ifndef MAX_LENGTH_IPv4_ADDR
32 #define MAX_LENGTH_IPv4_ADDR 16
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
40 * List of methods that can be inititated from the client
44 TEST_DISCOVER_REQ = 1,
53 * List of connectivity types that can be initiated from the client
54 * Required for user input validation
57 CT_ADAPTER_DEFAULT = 0,
60 } CLIENT_CONNECTIVITY_TYPE;
62 //-----------------------------------------------------------------------------
64 //-----------------------------------------------------------------------------
66 /* call getResult in common.cpp to get the result in string format. */
67 const char *getResult(OCStackResult result);
69 /* Get the IP address of the server */
70 std::string getIPAddrTBServer(OCClientResponse * clientResponse);
72 /* Get the port number the server is listening on */
73 std::string getPortTBServer(OCClientResponse * clientResponse);
75 /* Returns the query string for GET and PUT operations */
76 std::string getQueryStrForGetPut(OCClientResponse * clientResponse);
78 /* Following are initialization functions for GET, PUT
79 * POST & Discovery operations
81 int InitGetRequest(OCQualityOfService qos);
82 int InitPutRequest(OCQualityOfService qos);
85 /* Function to retrieve ip address, port no. of the server
86 * and query for the operations to be performed.
88 void parseClientResponse(OCClientResponse * clientResponse);
90 /* This function calls OCDoResource() which in turn makes calls
93 OCStackResult InvokeOCDoResource(std::ostringstream &query,
94 OCMethod method, OCQualityOfService qos,
95 OCClientResponseHandler cb, OCHeaderOption * options, uint8_t numOptions);
97 //-----------------------------------------------------------------------------
99 //-----------------------------------------------------------------------------
101 /* Following are callback functions for the GET and Discovery operations
104 OCStackApplicationResult getReqCB(void* ctx, OCDoHandle handle, OCClientResponse * clientResponse);
106 OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
107 OCClientResponse * clientResponse);