Commit 6bf5a19a authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

remove controller files and move them to another repository

parent 55c1e997
build/
cmake-build*
sdkconfig
sdkconfig.old
cmake_minimum_required(VERSION 3.5)
if(COMPILE_UNIVERSAL_TESTS)
set(PROJECT_NAME door-controller-universal-tests)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
project(${PROJECT_NAME} C CXX)
find_package(Catch2 REQUIRED)
set(INCLUDE_DIR main/include)
set(APP_SRC main/src/app)
set(CONNECTOR_TEST main/src/connectors/tests)
set(TEST_SRC main/src/test)
file(GLOB_RECURSE FILES
${INCLUDE_DIR}/*.h
${APP_SRC}/*.c
${CONNECTOR_TEST}/*.c
${TEST_SRC}/*.cpp
)
add_executable(${PROJECT_NAME} ${FILES})
target_include_directories(${PROJECT_NAME} PRIVATE ${INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} Catch2::Catch2)
else()
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(door-controller)
endif()
FROM espressif/idf:latest
RUN apt-get update && apt-get install -y \
build-essential \
gcc \
g++ \
gdb \
cmake \
&& apt-get clean \
&& apt-get autoremove -y \
&& rm -rf /var/lib/apt/lists/*
# Install catch2
RUN git clone https://github.com/catchorg/Catch2.git /catch2 \
&& cd /catch2 && cmake -Bbuild -H. -DBUILD_TESTING=OFF \
&& cmake --build build/ --target install \
&& cd / \
&& rm -rf /catch2
ENTRYPOINT [ "/opt/esp/entrypoint.sh" ]
CMD [ "/bin/bash" ]
Code in this repository is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
#
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
# project subdirectory.
#
PROJECT_NAME := app-template
include $(IDF_PATH)/make/project.mk
# Useful commands
- Building
- `idf build`
- To flash
- On my local machine run idfinit which runs `source /opt/esp-idf/export.sh`
- `idf -p /dev/ttyUSB0 flash`
- To Monitor:
- `idf -p /dev/ttyUSB0 monitor`
# CLion Development Setup
Disclaimer, I set this up before clion has full docker integration, so once that comes out, these steps
will need to be changed.
## Toolchain Setup
Add a new toolchain and point the c compiler, c++ compiler, and gdb to the installed xtensa esp idf executables.
For me these were located in `~/.espressif/tools/xtensa-esp32-elf/esp-2020r1-8.2.0/xtensa-esp32-elf/bin/`
## CMake Setup
Make sure you followed the esp-idf setup instructions. Set the `IDF_PATH` and `PYTHON` environment variables
in the cmake configuration you want to use. `IDF_PATH` should be set to the base esp-idf install directory.
`PYTHON` should point to the python executable that the esp-idf installation setup for you.
For me `ESP_IDF` was `/opt/esp-idf`
`PATH` should also be overwritten to contain the tools directory of the base esp-idf installation,
as well as the xtensa toolchain bin that was installed to your home directory (mentioned earlier in toolchain setup).
config.h
*.pem
\ No newline at end of file
set(INCLUDE_DIR include)
set(APP_SRC src/app)
set(CONNECTOR_SRC src/connectors/esp32)
file(GLOB_RECURSE FILES ${APP_SRC}/*.c ${CONNECTOR_SRC}/*.c)
idf_component_register(SRCS ${FILES} "main.c"
INCLUDE_DIRS ${INCLUDE_DIR}
EMBED_TXTFILES "doorcode_root_cert.pem")
# put here your custom config value
menu "Example Configuration"
config ESP_WIFI_SSID
string "WiFi SSID"
default "myssid"
help
SSID (network name) for the example to connect to.
config ESP_WIFI_PASSWORD
string "WiFi Password"
default "mypassword"
help
WiFi password (WPA or WPA2) for the example to use.
endmenu
#ifndef DOOR_CONTROLLER_MAIN_API_H_
#define DOOR_CONTROLLER_MAIN_API_H_
#include <stdbool.h>
#include "connectors/http.h"
#define HTTP_SUCCESS 200
// Requires door_wifi to be initialized
/**
* @param code MUST be null terminated
* @return
*/
bool door_api_verify_code(const char* code);
#endif //DOOR_CONTROLLER_MAIN_API_H_
#ifndef DOOR_CONTROLLER_MAIN_INCLUDE_APP_DIAGNOSTIC_H_
#define DOOR_CONTROLLER_MAIN_INCLUDE_APP_DIAGNOSTIC_H_
#include <stdbool.h>
bool door_diagnostic_self_test(void);
#endif //DOOR_CONTROLLER_MAIN_INCLUDE_APP_DIAGNOSTIC_H_
#ifndef DOOR_CONTROLLER_MAIN_INCLUDE_APP_EVENT_H_
#define DOOR_CONTROLLER_MAIN_INCLUDE_APP_EVENT_H_
#include "connectors/rtos.h"
#define WIFI_CONNECTED_EVENT BIT0
#define TIME_SYNCED_EVENT BIT1
#endif //DOOR_CONTROLLER_MAIN_INCLUDE_APP_EVENT_H_
#ifndef DOOR_CONTROLLER_MAIN_INCLUDE_APP_RANDOM_H_
#define DOOR_CONTROLLER_MAIN_INCLUDE_APP_RANDOM_H_
#include <stdint.h>
uint32_t door_random_get_random_between(uint32_t min, uint32_t max);
#endif //DOOR_CONTROLLER_MAIN_INCLUDE_APP_RANDOM_H_
#ifndef DOOR_CONTROLLER_MAIN_INCLUDE_APP_STATE_H_
#define DOOR_CONTROLLER_MAIN_INCLUDE_APP_STATE_H_
void state_task(void* parameters);
#endif //DOOR_CONTROLLER_MAIN_INCLUDE_APP_STATE_H_
#ifndef DOOR_CONTROLLER_MAIN_INCLUDE_APP_TIME_H_
#define DOOR_CONTROLLER_MAIN_INCLUDE_APP_TIME_H_
int door_time_get_current_hour(void);
#endif //DOOR_CONTROLLER_MAIN_INCLUDE_APP_TIME_H_
#ifndef DOOR_CONTROLLER_MAIN_INCLUDE_APP_TOKEN_H_
#define DOOR_CONTROLLER_MAIN_INCLUDE_APP_TOKEN_H_
void door_token_initialize(const char* default_token);
void door_token_set(const char* token);
const char* door_token_get(void);
#endif //DOOR_CONTROLLER_MAIN_INCLUDE_APP_TOKEN_H_
#ifndef DOOR_CONTROLLER_MAIN_INCLUDE_APP_UPDATE_H
#define DOOR_CONTROLLER_MAIN_INCLUDE_APP_UPDATE_H_
void update_task(void* parameters);
#endif //DOOR_CONTROLLER_MAIN_INCLUDE_APP_UPDATE_H_
#ifndef DOOR_CONFIG_H
#define DOOR_CONFIG_H
#define DOOR_WIFI_SSID "ssid"
#define DOOR_WIFI_PASSWORD "password"
#define API_HOST "host or ip"
#define API_PORT 443
#define API_TOKEN "door_1_api_token"
#define API_BASE_PATH "/api/door"
#define API_UPDATE_URL API_BASE_PATH "/update"
#define API_TIMEOUT_MS 10000
#define API_USE_SSL
#define API_NO_NAME_VERIFY
#define NTP_SERVER "pool.ntp.org"
#define TIMEZONE "PST8PDT,M3.2.0/2,M11.1.0"
#define UPDATE_HOUR_START 2
// 3 hours
#define UPDATE_MAX_FUDGE_FACTOR_MS ((1000*60*60)*3)
// Every hour
#define UPDATE_CHECK_PERIOD_MS (1000*60*60)
//#define UPDATE_SKIP_VERSION_CHECK
#endif //DOOR_CONFIG_H
#ifndef DOOR_CONTROLLER_MAIN_HTTP_H_
#define DOOR_CONTROLLER_MAIN_HTTP_H_
#include <stdbool.h>
#define DOOR_HTTP_SUCCESS 0
#define DOOR_HTTP_ERR_FAIL -1
#define DOOR_HTTP_ERR_TIMEOUT -2
/**
* @brief return false if something goes wrong. Can be called multiple times on one request because of chunked data
*/
typedef bool (* door_http_process_data_cb)(const void* data, const int len);
typedef struct
{
door_http_process_data_cb data_handler;
} door_http_callback_t;
/**
* @brief Initializes the door http system
* @param[in] token The API token to use
* @return < 0 on failure
*/
int door_http_initialize(const char* token);
/**
* @brief De-initalizes the http system. If it is to be used again, door_http_init must be called again
*/
void door_http_destroy(void);
/**
* @brief Performs a get request to the door code server. door_http_free_buffer must be called
* when the callee is done with the data before the next request
* @param[in] path the path of the url to make the request to
* @param[in] callbacks http request callbacks to handle getting data etc...
* @return
* - status code on success
* - < 0 on fail
*/
int door_http_get(const char* path, door_http_callback_t* callbacks);
/**
* @brief Downloads and updates the next OTA partition from the server.
* Will return false if not connected to WiFi
* @param[in] api_token the api token to use for authentication/authorization/identification
* @return
* - true on success
* - false otherwise
*/
bool door_http_ota_update(const char* api_token);
#endif //DOOR_CONTROLLER_MAIN_HTTP_H_
#ifndef DOOR_CONTROLLER_MAIN_INCLUDE_CONNECTORS_NVS_H_
#define DOOR_CONTROLLER_MAIN_INCLUDE_CONNECTORS_NVS_H_
#define DOOR_NVS_SUCCESS 0
#define DOOR_NVS_ERR_KEY_NOT_FOUND -1
#define DOOR_NVS_ERR_NO_HANDLE -2
#define DOOR_NVS_ERR_NO_MEM -3
#define DOOR_NVS_ERR_NOT_ENOUGH_SPACE -4
#define DOOR_NVS_ERR_VALUE_TOO_LONG -5
#define DOOR_NVS_ERR_OTHER -6
/**
* @brief Initializes the NVS system on the chip. If this fails the application will stop
*/
void door_nvs_initialize(void);
/**
* @brief Gets a string from NVS
* @param[in] key
* @param[out] string pointer to allocated memory for string. This must be freed.
* @return
*/
int door_nvs_get_string(const char* key, const char** string);
/**
* @brief Sets a string value.
* @param key The key to save the value under
* @param value The value to be saved in NVS
* @return
*/
int door_nvs_set_string(const char* key, const char* value);
#endif //DOOR_CONTROLLER_MAIN_INCLUDE_CONNECTORS_NVS_H_
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment