mbed Connector Interface simplification API on top of mbed-client

Fork of mbedConnectorInterfaceV3 by Doug Anson

NOTE:

This repo has been replaced with https://github.com/ARMmbed/mbedConnectorInterface. No further updates will occur with this repo. Please use the github repo instead. Thanks!

Committer:
ansond
Date:
Thu Jun 23 22:26:15 2016 +0000
Revision:
49:c603a22495bb
Parent:
27:b8aaf7dc7023
Child:
54:dfee8691c83a
reduced memory usage

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 8:f950fb1b78c0 1 /**
ansond 8:f950fb1b78c0 2 * @file OptionsBuilder.h
ansond 8:f950fb1b78c0 3 * @brief mbed CoAP OptionsBuilder class header
ansond 8:f950fb1b78c0 4 * @author Doug Anson/Chris Paola
ansond 8:f950fb1b78c0 5 * @version 1.0
ansond 8:f950fb1b78c0 6 * @see
ansond 8:f950fb1b78c0 7 *
ansond 8:f950fb1b78c0 8 * Copyright (c) 2014
ansond 8:f950fb1b78c0 9 *
ansond 8:f950fb1b78c0 10 * Licensed under the Apache License, Version 2.0 (the "License");
ansond 8:f950fb1b78c0 11 * you may not use this file except in compliance with the License.
ansond 8:f950fb1b78c0 12 * You may obtain a copy of the License at
ansond 8:f950fb1b78c0 13 *
ansond 8:f950fb1b78c0 14 * http://www.apache.org/licenses/LICENSE-2.0
ansond 8:f950fb1b78c0 15 *
ansond 8:f950fb1b78c0 16 * Unless required by applicable law or agreed to in writing, software
ansond 8:f950fb1b78c0 17 * distributed under the License is distributed on an "AS IS" BASIS,
ansond 8:f950fb1b78c0 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ansond 8:f950fb1b78c0 19 * See the License for the specific language governing permissions and
ansond 8:f950fb1b78c0 20 * limitations under the License.
ansond 8:f950fb1b78c0 21 */
ansond 8:f950fb1b78c0 22
ansond 8:f950fb1b78c0 23 #ifndef __OPTIONS_BUILDER_H__
ansond 8:f950fb1b78c0 24 #define __OPTIONS_BUILDER_H__
ansond 8:f950fb1b78c0 25
ansond 8:f950fb1b78c0 26 // base class support
ansond 8:f950fb1b78c0 27 #include "mbed-connector-interface/Options.h"
ansond 8:f950fb1b78c0 28
ansond 8:f950fb1b78c0 29 // Connector namespace
ansond 8:f950fb1b78c0 30 namespace Connector {
ansond 8:f950fb1b78c0 31
ansond 8:f950fb1b78c0 32 /** OptionsBuilder class
ansond 8:f950fb1b78c0 33 */
ansond 8:f950fb1b78c0 34 class OptionsBuilder : Options
ansond 8:f950fb1b78c0 35 {
ansond 8:f950fb1b78c0 36 public:
ansond 8:f950fb1b78c0 37 /**
ansond 8:f950fb1b78c0 38 Default Constructor
ansond 8:f950fb1b78c0 39 */
ansond 8:f950fb1b78c0 40 OptionsBuilder();
ansond 8:f950fb1b78c0 41
ansond 8:f950fb1b78c0 42 /**
ansond 8:f950fb1b78c0 43 Copy Constructor
ansond 8:f950fb1b78c0 44 @param ob input options builder instance to deep copy
ansond 8:f950fb1b78c0 45 */
ansond 8:f950fb1b78c0 46 OptionsBuilder(const OptionsBuilder &ob);
ansond 8:f950fb1b78c0 47
ansond 8:f950fb1b78c0 48 /**
ansond 8:f950fb1b78c0 49 Destructor
ansond 8:f950fb1b78c0 50 */
ansond 8:f950fb1b78c0 51 virtual ~OptionsBuilder();
ansond 8:f950fb1b78c0 52
ansond 8:f950fb1b78c0 53 /**
ansond 8:f950fb1b78c0 54 Set the NSDL Endpoint Lifetime
ansond 8:f950fb1b78c0 55 @param lifetime input the NSDL endpoint lifetime (seconds)
ansond 8:f950fb1b78c0 56 @return instance to ourself
ansond 8:f950fb1b78c0 57 */
ansond 8:f950fb1b78c0 58 OptionsBuilder &setLifetime(int lifetime);
ansond 8:f950fb1b78c0 59
ansond 8:f950fb1b78c0 60 /**
ansond 8:f950fb1b78c0 61 Set the NSDL Domain
ansond 8:f950fb1b78c0 62 @param domain input the NSDL domain to set
ansond 8:f950fb1b78c0 63 @return instance to ourself
ansond 8:f950fb1b78c0 64 */
ansond 8:f950fb1b78c0 65 OptionsBuilder &setDomain(const char *domain);
ansond 8:f950fb1b78c0 66
ansond 8:f950fb1b78c0 67 /**
ansond 8:f950fb1b78c0 68 Set the Endpoint Node Name
ansond 8:f950fb1b78c0 69 @param node_name input the node endpoint name
ansond 8:f950fb1b78c0 70 @return instance to ourself
ansond 8:f950fb1b78c0 71 */
ansond 8:f950fb1b78c0 72 OptionsBuilder &setEndpointNodename(const char *node_name);
ansond 8:f950fb1b78c0 73
ansond 8:f950fb1b78c0 74 /**
ansond 8:f950fb1b78c0 75 Set the NSDL Endpoint Type
ansond 8:f950fb1b78c0 76 @param endpoint_type input the NSDL endpoint type
ansond 8:f950fb1b78c0 77 @return instance to ourself
ansond 8:f950fb1b78c0 78 */
ansond 8:f950fb1b78c0 79 OptionsBuilder &setEndpointType(const char *endpoint_type);
ansond 8:f950fb1b78c0 80
ansond 8:f950fb1b78c0 81 /**
ansond 8:f950fb1b78c0 82 Set the mbed Registration Update Period
ansond 8:f950fb1b78c0 83 @param rd_update_period_ms input the NSDL read update period (in ms)
ansond 8:f950fb1b78c0 84 @return instance to ourself
ansond 8:f950fb1b78c0 85 */
ansond 8:f950fb1b78c0 86 OptionsBuilder &setRegUpdatePeriod(const int reg_update_period_ms);
ansond 8:f950fb1b78c0 87
ansond 8:f950fb1b78c0 88 /**
ansond 8:f950fb1b78c0 89 Set the Connector URL
ansond 8:f950fb1b78c0 90 @param url input the Connector URL
ansond 8:f950fb1b78c0 91 @return instance to ourself
ansond 8:f950fb1b78c0 92 */
ansond 8:f950fb1b78c0 93 OptionsBuilder &setConnectorURL(const char *connector_url);
ansond 0:1f1f55e73248 94
ansond 8:f950fb1b78c0 95 /**
ansond 27:b8aaf7dc7023 96 Set the LWM2M Device Resource Object Instance
ansond 27:b8aaf7dc7023 97 @param device_resources_object input the LWM2M device resource object instance
ansond 8:f950fb1b78c0 98 @return instance to ourself
ansond 8:f950fb1b78c0 99 */
ansond 27:b8aaf7dc7023 100 OptionsBuilder &setDeviceResourcesObject(const void *device_resources_object);
ansond 27:b8aaf7dc7023 101
ansond 27:b8aaf7dc7023 102 /**
ansond 27:b8aaf7dc7023 103 Set the LWM2M Firmware Resource Object Instance
ansond 27:b8aaf7dc7023 104 @param firmware_resources_object input the LWM2M firmware resource object instance
ansond 27:b8aaf7dc7023 105 @return instance to ourself
ansond 27:b8aaf7dc7023 106 */
ansond 27:b8aaf7dc7023 107 OptionsBuilder &setFirmwareResourcesObject(const void *firmware_resources_object);
ansond 8:f950fb1b78c0 108
ansond 8:f950fb1b78c0 109 /**
ansond 8:f950fb1b78c0 110 Add a NSDL endpoint resource (static)
ansond 8:f950fb1b78c0 111 @param static_resource input the NSDL static resource
ansond 8:f950fb1b78c0 112 @return instance to ourself
ansond 8:f950fb1b78c0 113 */
ansond 8:f950fb1b78c0 114 OptionsBuilder &addResource(const StaticResource *static_resource);
ansond 8:f950fb1b78c0 115
ansond 8:f950fb1b78c0 116 /**
ansond 8:f950fb1b78c0 117 Add a NSDL endpoint resource (dynamic)
ansond 8:f950fb1b78c0 118 @param dynamic_resource input the NSDL dynamic resource
ansond 27:b8aaf7dc7023 119 @return instance to ourself
ansond 8:f950fb1b78c0 120 */
ansond 8:f950fb1b78c0 121 OptionsBuilder &addResource(const DynamicResource *dynamic_resource);
ansond 8:f950fb1b78c0 122
ansond 8:f950fb1b78c0 123 /**
ansond 8:f950fb1b78c0 124 Add a NSDL endpoint resource (dynamic)
ansond 8:f950fb1b78c0 125 @param dynamic_resource input the NSDL dynamic resource
ansond 8:f950fb1b78c0 126 @param use_observer input if true, use an appropriate ResourceObserver to observer. if false, the underlying resource will handle it
ansond 8:f950fb1b78c0 127 @return instance to ourself
ansond 8:f950fb1b78c0 128 */
ansond 8:f950fb1b78c0 129 OptionsBuilder &addResource(const DynamicResource *dynamic_resource,const bool use_observer);
ansond 8:f950fb1b78c0 130
ansond 8:f950fb1b78c0 131 /**
ansond 8:f950fb1b78c0 132 Add a NSDL endpoint resource (dynamic)
ansond 8:f950fb1b78c0 133 @param dynamic_resource input the NSDL dynamic resource
ansond 8:f950fb1b78c0 134 @param sleep_time input the observation sleep time in milliseconds (for observable resource only)
ansond 8:f950fb1b78c0 135 @return instance to ourself
ansond 8:f950fb1b78c0 136 */
ansond 8:f950fb1b78c0 137 OptionsBuilder &addResource(const DynamicResource *dynamic_resource,const int sleep_time);
ansond 8:f950fb1b78c0 138
ansond 8:f950fb1b78c0 139 /**
ansond 8:f950fb1b78c0 140 Add a NSDL endpoint resource (dynamic)
ansond 8:f950fb1b78c0 141 @param dynamic_resource input the NSDL dynamic resource
ansond 8:f950fb1b78c0 142 @param sleep_time input the observation sleep time in milliseconds (for observable resource only)
ansond 8:f950fb1b78c0 143 @param use_observer input if true, use an appropriate ResourceObserver to observer. if false, the underlying resource will handle it
ansond 8:f950fb1b78c0 144 @return instance to ourself
ansond 8:f950fb1b78c0 145 */
ansond 8:f950fb1b78c0 146 OptionsBuilder &addResource(const DynamicResource *dynamic_resource,const int sleep_time,const bool use_observer);
ansond 8:f950fb1b78c0 147
ansond 8:f950fb1b78c0 148 /**
ansond 8:f950fb1b78c0 149 Set the WiFi SSID
ansond 8:f950fb1b78c0 150 @param ssid input the WiFi SSID
ansond 8:f950fb1b78c0 151 */
ansond 8:f950fb1b78c0 152 OptionsBuilder &setWiFiSSID(char *ssid);
ansond 8:f950fb1b78c0 153
ansond 8:f950fb1b78c0 154 /**
ansond 8:f950fb1b78c0 155 Set the WiFi AuthType
ansond 8:f950fb1b78c0 156 @param auth_type input the WiFi AuthType
ansond 8:f950fb1b78c0 157 */
ansond 8:f950fb1b78c0 158 OptionsBuilder &setWiFiAuthType(WiFiAuthTypes auth_type);
ansond 8:f950fb1b78c0 159
ansond 8:f950fb1b78c0 160 /**
ansond 8:f950fb1b78c0 161 Set the WiFi AuthKey
ansond 8:f950fb1b78c0 162 @param auth_key input the WiFi AuthKey
ansond 8:f950fb1b78c0 163 */
ansond 8:f950fb1b78c0 164 OptionsBuilder &setWiFiAuthKey(char *auth_key);
ansond 8:f950fb1b78c0 165
ansond 8:f950fb1b78c0 166 /**
ansond 8:f950fb1b78c0 167 Set the 802.15.4 Pre Shared Key
ansond 10:3f79b5e67c22 168 @param psk input the 802.15.4 mesh pre shared key
ansond 8:f950fb1b78c0 169 */
ansond 8:f950fb1b78c0 170 OptionsBuilder &setPreSharedKey(unsigned char psk[16]);
ansond 8:f950fb1b78c0 171
ansond 10:3f79b5e67c22 172 /**
ansond 8:f950fb1b78c0 173 Set the 802.15.4 Pre Shared Key Identity
ansond 10:3f79b5e67c22 174 @param psk_identity input the 802.15.4 mesh pre shared key Identity
ansond 8:f950fb1b78c0 175 */
ansond 8:f950fb1b78c0 176 OptionsBuilder &setPreSharedKeyIdentity(unsigned char psk_identity[2]);
ansond 10:3f79b5e67c22 177
ansond 10:3f79b5e67c22 178 /**
ansond 9:faa43faea4ca 179 Set the 802.15.4 Mesh Type
ansond 9:faa43faea4ca 180 @param mesh_type input the 802.15.4 mesh type
ansond 9:faa43faea4ca 181 */
ansond 9:faa43faea4ca 182 OptionsBuilder &setMeshType(MeshTypes mesh_type);
ansond 10:3f79b5e67c22 183
ansond 10:3f79b5e67c22 184 /**
ansond 10:3f79b5e67c22 185 Set the CoAP Connection Type
ansond 10:3f79b5e67c22 186 @param coap_connection_type input the CoAP Connection type
ansond 10:3f79b5e67c22 187 */
ansond 10:3f79b5e67c22 188 OptionsBuilder &setCoAPConnectionType(CoAPConnectionTypes coap_connection_type);
ansond 10:3f79b5e67c22 189
ansond 10:3f79b5e67c22 190 /**
ansond 10:3f79b5e67c22 191 Set the IP Address Type
ansond 10:3f79b5e67c22 192 @param ip_address_type input the IP Address type
ansond 10:3f79b5e67c22 193 */
ansond 10:3f79b5e67c22 194 OptionsBuilder &setIPAddressType(IPAddressTypes ip_address_type);
ansond 9:faa43faea4ca 195
ansond 8:f950fb1b78c0 196 /**
ansond 8:f950fb1b78c0 197 Enable/Disable immediate observationing
ansond 8:f950fb1b78c0 198 @param enable input enable immediate observationing without GET
ansond 8:f950fb1b78c0 199 */
ansond 8:f950fb1b78c0 200 OptionsBuilder &setImmedateObservationEnabled(bool enable);
ansond 8:f950fb1b78c0 201
ansond 8:f950fb1b78c0 202 /**
ansond 8:f950fb1b78c0 203 Enable/Disable GET-based control of observations
ansond 8:f950fb1b78c0 204 @param enable input enable GET-based observation enable/disable control
ansond 8:f950fb1b78c0 205 */
ansond 8:f950fb1b78c0 206 OptionsBuilder &setEnableGETObservationControl(bool enable);
ansond 8:f950fb1b78c0 207
ansond 8:f950fb1b78c0 208 /**
ansond 8:f950fb1b78c0 209 Set the Server Certificate
ansond 8:f950fb1b78c0 210 @param cert input the server certificate
ansond 8:f950fb1b78c0 211 @param cert_size input the length of the server certificate
ansond 8:f950fb1b78c0 212 */
ansond 49:c603a22495bb 213 OptionsBuilder &setServerCertificate(uint8_t *cert,int cert_size);
ansond 8:f950fb1b78c0 214
ansond 8:f950fb1b78c0 215 /**
ansond 8:f950fb1b78c0 216 Set the Client Certificate
ansond 8:f950fb1b78c0 217 @param cert input the client certificate
ansond 8:f950fb1b78c0 218 @param cert_size input the length of the client certificate
ansond 8:f950fb1b78c0 219 */
ansond 49:c603a22495bb 220 OptionsBuilder &setClientCertificate(uint8_t *cert,int cert_size);
ansond 8:f950fb1b78c0 221
ansond 8:f950fb1b78c0 222 /**
ansond 8:f950fb1b78c0 223 Set the Client Key
ansond 8:f950fb1b78c0 224 @param key input the client key
ansond 8:f950fb1b78c0 225 @param key_size input the length of the client key
ansond 8:f950fb1b78c0 226 */
ansond 49:c603a22495bb 227 OptionsBuilder &setClientKey(uint8_t *key,int key_size);
ansond 8:f950fb1b78c0 228
ansond 8:f950fb1b78c0 229 /**
ansond 8:f950fb1b78c0 230 Build our our immutable self
ansond 8:f950fb1b78c0 231 */
ansond 8:f950fb1b78c0 232 Options *build();
ansond 22:68fcdc40b397 233
ansond 22:68fcdc40b397 234 /**
ansond 22:68fcdc40b397 235 Set our Endpoint instance
ansond 22:68fcdc40b397 236 */
ansond 22:68fcdc40b397 237 void setEndpoint(void *endpoint);
ansond 8:f950fb1b78c0 238 };
ansond 8:f950fb1b78c0 239
ansond 8:f950fb1b78c0 240 } // namespace Connector
ansond 8:f950fb1b78c0 241
ansond 8:f950fb1b78c0 242 #endif // __OPTIONS_BUILDER_H__