From e29a324d79b542d27653bb578869e9d0a4eab442 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 8 Jun 2021 16:14:04 +0700 Subject: [PATCH] add most of the ble char --- cores/nRF5/utility/debug.cpp | 24 +++---- cores/nRF5/verify.h | 2 +- .../tf4micro-motion-kit.ino | 72 +++++++++---------- 3 files changed, 49 insertions(+), 49 deletions(-) diff --git a/cores/nRF5/utility/debug.cpp b/cores/nRF5/utility/debug.cpp index 33118c30..cf2aef35 100644 --- a/cores/nRF5/utility/debug.cpp +++ b/cores/nRF5/utility/debug.cpp @@ -107,14 +107,14 @@ static void printMemRegion(const char* name, uint32_t top, uint32_t bottom, uint sprintf(buffer, "%lu", top-bottom); } - PRINTF("| %-5s| 0x%04X - 0x%04X | %-19s |\n", name, (uint16_t) bottom, (uint16_t) (top-1), buffer); + PRINTF("| %-5s| 0x%04X - 0x%04X | %-19s |\r\n", name, (uint16_t) bottom, (uint16_t) (top-1), buffer); } void dbgMemInfo(void) { - PRINTF(" ______________________________________________\n"); - PRINTF("| Name | Addr 0x2000xxxx | Usage |\n"); - PRINTF("| ---------------------------------------------|\n"); + PRINTF(" ______________________________________________\r\n"); + PRINTF("| Name | Addr 0x2000xxxx | Usage |\r\n"); + PRINTF("| ---------------------------------------------|\r\n"); // Pritn SRAM used for Stack executed by Softdevice and ISR printMemRegion("Stack", ((uint32_t) __StackTop), ((uint32_t) __StackLimit), dbgStackUsed() ); @@ -128,7 +128,7 @@ void dbgMemInfo(void) // Print SRAM Used by SoftDevice printMemRegion("SD", (uint32_t) __data_start__, 0x20000000, 0); - PRINTF("|______________________________________________|\n"); + PRINTF("|______________________________________________|\r\n"); PRINTF("\n"); // Print Task list @@ -137,8 +137,8 @@ void dbgMemInfo(void) vTaskList(buf); - PRINTF("Task State Prio StackLeft Num\n"); - PRINTF("-----------------------------------\n"); + PRINTF("Task State Prio StackLeft Num\r\n"); + PRINTF("-----------------------------------\r\n"); PRINTF(buf); PRINTF("\n"); rtos_free(buf); @@ -146,11 +146,11 @@ void dbgMemInfo(void) void dbgPrintVersion(void) { - PRINTF("\n"); - PRINTF("BSP Library : " ARDUINO_BSP_VERSION "\n"); - PRINTF("Bootloader : %s\n", getBootloaderVersion()); - PRINTF("Serial No : %s\n", getMcuUniqueID()); - PRINTF("\n"); + PRINTF("\r\n"); + PRINTF("BSP Library : " ARDUINO_BSP_VERSION "\r\n"); + PRINTF("Bootloader : %s\r\n", getBootloaderVersion()); + PRINTF("Serial No : %s\r\n", getMcuUniqueID()); + PRINTF("\r\n"); } /******************************************************************************/ diff --git a/cores/nRF5/verify.h b/cores/nRF5/verify.h index b4d028a8..cc0886e3 100644 --- a/cores/nRF5/verify.h +++ b/cores/nRF5/verify.h @@ -67,7 +67,7 @@ extern "C" { PRINTF("0x%lX (%ld)", _status, _status); } - PRINTF("\n"); + PRINTF("\r\n"); } #else #define VERIFY_MESS(_status, _funcstr) diff --git a/libraries/Bluefruit52Lib/examples/Peripheral/tf4micro-motion-kit/tf4micro-motion-kit.ino b/libraries/Bluefruit52Lib/examples/Peripheral/tf4micro-motion-kit/tf4micro-motion-kit.ino index 977586c5..28cb8c3d 100644 --- a/libraries/Bluefruit52Lib/examples/Peripheral/tf4micro-motion-kit/tf4micro-motion-kit.ino +++ b/libraries/Bluefruit52Lib/examples/Peripheral/tf4micro-motion-kit/tf4micro-motion-kit.ino @@ -72,27 +72,27 @@ Adafruit_NeoPixel neopixels = Adafruit_NeoPixel(NEOPIXEL_NUM, PIN_NEOPIXEL, NEO_ #define UUID_GEN(val) ("81c30e5c-" val "-4f7d-a886-de3e90749161") -BLEService service (UUID_GEN("0000")); +BLEService service (UUID_GEN("0000")); -BLECharacteristic dataProviderTxChar (UUID_GEN("1001"), BLERead | BLENotify, 9 * FLOAT_BYTE_SIZE); -BLECharacteristic dataProviderLabelsTxChar (UUID_GEN("1002"), BLERead, 128); -BLECharacteristic versionTxChar (UUID_GEN("1003"), BLERead, 1, true); -//BLECharacteristic inferenceTxChar (UUID_GEN("1004"), BLERead | BLENotify, 3); -// -//BLEUnsignedCharCharacteristic numClassesRxChar (UUID_GEN("2001"), BLEWrite); -//BLEIntCharacteristic numSamplesRxChar (UUID_GEN("2002"), BLEWrite); -//BLEIntCharacteristic captureDelayRxChar (UUID_GEN("2003"), BLEWrite); -//BLEFloatCharacteristic thresholdRxChar (UUID_GEN("2004"), BLEWrite); -//BLEBoolCharacteristic disableMagnetometerRx (UUID_GEN("2005"), BLEWrite); -// -//BLEUnsignedCharCharacteristic stateRxChar (UUID_GEN("3001"), BLEWrite); -//BLEUnsignedCharCharacteristic stateTxChar (UUID_GEN("3002"), BLERead | BLENotify); -//BLEUnsignedCharCharacteristic fileTransferTypeRxChar (UUID_GEN("3003"), BLEWrite); -//BLEBoolCharacteristic hasModelTxChar (UUID_GEN("3004"), BLERead | BLENotify); -// -//// Meta is for future-proofing, we can use it to store and read any 64 bytes -//BLECharacteristic metaRxChar (UUID_GEN("4001"), BLEWrite, 64); -//BLECharacteristic metaTxChar (UUID_GEN("4002"), BLERead, 64); +BLECharacteristic dataProviderTxChar (UUID_GEN("1001") , BLERead | BLENotify , 9 * FLOAT_BYTE_SIZE); +BLECharacteristic dataProviderLabelsTxChar (UUID_GEN("1002") , BLERead , 128); +BLECharacteristic versionTxChar (UUID_GEN("1003") , BLERead , 1 , true); +BLECharacteristic inferenceTxChar (UUID_GEN("1004") , BLERead | BLENotify , 3 , true); + +BLECharacteristic numClassesRxChar (UUID_GEN("2001") , BLEWrite , 1 , true); +BLECharacteristic numSamplesRxChar (UUID_GEN("2002") , BLEWrite , 4 , true); +BLECharacteristic captureDelayRxChar (UUID_GEN("2003") , BLEWrite , 4 , true); +BLECharacteristic thresholdRxChar (UUID_GEN("2004") , BLEWrite , 4 , true); +BLECharacteristic disableMagnetometerRx (UUID_GEN("2005") , BLEWrite , 1 , true); + +BLECharacteristic stateRxChar (UUID_GEN("3001") , BLEWrite , 1 , true); +BLECharacteristic stateTxChar (UUID_GEN("3002") , BLERead | BLENotify , 1 , true); +BLECharacteristic fileTransferTypeRxChar (UUID_GEN("3003") , BLEWrite , 1 , true); +BLECharacteristic hasModelTxChar (UUID_GEN("3004") , BLERead | BLENotify , 1 , true); + +// Meta is for future-proofing, we can use it to store and read any 64 bytes +BLECharacteristic metaRxChar (UUID_GEN("4001") , BLEWrite , 64); +BLECharacteristic metaTxChar (UUID_GEN("4002") , BLERead , 64); /************************************************************************ * Model file transfer @@ -421,6 +421,7 @@ void setup() } Bluefruit.autoConnLed(true); + Bluefruit.configUuid128Count(20); Bluefruit.configPrphBandwidth(BANDWIDTH_MAX); Bluefruit.begin(); Bluefruit.setTxPower(4); @@ -430,24 +431,23 @@ void setup() versionTxChar.begin(); dataProviderTxChar.begin(); dataProviderLabelsTxChar.begin(); + inferenceTxChar.begin(); + + numClassesRxChar.begin(); + numSamplesRxChar.begin(); + captureDelayRxChar.begin(); + thresholdRxChar.begin(); + disableMagnetometerRx.begin(); + + stateRxChar.begin(); + stateTxChar.begin(); + fileTransferTypeRxChar.begin(); + hasModelTxChar.begin(); + + metaRxChar.begin(); + metaTxChar.begin(); #if 0 - service.addCharacteristic(inferenceTxChar); - - service.addCharacteristic(numClassesRxChar); - service.addCharacteristic(numSamplesRxChar); - service.addCharacteristic(captureDelayRxChar); - service.addCharacteristic(thresholdRxChar); - service.addCharacteristic(disableMagnetometerRx); - - service.addCharacteristic(stateRxChar); - service.addCharacteristic(stateTxChar); - service.addCharacteristic(fileTransferTypeRxChar); - service.addCharacteristic(hasModelTxChar); - - service.addCharacteristic(metaRxChar); - service.addCharacteristic(metaTxChar); - // Event driven reads. numClassesRxChar.setEventHandler(BLEWritten, handleNumClassesRxWritten); numSamplesRxChar.setEventHandler(BLEWritten, handleNumSamplesRxWritten);