-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
179 additions
and
8 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
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,63 @@ | ||
# Examples | ||
|
||
This directory contains application examples of how to use ucxclient. The examples make use of the [example ports](port/README.md). | ||
|
||
| Files | Description | | ||
| -------------------- | ----------- | | ||
| http_example.c | Example of doing a HTTP GET request using the uCx API. | | ||
| http_example_no_os.c | Same example as http_example.c but illustrating how it could be done on a bare-metal system with no OS. | | ||
|
||
## Building | ||
|
||
To build all the examples on a Linux based system, just execute the following in repo root if you prefer Makefile: | ||
|
||
```sh | ||
> cmake -S . -B build -G "Unix Makefiles" | ||
> make -C build | ||
``` | ||
|
||
or if you prefer Ninja: | ||
|
||
```sh | ||
> cmake -S . -B build -G "Ninja" | ||
> ninja -C build | ||
``` | ||
|
||
## Running | ||
|
||
### http_example | ||
|
||
If you have built http_example using the steps above it will be built for Linux and located in `build/http_example`. | ||
To start it you will need to pass some arguments: | ||
|
||
``` | ||
http_example <device> <SSID> <WPA_PSK> | ||
device: the UART device that is connected to a u-connectXpress module | ||
SSID: the Wi-Fi SSID to connect to | ||
WPA_PSK: the Wi-Fi WPA PSK | ||
``` | ||
|
||
Example: | ||
|
||
```sh | ||
> build/http_example /dev/ttyUSB0 MySSID MyWiFiPasswd | ||
``` | ||
|
||
### http_example_no_os | ||
|
||
Just like http_example this example will also be compiled for Linux, but in this case the UART device, Wi-Fi SSID and PSK are configured using defines. | ||
To set these defines using CMake you can either use `cmake-gui`: | ||
|
||
![cmake-gui](/images/cmake-gui.png) | ||
|
||
or from command line: | ||
|
||
```sh | ||
> cmake -S . -B build -D U_EXAMPLE_UART="/dev/ttyUSB0" -D U_EXAMPLE_SSID="MySSID" -D U_EXAMPLE_WPA_PSK="MyWiFiPasswd" | ||
``` | ||
|
||
Now you should be able to start the example using: | ||
|
||
```sh | ||
> build/http_example_no_os | ||
``` |
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,22 @@ | ||
# Port Examples | ||
|
||
This directory contains example ports that you can either use out-of-box or use as inspiration. | ||
|
||
| Files | Description | | ||
| ------------- | ----------- | | ||
| u_port.h | A common API mainly for being able to run the [example code](/examples/README.md) using any of the ports. | | ||
| u_port_posix | A Linux port example using Posix threads. | | ||
| u_port_no_os | A "no OS" port example to illustrate how ucxclient could be ported to a bare-metal system. The UART and time porting layer is using Linux API for this example so you will need to adjust it for your specific target. | | ||
| u_port_zephyr | A Zephyr port example. You will find details on how to use it in [/zephyr/README.md](/zephyr/README.md). | | ||
|
||
## Using an Example Port | ||
|
||
You can tell ucxclient which port to use by using the following defines during build: | ||
|
||
| Port | Define | | ||
| ------------- | -------------- | | ||
| u_port_posix | `U_PORT_POSIX` | | ||
| u_port_no_os | `U_PORT_NO_OS` | | ||
| u_port_zephyr | No define needed; it will be selected automatically if you use ucxclient as a Zephyr module (see [/zephyr/README.md](/zephyr/README.md)). | | ||
|
||
You will also need to add corresponding .c file to your build (not needed for Zephyr). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,56 @@ | ||
# Zephyr Module | ||
|
||
ucxclient can be used as a Zephyr module for easy integration to your Zephyr application. | ||
|
||
## Adding ucxclient to Your Zephyr App | ||
|
||
There are several ways of including ucxclient to your Zephyr application. | ||
|
||
### Using `west.yml` manifest | ||
|
||
If you use a `west.yml` manifest for your application then you can add ucxclient as to the list of projects like this: | ||
|
||
```yml | ||
manifest: | ||
remotes: | ||
- name: zephyrproject-rtos | ||
url-base: https://github.com/zephyrproject-rtos | ||
- name: u-blox | ||
url-base: https://github.com/u-blox | ||
|
||
projects: | ||
- name: zephyr | ||
remote: zephyrproject-rtos | ||
revision: main | ||
|
||
- name: ucxclient | ||
remote: u-blox | ||
repo-path: ucxclient.git | ||
revision: master | ||
``` | ||
There is a very useful Zephyr example app illustrating how to create folder structure etc for a Zephyr application using a `west.yml` manifest file available here: | ||
[https://github.com/zephyrproject-rtos/example-application](https://github.com/zephyrproject-rtos/example-application) | ||
|
||
### Using `ZEPHYR_MODULES` CMake Variable | ||
|
||
With this method you need to clone ucxclient manually or use git submodule or similar. | ||
After that you need to add the path of ucxclient to the `ZEPHYR_MODULES` CMake variable. | ||
This can be done in several ways as described here: | ||
[https://docs.zephyrproject.org/latest/develop/modules.html#without-west](https://docs.zephyrproject.org/latest/develop/modules.html#without-west) | ||
|
||
## Config | ||
|
||
To build ucxclient with your Zephyr application you must add the following to your `prj.conf`: | ||
|
||
```ini | ||
CONFIG_SERIAL=y | ||
CONFIG_UART_INTERRUPT_DRIVEN=y | ||
CONFIG_RING_BUFFER=y | ||
CONFIG_UCXCLIENT=y | ||
``` | ||
|
||
The current Zephyr port only support the interrupt driven UART API. | ||
|
||
Further configuration of ucxclient are also possible. | ||
Use [menuconfig](https://docs.zephyrproject.org/latest/build/kconfig/menuconfig.html) to view and configure these. |