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 if(TARGET_LIKE_X86_LINUX_NATIVE_COVERAGE)
edamame22 0:29983394c6b6 2 SET(CMAKE_CXX_FLAGS "")
edamame22 0:29983394c6b6 3 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage -Wall -Wextra -include /usr/include/CppUTest/MemoryLeakDetectorMallocMacros.h -include /usr/include/CppUTest/MemoryLeakDetectorNewMacros.h -D__thumb2__ -DMBED_CLIENT_C_NEW_API -w")
edamame22 0:29983394c6b6 4 include_directories($ENV{CPPUTEST_HOME}/include)
edamame22 0:29983394c6b6 5 link_directories($ENV{CPPUTEST_HOME}/lib)
edamame22 0:29983394c6b6 6 MACRO(SUBDIRLIST result curdir)
edamame22 0:29983394c6b6 7 FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
edamame22 0:29983394c6b6 8 SET(dirlist "")
edamame22 0:29983394c6b6 9 FOREACH(child ${children})
edamame22 0:29983394c6b6 10 IF(IS_DIRECTORY ${curdir}/${child})
edamame22 0:29983394c6b6 11 if(EXISTS "${curdir}/${child}/CMakeLists.txt")
edamame22 0:29983394c6b6 12 LIST(APPEND dirlist ${curdir}/${child})
edamame22 0:29983394c6b6 13 endif()
edamame22 0:29983394c6b6 14 ENDIF()
edamame22 0:29983394c6b6 15 ENDFOREACH()
edamame22 0:29983394c6b6 16 SET(${result} ${dirlist})
edamame22 0:29983394c6b6 17 ENDMACRO()
edamame22 0:29983394c6b6 18
edamame22 0:29983394c6b6 19 SUBDIRLIST(SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR}/mbedclient/utest)
edamame22 0:29983394c6b6 20
edamame22 0:29983394c6b6 21 FOREACH(subdir ${SUBDIRS})
edamame22 0:29983394c6b6 22 ADD_SUBDIRECTORY(${subdir})
edamame22 0:29983394c6b6 23 ENDFOREACH()
edamame22 0:29983394c6b6 24
edamame22 0:29983394c6b6 25 endif()
edamame22 0:29983394c6b6 26
edamame22 0:29983394c6b6 27 if(TARGET_LIKE_LINUX AND NOT TARGET_LIKE_X86_LINUX_NATIVE_COVERAGE)
edamame22 0:29983394c6b6 28 add_executable(mbed-client-test-mbedclient_linux
edamame22 0:29983394c6b6 29 "mbedclient_linux/main.cpp"
edamame22 0:29983394c6b6 30 )
edamame22 0:29983394c6b6 31 target_link_libraries(mbed-client-test-mbedclient_linux
edamame22 0:29983394c6b6 32 mbed-client-c
edamame22 0:29983394c6b6 33 mbed-client-linux
edamame22 0:29983394c6b6 34 mbed-client
edamame22 0:29983394c6b6 35 )
edamame22 0:29983394c6b6 36 #add_test(mbed-client-test-mbedclient_linux mbed-client-test-mbedclient_linux)
edamame22 0:29983394c6b6 37 add_dependencies(all_tests mbed-client-test-mbedclient_linux)
edamame22 0:29983394c6b6 38
edamame22 0:29983394c6b6 39 add_executable(mbed-client-test-helloworld-mbedclient
edamame22 0:29983394c6b6 40 "helloworld-mbedclient/main.cpp"
edamame22 0:29983394c6b6 41 "helloworld-mbedclient/mbedclient.cpp"
edamame22 0:29983394c6b6 42 "helloworld-mbedclient/to_be_ported.c"
edamame22 0:29983394c6b6 43 )
edamame22 0:29983394c6b6 44 target_link_libraries(mbed-client-test-helloworld-mbedclient
edamame22 0:29983394c6b6 45 mbed-client-c
edamame22 0:29983394c6b6 46 mbed-client-linux
edamame22 0:29983394c6b6 47 mbed-client
edamame22 0:29983394c6b6 48 )
edamame22 0:29983394c6b6 49 #add_test(mbed-client-test-helloworld-mbedclient mbed-client-test-helloworld-mbedclient)
edamame22 0:29983394c6b6 50 add_dependencies(all_tests mbed-client-test-helloworld-mbedclient)
edamame22 0:29983394c6b6 51
edamame22 0:29983394c6b6 52 endif()
edamame22 0:29983394c6b6 53
edamame22 0:29983394c6b6 54 if(TARGET_LIKE_MBED)
edamame22 0:29983394c6b6 55
edamame22 0:29983394c6b6 56 add_executable(mbed-client-test-mbedclient-smokeTest EXCLUDE_FROM_ALL
edamame22 0:29983394c6b6 57 "mbedclient-smokeTest/main.cpp"
edamame22 0:29983394c6b6 58 "mbedclient-smokeTest/testconfig.cpp"
edamame22 0:29983394c6b6 59 "mbedclient-smokeTest/testconfig.h"
edamame22 0:29983394c6b6 60 )
edamame22 0:29983394c6b6 61 target_link_libraries(mbed-client-test-mbedclient-smokeTest
edamame22 0:29983394c6b6 62 mbed-client-c
edamame22 0:29983394c6b6 63 mbed-client-mbed-os
edamame22 0:29983394c6b6 64 mbed-client
edamame22 0:29983394c6b6 65 )
edamame22 0:29983394c6b6 66
edamame22 0:29983394c6b6 67 #add_test(mbed-client-test-mbedclient-smokeTest mbed-client-test-mbedclient-smokeTest)
edamame22 0:29983394c6b6 68 add_dependencies(all_tests mbed-client-test-mbedclient-smokeTest)
edamame22 0:29983394c6b6 69
edamame22 0:29983394c6b6 70 # if the target has defined a post-processing step, perform it:
edamame22 0:29983394c6b6 71 if(YOTTA_POSTPROCESS_COMMAND)
edamame22 0:29983394c6b6 72 string(REPLACE YOTTA_CURRENT_EXE_NAME "mbed-client-test-mbedclient-smokeTest" LOCAL_POSTPROCESS_COMMAND "${YOTTA_POSTPROCESS_COMMAND}")
edamame22 0:29983394c6b6 73 separate_arguments(LOCAL_POSTPROCESS_COMMAND_SEPARATED UNIX_COMMAND ${LOCAL_POSTPROCESS_COMMAND})
edamame22 0:29983394c6b6 74 add_custom_command(
edamame22 0:29983394c6b6 75 TARGET mbed-client-test-mbedclient-smokeTest
edamame22 0:29983394c6b6 76 POST_BUILD
edamame22 0:29983394c6b6 77 COMMAND ${LOCAL_POSTPROCESS_COMMAND_SEPARATED}
edamame22 0:29983394c6b6 78 )
edamame22 0:29983394c6b6 79 endif()
edamame22 0:29983394c6b6 80
edamame22 0:29983394c6b6 81 add_executable(mbed-client-test-helloworld-mbedclient EXCLUDE_FROM_ALL
edamame22 0:29983394c6b6 82 "helloworld-mbedclient/main.cpp"
edamame22 0:29983394c6b6 83 "helloworld-mbedclient/mbedclient.cpp"
edamame22 0:29983394c6b6 84 "helloworld-mbedclient/to_be_ported.c"
edamame22 0:29983394c6b6 85 )
edamame22 0:29983394c6b6 86 target_link_libraries(mbed-client-test-helloworld-mbedclient
edamame22 0:29983394c6b6 87 mbed-client-c
edamame22 0:29983394c6b6 88 mbed-client-mbed-os
edamame22 0:29983394c6b6 89 mbed-client
edamame22 0:29983394c6b6 90 )
edamame22 0:29983394c6b6 91 # if the target has defined a post-processing step, perform it:
edamame22 0:29983394c6b6 92 if(YOTTA_POSTPROCESS_COMMAND)
edamame22 0:29983394c6b6 93 string(REPLACE YOTTA_CURRENT_EXE_NAME "mbed-client-test-helloworld-mbedclient" LOCAL_POSTPROCESS_COMMAND "${YOTTA_POSTPROCESS_COMMAND}")
edamame22 0:29983394c6b6 94 separate_arguments(LOCAL_POSTPROCESS_COMMAND_SEPARATED UNIX_COMMAND ${LOCAL_POSTPROCESS_COMMAND})
edamame22 0:29983394c6b6 95 add_custom_command(
edamame22 0:29983394c6b6 96 TARGET mbed-client-test-helloworld-mbedclient
edamame22 0:29983394c6b6 97 POST_BUILD
edamame22 0:29983394c6b6 98 COMMAND ${LOCAL_POSTPROCESS_COMMAND_SEPARATED}
edamame22 0:29983394c6b6 99 )
edamame22 0:29983394c6b6 100 endif()
edamame22 0:29983394c6b6 101
edamame22 0:29983394c6b6 102 #add_test(mbed-client-test-helloworld-mbedclient mbed-client-test-helloworld-mbedclient)
edamame22 0:29983394c6b6 103 add_dependencies(all_tests mbed-client-test-helloworld-mbedclient)
edamame22 0:29983394c6b6 104
edamame22 0:29983394c6b6 105 endif()
edamame22 0:29983394c6b6 106
edamame22 0:29983394c6b6 107
edamame22 0:29983394c6b6 108