Skip to content

Commit

Permalink
Merge pull request #56 from ronanj/master
Browse files Browse the repository at this point in the history
Add support for ESP-IDF component
  • Loading branch information
joscha authored Oct 5, 2024
2 parents c66ab49 + ef4f6f7 commit 1415400
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
51 changes: 51 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
cmake_minimum_required(VERSION 3.13)

if(ESP_PLATFORM)
# Build LoRaSerialization as an ESP-IDF component
# required because ESP-IDF runs cmake in script mode
# and needs idf_component_register()
file(GLOB_RECURSE LORA_SERIALIZATION_ESP_SOURCES
"src/*.*"
)

idf_component_register(
SRCS ${LORA_SERIALIZATION_ESP_SOURCES}
INCLUDE_DIRS . src
)

return()
endif()

if(CMAKE_SCRIPT_MODE_FILE)
message(FATAL_ERROR "Attempted to build LoRaSerialization in script mode")
endif()

project(radiolib)

file(GLOB_RECURSE LORA_SERIALIZATION_SOURCES
"src/*.cpp"
)

add_library(LoRaSerialization ${LORA_SERIALIZATION_SOURCES})

target_include_directories(LoRaSerialization
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

# use c++20 standard
set_property(TARGET LoRaSerialization PROPERTY CXX_STANDARD 20)

# enable most warnings
target_compile_options(LoRaSerialization PRIVATE -Wall -Wextra)

include(GNUInstallDirs)

install(TARGETS LoRaSerialization
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/LoRaSerialization
FILES_MATCHING PATTERN "*.h"
)
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,23 @@ The decode method already does most of the necessary transformations, so in most
* Check the coverage (JavaScript) via `yarn coverage` (see `coverage/lcov-report`)

The CI will kick off once you create a pull request automatically.

# Installation

## ESP-IDF

Add the `lora-serialization` dependency to the `main/idf_component.yml` file in your ESP-IDF project:

```
dependencies:
lora-serialization:
git: https://github.com/thesolarnomad/lora-serialization.git
```

As well as to the `main/CMakeLists.txt`

```
idf_component_register( ...
REQUIRES .... lora-serialization
)
```
11 changes: 11 additions & 0 deletions idf_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dependencies:
idf: '>=4.1'
description: LoRaWAN serialization/deserialization library for The Things Network
license: MIT
repository: https://github.com/thesolarnomad/lora-serialization.git
tags:
- LoRaWAN
- encoding
- serialization
- deserialization
version: 3.2.1
3 changes: 3 additions & 0 deletions src/LoraMessage.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#if ARDUINO >= 100
#include "Arduino.h"
#endif
#ifdef ESP_PLATFORM
#include <cstdio>
#endif
#include <stdlib.h>
#include "LoraMessage.h"
#include "LoraEncoder.h"
Expand Down

0 comments on commit 1415400

Please sign in to comment.