This is an example of BLE GATT Client, which receives broadcast data from BLE_Server_BME280 ( a GATT server) , then transfers values up to mbed Device Connector (cloud).
Please refer details about BLEClient_mbedDevConn below. https://github.com/soramame21/BLEClient_mbedDevConn
The location of required BLE GATT server, BLE_Server_BME280, is at here. https://developer.mbed.org/users/edamame22/code/BLE_Server_BME280/
mbed-client/source/include/m2mnsdlobserver.h@2:b894b3508057, 2017-09-05 (annotated)
- Committer:
- Ren Boting
- Date:
- Tue Sep 05 11:56:13 2017 +0900
- Revision:
- 2:b894b3508057
- Parent:
- 0:29983394c6b6
Update all libraries and reform main.cpp
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
edamame22 | 0:29983394c6b6 | 1 | /* |
edamame22 | 0:29983394c6b6 | 2 | * Copyright (c) 2015 ARM Limited. All rights reserved. |
edamame22 | 0:29983394c6b6 | 3 | * SPDX-License-Identifier: Apache-2.0 |
edamame22 | 0:29983394c6b6 | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
edamame22 | 0:29983394c6b6 | 5 | * not use this file except in compliance with the License. |
edamame22 | 0:29983394c6b6 | 6 | * You may obtain a copy of the License at |
edamame22 | 0:29983394c6b6 | 7 | * |
edamame22 | 0:29983394c6b6 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
edamame22 | 0:29983394c6b6 | 9 | * |
edamame22 | 0:29983394c6b6 | 10 | * Unless required by applicable law or agreed to in writing, software |
edamame22 | 0:29983394c6b6 | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
edamame22 | 0:29983394c6b6 | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
edamame22 | 0:29983394c6b6 | 13 | * See the License for the specific language governing permissions and |
edamame22 | 0:29983394c6b6 | 14 | * limitations under the License. |
edamame22 | 0:29983394c6b6 | 15 | */ |
edamame22 | 0:29983394c6b6 | 16 | #ifndef M2M_NSDL_OBSERVER_H |
edamame22 | 0:29983394c6b6 | 17 | #define M2M_NSDL_OBSERVER_H |
edamame22 | 0:29983394c6b6 | 18 | |
edamame22 | 0:29983394c6b6 | 19 | #include "include/nsdllinker.h" |
edamame22 | 0:29983394c6b6 | 20 | |
edamame22 | 0:29983394c6b6 | 21 | //FORWARD DECLARATION |
edamame22 | 0:29983394c6b6 | 22 | class M2MSecurity; |
edamame22 | 0:29983394c6b6 | 23 | class M2MServer; |
edamame22 | 0:29983394c6b6 | 24 | |
edamame22 | 0:29983394c6b6 | 25 | /** |
edamame22 | 0:29983394c6b6 | 26 | * @brief Observer class for informing NSDL callback to the state machine |
edamame22 | 0:29983394c6b6 | 27 | */ |
edamame22 | 0:29983394c6b6 | 28 | |
edamame22 | 0:29983394c6b6 | 29 | class M2MNsdlObserver |
edamame22 | 0:29983394c6b6 | 30 | { |
edamame22 | 0:29983394c6b6 | 31 | |
edamame22 | 0:29983394c6b6 | 32 | public : |
edamame22 | 0:29983394c6b6 | 33 | |
edamame22 | 0:29983394c6b6 | 34 | /** |
edamame22 | 0:29983394c6b6 | 35 | * @brief Informs that coap message is ready. |
edamame22 | 0:29983394c6b6 | 36 | * @param data_ptr, Data object of coap message. |
edamame22 | 0:29983394c6b6 | 37 | * @param data_len, Length of the data object. |
edamame22 | 0:29983394c6b6 | 38 | * @param address_ptr, Address structure of the server. |
edamame22 | 0:29983394c6b6 | 39 | */ |
edamame22 | 0:29983394c6b6 | 40 | virtual void coap_message_ready(uint8_t *data_ptr, |
edamame22 | 0:29983394c6b6 | 41 | uint16_t data_len, |
edamame22 | 0:29983394c6b6 | 42 | sn_nsdl_addr_s *address_ptr) = 0; |
edamame22 | 0:29983394c6b6 | 43 | |
edamame22 | 0:29983394c6b6 | 44 | /** |
edamame22 | 0:29983394c6b6 | 45 | * @brief Informs that client is registered successfully. |
edamame22 | 0:29983394c6b6 | 46 | * @param server_object, Server object associated with |
edamame22 | 0:29983394c6b6 | 47 | * registered server. |
edamame22 | 0:29983394c6b6 | 48 | */ |
edamame22 | 0:29983394c6b6 | 49 | virtual void client_registered(M2MServer *server_object) = 0; |
edamame22 | 0:29983394c6b6 | 50 | |
edamame22 | 0:29983394c6b6 | 51 | /** |
edamame22 | 0:29983394c6b6 | 52 | * @brief Informs that client registration is updated successfully. |
edamame22 | 0:29983394c6b6 | 53 | * @param server_object, Server object associated with |
edamame22 | 0:29983394c6b6 | 54 | * registered server. |
edamame22 | 0:29983394c6b6 | 55 | */ |
edamame22 | 0:29983394c6b6 | 56 | virtual void registration_updated(const M2MServer &server_object) = 0; |
edamame22 | 0:29983394c6b6 | 57 | |
edamame22 | 0:29983394c6b6 | 58 | /** |
edamame22 | 0:29983394c6b6 | 59 | * @brief Informs that some error occured during |
edamame22 | 0:29983394c6b6 | 60 | * registration. |
edamame22 | 0:29983394c6b6 | 61 | * @param error_code, Error code for registration error |
edamame22 | 0:29983394c6b6 | 62 | * @param retry, Indicates state machine to re-establish connection |
edamame22 | 0:29983394c6b6 | 63 | */ |
edamame22 | 0:29983394c6b6 | 64 | virtual void registration_error(uint8_t error_code, bool retry = false) = 0; |
edamame22 | 0:29983394c6b6 | 65 | |
edamame22 | 0:29983394c6b6 | 66 | /** |
edamame22 | 0:29983394c6b6 | 67 | * @brief Informs that client is unregistered successfully. |
edamame22 | 0:29983394c6b6 | 68 | */ |
edamame22 | 0:29983394c6b6 | 69 | virtual void client_unregistered() = 0; |
edamame22 | 0:29983394c6b6 | 70 | |
edamame22 | 0:29983394c6b6 | 71 | /** |
edamame22 | 0:29983394c6b6 | 72 | * @brief Informs that client bootstrapping is done. |
edamame22 | 0:29983394c6b6 | 73 | * @param security_object, M2MSecurity Object which contains information about |
edamame22 | 0:29983394c6b6 | 74 | * LWM2M server fetched from bootstrap server. |
edamame22 | 0:29983394c6b6 | 75 | */ |
edamame22 | 0:29983394c6b6 | 76 | virtual void bootstrap_done(M2MSecurity *security_object) = 0; |
edamame22 | 0:29983394c6b6 | 77 | |
edamame22 | 0:29983394c6b6 | 78 | /** |
edamame22 | 0:29983394c6b6 | 79 | * @brief Informs that client bootstrapping is waiting for message to be sent. |
edamame22 | 0:29983394c6b6 | 80 | * @param security_object, M2MSecurity Object which contains information about |
edamame22 | 0:29983394c6b6 | 81 | * LWM2M server fetched from bootstrap server. |
edamame22 | 0:29983394c6b6 | 82 | */ |
edamame22 | 0:29983394c6b6 | 83 | virtual void bootstrap_wait(M2MSecurity *security_object) = 0; |
edamame22 | 0:29983394c6b6 | 84 | |
edamame22 | 0:29983394c6b6 | 85 | /** |
edamame22 | 0:29983394c6b6 | 86 | * @brief Informs that some error occured during |
edamame22 | 0:29983394c6b6 | 87 | * bootstrapping. |
edamame22 | 0:29983394c6b6 | 88 | */ |
edamame22 | 0:29983394c6b6 | 89 | virtual void bootstrap_error() = 0; |
edamame22 | 0:29983394c6b6 | 90 | |
edamame22 | 0:29983394c6b6 | 91 | /** |
edamame22 | 0:29983394c6b6 | 92 | * @brief Informs that received data has been processed. |
edamame22 | 0:29983394c6b6 | 93 | */ |
edamame22 | 0:29983394c6b6 | 94 | virtual void coap_data_processed() = 0; |
edamame22 | 0:29983394c6b6 | 95 | |
edamame22 | 0:29983394c6b6 | 96 | /** |
edamame22 | 0:29983394c6b6 | 97 | * @brief Callback informing that the value of the resource object is updated by server. |
edamame22 | 0:29983394c6b6 | 98 | * @param base Object whose value is updated. |
edamame22 | 0:29983394c6b6 | 99 | */ |
edamame22 | 0:29983394c6b6 | 100 | virtual void value_updated(M2MBase *base) = 0; |
edamame22 | 0:29983394c6b6 | 101 | }; |
edamame22 | 0:29983394c6b6 | 102 | #endif // M2M_NSDL_OBSERVER_H |