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