Skip to content

Commit

Permalink
Dev (#8)
Browse files Browse the repository at this point in the history
* Add POST method to HttpClient class

* update readme

* Added zbus example

* Adding dev container
  • Loading branch information
kaizoku-oh committed Dec 21, 2023
1 parent c0b3331 commit ab2249d
Show file tree
Hide file tree
Showing 14 changed files with 659 additions and 106 deletions.
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"image": "ghcr.io/embeddedcontainers/zephyr:arm-0.16.4SDK",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace/app,type=bind",
"workspaceFolder": "/workspace",
"onCreateCommand": "west init -l app/ && west update && west zephyr-export && pip install -r deps/zephyr/scripts/requirements-base.txt",
"mounts": [
"source=${localWorkspaceFolder}/.vscode/,target=/workspace/.vscode,type=bind,consistency=cached"
],
"customizations": {
"vscode": {
"settings": {
// Hush CMake
"cmake.configureOnOpen": false,
// IntelliSense
"C_Cpp.default.compilerPath": "/opt/toolchains/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc",
"C_Cpp.default.compileCommands": "${workspaceFolder}/app/build/compile_commands.json",
// File Associations
"files.associations": {}
},
"extensions": [
"ms-vscode.cpptools",
"ms-python.python",
"ms-vscode.vscode-embedded-tools",
"marus25.cortex-debug",
"plorefice.devicetree",
"PKief.material-icon-theme",
"streetsidesoftware.code-spell-checker"
]
}
}
}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
build
deps
.vscode
deps
49 changes: 49 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"command": "west",
"args": [
"build",
"${workspaceFolder}/app",
"--build-dir",
"${workspaceFolder}/app/build",
"-p",
"auto",
"-b",
"nucleo_f767zi"
],
"problemMatcher": [
"$gcc"
]
},
{
"label": "Clean",
"type": "shell",
"command": "rm",
"args": [
"-rf",
"${workspaceFolder}/app/build"
],
"problemMatcher": [
"$gcc"
]
},
{
"label": "Update",
"type": "shell",
"command": "west",
"args": [
"update"
]
}
]
}
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ Once the app is flashed open a serial monitor like PuTTY and reset your board.

| Memory region | Used Size | Region Size | %age Used |
| ------------- | ----------- | ----------- | ----------- |
| FLASH | 186708 B | 768 KB | 23.74% |
| RAM | 58824 B | 384 KB | 14.96% |
| FLASH | 186096 B | 768 KB | 23.66% |
| RAM | 65648 B | 384 KB | 16.70% |
| QSPI | 0 GB | 256 MB | 0.00% |
| DTCM | 12544 B | 128 KB | 9.57% |
| IDT_LIST | 0 GB | 2 KB | 0.00% |
Expand Down Expand Up @@ -79,6 +79,18 @@ Once the app is flashed open a serial monitor like PuTTY and reset your board.

- [x] Add NVS Storage class

- [x] Add HTTP client class

- [ ] Add an IoT app that reads die temperature, store it in NVS, retrieve it, format it then send it

- [ ] Run app in Renode

- [ ] Add configurable vscode tasks

- [x] Add vscode dev container environment

- [ ] Integrate Renode + robot in the CI workflow

- [ ] Build project with MCUBoot

- [ ] Solve the Shared Callback Registration problem in the Network class
Expand All @@ -97,14 +109,12 @@ Once the app is flashed open a serial monitor like PuTTY and reset your board.

- [ ] Add HIL tests using GitHub local runner

- [ ] Add application events manager
- [ ] Add application events manager using zbus

- [ ] Automate updating the README.md Build footprint table automatically by running a post build

- [ ] Add debouncing mechanism to Button class

- [ ] Add an IoT app that reads die temperature, store it in NVS, retrieve it, format it then send it

- [ ] Add OTA update example

- [ ] Add lambda callback to Button class
Expand All @@ -115,8 +125,6 @@ Once the app is flashed open a serial monitor like PuTTY and reset your board.

- [ ] Add Local class for managing local time and geo-location

- [ ] Add HTTP client class

- [ ] Add MQTT client class

- [ ] Add TCP class
Expand Down
26 changes: 26 additions & 0 deletions boards/nucleo_f767zi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,29 @@ CONFIG_UART_INTERRUPT_DRIVEN=y
# Die temperature
CONFIG_SENSOR=y
CONFIG_ADC=y

