A metronome using the FRDM K64F board

Committer:
ram54288
Date:
Sun May 14 18:40:18 2017 +0000
Revision:
0:a7a43371b306
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ram54288 0:a7a43371b306 1 /*
ram54288 0:a7a43371b306 2 * Copyright (c) 2015 ARM Limited. All rights reserved.
ram54288 0:a7a43371b306 3 * SPDX-License-Identifier: Apache-2.0
ram54288 0:a7a43371b306 4 * Licensed under the Apache License, Version 2.0 (the License); you may
ram54288 0:a7a43371b306 5 * not use this file except in compliance with the License.
ram54288 0:a7a43371b306 6 * You may obtain a copy of the License at
ram54288 0:a7a43371b306 7 *
ram54288 0:a7a43371b306 8 * http://www.apache.org/licenses/LICENSE-2.0
ram54288 0:a7a43371b306 9 *
ram54288 0:a7a43371b306 10 * Unless required by applicable law or agreed to in writing, software
ram54288 0:a7a43371b306 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
ram54288 0:a7a43371b306 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ram54288 0:a7a43371b306 13 * See the License for the specific language governing permissions and
ram54288 0:a7a43371b306 14 * limitations under the License.
ram54288 0:a7a43371b306 15 */
ram54288 0:a7a43371b306 16 #ifndef __MBED_CLIENT_H__
ram54288 0:a7a43371b306 17 #define __MBED_CLIENT_H__
ram54288 0:a7a43371b306 18
ram54288 0:a7a43371b306 19 #undef SIXLOWPAN_INTERFACE
ram54288 0:a7a43371b306 20
ram54288 0:a7a43371b306 21 #include "mbed-client/m2minterfaceobserver.h"
ram54288 0:a7a43371b306 22
ram54288 0:a7a43371b306 23 #ifndef TARGET_LIKE_LINUX
ram54288 0:a7a43371b306 24 #include "mbed/DigitalOut.h"
ram54288 0:a7a43371b306 25 #endif
ram54288 0:a7a43371b306 26
ram54288 0:a7a43371b306 27
ram54288 0:a7a43371b306 28 //#define BOOTSTRAP_ENABLED
ram54288 0:a7a43371b306 29
ram54288 0:a7a43371b306 30 class M2MDevice;
ram54288 0:a7a43371b306 31 class M2MSecurity;
ram54288 0:a7a43371b306 32 class M2MObject;
ram54288 0:a7a43371b306 33
ram54288 0:a7a43371b306 34 class MbedClient: public M2MInterfaceObserver {
ram54288 0:a7a43371b306 35 public:
ram54288 0:a7a43371b306 36 MbedClient();
ram54288 0:a7a43371b306 37
ram54288 0:a7a43371b306 38 ~MbedClient();
ram54288 0:a7a43371b306 39
ram54288 0:a7a43371b306 40 bool create_interface();
ram54288 0:a7a43371b306 41
ram54288 0:a7a43371b306 42 bool bootstrap_successful();
ram54288 0:a7a43371b306 43
ram54288 0:a7a43371b306 44 bool register_successful();
ram54288 0:a7a43371b306 45
ram54288 0:a7a43371b306 46 bool unregister_successful();
ram54288 0:a7a43371b306 47
ram54288 0:a7a43371b306 48 bool registration_update_successful();
ram54288 0:a7a43371b306 49
ram54288 0:a7a43371b306 50 M2MSecurity* create_bootstrap_object(bool useSecureConnection);
ram54288 0:a7a43371b306 51
ram54288 0:a7a43371b306 52 M2MSecurity* create_register_object(bool useSecureConnection);
ram54288 0:a7a43371b306 53
ram54288 0:a7a43371b306 54 void test_bootstrap(M2MSecurity *security);
ram54288 0:a7a43371b306 55
ram54288 0:a7a43371b306 56 M2MDevice* create_device_object();
ram54288 0:a7a43371b306 57
ram54288 0:a7a43371b306 58 void execute_function(void *argument);
ram54288 0:a7a43371b306 59
ram54288 0:a7a43371b306 60 M2MObject* create_generic_object();
ram54288 0:a7a43371b306 61
ram54288 0:a7a43371b306 62 void update_resource();
ram54288 0:a7a43371b306 63
ram54288 0:a7a43371b306 64 void test_register(M2MObjectList object_list);
ram54288 0:a7a43371b306 65
ram54288 0:a7a43371b306 66 void set_register_object(M2MSecurity *&register_object);
ram54288 0:a7a43371b306 67
ram54288 0:a7a43371b306 68 void test_update_register();
ram54288 0:a7a43371b306 69
ram54288 0:a7a43371b306 70 void test_unregister();
ram54288 0:a7a43371b306 71
ram54288 0:a7a43371b306 72 //Callback from mbed client stack when the bootstrap
ram54288 0:a7a43371b306 73 // is successful, it returns the mbed Device Server object
ram54288 0:a7a43371b306 74 // which will be used for registering the resources to
ram54288 0:a7a43371b306 75 // mbed Device server.
ram54288 0:a7a43371b306 76 void bootstrap_done(M2MSecurity *server_object);
ram54288 0:a7a43371b306 77
ram54288 0:a7a43371b306 78 //Callback from mbed client stack when the registration
ram54288 0:a7a43371b306 79 // is successful, it returns the mbed Device Server object
ram54288 0:a7a43371b306 80 // to which the resources are registered and registered objects.
ram54288 0:a7a43371b306 81 void object_registered(M2MSecurity */*security_object*/, const M2MServer &/*server_object*/);
ram54288 0:a7a43371b306 82
ram54288 0:a7a43371b306 83 //Callback from mbed client stack when the unregistration
ram54288 0:a7a43371b306 84 // is successful, it returns the mbed Device Server object
ram54288 0:a7a43371b306 85 // to which the resources were unregistered.
ram54288 0:a7a43371b306 86 void object_unregistered(M2MSecurity */*server_object*/);
ram54288 0:a7a43371b306 87
ram54288 0:a7a43371b306 88 void registration_updated(M2MSecurity */*security_object*/, const M2MServer & /*server_object*/);
ram54288 0:a7a43371b306 89
ram54288 0:a7a43371b306 90 //Callback from mbed client stack if any error is encountered
ram54288 0:a7a43371b306 91 // during any of the LWM2M operations. Error type is passed in
ram54288 0:a7a43371b306 92 // the callback.
ram54288 0:a7a43371b306 93 void error(M2MInterface::Error error);
ram54288 0:a7a43371b306 94
ram54288 0:a7a43371b306 95 //Callback from mbed client stack if any value has changed
ram54288 0:a7a43371b306 96 // during PUT operation. Object and its type is passed in
ram54288 0:a7a43371b306 97 // the callback.
ram54288 0:a7a43371b306 98 void value_updated(M2MBase *base, M2MBase::BaseType type);
ram54288 0:a7a43371b306 99
ram54288 0:a7a43371b306 100 private:
ram54288 0:a7a43371b306 101
ram54288 0:a7a43371b306 102 #ifndef TARGET_LIKE_LINUX
ram54288 0:a7a43371b306 103 mbed::DigitalOut _led;
ram54288 0:a7a43371b306 104 #endif
ram54288 0:a7a43371b306 105 M2MInterface *_interface;
ram54288 0:a7a43371b306 106 M2MSecurity *_security;
ram54288 0:a7a43371b306 107 M2MSecurity *_register_security;
ram54288 0:a7a43371b306 108 M2MDevice *_device;
ram54288 0:a7a43371b306 109 M2MObject *_object;
ram54288 0:a7a43371b306 110 bool _bootstrapped;
ram54288 0:a7a43371b306 111 bool _error;
ram54288 0:a7a43371b306 112 bool _registered;
ram54288 0:a7a43371b306 113 bool _unregistered;
ram54288 0:a7a43371b306 114 bool _registration_updated;
ram54288 0:a7a43371b306 115 int _value;
ram54288 0:a7a43371b306 116 };
ram54288 0:a7a43371b306 117
ram54288 0:a7a43371b306 118
ram54288 0:a7a43371b306 119
ram54288 0:a7a43371b306 120 #endif //__MBED_CLIENT_H__