1 /* *****************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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 _PM_UTILITY_H_
22 #define _PM_UTILITY_H_
33 #define DEFAULT_SECURE_PORT 5684
35 #define COAPS_PREFIX "coaps://"
36 #define COAP_PREFIX "coap://"
37 #define COAPS_QUERY "coaps://%s:%d%s"
38 #define COAP_QUERY "coap://%s:%d%s"
40 #define COAP_TCP_PREFIX "coap+tcp://"
41 #define COAPS_TCP_PREFIX "coaps+tcp://"
43 * Discover owned/unowned devices in the same IP subnet. .
45 * @param[in] waittime Timeout in seconds.
46 * @param[in] isOwned bool flag for owned / unowned discovery
47 * @param[in] ppList List of OCProvisionDev_t.
49 * @return OC_STACK_OK on success otherwise error.
51 OCStackResult PMDeviceDiscovery(unsigned short waittime, bool isOwned, OCProvisionDev_t **ppList);
54 * This function deletes list of provision target devices
56 * @param[in] pList List of OCProvisionDev_t.
58 void PMDeleteDeviceList(OCProvisionDev_t *pList);
61 * Timeout implementation for secure discovery. When performing secure discovery,
62 * we should wait a certain period of time for getting response of each devices.
64 * @param[in] waittime Timeout in seconds.
65 * @param[in] waitForStackResponse if true timeout function will call OCProcess while waiting.
66 * @return OC_STACK_OK on success otherwise error.
68 OCStackResult PMTimeout(unsigned short waittime, bool waitForStackResponse);
71 * Function to clone OCProvisionDev_t
73 * @param[in] src pointer of OCProvisionDev_t to be copied.
75 * @return copied OCProvisionDev_t on success otherwise NULL.
77 OCProvisionDev_t* PMCloneOCProvisionDev(const OCProvisionDev_t* src);
81 * Function to generate qurey for coap/coaps request.
83 * @param[in] isSeucre Choose whether to encrypt the payload.
84 * @param[in] address Network address of remote device
85 * @param[in] port Port number
86 * @param[in] connType Connectivity type of remote device
87 * @param[in,out] buffer A buffer to save the query.
88 * @param[in] bufferSize Size of buffer
89 * @param[in] uri The resource URI
91 * @return true on success
93 bool PMGenerateQuery(bool isSecure,
94 const char* address, uint16_t port,
95 OCConnectivityType connType,
96 char* buffer, size_t bufferSize, const char* uri);
99 * Function to print OCProvisionDev_t for debug purpose.
101 * @param[in] pDev Pointer to OCProvisionDev_t. It's information will be printed by OIC_LOG_XX
104 void PMPrintOCProvisionDev(const OCProvisionDev_t* pDev);
106 /** Function to delete matched UUID from the UUIDlist.
108 * @param[in] pUuidList a pointer to UUID list.
109 * @param[in] targetId a pointer to UUID to be deleted in the list.
111 * @return true when deletion is happened, false when no deletion is occured. In case either of
112 * two arguments is null it will return false.
114 bool PMDeleteFromUUIDList(OCUuidList_t **pUuidList, OicUuid_t *targetId);
119 #endif //_PM_UTILITY_H_