diff --git a/README.md b/README.md index 2d575585..0376b8e4 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # STM32duinoBLE -This library is a fork of ArduinoBLE library to add the support of STBTLE-RF and STBTLE-1S BLE modules. +This library is a fork of ArduinoBLE library to add the support of SPBTLE-RF and SPBTLE-1S BLE modules. It was successfully tested with the X-NUCLEO-IDB05A1 expansion board and a NUCLEO-F401RE or NUCLEO-L476RG or NUCLEO-L053R8, with B-L475E-IOT01A and with STEVAL-MKSBOX1V1. -In order to use this library with STEVAL-MKSBOX1V1, you need to update the firmware of the STBTLE-1S BLE module +In order to use this library with STEVAL-MKSBOX1V1, you need to update the firmware of the SPBTLE-1S BLE module mounted on that board as described in the following wiki page: https://github.com/stm32duino/wiki/wiki/STM32duinoBLE-with-STEVAL_MKSBOX1V1 diff --git a/library.properties b/library.properties index f63b530a..4f8706ca 100644 --- a/library.properties +++ b/library.properties @@ -2,7 +2,7 @@ name=STM32duinoBLE version=1.1.1 author=Arduino, SRA maintainer=stm32duino -sentence=Fork of ArduinoBLE library to add the support of STBTLE-RF and STBTLE-1S BLE modules. +sentence=Fork of ArduinoBLE library to add the support of SPBTLE-RF and SPBTLE-1S BLE modules. paragraph=This library supports creating a BLE peripheral and BLE central mode. category=Communication url=https://github.com/stm32duino/STM32duinoBLE diff --git a/src/utility/HCISpiTransport.cpp b/src/utility/HCISpiTransport.cpp index dd157e43..ab9eeaea 100644 --- a/src/utility/HCISpiTransport.cpp +++ b/src/utility/HCISpiTransport.cpp @@ -75,15 +75,15 @@ int HCISpiTransportClass::begin() digitalWrite(_ble_rst, HIGH); delay(5); -#if defined(STBTLE_RF) +#if defined(SPBTLE_RF) // Wait for Blue Initialize wait_for_blue_initialize(); -#endif /* STBTLE_RF */ +#endif /* SPBTLE_RF */ -#if defined(STBTLE_1S) +#if defined(SPBTLE_1S) // Wait a while for the reset of the BLE module delay(300); -#endif /* STBTLE_1S */ +#endif /* SPBTLE_1S */ return 1; } @@ -132,11 +132,11 @@ int HCISpiTransportClass::available() /* Write the header */ _spi->transfer(header_master, 5); -#if defined(STBTLE_RF) +#if defined(SPBTLE_RF) /* device is ready */ if(header_master[0] == 0x02) { -#endif /* STBTLE_RF */ +#endif /* SPBTLE_RF */ uint16_t byte_count = (header_master[4] << 8) | header_master[3]; if(byte_count > 0) @@ -156,7 +156,7 @@ int HCISpiTransportClass::available() _write_index_initial++; } -#if defined(STBTLE_RF) +#if defined(SPBTLE_RF) /* Check if the message is a Blue Initialize */ /* If so we need to send the command to enable LL_ONLY */ if(byte_count == 6) @@ -171,8 +171,8 @@ int HCISpiTransportClass::available() ble_reset = 1; } } -#endif /* STBTLE_RF */ -#if defined(STBTLE_1S) +#endif /* SPBTLE_RF */ +#if defined(SPBTLE_1S) /* Check if the message is a CMD_COMPLETE */ /* We suppose that the first CMD is always a HCI_RESET */ if(byte_count == 7) @@ -188,7 +188,7 @@ int HCISpiTransportClass::available() ble_reset = 1; } } -#endif /* STBTLE_1S */ +#endif /* SPBTLE_1S */ } else { /* avoid to read more data that available size of the buffer */ @@ -207,9 +207,9 @@ int HCISpiTransportClass::available() } } } -#if defined(STBTLE_RF) +#if defined(SPBTLE_RF) } -#endif /* STBTLE_RF */ +#endif /* SPBTLE_RF */ digitalWrite(_cs_pin, HIGH); @@ -218,15 +218,15 @@ int HCISpiTransportClass::available() if(ble_reset) { -#if defined(STBTLE_RF) +#if defined(SPBTLE_RF) /* BLE chip was reset: we need to enable LL_ONLY */ enable_ll_only(); wait_for_enable_ll_only(); -#endif /* STBTLE_RF */ -#if defined(STBTLE_1S) +#endif /* SPBTLE_RF */ +#if defined(SPBTLE_1S) /* BLE chip was reset: we need to wait for a while */ delay(300); -#endif /* STBTLE_1S */ +#endif /* SPBTLE_1S */ /* Now we can update the write index and close the initial phase */ _write_index = _write_index_initial; @@ -287,16 +287,16 @@ size_t HCISpiTransportClass::write(const uint8_t* data, size_t length) do { -#if defined(STBTLE_1S) +#if defined(SPBTLE_1S) uint32_t tickstart_data_available = millis(); -#endif /* STBTLE_1S */ +#endif /* SPBTLE_1S */ result = 0; _spi->beginTransaction(SPISettings(_frequency, MSBFIRST, _spi_mode)); digitalWrite(_cs_pin, LOW); -#if defined(STBTLE_1S) +#if defined(SPBTLE_1S) /* * Wait until BlueNRG-1 is ready. * When ready it will raise the IRQ pin. @@ -316,20 +316,20 @@ size_t HCISpiTransportClass::write(const uint8_t* data, size_t length) _spi->endTransaction(); break; } -#endif /* STBTLE_1S */ +#endif /* SPBTLE_1S */ /* Write the header */ _spi->transfer(header_master, 5); -#if defined(STBTLE_RF) +#if defined(SPBTLE_RF) /* device is ready */ if(header_master[0] == 0x02) { if(header_master[1] >= length) -#endif /* STBTLE_RF */ -#if defined(STBTLE_1S) +#endif /* SPBTLE_RF */ +#if defined(SPBTLE_1S) if((int)((((uint16_t)header_master[2])<<8) | ((uint16_t)header_master[1])) >= (int)length) -#endif /* STBTLE_1S */ +#endif /* SPBTLE_1S */ { /* Write the data */ _spi->transfer(my_data, length); @@ -337,12 +337,12 @@ size_t HCISpiTransportClass::write(const uint8_t* data, size_t length) { result = -2; } -#if defined(STBTLE_RF) +#if defined(SPBTLE_RF) } else { result = -1; } -#endif /* STBTLE_RF */ +#endif /* SPBTLE_RF */ digitalWrite(_cs_pin, HIGH); @@ -364,7 +364,7 @@ size_t HCISpiTransportClass::write(const uint8_t* data, size_t length) } } -#if defined(STBTLE_RF) +#if defined(SPBTLE_RF) void HCISpiTransportClass::wait_for_blue_initialize() { int event_blue_initialize = 0; @@ -535,7 +535,7 @@ void HCISpiTransportClass::enable_ll_only() _spi->endTransaction(); } while (result < 0); } -#endif /* STBTLE_RF */ +#endif /* SPBTLE_RF */ #if defined(ARDUINO_STEVAL_MKSBOX1V1) HCISpiTransportClass HCISpiTransport(SpiHCI, PD0, PD4, PA8, 1000000, SPI_MODE1); /* STEVAL_MKSBOX1V1 */ diff --git a/src/utility/HCISpiTransport.h b/src/utility/HCISpiTransport.h index 1515257a..70f03684 100644 --- a/src/utility/HCISpiTransport.h +++ b/src/utility/HCISpiTransport.h @@ -24,11 +24,11 @@ #include "SPI.h" #if defined(ARDUINO_STEVAL_MKSBOX1V1) -#define STBTLE_1S /* STEVAL_MKSBOX1V1 */ +#define SPBTLE_1S /* STEVAL_MKSBOX1V1 */ #elif defined(ARDUINO_DISCO_L475VG_IOT) -#define STBTLE_RF /* B-L475E-IOT01A1 */ +#define SPBTLE_RF /* B-L475E-IOT01A1 */ #else -#define STBTLE_RF /* Shield IDB05A1 */ +#define SPBTLE_RF /* Shield IDB05A1 */ #endif /* ARDUINO_STEVAL_MKSBOX1V1 */ #define BLE_MODULE_SPI_BUFFER_SIZE 128 @@ -50,11 +50,11 @@ class HCISpiTransportClass : public HCITransportInterface { virtual size_t write(const uint8_t* data, size_t length); private: -#if defined(STBTLE_RF) +#if defined(SPBTLE_RF) void wait_for_blue_initialize(); void wait_for_enable_ll_only(); void enable_ll_only(); -#endif /* STBTLE_RF */ +#endif /* SPBTLE_RF */ SPIClass* _spi; uint8_t _cs_pin; uint8_t _spi_irq;