Skip to content

Commit

Permalink
Merge pull request #1160 from google/embedded
Browse files Browse the repository at this point in the history
Merge embedded branch
  • Loading branch information
jgsobczak authored Dec 22, 2022
2 parents f56e50f + d207756 commit 504ab8a
Show file tree
Hide file tree
Showing 29 changed files with 4,105 additions and 533 deletions.
32 changes: 32 additions & 0 deletions embedded/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

GTEST_DIR = ../third_party/gtest/googletest/
GMOCK_DIR = ../third_party/gtest/googlemock/
MBEDTLS_DIR = ../third_party/mbedtls/


ARCH ?= host
OUT_DIR_NAME ?= $(ARCH)
Expand Down Expand Up @@ -84,12 +86,42 @@ ifeq ($(wildcard common/target/$(ARCH_COMMON_NAME)),)
$(error need to create directory common/target/$(ARCH_COMMON_NAME) )
endif

ifdef NEARBY_FP_ENABLE_BATTERY_NOTIFICATION
CFLAGS += -DNEARBY_FP_ENABLE_BATTERY_NOTIFICATION=$(NEARBY_FP_ENABLE_BATTERY_NOTIFICATION)
endif

ifdef NEARBY_FP_ENABLE_ADDITIONAL_DATA
CFLAGS += -DNEARBY_FP_ENABLE_ADDITIONAL_DATA=$(NEARBY_FP_ENABLE_ADDITIONAL_DATA)
endif

ifdef NEARBY_FP_MESSAGE_STREAM
CFLAGS += -DNEARBY_FP_MESSAGE_STREAM=$(NEARBY_FP_MESSAGE_STREAM)
endif

ifdef NEARBY_FP_RETROACTIVE_PAIRING
CFLAGS += -DNEARBY_FP_RETROACTIVE_PAIRING=$(NEARBY_FP_RETROACTIVE_PAIRING)
endif

ifdef NEARBY_FP_BLE_ONLY
CFLAGS += -DNEARBY_FP_BLE_ONLY=$(NEARBY_FP_BLE_ONLY)
endif

ifdef NEARBY_FP_PREFER_BLE_BONDING
CFLAGS += -DNEARBY_FP_PREFER_BLE_BONDING=$(NEARBY_FP_PREFER_BLE_BONDING)
endif

ifdef NEARBY_FP_PREFER_LE_TRANSPORT
CFLAGS += -DNEARBY_FP_PREFER_LE_TRANSPORT=$(NEARBY_FP_PREFER_LE_TRANSPORT)
endif
COMMON_INCLUDE_DIRS += \
-I. \
-I$(ARCH_COMMON_DIR) \
-Icommon/target \
-Icommon/target/$(ARCH_COMMON_NAME) \
-I$(COMMON_DIR)
ifeq ($(NEARBY_PLATFORM_USE_MBEDTLS),1)
COMMON_INCLUDE_DIRS += -I$(MBEDTLS_DIR)/include
endif

CLIENT_INCLUDES += \
-I$(CLIENT_DIR) \
Expand Down
14 changes: 13 additions & 1 deletion embedded/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@ Nearby SDK assumes a single-threading model. All calls to the SDK must be on the
nearby_fp_client_Init(NULL);
nearby_fp_client_SetAdvertisement(NEARBY_FP_ADVERTISEMENT_DISCOVERABLE);
```
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.
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.

## Optional modules
The optional modules provide partial implementation of HAL interfaces using common libraries, mbedtls in particular.

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()`.

Nearby SDK can be configured to use the MBEDTLS package, commonly available on ARM
implementations, with the config.mk flag `NEARBY_PLATFORM_USE_MBEDTLS`.

2. *gen_secret* located in `common/source/mbedtls/gen_secret.c` implements `nearby_platform_GenSec256r1Secret()`.

*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.
Loading

0 comments on commit 504ab8a

Please sign in to comment.