Skip to content

Commit 504ab8a

Browse files
authored
Merge pull request #1160 from google/embedded
Merge embedded branch
2 parents f56e50f + d207756 commit 504ab8a

29 files changed

+4105
-533
lines changed

embedded/Makefile

+32
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
GTEST_DIR = ../third_party/gtest/googletest/
99
GMOCK_DIR = ../third_party/gtest/googlemock/
10+
MBEDTLS_DIR = ../third_party/mbedtls/
11+
1012

1113
ARCH ?= host
1214
OUT_DIR_NAME ?= $(ARCH)
@@ -84,12 +86,42 @@ ifeq ($(wildcard common/target/$(ARCH_COMMON_NAME)),)
8486
$(error need to create directory common/target/$(ARCH_COMMON_NAME) )
8587
endif
8688

89+
ifdef NEARBY_FP_ENABLE_BATTERY_NOTIFICATION
90+
CFLAGS += -DNEARBY_FP_ENABLE_BATTERY_NOTIFICATION=$(NEARBY_FP_ENABLE_BATTERY_NOTIFICATION)
91+
endif
92+
93+
ifdef NEARBY_FP_ENABLE_ADDITIONAL_DATA
94+
CFLAGS += -DNEARBY_FP_ENABLE_ADDITIONAL_DATA=$(NEARBY_FP_ENABLE_ADDITIONAL_DATA)
95+
endif
96+
97+
ifdef NEARBY_FP_MESSAGE_STREAM
98+
CFLAGS += -DNEARBY_FP_MESSAGE_STREAM=$(NEARBY_FP_MESSAGE_STREAM)
99+
endif
100+
101+
ifdef NEARBY_FP_RETROACTIVE_PAIRING
102+
CFLAGS += -DNEARBY_FP_RETROACTIVE_PAIRING=$(NEARBY_FP_RETROACTIVE_PAIRING)
103+
endif
104+
105+
ifdef NEARBY_FP_BLE_ONLY
106+
CFLAGS += -DNEARBY_FP_BLE_ONLY=$(NEARBY_FP_BLE_ONLY)
107+
endif
108+
109+
ifdef NEARBY_FP_PREFER_BLE_BONDING
110+
CFLAGS += -DNEARBY_FP_PREFER_BLE_BONDING=$(NEARBY_FP_PREFER_BLE_BONDING)
111+
endif
112+
113+
ifdef NEARBY_FP_PREFER_LE_TRANSPORT
114+
CFLAGS += -DNEARBY_FP_PREFER_LE_TRANSPORT=$(NEARBY_FP_PREFER_LE_TRANSPORT)
115+
endif
87116
COMMON_INCLUDE_DIRS += \
88117
-I. \
89118
-I$(ARCH_COMMON_DIR) \
90119
-Icommon/target \
91120
-Icommon/target/$(ARCH_COMMON_NAME) \
92121
-I$(COMMON_DIR)
122+
ifeq ($(NEARBY_PLATFORM_USE_MBEDTLS),1)
123+
COMMON_INCLUDE_DIRS += -I$(MBEDTLS_DIR)/include
124+
endif
93125

94126
CLIENT_INCLUDES += \
95127
-I$(CLIENT_DIR) \

embedded/README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,16 @@ Nearby SDK assumes a single-threading model. All calls to the SDK must be on the
2828
nearby_fp_client_Init(NULL);
2929
nearby_fp_client_SetAdvertisement(NEARBY_FP_ADVERTISEMENT_DISCOVERABLE);
3030
```
31-
1. Use [Fast Pair Validator](https://play.google.com/store/apps/details?id=com.google.location.nearby.apps.fastpair.validator) to verify that your device is behaving correctly.
31+
1. Use [Fast Pair Validator](https://play.google.com/store/apps/details?id=com.google.location.nearby.apps.fastpair.validator) to verify that your device is behaving correctly.
32+
33+
## Optional modules
34+
The optional modules provide partial implementation of HAL interfaces using common libraries, mbedtls in particular.
35+
36+
1. *mbedtls* located in `common/source/mbedtls/mbedtls.c` implements `nearby_platform_Sha256Start()`, `nearby_platform_Sha256Update()`, `nearby_platform_Sha256Finish()`, `nearby_platform_Aes128Encrypt()`, `nearby_platform_Aes128Decrypt()`.
37+
38+
Nearby SDK can be configured to use the MBEDTLS package, commonly available on ARM
39+
implementations, with the config.mk flag `NEARBY_PLATFORM_USE_MBEDTLS`.
40+
41+
2. *gen_secret* located in `common/source/mbedtls/gen_secret.c` implements `nearby_platform_GenSec256r1Secret()`.
42+
43+
*gen_secret* generates a shared secret based on a given private key on platforms that don't support hardware SE. *gen_secret* module is enabled `NEARBY_PLATFORM_USE_MBEDTLS` is set and `NEARBY_PLATFORM_HAS_SE` is *not* set. When `NEARBY_PLATFORM_HAS_SE` is set, the platform needs to provide their own `nearby_platform_GenSec256r1Secret()` routine.

0 commit comments

Comments
 (0)