Mbed Cloud example program for workshop in W27 2018.

Dependencies:   MMA7660 LM75B

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FirmwareUpdateResource.h Source File

FirmwareUpdateResource.h

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2016-2017 ARM Ltd.
00003 //
00004 // SPDX-License-Identifier: Apache-2.0
00005 //
00006 // Licensed under the Apache License, Version 2.0 (the "License");
00007 // you may not use this file except in compliance with the License.
00008 // You may obtain a copy of the License at
00009 //
00010 //     http://www.apache.org/licenses/LICENSE-2.0
00011 //
00012 // Unless required by applicable law or agreed to in writing, software
00013 // distributed under the License is distributed on an "AS IS" BASIS,
00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015 // See the License for the specific language governing permissions and
00016 // limitations under the License.
00017 // ----------------------------------------------------------------------------
00018 
00019 #ifndef __ARM_UCS_FIRMWARE_UPDATE_RESOURCE_H__
00020 #define __ARM_UCS_FIRMWARE_UPDATE_RESOURCE_H__
00021 
00022 #include "mbed-client/m2minterfacefactory.h"
00023 #include "mbed-client/m2mresource.h"
00024 #include "mbed-client/m2mobject.h"
00025 
00026 namespace FirmwareUpdateResource {
00027 
00028     typedef enum {
00029         ARM_UCS_LWM2M_STATE_FIRST       = 0,
00030         ARM_UCS_LWM2M_STATE_IDLE        = ARM_UCS_LWM2M_STATE_FIRST,
00031         ARM_UCS_LWM2M_STATE_DOWNLOADING = 1,
00032         ARM_UCS_LWM2M_STATE_DOWNLOADED  = 2,
00033         ARM_UCS_LWM2M_STATE_UPDATING    = 3,
00034         ARM_UCS_LWM2M_STATE_LAST        = ARM_UCS_LWM2M_STATE_UPDATING
00035     } arm_ucs_lwm2m_state_t;
00036 
00037     typedef enum {
00038         ARM_UCS_LWM2M_RESULT_FIRST            = 0,
00039         ARM_UCS_LWM2M_RESULT_INITIAL          = ARM_UCS_LWM2M_RESULT_FIRST,
00040         ARM_UCS_LWM2M_RESULT_SUCCESS          = 1,
00041         ARM_UCS_LWM2M_RESULT_ERROR_STORAGE    = 2,
00042         ARM_UCS_LWM2M_RESULT_ERROR_MEMORY     = 3,
00043         ARM_UCS_LWM2M_RESULT_ERROR_CONNECTION = 4,
00044         ARM_UCS_LWM2M_RESULT_ERROR_CRC        = 5,
00045         ARM_UCS_LWM2M_RESULT_ERROR_TYPE       = 6,
00046         ARM_UCS_LWM2M_RESULT_ERROR_URI        = 7,
00047         ARM_UCS_LWM2M_RESULT_ERROR_UPDATE     = 8,
00048         ARM_UCS_LWM2M_RESULT_ERROR_HASH       = 9,
00049         ARM_UCS_LWM2M_RESULT_LAST             = ARM_UCS_LWM2M_RESULT_ERROR_HASH
00050     } arm_ucs_lwm2m_result_t;
00051 
00052     void Initialize(void);
00053 
00054     M2MObject* getObject(void);
00055 
00056     /* Add callback for resource /5/0/0, Package */
00057     int32_t addPackageCallback(void (*cb)(const uint8_t* buffer, uint16_t length));
00058 
00059     /* Add callback for resource /5/0/1, Package URI */
00060     int32_t addPackageURICallback(void (*cb)(const uint8_t* buffer, uint16_t length));
00061 
00062     /* Add callback for resource /5/0/2, Update */
00063     int32_t addUpdateCallback(void (*cb)(void));
00064 
00065     /* Add callback for when send{State, UpdateResult} is done */
00066     int32_t addNotificationCallback(void (*notification_handler)(void));
00067 
00068     /* Send state for resource /5/0/3, State */
00069     int32_t sendState(arm_ucs_lwm2m_state_t state);
00070 
00071     /* Send result for resource /5/0/5, Update Result */
00072     int32_t sendUpdateResult(arm_ucs_lwm2m_result_t result);
00073 
00074     /* Send name for resource /5/0/6, PkgName */
00075     int32_t sendPkgName(const uint8_t* name, uint16_t length);
00076 
00077     /* Send version for resource /5/0/7, PkgVersion */
00078     int32_t sendPkgVersion(uint64_t version);
00079 }
00080 
00081 #endif // __ARM_UCS_FIRMWARE_UPDATE_RESOURCE_H__