Skip to content

Commit

Permalink
enable jenkins build (fix #4)
Browse files Browse the repository at this point in the history
fix unit test configuration
fix test failing for bmp280
add default config (fix #13)
  • Loading branch information
kglowacki committed Sep 23, 2017
1 parent fb8e13b commit c40d466
Show file tree
Hide file tree
Showing 21 changed files with 1,090 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build/
sdkconfig
sdkconfig.*
sdkconfig.old
sdkconfig.bak
.DS_Store
main/*.bak
core.dat
Expand Down
6 changes: 6 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
Expand All @@ -23,5 +28,6 @@
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
5 changes: 5 additions & 0 deletions .pydevproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?><pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
</pydev_project>
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.5.0

- enable Jenkins build and automated unit tests ([#4](https://github.com/openairproject/sensor-esp32/issues/4))

# 0.4.3

- OTA updates ([#2](https://github.com/openairproject/sensor-esp32/issues/2))
Expand Down
31 changes: 31 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
pipeline {
agent any
stages {
stage('build') {
steps {
checkout scm
sh 'make clean'
sh 'make all -j5'
}
}
stage('test') {
steps {
sh 'bin/make_tests.sh'
sh 'sleep 3'
sh 'bin/run_tests.py'
}
}
stage('archive') {
steps {
sh 'cat build/sensor-esp32.bin | openssl dgst -sha256 > build/sensor-esp32.bin.sha256'
}
post {
success {
archiveArtifacts artifacts: 'build/sensor-esp32.*', fingerprint: true
archiveArtifacts artifacts: 'build/partitions_singleapp.bin', fingerprint: true
archiveArtifacts artifacts: 'build/bootloader/bootloader.bin', fingerprint: true
}
}
}
}
}
2 changes: 1 addition & 1 deletion coredump.sh → bin/coredump.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

$IDF_PATH/components/espcoredump/espcoredump.py info_corefile -t b64 -c core.dat build/sensor-esp32.elf
$IDF_PATH/components/espcoredump/espcoredump.py info_corefile -t b64 -c logs/core.dat build/sensor-esp32.elf
2 changes: 1 addition & 1 deletion coredump2.sh → bin/coredump2.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

$IDF_PATH/components/espcoredump/espcoredump.py dbg_corefile -t b64 -c core.dat build/sensor-esp32.elf
$IDF_PATH/components/espcoredump/espcoredump.py dbg_corefile -t b64 -c logs/core.dat build/sensor-esp32.elf
File renamed without changes.
File renamed without changes.
Empty file modified bin/firmware_installer.py
100644 → 100755
Empty file.
File renamed without changes.
5 changes: 4 additions & 1 deletion test.sh → bin/make_tests.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/bin/sh

#https://www.esp32.com/viewtopic.php?t=2867

project=`pwd`
make -C unit-test-app EXTRA_COMPONENT_DIRS=$project/components TEST_COMPONENTS='oap_common ota awsiot bmx280 pmsx003' flash monitor -j5
export BATCH_BUILD=1
make -C unit-test-app EXTRA_COMPONENT_DIRS=$project/components TEST_COMPONENTS='oap_common ota awsiot bmx280 pmsx003' defconfig all flash $1 -j5
42 changes: 42 additions & 0 deletions bin/run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/python
import serial
import sys
import time

ser = serial.Serial('/dev/tty.SLAB_USBtoUART',115200,timeout=1)

def readall(exp, timeout = 5):
line = ser.readline()
lastline = ''
start = time.time()
while line != exp:
lastline = line

if line == 'Rebooting...':
lastline = 'UNEXPECTED REBOOT'
break

if ":FAIL" in line or ":PASS" in line:
start = time.time()

if time.time() - start > timeout:
lastline = 'TIMEOUT after '+str(timeout)+' seconds'
break

line = ser.readline()
sys.stdout.write(line)
sys.stdout.flush()
line = line.strip()
return lastline

def wait_for_test_result():
return readall('Enter next test, or \'enter\' to see menu',10)

ser.write('\n');
readall('Here\'s the test menu, pick your combo:')
ser.write('*' if len(sys.argv) == 1 else sys.argv[1])
ser.write('\n')
result = wait_for_test_result().strip()
sys.stdout.write('TEST RESULT: '+result)
ser.close()
sys.exit(0 if result == 'OK' else 1)
9 changes: 7 additions & 2 deletions components/bmx280/i2c_bme280.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,11 @@ esp_err_t BME280_read(bme280_sensor_t* bme280_sensor, env_data* result){
temp_reading_t temp_reading = BME280_compensate_T_double(&bme280_sensor->calib, temp_raw);
result->temp = temp_reading.temp;//Celsius
result->pressure = BME280_compensate_P_double(&bme280_sensor->calib, temp_reading.t_fine, pres_raw) / 100.0; //hPA
result->humidity = BME280_compensate_H_double(&bme280_sensor->calib, temp_reading.t_fine, hum_raw);// pct

if (bme280_sensor->chip_type == CHIP_TYPE_BME) {
result->humidity = BME280_compensate_H_double(&bme280_sensor->calib, temp_reading.t_fine, hum_raw);// pct
} else {
result->humidity = HUMIDITY_MEAS_UNSUPPORTED;
}

return ESP_OK;
}
Expand All @@ -242,11 +245,13 @@ esp_err_t BME280_verify_chip(bme280_sensor_t* bme280_sensor) {

switch (chipID) {
case BME280_CHIP_ID:
bme280_sensor->chip_type=CHIP_TYPE_BME;
ESP_LOGI(TAG,"[%x] detected BME280 (0x%X)", bme280_sensor->i2c_comm.device_addr, chipID);
return ESP_OK;
case BMP280_CHIP_ID1:
case BMP280_CHIP_ID2:
case BMP280_CHIP_ID3:
bme280_sensor->chip_type=CHIP_TYPE_BMP;
ESP_LOGI(TAG,"[%x] detected BMP280 - no humidity data (0x%X)", bme280_sensor->i2c_comm.device_addr, chipID);
return ESP_OK;
default:
Expand Down
6 changes: 6 additions & 0 deletions components/bmx280/i2c_bme280.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#define BME280_MODE_NORMAL 0x03 //reads sensors at set interval
#define BME280_MODE_FORCED 0x01 //reads sensors once when you write this register

#define CHIP_TYPE_BMP 1
#define CHIP_TYPE_BME 2

#define HUMIDITY_MEAS_UNSUPPORTED -1

typedef struct bmx280_calib_t {
uint16_t dig_T1;
int16_t dig_T2;
Expand Down Expand Up @@ -55,6 +60,7 @@ typedef struct bme280_sensor_t {
uint8_t operation_mode;
i2c_comm_t i2c_comm;
bmx280_calib_t calib;
uint8_t chip_type;
} bme280_sensor_t;

esp_err_t BME280_verify_chip(bme280_sensor_t* bme280_sensor);
Expand Down
4 changes: 3 additions & 1 deletion components/bmx280/test/test_bmx280.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ TEST_CASE("bmx280 measurement","[bmx280]") {
TEST_ASSERT_EQUAL_UINT(9, last_result.sensor);
TEST_ASSERT_TRUE_MESSAGE(last_result.temp > 10 && last_result.temp < 50, "invalid temperature"); //let's assume we do it indoors ;)
TEST_ASSERT_TRUE_MESSAGE(last_result.pressure>850 && last_result.pressure < 1050, "invalid pressure");
TEST_ASSERT_TRUE_MESSAGE(last_result.humidity > 0 && last_result.humidity < 100, "invalid humidity"); //bme280 only
if (last_result.humidity != -1) {
TEST_ASSERT_TRUE_MESSAGE(last_result.humidity > 0 && last_result.humidity < 100, "invalid humidity"); //bme280 only
}
}
4 changes: 2 additions & 2 deletions components/oap_common/include/oap_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#include "esp_err.h"

#define OAP_VER_MAJOR 0
#define OAP_VER_MINOR 4
#define OAP_VER_PATCH 3
#define OAP_VER_MINOR 5
#define OAP_VER_PATCH 0

typedef struct {
uint8_t major;
Expand Down
2 changes: 1 addition & 1 deletion components/oap_common/oap_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static void storage_init_config() {
ESP_LOGE(TAG,"default config is not a proper json\n%s", str);
abort();
} else {
ESP_LOGI(TAG,"default config\n%s",str);
ESP_LOGD(TAG,"default config\n%s",str);
}
free(str);
storage_update_config(def_config);
Expand Down
Loading

0 comments on commit c40d466

Please sign in to comment.