Mistake on this page? Email us
m2mfirmware.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 ARM Limited. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  * Licensed under the Apache License, Version 2.0 (the License); you may
5  * not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef M2MFIRMWARE_H
17 #define M2MFIRMWARE_H
18 
19 #include "mbed-client/m2mobject.h"
20 
21 // FORWARD DECLARATION
22 class M2MResource;
24 
32 class M2MFirmware : public M2MObject {
33 
34 friend class M2MInterfaceFactory;
35 
36 public:
37 
42  typedef enum {
43  Package,
44  PackageUri,
45  Update,
46  State,
47  UpdateSupportedObjects,
48  UpdateResult,
49  PackageName,
50  PackageVersion
52 
56  typedef enum {
57  Idle = 0,
58  Downloading,
59  Downloaded,
60  Updating
61  } UpdateState;
62 
66  typedef enum {
67  Default = 0,
68  SuccessfullyUpdated,
69  NotEnoughSpace,
70  OutOfMemory,
71  ConnectionLost,
72  CRCCheckFailure,
73  UnsupportedPackageType,
74  InvalidURI
76 
77 private:
78 
82  M2MFirmware();
83 
84  // Prevents the use of assignment operator.
85  M2MFirmware& operator=( const M2MFirmware& /*other*/ );
86 
87  // Prevents the use of copy constructor.
88  M2MFirmware( const M2MFirmware& /*other*/ );
89 
93  virtual ~M2MFirmware();
94 
95  static M2MFirmware* get_instance();
96 
97 public:
98 
102  static void delete_instance() m2m_deprecated;
103 
111  M2MResource* create_resource(FirmwareResource resource, const String &value) m2m_deprecated;
112 
120  M2MResource* create_resource(FirmwareResource resource, int64_t value) m2m_deprecated;
121 
128  bool delete_resource(FirmwareResource resource) m2m_deprecated;
129 
137  bool set_resource_value(FirmwareResource resource,
138  const String &value) m2m_deprecated;
139 
147  bool set_resource_value(FirmwareResource resource,
148  int64_t value) m2m_deprecated;
149 
158  bool set_resource_value(FirmwareResource resource,
159  const uint8_t *value,
160  const uint32_t length) m2m_deprecated;
161 
168  String resource_value_string(FirmwareResource resource) const m2m_deprecated;
169 
176  int64_t resource_value_int(FirmwareResource resource) const m2m_deprecated;
177 
188  uint32_t resource_value_buffer(FirmwareResource resource,
189  uint8_t *&data) const m2m_deprecated;
190 
196  bool is_resource_present(FirmwareResource resource) const m2m_deprecated;
197 
202  uint16_t total_resource_count() const m2m_deprecated;
203 
211  uint16_t per_resource_count(FirmwareResource resource) const m2m_deprecated;
212 
220 
228  bool set_resource_value_update_callback(FirmwareResource resource,
229  value_updated_callback callback);
230 
239  bool set_resource_notification_sent_callback(FirmwareResource resource,
240  notification_sent_callback_2 callback) m2m_deprecated;
241 
242 
249  bool set_resource_notification_sent_callback(FirmwareResource resource,
250  notification_delivery_status_cb callback) m2m_deprecated;
251 
252 
259  bool set_resource_notification_sent_callback(FirmwareResource resource,
260  message_delivery_status_cb callback);
261 
262 #ifndef DISABLE_BLOCK_MESSAGE
263 
270 #endif
271 
272 private:
273 
274  M2MResource* get_resource(FirmwareResource resource) const;
275 
276  static const char* resource_name(FirmwareResource resource);
277 
278  void create_mandatory_resources();
279 
280  bool check_value_range(FirmwareResource resource, const int64_t value) const;
281 
282 private :
283 
284  M2MObjectInstance* _firmware_instance; //Not owned
285 
286 protected:
287 
288  static M2MFirmware* _instance;
289 
290  friend class Test_M2MFirmware;
291  friend class Test_M2MInterfaceFactory;
292 } m2m_deprecated;
293 
294 
295 #endif // M2MFIRMWARE_H
The base class for Client Objects.
Definition: m2mobject.h:39
String resource_value_string(FirmwareResource resource) const m2m_deprecated
Returns a value of a given resource enum, in string format.
bool delete_resource(FirmwareResource resource) m2m_deprecated
Deletes a resource with a given resource enum. Mandatory resources cannot be deleted.
bool set_resource_value(FirmwareResource resource, const String &value) m2m_deprecated
Sets a value of a given resource enum.
M2MObject. This class is the base class for the mbed Client Objects.
uint16_t per_resource_count(FirmwareResource resource) const m2m_deprecated
Returns the number of resources for a given resource enum.
Definition: m2mobjectinstance.h:36
Definition: m2mfirmware.h:32
Definition: m2mstring.h:33
ResultOfUpdate
An enum defining the result of the firmware update.
Definition: m2mfirmware.h:66
uint32_t resource_value_buffer(FirmwareResource resource, uint8_t *&data) const m2m_deprecated
Populates the data buffer and returns the size of the buffer.
bool set_resource_value_update_callback(FirmwareResource resource, value_updated_callback callback)
Set resource value update callback function. This is called when resource value is updated...
Definition: m2mresourceinstance.h:32
uint16_t total_resource_count() const m2m_deprecated
Returns the number of resources for a whole firmware object.
M2MResource * create_resource(FirmwareResource resource, const String &value) m2m_deprecated
Creates a new resource for a given resource enum.
UpdateState
An enum defining the state of the firmware update.
Definition: m2mfirmware.h:56
The base class for Client Resources.
Definition: m2mresource.h:40
bool is_resource_present(FirmwareResource resource) const m2m_deprecated
Returns whether a resource instance with a given resource enum exists or not.
bool set_resource_notification_sent_callback(FirmwareResource resource, notification_sent_callback_2 callback) m2m_deprecated
Sets the callback function that is executed when this object receives response(Empty ACK) for notific...
bool set_update_execute_callback(execute_callback callback)
Set update resource execute callback function. This is called when update resource receives POST comm...
Definition: m2minterfacefactory.h:36
FirmwareResource
An enum defining all the resources associated with a Firmware Object in the LWM2M framework...
Definition: m2mfirmware.h:42
static void delete_instance() m2m_deprecated
Deletes a M2MFirmware instance.
int64_t resource_value_int(FirmwareResource resource) const m2m_deprecated
Returns a value of a given resource key name, in integer format.
bool set_package_block_message_callback(incoming_block_message_callback callback)
Set incoming_block_message_callback for the package resource. The callback will be called when a bloc...
Definition: functionpointer.h:114