Commit f2ab48d0 authored by Jacob Priddy's avatar Jacob Priddy 👌

Merge branch 'master' of gitlab.cs.wallawalla.edu:elock/controller

parents 6dc3fb50 1f946b66
Pipeline #18163 passed with stages
in 4 minutes and 34 seconds
image: gitlab.cs.wallawalla.edu:5050/elock/controller:latest
.get_version_from_tag:
variables:
VERSION: $CI_COMMIT_TAG
.get_version_from_build:
variables:
VERSION: 0.0.0.$CI_PIPELINE_ID
stages:
- build
- test
- deploy
before_script:
- >
if [[ -n ${CI_COMMIT_TAG+x} ]]; then
printf "${CI_COMMIT_TAG}" > version.txt
fi
build_tests:
stage: build
script:
......@@ -26,56 +24,35 @@ build_tests:
- build/door-controller-universal-tests
expire_in: 1 hour
test_application:
stage: test
script:
- build/door-controller-universal-tests
.build_esp32:
build_esp32_application:
stage: build
script:
- echo $WEBSERVER_ROOT_CERT | base64 -d -w 0 > main/doorcode_root_cert.cert
- mv main/doorcode_root_cert.cert.prod main/doorcode_root_cert.cert
- cp main/include/config.h.example main/include/config.h
- echo $VERSION > version.txt
- /opt/esp/entrypoint.sh bash
- idf.py build
artifacts:
paths:
- build/door-controller.bin
- version.txt
expire_in: 2 months
.build_head:
extends:
- .get_version_from_build
- .build_esp32
except:
refs:
- tags
.build_release:
extends:
- .get_version_from_tag
- .build_esp32
only:
refs:
- tags
test_application:
stage: test
script:
- build/door-controller-universal-tests
deploy_controller_update:
stage: deploy
tags:
- elock
extends:
- .get_version_from_tag
before_script:
- echo "CI_COMMIT_TAG"
script:
- echo "$SIGNING_KEY" | base64 -d -w 0 > decoded.pem
- espsecure.py sign_data --keyfile decoded.pem --version 1 build/door-controller.bin
- deploy_name="v${VERSION}.bin"
- version=$(<version.txt)
- deploy_name="v${version}.bin"
- echo "Deploying ${deploy_name}"
- chown 1000:1000 build/door-controller.bin
- mv build/door-controller.bin $PROJ_DIR/controller-bins/$deploy_name
- mv "build/door-controller.bin" "${PROJ_DIR}/controller-bins/${deploy_name}"
only:
refs:
- tags
- tags
-----BEGIN CERT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YwFAYDVQQHDA1Db2xsZWdlIFBsYWNlMQwwCgYDVQQKDANX
V1UxJDAiBgNVBAsMGzE5Mi4xNjguMC4xMyBST09UIENBIElTU1VFUjEVMBMGA1UE
AwwMMTkyLjE2OC4wLjEzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
t55SyIy/1C+rwolf2mqaJzBaVTaLMWk0NjVImfsJOdKIHYE1hpJUe1UNNbQYeRPr
QElf3BletQl1B3PEaJwBbg6AzPWwVD+DDS0CqmD6URmq20M1bWYEYgJMrwpqpY33
wm0BJsTd62+emhIhGoym5DZJ59g7+jnoHsxchXNsGOi6qddxtnm5sr4ezZvFOoc+
ALsElo6YE8OuumQ3jSsWTESFJxRsWvZ2ppcIJRHdAAwdhyUCokyVJdzyk3L/Dk9l
LZye64OhV1BYB0I2rVp2iBPZ/gxSliL0Tiut8XkIsMNN7JJNA4AFL8nwo52v9eli
usV2Ma3x6xLj+KiNh7KZ7wIDAQABMA0GCSqGSIb3DQEBCwUAA4IBAQBeJv5EWaVL
4ZEVDx+yNAZ/PqWzpi6B8XRoGBpAsk83mJ429NmfAD5G74rmDwPZ9FHWCWHK6Cpy
3MO75nepmk6qVYccuEW1bs/itO8NbADeJRIqzpVDP8F0dWefmUGo5bV2oAVhLdLI
QfPXMNyHyaQUp8gFh1xzCXyPU5jrmcFLw8L29aRlOfGYdmKq/tYbULjdYtysrigl
IZFQrM+oXpKEDKq+Fqax27O9RrgmIIrxpAU0/KxASbKgpCkW+T2UZTjOjms8NpdO
EH7zjGq59lewpAyG5trG/OAVzmi4sIKiRwXQwdHjcGXwjio+isDbu0s2HI5nCZSh
MlKGC4g2E4bP
-----END CERTIFICATE-----
......@@ -4,14 +4,14 @@
#define DOOR_WIFI_SSID "WWU-HWAuth"
#define DOOR_WIFI_PASSWORD ""
#define API_HOST "elock.cs.wallawalla.edu"
#define API_HOST "172.27.2.11"
#define API_PORT 4433
#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 3500
#define API_TIMEOUT_MS 3000
#define API_USE_SSL
#define API_NO_NAME_VERIFY
......@@ -49,6 +49,9 @@
#define MIN_CODE_LENGTH 4
// Time in MS we are allowed to go without contacting the server
// Set to 1 minute instead of something like 15 minutes to keep the SSL connection alive
// so it can be reused as much as possible, as it takes around 2 seconds with RSA 2048 keys
// and a whopping 5 seconds with ECDSA keys :(
#define STATUS_MAX_NO_CONTACT_TIME_MS (1000 * 60)
// How often to update the keypad state
......
......@@ -166,16 +166,22 @@ int door_http_get(door_http_client_handle_t client, const char* path, door_http_
esp_http_client_set_url(handle, path);
esp_http_client_set_method(handle, HTTP_METHOD_GET);
esp_err_t err = esp_http_client_perform(handle);
if (err != ESP_OK)
{
ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err));
return DOOR_HTTP_ERR_FAIL;
}
// Bug in the framework, have to retry until it works
// https://github.com/espressif/esp-idf/issues/2684
for (int tries = 0; tries < 3; ++tries) {
esp_err_t err = esp_http_client_perform(handle);
int status_code = esp_http_client_get_status_code(handle);
ESP_LOGI(TAG, "Status code from GET call: %d", status_code);
return status_code;
if (err == ESP_OK)
{
int status_code = esp_http_client_get_status_code(handle);
ESP_LOGI(TAG, "Status code from GET call: %d", status_code);
return status_code;
}
ESP_LOGE(TAG, "Error perform http request %s. Retrying...", esp_err_to_name(err));
esp_http_client_close(handle);
}
return DOOR_HTTP_ERR_FAIL;
}
int door_http_post(
......@@ -197,15 +203,23 @@ int door_http_post(
esp_http_client_set_url(handle, path);
esp_http_client_set_method(handle, HTTP_METHOD_POST);
esp_http_client_set_post_field(client, data, strlen(data));
esp_err_t err = esp_http_client_perform(handle);
if (err != ESP_OK)
{
ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err));
return DOOR_HTTP_ERR_FAIL;
// Bug in the framework, have to retry until it works
// https://github.com/espressif/esp-idf/issues/2684
for (int tries = 0; tries < 3; ++tries) {
esp_err_t err = esp_http_client_perform(handle);
if (err == ESP_OK)
{
int status_code = esp_http_client_get_status_code(handle);
ESP_LOGI(TAG, "Status code from POST call: %d", status_code);
return status_code;
}
ESP_LOGE(TAG, "Error perform http request %s. Retrying...", esp_err_to_name(err));
esp_http_client_close(handle);
}
int status_code = esp_http_client_get_status_code(handle);
ESP_LOGI(TAG, "Status code from POST call: %d", status_code);
return status_code;
return DOOR_HTTP_ERR_FAIL;
}
static esp_err_t door_http_ota_update_validate_image_header(esp_app_desc_t* new_app_info)
......
This diff is collapsed.
1.0.2.1
\ No newline at end of file
1.0.3.0
\ No newline at end of file
Markdown is supported
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