feat: Initial Commit

Signed-off-by: Avior <f.bouillon@aptatio.com>
This commit is contained in:
Florian Bouillon 2022-11-24 12:11:23 +01:00
commit dbfc66687b
Signed by: Florian Bouillon
GPG Key ID: E05B3A94178D3A7C
16 changed files with 300 additions and 0 deletions

7
.clang-tidy Normal file
View File

@ -0,0 +1,7 @@
# Clangtidy configuration file (not used until PIO 6)
---
Checks: 'abseil-*,boost-*,bugprone-*,cert-*,cppcoreguidelines-*,clang-analyzer-*,google-*,hicpp-*,modernize-*,performance-*,portability-*,readability-*,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-cppcoreguidelines-init-variables'
WarningsAsErrors: false
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: google

40
.editorconfig Normal file
View File

@ -0,0 +1,40 @@
#############################################
# EditorConfig #
# cross-platform Editor basic configuration #
#############################################
# make the editor config file not search in upper folders
root = true
# Base Configuration
[*]
indent_style = tab
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120
end_of_line = lf
# Yaml Standard
[*.{yaml,yml}]
indent_style = space
indent_size = 2
# Markdown Standards
[*.md]
indent_style = space
indent_size = 2
trim_trailing_whitespace = false
# C++ Standards
[*.{cpp,h,ino}]
indent_style = space
# PHP Standards
[*.php]
indent_style = space
# INI file Standards
[*.ini]
indent_style = space

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
* text=auto eol=lf

40
.github/workflows/test_build.yml vendored Normal file
View File

@ -0,0 +1,40 @@
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# this cache the platformio binaries and not the .pio folder
- name: Cache PlatformIO
uses: actions/cache@v3
with:
path: ~/.platformio
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
- name: Set up Python
uses: actions/setup-python@v3
- name: Install PlatformIO
run: pip install platformio
- name: Build the project
run: platformio run
- name: Test the project
run: platformio check --fail-on-defect high

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
# Platformio specifics
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
# Aptatio/Platformio specifics
secrets.ini

10
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}

19
config.cppcheck Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- CPP Check configuation file -->
<project version="1">
<builddir>.cppcheck-build</builddir>
<platform>Unspecified</platform>
<analyze-all-vs-configs>false</analyze-all-vs-configs>
<check-headers>true</check-headers>
<check-unused-templates>false</check-unused-templates>
<max-ctu-depth>10</max-ctu-depth>
<exclude>
<path name=".pio/"/>
</exclude>
<suppressions>
<suppression>noCopyConstructor</suppression>
<suppression>noExplicitConstructor</suppression>
<suppression>unusedFunction</suppression>
<suppression>noOperatorEq</suppression>
</suppressions>
</project>

19
config.ini Normal file
View File

@ -0,0 +1,19 @@
; Project configuration file
[config]
; Hardware Serial baud rate
; Also available in the code as `MONITOR_SPEED`
monitor_speed = 115200
; Software Config
; note: additionnal flags are added by Platform.io (see total amount in `.vscode/c_cpp_properties.json` in the `defines` section)
; notworthy ones:
; __PLATFORMIO_BUILD_DEBUG__ = debug mode
build_flags =
; DO NOT TOUCH --- START
-D MONITOR_SPEED=${config.monitor_speed}
; DO NOT TOUCH --- END
-D EXAMPLE_NUMBER=69
-D EXAMPLE_STRING=\"Pouet\"

15
envs.ini Normal file
View File

@ -0,0 +1,15 @@
; Add additionnal environments in this file
; Default production environment
[env:prod]
; Debug environemnt
[env:debug]
build_type = debug
; Example additionnal env
; [env:example]
; ; note: keep the `${env.build_flags}` to includes others build flags
; build_flags = ${env.build_flags}
; -D POUET

19
include/Program.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef PROGRAM_H
#define PROGRAM_H
#include "Arduino.h"
class Program {
public:
/**
* Program startup
*/
Program();
/**
* Program main loop
*/
void loop();
};
#endif

0
lib/.gitkeep Normal file
View File

55
platformio.ini Normal file
View File

@ -0,0 +1,55 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[secrets]
build_flags =
[platformio]
default_envs = debug
extra_configs =
secrets.ini
config.ini
envs.ini
[env]
build_flags = ${config.build_flags} ${secrets.build_flags}
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = ${config.monitor_speed}
monitor_filters = esp32_exception_decoder, default
monitor_flags =
--echo
lib_deps =
check_tool = clangtidy, cppcheck
check_patterns =
src/
include/
lib/
check_skip_packages = yes
check_flags =
clangtidy: --checks=abseil-*,boost-*,bugprone-*,cert-*,cppcoreguidelines-*,clang-analyzer-*,google-*,hicpp-*,modernize-*,performance-*,portability-*,readability-*,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-cppcoreguidelines-init-variables
cppcheck: --project=config.cppcheck
[config]
monitor_speed = 115200
build_flags =
-D MONITOR_SPEED=${config.monitor_speed}
-D EXAMPLE_NUMBER=69
-D EXAMPLE_STRING=\"Pouet\"
[env:prod]
lib_deps = t-vk/ESP32 BLE Keyboard@^0.3.2
[env:debug]
build_type = debug
lib_deps = t-vk/ESP32 BLE Keyboard@^0.3.2

6
secrets.ini.example Normal file
View File

@ -0,0 +1,6 @@
; Add secrets token/logins/etc `secrets.ini`
; Add the sames values as blank in `secrets.ini.example
; To be able to reproduce it
[secrets]
build_flags =

49
src/Program.cpp Normal file
View File

@ -0,0 +1,49 @@
#include "Program.h"
#include <BleKeyboard.h>
BleKeyboard bleKeyboard;
Program::Program() {
// Startup
Serial.begin(MONITOR_SPEED);
Serial.println("Starting BLE work!");
bleKeyboard.begin();
}
void Program::loop() {
if(bleKeyboard.isConnected()) {
Serial.println("Sending 'Hello world'...");
bleKeyboard.print("Hello world");
delay(1000);
Serial.println("Sending Enter key...");
bleKeyboard.write(KEY_RETURN);
delay(1000);
Serial.println("Sending Play/Pause media key...");
// bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE);
delay(1000);
//
// Below is an example of pressing multiple keyboard modifiers
// which by default is commented out.
/*Hello world
Serial.println("Sending Ctrl+Alt+Delete...");
bleKeyboard.press(KEY_LEFT_CTRL);
bleKeyboard.press(KEY_LEFT_ALT);
bleKeyboard.press(KEY_DELETE);Hello world
Hello world
Hello world
delay(100);Hello world
bleKeyboard.releaseAll();
*/
}
Serial.println("Waiting 5 seconds...");
delay(5000);
}

11
src/main.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "Program.h"
Program* program;
void setup() {
program = new Program();
}
void loop() {
program->loop();
}

0
test/.gitkeep Normal file
View File