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:
edamame22
Date:
Thu Apr 13 04:48:11 2017 +0000
Revision:
0:29983394c6b6
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
edamame22 0:29983394c6b6 1 #
edamame22 0:29983394c6b6 2 # Toolchain rules for building libraries
edamame22 0:29983394c6b6 3 #
edamame22 0:29983394c6b6 4 # Support multi-platform builds
edamame22 0:29983394c6b6 5 # You may define PLATFORM=.. prefix for compiler
edamame22 0:29983394c6b6 6 # if PLATFORM is defined it will owerride CC and AR
edamame22 0:29983394c6b6 7 # You may also specify CC and AR separately.
edamame22 0:29983394c6b6 8 # example: Compile with KEIL
edamame22 0:29983394c6b6 9 # make CC=ArmCC AR=ArmAR
edamame22 0:29983394c6b6 10 #
edamame22 0:29983394c6b6 11 # example: Cross Compile with Gnu toolchain, for embedded Linux
edamame22 0:29983394c6b6 12 # make PLATFORM=arm-linux-gnueabi-
edamame22 0:29983394c6b6 13 #
edamame22 0:29983394c6b6 14 # Special rules for IAR-ARM toolchains added, AR tool on that does not follow common arquements.
edamame22 0:29983394c6b6 15 # make CC=iccarm uses iarchive.exe for creating a archive.
edamame22 0:29983394c6b6 16 #
edamame22 0:29983394c6b6 17 # Special rules for IAR-RL78 toolchain added, uses own AR and compiler requires specific flags
edamame22 0:29983394c6b6 18 # make CC=iccrl78
edamame22 0:29983394c6b6 19 #
edamame22 0:29983394c6b6 20 # When using ArmCC, Select CPU by defining one of following supported values
edamame22 0:29983394c6b6 21 # CPU=Cortex-M0
edamame22 0:29983394c6b6 22 # CPU=Cortex-M3
edamame22 0:29983394c6b6 23 # CPU=Cortex-M4
edamame22 0:29983394c6b6 24 #
edamame22 0:29983394c6b6 25 # example:
edamame22 0:29983394c6b6 26 # make CC=armcc CPU=Cortex-M4
edamame22 0:29983394c6b6 27
edamame22 0:29983394c6b6 28 #
edamame22 0:29983394c6b6 29 # If PLATFORM prefix is defined,
edamame22 0:29983394c6b6 30 # generate CC and AR accordingly
edamame22 0:29983394c6b6 31 #
edamame22 0:29983394c6b6 32 ifneq ($(strip $(PLATFORM)),)
edamame22 0:29983394c6b6 33 CC:=$(PLATFORM)gcc
edamame22 0:29983394c6b6 34 AR:=$(PLATFORM)ar
edamame22 0:29983394c6b6 35 endif
edamame22 0:29983394c6b6 36
edamame22 0:29983394c6b6 37 #
edamame22 0:29983394c6b6 38 # Windows specific tweaks for echo and mkdir to work
edamame22 0:29983394c6b6 39 #
edamame22 0:29983394c6b6 40 ifeq ($(OS),Windows_NT)
edamame22 0:29983394c6b6 41 SHELL := cmd.exe
edamame22 0:29983394c6b6 42 mkdir = if not exist $(1) md $(subst /,\,$(1))
edamame22 0:29983394c6b6 43 else
edamame22 0:29983394c6b6 44 mkdir = mkdir -p $(1)
edamame22 0:29983394c6b6 45 endif
edamame22 0:29983394c6b6 46
edamame22 0:29983394c6b6 47 #
edamame22 0:29983394c6b6 48 # Append CC and CPU to library names
edamame22 0:29983394c6b6 49 #
edamame22 0:29983394c6b6 50 LIB:=$(LIB:%.a=%_$(CC).a)
edamame22 0:29983394c6b6 51 ifneq (,$(CPU))
edamame22 0:29983394c6b6 52 LIB:=$(LIB:%.a=%_$(CPU).a)
edamame22 0:29983394c6b6 53 endif
edamame22 0:29983394c6b6 54
edamame22 0:29983394c6b6 55 ##########################################################
edamame22 0:29983394c6b6 56 # TOOLCHAIN SPECIFIC RULES AND FLAGS #
edamame22 0:29983394c6b6 57 ##########################################################
edamame22 0:29983394c6b6 58
edamame22 0:29983394c6b6 59 #
edamame22 0:29983394c6b6 60 # GCC toolchains
edamame22 0:29983394c6b6 61 #
edamame22 0:29983394c6b6 62 ifneq (,$(findstring gcc,$(CC)))
edamame22 0:29983394c6b6 63 # Flags for common toolchain, usually GCC or CC
edamame22 0:29983394c6b6 64 AROPTS=-rsc $@ $^
edamame22 0:29983394c6b6 65 override CFLAGS += -Wall -pedantic-errors
edamame22 0:29983394c6b6 66 # Dependency generation
edamame22 0:29983394c6b6 67 override CFLAGS += -MMD -MP
edamame22 0:29983394c6b6 68 ifneq (,$(CPU))
edamame22 0:29983394c6b6 69 # CPU must be lowercase on GCC
edamame22 0:29983394c6b6 70 CPU_L:=$(shell echo $(CPU) | tr A-Z a-z)
edamame22 0:29983394c6b6 71 override CFLAGS += -mcpu=$(CPU_L)
edamame22 0:29983394c6b6 72 # Use THUMB instructions of Cortex-M cores
edamame22 0:29983394c6b6 73 ifeq (cortex-m,$(findstring cortex-m,$(CPU_L)))
edamame22 0:29983394c6b6 74 override CFLAGS += -mthumb
edamame22 0:29983394c6b6 75 endif
edamame22 0:29983394c6b6 76 endif
edamame22 0:29983394c6b6 77 # Debug
edamame22 0:29983394c6b6 78 ifeq ($(DEBUG),1)
edamame22 0:29983394c6b6 79 override CFLAGS += -g -O0
edamame22 0:29983394c6b6 80 else
edamame22 0:29983394c6b6 81 override CFLAGS += -O2
edamame22 0:29983394c6b6 82 endif
edamame22 0:29983394c6b6 83 # Enable Coverage generation
edamame22 0:29983394c6b6 84 ifeq ($(COVERAGE),1)
edamame22 0:29983394c6b6 85 override CFLAGS += -ftest-coverage -fprofile-arcs
edamame22 0:29983394c6b6 86 override LDFLAGS += -ftest-coverage -fprofile-arcs
edamame22 0:29983394c6b6 87 endif
edamame22 0:29983394c6b6 88 COMPILE = $(CC) -std=gnu99 -c -o $@
edamame22 0:29983394c6b6 89 CXXCOMPILE = $(CC) -std=c++11 -c -o $@
edamame22 0:29983394c6b6 90
edamame22 0:29983394c6b6 91 #
edamame22 0:29983394c6b6 92 # IAR-ARM toolchain
edamame22 0:29983394c6b6 93 #
edamame22 0:29983394c6b6 94 else ifneq (,$(findstring iccarm,$(CC)))
edamame22 0:29983394c6b6 95 AR:=iarchive
edamame22 0:29983394c6b6 96 AROPTS=$^ --create -o $@
edamame22 0:29983394c6b6 97 DLIB_FILE=$(subst bin\iccarm.exe,inc\c\DLib_Config_Full.h,$(shell where iccarm))
edamame22 0:29983394c6b6 98 override CFLAGS += --dlib_config '$(DLIB_FILE)' --cpu Cortex-M4 --vla --diag_suppress Pa50
edamame22 0:29983394c6b6 99 # Dependency generation
edamame22 0:29983394c6b6 100 override CFLAGS += --dependencies=m $(basename $@).d
edamame22 0:29983394c6b6 101 # Debug
edamame22 0:29983394c6b6 102 ifeq ($(DEBUG),1)
edamame22 0:29983394c6b6 103 override CFLAGS += --debug -On
edamame22 0:29983394c6b6 104 else
edamame22 0:29983394c6b6 105 override CFLAGS += -Om
edamame22 0:29983394c6b6 106 endif
edamame22 0:29983394c6b6 107 COMPILE = $(CC) -c -o $@
edamame22 0:29983394c6b6 108
edamame22 0:29983394c6b6 109 #
edamame22 0:29983394c6b6 110 # ArmCC toolchain (Used by Keil)
edamame22 0:29983394c6b6 111 #
edamame22 0:29983394c6b6 112 else ifneq (,$(findstring armcc,$(CC)))
edamame22 0:29983394c6b6 113 AR:=armar
edamame22 0:29983394c6b6 114 AROPTS=-rsc $@ $^
edamame22 0:29983394c6b6 115 override CFLAGS += --c99 --no_wrap_diagnostics
edamame22 0:29983394c6b6 116 # Dependency generation
edamame22 0:29983394c6b6 117 override CFLAGS += --depend $(basename $@).d --phony_targets
edamame22 0:29983394c6b6 118 LIB:=$(LIB:%.a=%.lib)
edamame22 0:29983394c6b6 119 ifneq (,$(CPU))
edamame22 0:29983394c6b6 120 override CFLAGS += --cpu=$(CPU)
edamame22 0:29983394c6b6 121 endif
edamame22 0:29983394c6b6 122 # Debug
edamame22 0:29983394c6b6 123 ifeq ($(DEBUG),1)
edamame22 0:29983394c6b6 124 override CFLAGS += -g -O0
edamame22 0:29983394c6b6 125 else
edamame22 0:29983394c6b6 126 override CFLAGS += -O2
edamame22 0:29983394c6b6 127 endif
edamame22 0:29983394c6b6 128 COMPILE = $(CC) -c -o $@
edamame22 0:29983394c6b6 129
edamame22 0:29983394c6b6 130 #
edamame22 0:29983394c6b6 131 # IAR Renesas78 toolchain
edamame22 0:29983394c6b6 132 #
edamame22 0:29983394c6b6 133 else ifneq (,$(findstring iccrl78,$(CC)))
edamame22 0:29983394c6b6 134 AR:=xar
edamame22 0:29983394c6b6 135 AROPTS=$@ $^
edamame22 0:29983394c6b6 136 # Hack to get \lib include path which contains dlib config headers for compiler
edamame22 0:29983394c6b6 137 DIR=$(subst iccrl78.exe,..\lib\,$(shell where iccrl78))
edamame22 0:29983394c6b6 138 override CFLAGS += --core rl78_1 --code_model far --data_model far --dlib_config full --vla --no_wrap_diagnostics -I'$(DIR)'
edamame22 0:29983394c6b6 139 # Dependency generation
edamame22 0:29983394c6b6 140 LIB:=$(LIB:%.a=%.lib)
edamame22 0:29983394c6b6 141 override CFLAGS += --dependencies=m $(basename $@).d
edamame22 0:29983394c6b6 142 # Debug
edamame22 0:29983394c6b6 143 ifeq ($(DEBUG),1)
edamame22 0:29983394c6b6 144 override CFLAGS += --debug -Oh
edamame22 0:29983394c6b6 145 else
edamame22 0:29983394c6b6 146 override CFLAGS += -Ohz
edamame22 0:29983394c6b6 147 endif
edamame22 0:29983394c6b6 148 COMPILE = $(CC) -o $@
edamame22 0:29983394c6b6 149
edamame22 0:29983394c6b6 150 #
edamame22 0:29983394c6b6 151 # IAR MSP430 toolchain
edamame22 0:29983394c6b6 152 #
edamame22 0:29983394c6b6 153 else ifneq (,$(findstring icc430,$(CC)))
edamame22 0:29983394c6b6 154 AR:=xar
edamame22 0:29983394c6b6 155 AROPTS=$@ $^
edamame22 0:29983394c6b6 156 # Hack to get \lib include path which contains dlib config headers for compiler
edamame22 0:29983394c6b6 157 DIR=$(subst bin\icc430.exe,lib,$(shell where icc430))
edamame22 0:29983394c6b6 158 DLIB_FILE=$(subst bin\icc430.exe,lib\dlib\dl430xllff.h,$(shell where icc430))
edamame22 0:29983394c6b6 159 override CFLAGS += --dlib_config '$(DLIB_FILE)' --vla --core 430X --data_model large --no_wrap_diagnostics -I'$(DIR)'
edamame22 0:29983394c6b6 160 # Dependency generation
edamame22 0:29983394c6b6 161 LIB:=$(LIB:%.a=%.lib)
edamame22 0:29983394c6b6 162 override CFLAGS += --dependencies=m $(basename $@).d
edamame22 0:29983394c6b6 163 # Debug
edamame22 0:29983394c6b6 164 ifeq ($(DEBUG),1)
edamame22 0:29983394c6b6 165 override CFLAGS += --debug -On
edamame22 0:29983394c6b6 166 else
edamame22 0:29983394c6b6 167 override CFLAGS += -Ohz
edamame22 0:29983394c6b6 168 endif
edamame22 0:29983394c6b6 169 COMPILE = $(CC) -o $@
edamame22 0:29983394c6b6 170
edamame22 0:29983394c6b6 171 #
edamame22 0:29983394c6b6 172 # CppCheck toolchain
edamame22 0:29983394c6b6 173 # This is used only for static testing the code.
edamame22 0:29983394c6b6 174 # cppcheck is used in place of compiler and linker phase is ignored
edamame22 0:29983394c6b6 175 else ifneq (,$(findstring cppcheck,$(CC)))
edamame22 0:29983394c6b6 176 AR = cppcheck -q --enable=warning --enable=style --std=c99 --inline-suppr -DCPPCHECK $(CPPCHECK_OPTS) $(CFLAGS) $(SRCS)
edamame22 0:29983394c6b6 177 COMPILE = true
edamame22 0:29983394c6b6 178 CPPCHECK = 1
edamame22 0:29983394c6b6 179 LIB:= "ignored_with_cppcheck"
edamame22 0:29983394c6b6 180
edamame22 0:29983394c6b6 181
edamame22 0:29983394c6b6 182 ###################################
edamame22 0:29983394c6b6 183 # End of toolchain specific rules #
edamame22 0:29983394c6b6 184 ###################################
edamame22 0:29983394c6b6 185 endif
edamame22 0:29983394c6b6 186
edamame22 0:29983394c6b6 187 #
edamame22 0:29983394c6b6 188 # Generate VERSION tag
edamame22 0:29983394c6b6 189 #
edamame22 0:29983394c6b6 190 ifeq (,$(CPPCHECK))
edamame22 0:29983394c6b6 191 VERSION := $(shell git describe --tags --long --dirty --always)
edamame22 0:29983394c6b6 192 CFLAGS += -DVERSION='"$(VERSION)"'
edamame22 0:29983394c6b6 193 endif
edamame22 0:29983394c6b6 194
edamame22 0:29983394c6b6 195 ############################################################
edamame22 0:29983394c6b6 196 # AUTOMATICALLY GENERATE LIBRARY COMPILATION RULES #
edamame22 0:29983394c6b6 197 # #
edamame22 0:29983394c6b6 198 # Use: #
edamame22 0:29983394c6b6 199 # $(eval $(call generate_rules,$(OUTPUT_LIB),$(SRCS))) #
edamame22 0:29983394c6b6 200 # at the end of your Makefile #
edamame22 0:29983394c6b6 201 # #
edamame22 0:29983394c6b6 202 ############################################################
edamame22 0:29983394c6b6 203
edamame22 0:29983394c6b6 204 define generate_rules
edamame22 0:29983394c6b6 205
edamame22 0:29983394c6b6 206 DEST_LIB := $(1)
edamame22 0:29983394c6b6 207 LIB_SRCS := $(2)
edamame22 0:29983394c6b6 208 C_SRCS := $$(filter %.c,$$(LIB_SRCS))
edamame22 0:29983394c6b6 209 CXX_SRCS := $$(filter %.cpp,$$(LIB_SRCS))
edamame22 0:29983394c6b6 210 all: $$(DEST_LIB)
edamame22 0:29983394c6b6 211
edamame22 0:29983394c6b6 212 #
edamame22 0:29983394c6b6 213 # Define build dir outside from src folders
edamame22 0:29983394c6b6 214 #
edamame22 0:29983394c6b6 215 BUILD_DIR := output/$$(CC)
edamame22 0:29983394c6b6 216 ifneq (,$$(CPU))
edamame22 0:29983394c6b6 217 BUILD_DIR := $$(BUILD_DIR)_$$(CPU)
edamame22 0:29983394c6b6 218 endif
edamame22 0:29983394c6b6 219 ifneq (generic,$$(CONFIG))
edamame22 0:29983394c6b6 220 BUILD_DIR := $$(BUILD_DIR)_$$(CONFIG)
edamame22 0:29983394c6b6 221 endif
edamame22 0:29983394c6b6 222 OBJS := $$(C_SRCS:%.c=$$(BUILD_DIR)/%.o) $$(CXX_SRCS:%.cpp=$$(BUILD_DIR)/%.o)
edamame22 0:29983394c6b6 223
edamame22 0:29983394c6b6 224 # Include auto-dependencies
edamame22 0:29983394c6b6 225 -include $$(OBJS:.o=.d)
edamame22 0:29983394c6b6 226
edamame22 0:29983394c6b6 227 # Create list of output directories.
edamame22 0:29983394c6b6 228 OBJ_DIRS := $$(sort $$(dir $$(OBJS)))
edamame22 0:29983394c6b6 229
edamame22 0:29983394c6b6 230 # requires directories to be created before build.
edamame22 0:29983394c6b6 231 # '|' means do not care about timestamps of requisities
edamame22 0:29983394c6b6 232 $$(OBJS): | $$(OBJ_DIRS)
edamame22 0:29983394c6b6 233
edamame22 0:29983394c6b6 234 # Need to redefine build rule to find the sources
edamame22 0:29983394c6b6 235 # from correct folder.
edamame22 0:29983394c6b6 236 $$(BUILD_DIR)/%.o: %.c
edamame22 0:29983394c6b6 237 ifeq ($(V),1)
edamame22 0:29983394c6b6 238 $$(COMPILE) $$(CFLAGS) $$<
edamame22 0:29983394c6b6 239 else ifeq (1,$(CPPCHECK))
edamame22 0:29983394c6b6 240 @$$(COMPILE) $$(CFLAGS) $$<
edamame22 0:29983394c6b6 241 else ifeq (1,$(UNITTEST))
edamame22 0:29983394c6b6 242 @echo Building unittest $$<
edamame22 0:29983394c6b6 243 ifneq ($(OS),Windows_NT)
edamame22 0:29983394c6b6 244 ruby $(UNIT_TEST_BASE)/../auto/generate_test_runner.rb Test.c Test_Runner.c
edamame22 0:29983394c6b6 245 endif
edamame22 0:29983394c6b6 246 @gcc $$(CFLAGS) $$(SRCS) -o $$(OUTPUT_LIB)
edamame22 0:29983394c6b6 247 else
edamame22 0:29983394c6b6 248 @echo Building $$<
edamame22 0:29983394c6b6 249 @$$(COMPILE) $$(CFLAGS) $$<
edamame22 0:29983394c6b6 250 endif
edamame22 0:29983394c6b6 251
edamame22 0:29983394c6b6 252 # Same again for C++
edamame22 0:29983394c6b6 253 $$(BUILD_DIR)/%.o: %.cpp
edamame22 0:29983394c6b6 254 ifeq ($(V),1)
edamame22 0:29983394c6b6 255 $$(CXXCOMPILE) $$(CFLAGS) $$<
edamame22 0:29983394c6b6 256 else ifeq (1,$(CPPCHECK))
edamame22 0:29983394c6b6 257 @$$(CXXCOMPILE) $$(CFLAGS) $$<
edamame22 0:29983394c6b6 258 else
edamame22 0:29983394c6b6 259 @echo Building $$<
edamame22 0:29983394c6b6 260 @$$(CXXCOMPILE) $$(CFLAGS) $$<
edamame22 0:29983394c6b6 261 endif
edamame22 0:29983394c6b6 262
edamame22 0:29983394c6b6 263 # Rule to create a object directory
edamame22 0:29983394c6b6 264 $$(OBJ_DIRS):
edamame22 0:29983394c6b6 265 @-$$(call mkdir,$$@)
edamame22 0:29983394c6b6 266
edamame22 0:29983394c6b6 267 $$(DEST_LIB): $$(OBJS)
edamame22 0:29983394c6b6 268 ifeq ($(V),1)
edamame22 0:29983394c6b6 269 -$$(addprefix $$(RM) ,$$(wildcard $$@))
edamame22 0:29983394c6b6 270 $$(AR) $$(AROPTS)
edamame22 0:29983394c6b6 271 else ifeq (1,$(CPPCHECK))
edamame22 0:29983394c6b6 272 @$$(AR) $$(AROPTS)
edamame22 0:29983394c6b6 273 else ifeq (1,$(UNITTEST))
edamame22 0:29983394c6b6 274 #ifneq ($(OS),Windows_NT)
edamame22 0:29983394c6b6 275 # lcov -q --capture -i --directory $(CURDIR) --output-file lib_base.info
edamame22 0:29983394c6b6 276 # ./$$@
edamame22 0:29983394c6b6 277 # lcov -q --capture --directory $(CURDIR) --output-file lib_test.info
edamame22 0:29983394c6b6 278 # lcov -a lib_base.info -a lib_test.info -o coverage.info
edamame22 0:29983394c6b6 279 #endif
edamame22 0:29983394c6b6 280 else
edamame22 0:29983394c6b6 281 @echo Linking $$(notdir $$@)
edamame22 0:29983394c6b6 282 @-$$(addprefix $$(RM) ,$$(wildcard $$@))
edamame22 0:29983394c6b6 283 @$$(AR) $$(AROPTS)
edamame22 0:29983394c6b6 284 endif
edamame22 0:29983394c6b6 285
edamame22 0:29983394c6b6 286 clean:
edamame22 0:29983394c6b6 287 @$(RM) -r $$(BUILD_DIR)
edamame22 0:29983394c6b6 288 @$(RM) $$(DEST_LIB)
edamame22 0:29983394c6b6 289
edamame22 0:29983394c6b6 290 clean-all:
edamame22 0:29983394c6b6 291 @$(RM) -r output *.a
edamame22 0:29983394c6b6 292
edamame22 0:29983394c6b6 293 endef