![](/media/cache/profiles/854d9fca60b4bd07f9bb215d59ef5561.jpg.50x50_q85.jpg)
Simulated product dispenser
Fork of mbed-cloud-workshop-connect-HTS221 by
simple-mbed-cloud-client/simple-mbed-cloud-client.h@4:e518dde96e59, 2018-10-25 (annotated)
- Committer:
- JimCarver
- Date:
- Thu Oct 25 14:00:12 2018 +0000
- Revision:
- 4:e518dde96e59
- Parent:
- 0:6b753f761943
Simulated dispenser
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JimCarver | 0:6b753f761943 | 1 | // ---------------------------------------------------------------------------- |
JimCarver | 0:6b753f761943 | 2 | // Copyright 2016-2018 ARM Ltd. |
JimCarver | 0:6b753f761943 | 3 | // |
JimCarver | 0:6b753f761943 | 4 | // SPDX-License-Identifier: Apache-2.0 |
JimCarver | 0:6b753f761943 | 5 | // |
JimCarver | 0:6b753f761943 | 6 | // Licensed under the Apache License, Version 2.0 (the "License"); |
JimCarver | 0:6b753f761943 | 7 | // you may not use this file except in compliance with the License. |
JimCarver | 0:6b753f761943 | 8 | // You may obtain a copy of the License at |
JimCarver | 0:6b753f761943 | 9 | // |
JimCarver | 0:6b753f761943 | 10 | // http://www.apache.org/licenses/LICENSE-2.0 |
JimCarver | 0:6b753f761943 | 11 | // |
JimCarver | 0:6b753f761943 | 12 | // Unless required by applicable law or agreed to in writing, software |
JimCarver | 0:6b753f761943 | 13 | // distributed under the License is distributed on an "AS IS" BASIS, |
JimCarver | 0:6b753f761943 | 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
JimCarver | 0:6b753f761943 | 15 | // See the License for the specific language governing permissions and |
JimCarver | 0:6b753f761943 | 16 | // limitations under the License. |
JimCarver | 0:6b753f761943 | 17 | // ---------------------------------------------------------------------------- |
JimCarver | 0:6b753f761943 | 18 | |
JimCarver | 0:6b753f761943 | 19 | #ifndef SIMPLEMBEDCLOUDCLIENT_H |
JimCarver | 0:6b753f761943 | 20 | #define SIMPLEMBEDCLOUDCLIENT_H |
JimCarver | 0:6b753f761943 | 21 | #include <stdio.h> |
JimCarver | 0:6b753f761943 | 22 | #include "mbed-cloud-client/MbedCloudClient.h" |
JimCarver | 0:6b753f761943 | 23 | #include "m2mdevice.h" |
JimCarver | 0:6b753f761943 | 24 | #include "m2mresource.h" |
JimCarver | 0:6b753f761943 | 25 | #include "mbed-client/m2minterface.h" |
JimCarver | 0:6b753f761943 | 26 | #include "mbed-client/m2mvector.h" |
JimCarver | 0:6b753f761943 | 27 | #include "mbed_cloud_client_resource.h" |
JimCarver | 0:6b753f761943 | 28 | #include "mbed.h" |
JimCarver | 0:6b753f761943 | 29 | #include "NetworkInterface.h" |
JimCarver | 0:6b753f761943 | 30 | |
JimCarver | 0:6b753f761943 | 31 | class MbedCloudClientResource; |
JimCarver | 0:6b753f761943 | 32 | |
JimCarver | 0:6b753f761943 | 33 | class SimpleMbedCloudClient { |
JimCarver | 0:6b753f761943 | 34 | |
JimCarver | 0:6b753f761943 | 35 | public: |
JimCarver | 0:6b753f761943 | 36 | |
JimCarver | 0:6b753f761943 | 37 | SimpleMbedCloudClient(NetworkInterface *net, BlockDevice *bd, FileSystem *fs); |
JimCarver | 0:6b753f761943 | 38 | ~SimpleMbedCloudClient(); |
JimCarver | 0:6b753f761943 | 39 | |
JimCarver | 0:6b753f761943 | 40 | int init(); |
JimCarver | 0:6b753f761943 | 41 | bool call_register(); |
JimCarver | 0:6b753f761943 | 42 | void close(); |
JimCarver | 0:6b753f761943 | 43 | void register_update(); |
JimCarver | 0:6b753f761943 | 44 | void client_registered(); |
JimCarver | 0:6b753f761943 | 45 | void client_unregistered(); |
JimCarver | 0:6b753f761943 | 46 | void error(int error_code); |
JimCarver | 0:6b753f761943 | 47 | bool is_client_registered(); |
JimCarver | 0:6b753f761943 | 48 | bool is_register_called(); |
JimCarver | 0:6b753f761943 | 49 | bool register_and_connect(); |
JimCarver | 0:6b753f761943 | 50 | MbedCloudClient& get_cloud_client(); |
JimCarver | 0:6b753f761943 | 51 | MbedCloudClientResource* create_resource(const char *path, const char *name); |
JimCarver | 0:6b753f761943 | 52 | void on_registered(Callback<void(const ConnectorClientEndpointInfo*)> cb); |
JimCarver | 0:6b753f761943 | 53 | void on_unregistered(Callback<void()> cb); |
JimCarver | 0:6b753f761943 | 54 | |
JimCarver | 0:6b753f761943 | 55 | private: |
JimCarver | 0:6b753f761943 | 56 | int reformat_storage(); |
JimCarver | 0:6b753f761943 | 57 | void reset_storage(); |
JimCarver | 0:6b753f761943 | 58 | int mount_storage(); |
JimCarver | 0:6b753f761943 | 59 | |
JimCarver | 0:6b753f761943 | 60 | M2MObjectList _obj_list; |
JimCarver | 0:6b753f761943 | 61 | MbedCloudClient _cloud_client; |
JimCarver | 0:6b753f761943 | 62 | bool _registered; |
JimCarver | 0:6b753f761943 | 63 | bool _register_called; |
JimCarver | 0:6b753f761943 | 64 | bool _register_and_connect_called; |
JimCarver | 0:6b753f761943 | 65 | Vector<MbedCloudClientResource*> _resources; |
JimCarver | 0:6b753f761943 | 66 | Callback<void(const ConnectorClientEndpointInfo*)> _registered_cb; |
JimCarver | 0:6b753f761943 | 67 | Callback<void()> _unregistered_cb; |
JimCarver | 0:6b753f761943 | 68 | NetworkInterface * _net; |
JimCarver | 0:6b753f761943 | 69 | BlockDevice * _bd; |
JimCarver | 0:6b753f761943 | 70 | FileSystem * _fs; |
JimCarver | 0:6b753f761943 | 71 | }; |
JimCarver | 0:6b753f761943 | 72 | |
JimCarver | 0:6b753f761943 | 73 | #endif // SIMPLEMBEDCLOUDCLIENT_H |