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/

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?

UserRevisionLine numberNew 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
edamame22 0:29983394c6b6 17 #include <string.h>
edamame22 0:29983394c6b6 18 #include "mbed-client/m2mconnectionhandler.h"
edamame22 0:29983394c6b6 19 #include "mbed-client/m2mconnectionsecurity.h"
edamame22 0:29983394c6b6 20 #include "mbed-client/m2mtimer.h"
edamame22 0:29983394c6b6 21 #include "mbed-client/m2msecurity.h"
edamame22 0:29983394c6b6 22 #include "mbed-client-mbedtls/m2mconnectionsecuritypimpl.h"
edamame22 0:29983394c6b6 23
edamame22 0:29983394c6b6 24 M2MConnectionSecurity::M2MConnectionSecurity(SecurityMode mode)
edamame22 0:29983394c6b6 25 {
edamame22 0:29983394c6b6 26 _private_impl = new M2MConnectionSecurityPimpl(mode);
edamame22 0:29983394c6b6 27 }
edamame22 0:29983394c6b6 28
edamame22 0:29983394c6b6 29 M2MConnectionSecurity::~M2MConnectionSecurity(){
edamame22 0:29983394c6b6 30 delete _private_impl;
edamame22 0:29983394c6b6 31 }
edamame22 0:29983394c6b6 32
edamame22 0:29983394c6b6 33 void M2MConnectionSecurity::reset(){
edamame22 0:29983394c6b6 34 _private_impl->reset();
edamame22 0:29983394c6b6 35 }
edamame22 0:29983394c6b6 36
edamame22 0:29983394c6b6 37 int M2MConnectionSecurity::init(const M2MSecurity *security){
edamame22 0:29983394c6b6 38 return _private_impl->init(security);
edamame22 0:29983394c6b6 39 }
edamame22 0:29983394c6b6 40
edamame22 0:29983394c6b6 41 int M2MConnectionSecurity::start_connecting_non_blocking(M2MConnectionHandler* connHandler)
edamame22 0:29983394c6b6 42 {
edamame22 0:29983394c6b6 43 return _private_impl->start_connecting_non_blocking(connHandler);
edamame22 0:29983394c6b6 44 }
edamame22 0:29983394c6b6 45
edamame22 0:29983394c6b6 46 int M2MConnectionSecurity::continue_connecting()
edamame22 0:29983394c6b6 47 {
edamame22 0:29983394c6b6 48 return _private_impl->continue_connecting();
edamame22 0:29983394c6b6 49 }
edamame22 0:29983394c6b6 50
edamame22 0:29983394c6b6 51 int M2MConnectionSecurity::connect(M2MConnectionHandler* connHandler){
edamame22 0:29983394c6b6 52 return _private_impl->connect(connHandler);
edamame22 0:29983394c6b6 53 }
edamame22 0:29983394c6b6 54
edamame22 0:29983394c6b6 55 int M2MConnectionSecurity::send_message(unsigned char *message, int len){
edamame22 0:29983394c6b6 56 return _private_impl->send_message(message, len);
edamame22 0:29983394c6b6 57 }
edamame22 0:29983394c6b6 58
edamame22 0:29983394c6b6 59 int M2MConnectionSecurity::read(unsigned char* buffer, uint16_t len){
edamame22 0:29983394c6b6 60 return _private_impl->read(buffer, len);
edamame22 0:29983394c6b6 61 }
edamame22 0:29983394c6b6 62
edamame22 0:29983394c6b6 63 void M2MConnectionSecurity::set_random_number_callback(random_number_cb callback)
edamame22 0:29983394c6b6 64 {
edamame22 0:29983394c6b6 65 _private_impl->set_random_number_callback(callback);
edamame22 0:29983394c6b6 66 }
edamame22 0:29983394c6b6 67
edamame22 0:29983394c6b6 68 void M2MConnectionSecurity::set_entropy_callback(entropy_cb callback)
edamame22 0:29983394c6b6 69 {
edamame22 0:29983394c6b6 70 _private_impl->set_entropy_callback(callback);
edamame22 0:29983394c6b6 71 }