doc(pico-sensor): updated readme with remote tests informations

This commit is contained in:
SylvanArnold
2025-06-04 10:51:17 +02:00
parent 2a5b481d66
commit 0bb52a3a07
6 changed files with 88 additions and 25 deletions

View File

@@ -1,11 +1,11 @@
# TSM_PicoW_Sensor
Project using the PicoW board. It publish sensors values (humidity, temperature) to an MQTT broker.
This project uses the PicoW board to publish sensor values (humidity and temperature) to an MQTT broker.
## Configuration
## Target Configuration
You have to use the serial terminal (Baud rate of 115200) to configure the board by sending commands. The application will then store the parameters in flash memory. You have to restart the device to update the changes.
Use a serial terminal (baud rate: 115200) to configure the board by sending commands. The application stores the parameters in flash memory. You must restart the device to apply any changes.
### Wifi
### Wi-Fi
```shell
McuMinINI write settings.ini WiFi ssid "YOUR_SSID"
@@ -14,7 +14,7 @@ McuMinINI write settings.ini WiFi pass "YOUR_PASSWORD"
### MQTT
Broker informations:
Broker information:
```shell
McuMinINI write settings.ini MQTT broker "BROKER_NAME"
McuMinINI write settings.ini MQTT user "USERNAME"
@@ -30,29 +30,60 @@ McuMinINI write settings.ini MQTT topic_send_measurement "<user>/<room>/<device>
## Build
Project has `Debug`, `Release` and `Test` targets, using CMake Presets.
Configure:
```
**Configure:**
```shell
cmake --list-presets
cmake --preset Debug
cmake --preset Release
cmake --preset Test
```
Build:
```
**Build:**
```shell
cmake --build --list-presets
cmake --build --preset app-debug
cmake --build --preset app-release
cmake --build --preset app-test
```
Test:
```
**Test:**
```shell
ctest --list-presets
ctest --test-dir build/Test -R Led_1
```
Worflow:
```
**Workflow:**
```shell
cmake --workflow --list-presets
```
## Running Tests on Another Machine
To run tests on a target connected to another machine (e.g., in a GitLab CI pipeline), follow these steps:
### On the Host Machine
Set up a J-Link tunnel to make the target accessible from anywhere:
```shell
JLinkRemoteServerCL -UseTunnel -TunnelBySN
```
The terminal output should look like this:
```
2025-06-04 08:43:57 - Remote Server started
2025-06-04 08:43:57 - Connected to J-Link with S/N 801000372
2025-06-04 08:43:57 - Resolving tunnel server name (jlink-europe.segger.com)...
2025-06-04 08:43:57 - Tunnel server IP: 185.162.249.2
2025-06-04 08:43:57 - Registered at tunnel server
2025-06-04 08:43:57 - Waiting for client connection
```
`801000372` is the tunnel ID required to reach the target. Include it in your CMake command:
```shell
cmake --preset Test -DTUNNEL_ID=801000372
```
When you run the tests, they will automatically execute on the host machine.

View File

View File

View File

@@ -0,0 +1,27 @@
/*
* Copyright (c) 2025, Sylvan Arnold
*
*/
#include "platform.h"
#if PL_CONFIG_USE_UNIT_TESTS
#include "test_sensors.h"
#include "unity.h"
#include "sensor.h"
void TestSensors_Test(void) {
float temp, hum;
/* Test that initial sensor values are within a reasonable range */
temp = Sensor_GetTemperature();
hum = Sensor_GetHumidity();
/* Check temperature is within plausible sensor range (-40°C to 125°C) */
TEST_ASSERT_TRUE_MESSAGE(temp > -50.0f && temp < 130.0f, "Temperature out of range");
/* Check humidity is within plausible sensor range (0% to 100%) */
TEST_ASSERT_TRUE_MESSAGE(hum >= 0.0f && hum <= 100.0f, "Humidity out of range");
/* Optionally, check that values are not both zero (unless sensor is uninitialized) */
TEST_ASSERT_FALSE_MESSAGE(temp == 0.0f && hum == 0.0f, "Sensor values are both zero, possible init error");
}
# endif

View File

@@ -0,0 +1,11 @@
/*
* Copyright (c) 2025, Sylvan Arnold
*
*/
#ifndef _TEST_SENSORS_H__
#define _TEST_SENSORS_H__
void TestSensors_Test(void);
#endif /* _TEST_SENSORS_H__ */

View File

@@ -14,10 +14,10 @@
#include "McuRTT.h"
#include "McuUtility.h"
#include "McuLog.h"
//#include "test_sensor.h"
//#include "test_leds.h"
#include "test_sensors.h"
#include "test_dns_resolver.h"
static void TestArgFailed(void) {
TEST_ASSERT_MESSAGE(false, "wrong test_arg value");
}
@@ -36,18 +36,12 @@ void Tests_Run(void) {
nofBytes = McuUnity_RTT_GetArgs(buf, sizeof(buf));
UNITY_BEGIN();
if (nofBytes>0) {
if (McuUtility_strcmp(buf, "led")==0) {
//RUN_TEST(TestLeds_OnOff);
//RUN_TEST(TestLeds_Toggle);
} else if (McuUtility_strcmp(buf, "sensor")==0) {
//RUN_TEST(TestSensor_Temperature);
//RUN_TEST(TestSensor_Humidity);
//RUN_TEST(TestSensor_Both);
if (McuUtility_strcmp(buf, "dummy")==0) {
RUN_TEST(TestDummy);
} else if (McuUtility_strcmp(buf, "sensors")==0) {
RUN_TEST(TestSensors_Test);
} else if (McuUtility_strcmp(buf, "dns")==0) {
RUN_TEST(TestDnsResolver_Test);
}
else if (McuUtility_strcmp(buf, "dummy")==0) {
RUN_TEST(TestDummy);
}
else {
RUN_TEST(TestArgFailed);