diff --git a/api/Jenkinsfile.ble_test b/api/Jenkinsfile.ble_test index 100c7e0..a9b8402 100644 --- a/api/Jenkinsfile.ble_test +++ b/api/Jenkinsfile.ble_test @@ -24,7 +24,7 @@ pipeline { stages { // --------------------------------------------------------------------- - // 1. Build a unique screen session name + // 1. Build a unique screen session name, disable MOTD // --------------------------------------------------------------------- stage('Prepare Test Hash') { steps { @@ -36,7 +36,15 @@ pipeline { env.TEST_HASH = "${String.format('%06d', epochSec % 1_000_000)}" - sh "echo Test Hash - ${env.TEST_HASH}" + sh """ + cd /tmp + echo Test Hash - ${env.TEST_HASH} + echo Disabling MOTD... + touch .hushlogin + scp .hushlogin root@${params.host_ip}:/root/.hushlogin + + """ + } } } @@ -49,6 +57,7 @@ pipeline { sshagent([env.SSH_CREDENTIALS_ID]) { sh """ ssh -q -o StrictHostKeyChecking=no root@${params.host_ip} -o ServerAliveInterval=60 -o ServerAliveCountMax=120 << EOF + echo Checking for screen application... if ! command -v screen > /dev/null; then echo "screen not found - installing" apt-get update && apt-get install -y screen @@ -66,6 +75,7 @@ pipeline { sshagent([env.SSH_CREDENTIALS_ID]) { sh """ ssh -q -o StrictHostKeyChecking=no root@${params.host_ip} -o ServerAliveInterval=60 -o ServerAliveCountMax=120 << EOF + echo Starting BLE test sleep 5 cd /opt/ble-test/ble_api git pull diff --git a/api/ble.py b/api/ble.py index 4af2ad0..8fa3e40 100644 --- a/api/ble.py +++ b/api/ble.py @@ -282,6 +282,7 @@ def test_driver(test_count = 0, bt_usb_id = None): #################################################### # here is the big main test loop # only for second function + # it loops until all MACs in mac_list are found #################################################### while not test_complete: @@ -325,7 +326,7 @@ def test_driver(test_count = 0, bt_usb_id = None): log.warning(f" Test run incomplete/failed, attempt {len(mac_history)} of {reset_retries}, re-running, loop {test_loop_count}. Updating test list.") print_sensor_data(sensors) # here is where test_list might shrink - test_list = get_failed_macs(sensors, mac_list, passed_list) + test_list = get_failed_macs(mac_list, passed_list) log.warning(f" Re-do list - {test_list}") # end of the big main test loop and test_driver function @@ -336,7 +337,7 @@ def test_driver(test_count = 0, bt_usb_id = None): # helper function for summarizing test run results def summarize_test_run(sensors): - log.info(f" {sensor['name']} - Temp: {round(temp_f,1)} | Humidity: {sensor['humidity']}") + log.info(f" {sensors['name']} - Temp: {temp_ctof(sensors['name'])} | Humidity: {sensors['humidity']}") result = { "found_macs": found_macs, "sensor_results": sensors @@ -345,7 +346,7 @@ def summarize_test_run(sensors): return result # helper function for processing failed tests -def get_failed_macs(sensors, mac_list, passed_list): +def get_failed_macs(mac_list, passed_list): mac_list_new = [] for mac in mac_list: if mac not in passed_list: @@ -356,8 +357,12 @@ def get_failed_macs(sensors, mac_list, passed_list): def print_sensor_data(sensors): for sensor in sensors: # Sorry I can't feel celcius, I want my freedom degrees - temp_f = (sensor['temp'] * 1.80) + 32.0 - log.info(f" {sensor['name']} - Temp: {round(temp_f,1)} | Humidity: {sensor['humidity']}") + log.info(f" {sensor['name']} - Temp: {temp_ctof(sensor['temp'])} | Humidity: {sensor['humidity']}") + +# yes i am an insufferable american that doesn't think in celcius, sue me +def temp_ctof(c_temp): + f_temp = (c_temp * 1.80) + 32.0 + return f_temp # This resets the BT adapter when things go caca def reset_adapter():