# Networking
CONFIG_NETWORKING=y
CONFIG_NET_LOG=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=n
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_POLL_MAX=4
CONFIG_NET_IPV6=n
CONFIG_NET_IPV4=y
CONFIG_NET_ARP=y
CONFIG_NET_TCP=y
CONFIG_NET_UDP=y
CONFIG_NET_DHCPV4=y
CONFIG_NET_HTTP_LOG_LEVEL_DBG=n
CONFIG_NET_SHELL=y
CONFIG_NET_MGMT=y
CONFIG_NET_MGMT_EVENT=y
CONFIG_NET_MGMT_EVENT_STACK_SIZE=1024
CONFIG_INIT_STACKS=y
CONFIG_SLIP_STATISTICS=n
CONFIG_TEST_RANDOM_GENERATOR=y

# HTTP
CONFIG_HTTP_CLIENT=y
9 changes: 9 additions & 0 deletions docs/notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### Class design
When it comes to class design for embedded systems and specifically microcontrollers there are different types of strategies.

There are BSP classes that are used to create an object that interact directly with hardware like a sensor or a peripheral, these are generally wrapper classes on top of the drivers.

There are Model classes that are used to describe and store object data, these are simply data holders that organize data in a single object replacing the old C data structuring.

There are Service classes that are used to create more complex objects that have their own threads of execution.

4 changes: 4 additions & 0 deletions include/HttpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class HttpClient {
HttpClient(char *server, uint16_t port);
~HttpClient();
int get(const char *endpoint, std::function<void(uint8_t *, uint32_t)> callback);
int post(const char *endpoint,
const char *data,
uint32_t length,
std::function<void(uint8_t *, uint32_t)> callback);

private:
int sock;
Expand Down
25 changes: 24 additions & 1 deletion linux.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@
"$gcc"
],
},
{
"label": "Configurable Build",
"type": "shell",
"group": {
"kind": "build",
},
"command": "${workspaceFolder}/.venv/bin/west",
"args": [
"build",
"${workspaceFolder}/app",
"--build-dir",
"${workspaceFolder}/app/build",
"-p",
"auto",
"-b",
"${input:board}"
],
"problemMatcher": [
"$gcc"
]
},
{
"label": "Flash",
"type": "shell",
Expand Down Expand Up @@ -154,7 +175,9 @@
"ms-python.python",
"ms-vscode.vscode-embedded-tools",
"marus25.cortex-debug",
"plorefice.devicetree"
"plorefice.devicetree",
"PKief.material-icon-theme",
"streetsidesoftware.code-spell-checker"
]
}
}
33 changes: 7 additions & 26 deletions prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,9 @@ CONFIG_CPP=y
CONFIG_STD_CPP20=y
CONFIG_REQUIRES_FULL_LIBCPP=y

# Networking
CONFIG_NETWORKING=y
CONFIG_NET_LOG=y
CONFIG_NET_STATISTICS=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=n
CONFIG_NET_SOCKETS_POSIX_NAMES=y
CONFIG_NET_SOCKETS_POLL_MAX=4
CONFIG_NET_IPV6=n
CONFIG_NET_IPV4=y
CONFIG_NET_ARP=y
CONFIG_NET_TCP=y
CONFIG_NET_UDP=y
CONFIG_NET_DHCPV4=y
CONFIG_NET_HTTP_LOG_LEVEL_DBG=y
CONFIG_NET_SHELL=y
CONFIG_NET_MGMT=y
CONFIG_NET_MGMT_EVENT=y
CONFIG_INIT_STACKS=y
CONFIG_SLIP_STATISTICS=n
CONFIG_TEST_RANDOM_GENERATOR=y

# HTTP
CONFIG_HTTP_CLIENT=y

# NVS
CONFIG_NVS=y
CONFIG_NVS_LOG_LEVEL_DBG=y
CONFIG_NVS_LOG_LEVEL_DBG=n
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y

Expand All @@ -46,3 +21,9 @@ CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_REBOOT=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_USE_DT_CODE_PARTITION=y

# ZBus
CONFIG_ZBUS=y
CONFIG_ZBUS_LOG_LEVEL_INF=y
CONFIG_ZBUS_CHANNEL_NAME=y
CONFIG_ZBUS_OBSERVER_NAME=y
Loading

0 comments on commit ab2249d

Please sign in to comment.