-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into ultrasonic
- Loading branch information
Showing
140 changed files
with
24,251 additions
and
4,215 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
{ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false } | ||
BasedOnStyle: LLVM | ||
UseTab: Never | ||
IndentWidth: 4 | ||
TabWidth: 4 | ||
BreakBeforeBraces: Allman | ||
AllowShortIfStatementsOnASingleLine: false | ||
IndentCaseLabels: false | ||
ColumnLimit: 0 | ||
AccessModifierOffset: -4 | ||
NamespaceIndentation: All | ||
FixNamespaceComments: false |
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,18 @@ | ||
name: Compile check | ||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Polyfill AWS certificates | ||
run: | | ||
cd components/ClientComponent/ | ||
touch ca.crt client.crt client.key aws.url | ||
- name: Build ESP-IDF project | ||
uses: espressif/esp-idf-ci-action@v1 | ||
with: | ||
esp_idf_version: v5.3.1 | ||
target: esp32 |
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,16 @@ | ||
name: Format check | ||
on: [push] | ||
|
||
jobs: | ||
format-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Run clang-format | ||
uses: DoozyX/[email protected] | ||
with: | ||
source: 'components main' | ||
exclude: 'managed_components components/hx711' | ||
clangFormatVersion: 18 | ||
style: file | ||
|
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,10 @@ | ||
{ | ||
"idf.flashType": "UART", | ||
"idf.port": "/dev/COM4", | ||
"idf.portWin": "COM7", | ||
"files.associations": { | ||
"system_error": "cpp" | ||
}, | ||
"idf.espIdfPath": "/Users/anthonychen/esp/v5.3.1/esp-idf", | ||
"idf.toolsPath": "/Users/anthonychen/.espressif" | ||
} |
Binary file not shown.
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# target_compile_options(Client.cpp PRIVATE -fpermissive) | ||
|
||
idf_component_register(SRCS "Client.cpp" | ||
idf_component_register(SRCS "Client.cpp" "Serialize.cpp" | ||
INCLUDE_DIRS "include" | ||
PRIV_REQUIRES log esp_system esp_partition nvs_flash esp_event esp_netif protocol_examples_common mqtt app_update) | ||
PRIV_REQUIRES log esp_system esp_partition nvs_flash esp_event esp_netif protocol_examples_common mqtt app_update json | ||
EMBED_TXTFILES client.key client.crt ca.crt aws.url) |
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,31 @@ | ||
#include "Serialize.hpp" | ||
#include <esp_mac.h> | ||
|
||
cJSON *Client::serialize(float fullness, uint32_t usage, bool overflow, int32_t weight) | ||
{ | ||
// Use the ESP32's MAC address as a UUID (since it is a UUID) | ||
uint8_t mac_addr_arr[6]; | ||
uint64_t mac_addr; | ||
if (esp_base_mac_addr_get(mac_addr_arr) != ESP_OK) | ||
{ | ||
// TODO: Handle mac address being unset properly | ||
mac_addr = 0x112233445566; | ||
} | ||
else | ||
{ | ||
mac_addr = | ||
((uint64_t)mac_addr_arr[5] << 0) | | ||
((uint64_t)mac_addr_arr[4] << 8) | | ||
((uint64_t)mac_addr_arr[3] << 16) | | ||
((uint64_t)mac_addr_arr[2] << 24) | | ||
((uint64_t)mac_addr_arr[1] << 32) | | ||
((uint64_t)mac_addr_arr[0] << 40); | ||
} | ||
cJSON *root = cJSON_CreateObject(); | ||
cJSON_AddNumberToObject(root, "bin_id", mac_addr); | ||
cJSON_AddNumberToObject(root, "fullness", fullness); | ||
cJSON_AddNumberToObject(root, "usage", usage); | ||
cJSON_AddBoolToObject(root, "overflow", overflow); | ||
cJSON_AddNumberToObject(root, "weight", weight); | ||
return root; | ||
} |
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 |
---|---|---|
@@ -1,8 +1,14 @@ | ||
#ifndef CLIENT_HPP | ||
#define CLIENT_HPP | ||
|
||
namespace Client { | ||
#include <stddef.h> | ||
|
||
namespace Client | ||
{ | ||
void clientStart(void); | ||
void clientPublish(const void *message, size_t len); | ||
// ONLY pass null terminated strings to this function! It uses strlen! | ||
void clientPublishStr(const char *message); | ||
} | ||
|
||
#endif | ||
#endif |
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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
#ifndef CREDENTIALS_HPP | ||
#define CREDENTIALS_HPP | ||
|
||
const char* AWS_IOT_ENDPOINT; | ||
const char* AWS_CERT_CA; | ||
const char* AWS_CERT_CRT; | ||
const char* AWS_CERT_PRIVATE; | ||
// These are generated by CMakeLists.txt | ||
// To make sure compilation succeeds, ensure ca.crt, client.crt, aws.url and client.key exist! | ||
// https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/build-system.html#embedding-binary-data | ||
// AWS root CA certificate | ||
extern const uint8_t AWS_CA_CRT[] asm("_binary_ca_crt_start"); | ||
// Device-local certificate | ||
extern const uint8_t AWS_CLIENT_CRT[] asm("_binary_client_crt_start"); | ||
// Device-local private key | ||
extern const uint8_t AWS_CLIENT_KEY[] asm("_binary_client_key_start"); | ||
// URL of AWS endpoint | ||
extern const uint8_t AWS_URL[] asm("_binary_aws_url_start"); | ||
|
||
#endif |
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,26 @@ | ||
#ifndef CLIENT_SERIALIZE_HPP | ||
#define CLIENT_SERIALIZE_HPP | ||
|
||
#include <cJSON.h> | ||
#include <stdint.h> | ||
|
||
namespace Client | ||
{ | ||
/* | ||
* @brief Serialize data from sensors for API interaction. | ||
* | ||
* The current shape of the JSON object returned is the following: | ||
* { | ||
* "bin_id": 18838586676582, | ||
* "fullness": 0.5, | ||
* "usage": 44, | ||
* "overflow": false, | ||
* "weight": 50 | ||
* } | ||
* | ||
* @return cJSON* root of a JSON object containing sensor data. Make sure to free this after you are done using it. | ||
*/ | ||
cJSON *serialize(float fullness, uint32_t usage, bool overflow, int32_t weight); | ||
} | ||
|
||
#endif |
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
Oops, something went wrong.