Simulated product dispenser

Dependencies:   HTS221

Fork of mbed-cloud-workshop-connect-HTS221 by Jim Carver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers simple-mbed-cloud-client.h Source File

simple-mbed-cloud-client.h

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2016-2018 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 SIMPLEMBEDCLOUDCLIENT_H
00020 #define SIMPLEMBEDCLOUDCLIENT_H
00021 #include <stdio.h>
00022 #include "mbed-cloud-client/MbedCloudClient.h"
00023 #include "m2mdevice.h"
00024 #include "m2mresource.h"
00025 #include "mbed-client/m2minterface.h"
00026 #include "mbed-client/m2mvector.h"
00027 #include "mbed_cloud_client_resource.h"
00028 #include "mbed.h"
00029 #include "NetworkInterface.h"
00030 
00031 class MbedCloudClientResource;
00032 
00033 class SimpleMbedCloudClient {
00034 
00035 public:
00036 
00037     SimpleMbedCloudClient(NetworkInterface *net, BlockDevice *bd, FileSystem *fs);
00038     ~SimpleMbedCloudClient();
00039 
00040     int init();
00041     bool call_register();
00042     void close();
00043     void register_update();
00044     void client_registered();
00045     void client_unregistered();
00046     void error(int error_code);
00047     bool is_client_registered();
00048     bool is_register_called();
00049     bool register_and_connect();
00050     MbedCloudClient& get_cloud_client();
00051     MbedCloudClientResource* create_resource(const char *path, const char *name);
00052     void on_registered(Callback<void(const ConnectorClientEndpointInfo*)> cb);
00053     void on_unregistered(Callback<void()> cb);
00054 
00055 private:
00056     int reformat_storage();
00057     void reset_storage();
00058     int mount_storage();
00059 
00060     M2MObjectList                                       _obj_list;
00061     MbedCloudClient                                     _cloud_client;
00062     bool                                                _registered;
00063     bool                                                _register_called;
00064     bool                                                _register_and_connect_called;
00065     Vector<MbedCloudClientResource*>                    _resources;
00066     Callback<void(const ConnectorClientEndpointInfo*)>  _registered_cb;
00067     Callback<void()>                                    _unregistered_cb;
00068     NetworkInterface *                                  _net;
00069     BlockDevice *                                       _bd;
00070     FileSystem *                                        _fs;
00071 };
00072 
00073 #endif // SIMPLEMBEDCLOUDCLIENT_H