Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / resource / csdk / stack / samples / linux / SimpleClientServer / ocremoteaccessclient.h
1 //******************************************************************
2 //
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #ifndef OCREMOTECLIENT_H_
22 #define OCREMOTECLIENT_H_
23
24 #include "ocstack.h"
25
26
27 //-----------------------------------------------------------------------------
28 // Defines
29 //-----------------------------------------------------------------------------
30 #define TAG "occlient_remoteaccess"
31 #define DEFAULT_CONTEXT_VALUE 0x99
32 #ifndef MAX_LENGTH_IPv4_ADDR
33 #define MAX_LENGTH_IPv4_ADDR 16
34 #endif
35
36 /**
37  * List of methods that can be initiated from the client
38  */
39 typedef enum {
40     TEST_DISCOVER_REQ = 1,
41     TEST_GET_REQ_NON,
42     TEST_PUT_REQ_NON,
43     TEST_POST_REQ_NON,
44     TEST_DELETE_REQ_NON,
45     TEST_OBS_REQ_NON,
46     TEST_OBS_REQ_NON_CANCEL_IMM,
47     TEST_DISCOVER_PLATFORM_REQ,
48     TEST_DISCOVER_DEV_REQ,
49     MAX_TESTS
50 } CLIENT_TEST;
51
52 /* call getResult in common.cpp to get the result in string format. */
53 const char *getResult(OCStackResult result);
54
55 /* Following are initialization functions for GET, Observe, PUT
56  * POST, Delete & Discovery operations
57  */
58 int InitGetRequestToUnavailableResource(OCQualityOfService qos);
59 int InitObserveRequest(OCQualityOfService qos);
60 int InitPutRequest(OCQualityOfService qos);
61 int InitGetRequest(OCQualityOfService qos);
62 int InitPostRequest(OCQualityOfService qos);
63 int InitDeleteRequest(OCQualityOfService qos);
64 int InitDeviceDiscovery(OCQualityOfService qos);
65 int InitPlatformDiscovery(OCQualityOfService qos);
66 int InitDiscovery(OCQualityOfService qos);
67
68
69 /*
70  * This method calls OCDoResource() which in turn makes calls
71  * to the lower layers
72  */
73 OCStackResult InvokeOCDoResource(std::ostringstream &query,
74         OCMethod method, OCQualityOfService qos,
75         OCClientResponseHandler cb, OCHeaderOption * options, uint8_t numOptions);
76
77 /*
78  * Following are callback functions for the  GET, Observe, PUT
79  * POST, Delete, Presence & Discovery operations
80  */
81 OCStackApplicationResult putReqCB   (void* ctx, OCDoHandle handle, OCClientResponse* clientResponse);
82 OCStackApplicationResult postReqCB  (void* ctx, OCDoHandle handle, OCClientResponse* clientResponse);
83 OCStackApplicationResult getReqCB   (void* ctx, OCDoHandle handle, OCClientResponse* clientResponse);
84 OCStackApplicationResult obsReqCB   (void* ctx, OCDoHandle handle, OCClientResponse* clientResponse);
85 OCStackApplicationResult presenceCB (void* ctx, OCDoHandle handle, OCClientResponse* clientResponse);
86 OCStackApplicationResult deleteReqCB(void* ctx, OCDoHandle handle, OCClientResponse* clientResponse);
87
88 OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle handle,
89     OCClientResponse *clientResponse);
90
91
92 #endif
93