-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into bracz-mspm0-blinkraw
* master: Fixes some compile errors in nucleo and bracz.acc. ESP-IDF CMakeLists (#800) BLE Basic Infrastructure (#788)
- Loading branch information
Showing
35 changed files
with
3,239 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
file(REAL_PATH ${COMPONENT_DIR} OPENMRNESPIDFPATH) | ||
set(OPENMRNPATH ${OPENMRNESPIDFPATH}/../..) | ||
|
||
set(SRCS | ||
${OPENMRNPATH}/src/ble/Advertisement.cxx | ||
${OPENMRNPATH}/src/ble/Defs.cxx | ||
|
||
${OPENMRNPATH}/src/dcc/dcc_constants.cxx | ||
${OPENMRNPATH}/src/dcc/DccDebug.cxx | ||
${OPENMRNPATH}/src/dcc/Defs.cxx | ||
${OPENMRNPATH}/src/dcc/LocalTrackIf.cxx | ||
${OPENMRNPATH}/src/dcc/Loco.cxx | ||
${OPENMRNPATH}/src/dcc/Packet.cxx | ||
${OPENMRNPATH}/src/dcc/RailcomBroadcastDecoder.cxx | ||
${OPENMRNPATH}/src/dcc/RailCom.cxx | ||
${OPENMRNPATH}/src/dcc/RailcomDebug.cxx | ||
${OPENMRNPATH}/src/dcc/SimpleUpdateLoop.cxx | ||
${OPENMRNPATH}/src/dcc/UpdateLoop.cxx | ||
|
||
${OPENMRNPATH}/src/executor/AsyncNotifiableBlock.cxx | ||
${OPENMRNPATH}/src/executor/Executor.cxx | ||
${OPENMRNPATH}/src/executor/Notifiable.cxx | ||
${OPENMRNPATH}/src/executor/Service.cxx | ||
${OPENMRNPATH}/src/executor/StateFlow.cxx | ||
${OPENMRNPATH}/src/executor/Timer.cxx | ||
|
||
${OPENMRNPATH}/src/freertos_drivers/esp32/Esp32HardwareI2C.cxx | ||
${OPENMRNPATH}/src/freertos_drivers/esp32/Esp32HardwareTwai.cxx | ||
${OPENMRNPATH}/src/freertos_drivers/esp32/Esp32Ledc.cxx | ||
${OPENMRNPATH}/src/freertos_drivers/esp32/Esp32SocInfo.cxx | ||
${OPENMRNPATH}/src/freertos_drivers/esp32/Esp32WiFiManager.cxx | ||
|
||
${OPENMRNPATH}/src/openlcb/AliasAllocator.cxx | ||
${OPENMRNPATH}/src/openlcb/AliasCache.cxx | ||
${OPENMRNPATH}/src/openlcb/BLEAdvertisement.cxx | ||
${OPENMRNPATH}/src/openlcb/BLEService.cxx | ||
${OPENMRNPATH}/src/openlcb/BroadcastTime.cxx | ||
${OPENMRNPATH}/src/openlcb/BroadcastTimeClient.cxx | ||
${OPENMRNPATH}/src/openlcb/BroadcastTimeDefs.cxx | ||
${OPENMRNPATH}/src/openlcb/BroadcastTimeServer.cxx | ||
${OPENMRNPATH}/src/openlcb/BulkAliasAllocator.cxx | ||
${OPENMRNPATH}/src/openlcb/CanDefs.cxx | ||
${OPENMRNPATH}/src/openlcb/ConfigEntry.cxx | ||
${OPENMRNPATH}/src/openlcb/ConfigUpdateFlow.cxx | ||
${OPENMRNPATH}/src/openlcb/Datagram.cxx | ||
${OPENMRNPATH}/src/openlcb/DatagramCan.cxx | ||
${OPENMRNPATH}/src/openlcb/DatagramTcp.cxx | ||
${OPENMRNPATH}/src/openlcb/DccAccyProducer.cxx | ||
${OPENMRNPATH}/src/openlcb/DefaultNode.cxx | ||
${OPENMRNPATH}/src/openlcb/DefaultCdi.cxx | ||
${OPENMRNPATH}/src/openlcb/EventHandler.cxx | ||
${OPENMRNPATH}/src/openlcb/EventHandlerContainer.cxx | ||
${OPENMRNPATH}/src/openlcb/EventHandlerTemplates.cxx | ||
${OPENMRNPATH}/src/openlcb/EventService.cxx | ||
${OPENMRNPATH}/src/openlcb/If.cxx | ||
${OPENMRNPATH}/src/openlcb/IfCan.cxx | ||
${OPENMRNPATH}/src/openlcb/IfImpl.cxx | ||
${OPENMRNPATH}/src/openlcb/IfTcp.cxx | ||
${OPENMRNPATH}/src/openlcb/MemoryConfig.cxx | ||
${OPENMRNPATH}/src/openlcb/nmranet_constants.cxx | ||
${OPENMRNPATH}/src/openlcb/Node.cxx | ||
${OPENMRNPATH}/src/openlcb/NodeBrowser.cxx | ||
${OPENMRNPATH}/src/openlcb/NodeInitializeFlow.cxx | ||
${OPENMRNPATH}/src/openlcb/NonAuthoritativeEventProducer.cxx | ||
${OPENMRNPATH}/src/openlcb/PIPClient.cxx | ||
${OPENMRNPATH}/src/openlcb/RoutingLogic.cxx | ||
${OPENMRNPATH}/src/openlcb/SimpleNodeInfo.cxx | ||
${OPENMRNPATH}/src/openlcb/SimpleNodeInfoMockUserFile.cxx | ||
${OPENMRNPATH}/src/openlcb/SimpleNodeInfoResponse.cxx | ||
${OPENMRNPATH}/src/openlcb/SimpleStack.cxx | ||
${OPENMRNPATH}/src/openlcb/StreamReceiver.cxx | ||
${OPENMRNPATH}/src/openlcb/StreamTransport.cxx | ||
${OPENMRNPATH}/src/openlcb/TcpDefs.cxx | ||
${OPENMRNPATH}/src/openlcb/TractionCvSpace.cxx | ||
${OPENMRNPATH}/src/openlcb/TractionDefs.cxx | ||
${OPENMRNPATH}/src/openlcb/TractionProxy.cxx | ||
${OPENMRNPATH}/src/openlcb/TractionTestTrain.cxx | ||
${OPENMRNPATH}/src/openlcb/TractionThrottle.cxx | ||
${OPENMRNPATH}/src/openlcb/TractionTrain.cxx | ||
${OPENMRNPATH}/src/openlcb/Velocity.cxx | ||
${OPENMRNPATH}/src/openlcb/WriteHelper.cxx | ||
|
||
|
||
${OPENMRNPATH}/src/os/FakeClock.cxx | ||
${OPENMRNPATH}/src/os/logging_malloc.cxx | ||
${OPENMRNPATH}/src/os/MDNS.cxx | ||
${OPENMRNPATH}/src/os/os.c | ||
${OPENMRNPATH}/src/os/OSImpl.cxx | ||
${OPENMRNPATH}/src/os/OSSelectWakeup.cxx | ||
${OPENMRNPATH}/src/os/stack_malloc.c | ||
${OPENMRNPATH}/src/os/TempFile.cxx | ||
${OPENMRNPATH}/src/os/watchdog.c | ||
|
||
${OPENMRNPATH}/src/utils/Base64.cxx | ||
${OPENMRNPATH}/src/utils/Blinker.cxx | ||
${OPENMRNPATH}/src/utils/Buffer.cxx | ||
${OPENMRNPATH}/src/utils/CanIf.cxx | ||
${OPENMRNPATH}/src/utils/ClientConnection.cxx | ||
${OPENMRNPATH}/src/utils/ConfigUpdateListener.cxx | ||
${OPENMRNPATH}/src/utils/constants.cxx | ||
${OPENMRNPATH}/src/utils/Crc.cxx | ||
${OPENMRNPATH}/src/utils/DirectHub.cxx | ||
${OPENMRNPATH}/src/utils/DirectHubGc.cxx | ||
${OPENMRNPATH}/src/utils/DirectHubLegacy.cxx | ||
${OPENMRNPATH}/src/utils/errno_exit.c | ||
${OPENMRNPATH}/src/utils/FdUtils.cxx | ||
${OPENMRNPATH}/src/utils/FileUtils.cxx | ||
${OPENMRNPATH}/src/utils/format_utils.cxx | ||
${OPENMRNPATH}/src/utils/ForwardAllocator.cxx | ||
${OPENMRNPATH}/src/utils/GcStreamParser.cxx | ||
${OPENMRNPATH}/src/utils/GcTcpHub.cxx | ||
${OPENMRNPATH}/src/utils/gc_format.cxx | ||
${OPENMRNPATH}/src/utils/GridConnect.cxx | ||
${OPENMRNPATH}/src/utils/GridConnectHub.cxx | ||
${OPENMRNPATH}/src/utils/HubDevice.cxx | ||
${OPENMRNPATH}/src/utils/HubDeviceSelect.cxx | ||
${OPENMRNPATH}/src/utils/ieeehalfprecision.c | ||
${OPENMRNPATH}/src/utils/JSHubPort.cxx | ||
${OPENMRNPATH}/src/utils/logging.cxx | ||
${OPENMRNPATH}/src/utils/Queue.cxx | ||
${OPENMRNPATH}/src/utils/ReflashBootloader.cxx | ||
${OPENMRNPATH}/src/utils/ServiceLocator.cxx | ||
${OPENMRNPATH}/src/utils/SocketCan.cxx | ||
${OPENMRNPATH}/src/utils/SocketClient.cxx | ||
${OPENMRNPATH}/src/utils/socket_listener.cxx | ||
${OPENMRNPATH}/src/utils/Stats.cxx | ||
${OPENMRNPATH}/src/utils/StringPrintf.cxx | ||
) | ||
|
||
set(INCLUDE_DIRS | ||
${OPENMRNPATH}/src | ||
${OPENMRNPATH}/include/esp-idf | ||
${OPENMRNPATH}/include | ||
) | ||
|
||
set(IDF_DEPS | ||
app_update | ||
bootloader_support | ||
bt | ||
driver | ||
esp_adc | ||
esp_app_format | ||
esp_system | ||
esp_wifi | ||
espcoredump | ||
hal | ||
heap | ||
mdns | ||
pthread | ||
vfs) | ||
|
||
idf_component_register(SRCS "${SRCS}" | ||
INCLUDE_DIRS "${INCLUDE_DIRS}" | ||
REQUIRES "${IDF_DEPS}") | ||
|
||
############################################################################### | ||
# Warn all and make all warnings into errors in OpenMRN | ||
############################################################################### | ||
target_compile_options(${COMPONENT_LIB} PRIVATE -Wall) | ||
target_compile_options(${COMPONENT_LIB} PRIVATE -Werror=all) | ||
target_compile_options(${COMPONENT_LIB} PRIVATE -Wextra) | ||
|
||
############################################################################### | ||
# Suppress compilation warnings in OpenMRN | ||
############################################################################### | ||
target_compile_options(${COMPONENT_LIB} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-volatile>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# ESP-IDF Build Instructions | ||
The ESP-IDF has its own CMake based build environment for application developers. Using the standard ESP-IDF application build environment, The openmrn/etc/esp-idf directory can be linked into the ESP application "components" directory. | ||
``` | ||
cd <application path>/components | ||
ln -s <openmrn path>/etc/esp-idf/ openmrn | ||
``` | ||
This will result in openmrn being compiled as a registered idf component with the name "openmrn". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../arduino/CDIXMLGenerator.hxx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../freertos/can_ioctl.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../freertos/freertos_includes.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../freertos_select/ifaddrs.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../freertos/stropts.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
/** @copyright | ||
* Copyright (c) 2024, Stuart Baker | ||
* All rights reserved | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are strictly prohibited without written consent. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
* @file Advertisement.cxx | ||
* | ||
* Advertisement definition. | ||
* | ||
* @author Stuart Baker | ||
* @date 2 March 2024 | ||
*/ | ||
|
||
#include "ble/Advertisement.hxx" | ||
|
||
namespace ble | ||
{ | ||
|
||
// | ||
// Advertisement::concat_service_data_128() | ||
// | ||
std::basic_string<uint8_t> Advertisement::concat_service_data_128( | ||
const uint8_t uuid[16], const void *buf, size_t size) | ||
{ | ||
const uint8_t *data = static_cast<const uint8_t*>(buf); | ||
std::basic_string<uint8_t> result(uuid, uuid + 16); | ||
result.append(data, size); | ||
return result; | ||
} | ||
|
||
// | ||
// Advertisement::prepend() | ||
// | ||
int Advertisement::prepend( | ||
Field field, Defs::AdvType type, const void *buf, size_t size, bool clip) | ||
{ | ||
const uint8_t *data = static_cast<const uint8_t*>(buf); | ||
std::basic_string<uint8_t> *d; | ||
size_t max; | ||
|
||
switch (field) | ||
{ | ||
default: | ||
case Field::DATA: | ||
d = &data_; | ||
max = extended_ ? | ||
MAX_EXT_DATA_PAYLOAD_SIZE : MAX_SCAN_DATA_PAYLOAD_SIZE; | ||
break; | ||
case Field::SCAN_DATA: | ||
HASSERT(!extended_); | ||
d = &scanData_; | ||
max = MAX_DATA_PAYLOAD_SIZE; | ||
break; | ||
} | ||
|
||
size_t space = std::min((size + 2), (max - d->size())); | ||
if (space < (size + 2) && clip == false) | ||
{ | ||
// Data doesn't fit and clipping is not allowed. | ||
return -1; | ||
} | ||
d->insert(0, 1, space - 1); | ||
d->insert(1, 1, static_cast<uint8_t>(type)); | ||
d->insert(2, data, space - 2); | ||
return space; | ||
} | ||
|
||
// | ||
// Advertisement::append() | ||
// | ||
int Advertisement::append( | ||
Field field, Defs::AdvType type, const void *buf, size_t size, bool clip) | ||
{ | ||
const uint8_t *data = static_cast<const uint8_t*>(buf); | ||
std::basic_string<uint8_t> *d; | ||
size_t max; | ||
|
||
switch (field) | ||
{ | ||
default: | ||
case Field::DATA: | ||
d = &data_; | ||
max = extended_ ? | ||
MAX_EXT_DATA_PAYLOAD_SIZE : MAX_SCAN_DATA_PAYLOAD_SIZE; | ||
break; | ||
case Field::SCAN_DATA: | ||
HASSERT(!extended_); | ||
d = &scanData_; | ||
max = MAX_DATA_PAYLOAD_SIZE; | ||
break; | ||
} | ||
|
||
size_t space = std::min((size + 2), (max - d->size())); | ||
if (space < (size + 2) && clip == false) | ||
{ | ||
// Data doesn't fit and clipping is not allowed. | ||
return -1; | ||
} | ||
d->push_back(space - 1); | ||
d->push_back(static_cast<uint8_t>(type)); | ||
d->append(data, space - 2); | ||
return space; | ||
} | ||
|
||
// | ||
// Advertisement::update() | ||
// | ||
int Advertisement::update(Field field, Defs::AdvType type, const void *buf, | ||
size_t size, unsigned instance, bool exact_size, | ||
bool clip) | ||
{ | ||
const uint8_t *data = static_cast<const uint8_t*>(buf); | ||
std::basic_string<uint8_t> *d; | ||
size_t max; | ||
|
||
switch (field) | ||
{ | ||
default: | ||
case Field::DATA: | ||
d = &data_; | ||
max = extended_ ? | ||
MAX_EXT_DATA_PAYLOAD_SIZE : MAX_SCAN_DATA_PAYLOAD_SIZE; | ||
break; | ||
case Field::SCAN_DATA: | ||
HASSERT(!extended_); | ||
d = &scanData_; | ||
max = MAX_DATA_PAYLOAD_SIZE; | ||
break; | ||
} | ||
|
||
uint8_t len; | ||
ssize_t pos = Defs::adv_find_data(*d, type, &len, instance); | ||
if (pos < 0) | ||
{ | ||
// No matching advertising data found. | ||
return -1; | ||
} | ||
if (exact_size && len != size) | ||
{ | ||
// Found the data, but it is the wrong size. | ||
return -1; | ||
} | ||
size_t space = std::min((size + 2), (max - d->size()) + (len + 2)); | ||
if (space < size && clip == false) | ||
{ | ||
// Data doesn't fit and clipping is not allowed. | ||
return -1; | ||
} | ||
d->at(pos) = space - 1; | ||
d->replace(pos + 2, len, data, space - 2); | ||
return space; | ||
} | ||
|
||
} // namespace ble |
Oops, something went wrong.