@@ -34,9 +34,8 @@ replace_value_at_position() {
3434
3535# Function
3636check_presence () {
37- TYPE=" $1 " # BLE MAC, LN
38- BLE_LN=" $2 "
39- BLE_MAC=" $3 "
37+ BLE_LN=" $1 "
38+ BLE_MAC=" $1 "
4039
4140 CURRENT_TIME_EPOCH=$( date +%s)
4241 MATCH=" ($BLE_LN |$BLE_MAC )"
@@ -54,10 +53,10 @@ check_presence() {
5453 echo $BLE_MAC
5554
5655 if echo " ${BLTCTL_OUT} " | grep -Eq " $MATCH " ; then
57- log_info " VIN $VIN $TYPE $MATCH presence detected"
56+ log_info " vin: $VIN ble_ln: $BLE_LN match: $MATCH presence detected"
5857
5958 if [ $CURRENT_TIME_EPOCH -ge $PRESENCE_EXPIRE_TIME ]; then
60- log_info " VIN $VIN $MATCH TTL expired, set presence ON"
59+ log_info " vin: $VIN ble_ln: $BLE_LN TTL expired, set presence ON"
6160 set +e
6261 # We need a function for mosquitto_pub w/ retry
6362 MQTT_OUT=$( eval $MOSQUITTO_PUB_BASE --nodelay -t " $MQTT_TOPIC " -m ON 2>&1 )
@@ -71,14 +70,14 @@ check_presence() {
7170
7271 # Update presence expire time
7372 EPOCH_EXPIRE_TIME=$(( CURRENT_TIME_EPOCH + PRESENCE_DETECTION_TTL))
74- log_debug " VIN $VIN $MATCH update presence expire time to $EPOCH_EXPIRE_TIME "
73+ log_debug " vin: $VIN ble_ln: $BLE_LN update presence expire time to $EPOCH_EXPIRE_TIME "
7574 PRESENCE_EXPIRE_TIME_LIST=$( replace_value_at_position " $PRESENCE_EXPIRE_TIME_LIST " \
7675 $position $EPOCH_EXPIRE_TIME )
7776 # END if MATCH
7877 else
79- log_debug " VIN $VIN $TYPE $MATCH presence not detected"
78+ log_debug " vin: $VIN ble_ln: $BLE_LN match: $MATCH presence not detected"
8079 if [ $CURRENT_TIME_EPOCH -ge $PRESENCE_EXPIRE_TIME ]; then
81- log_info " VIN $VIN $TYPE $MATCH presence has expired, setting presence OFF"
80+ log_info " vin: $VIN ble_ln: $BLE_LN presence has expired, setting presence OFF"
8281 set +e
8382 MQTT_OUT=$( eval $MOSQUITTO_PUB_BASE --nodelay -t " $MQTT_TOPIC " -m OFF 2>&1 )
8483 EXIT_STATUS=$?
@@ -88,7 +87,7 @@ check_presence() {
8887 return
8988 log_debug " mqtt topic $MQTT_TOPIC succesfully updated to OFF"
9089 else
91- log_info " VIN $VIN $TYPE $MATCH presence not expired"
90+ log_info " vin: $VIN ble_ln: $BLE_LN presence not expired"
9291 fi # END if expired time
9392 fi # END if ! MATCH
9493}
@@ -165,7 +164,7 @@ listen_to_ble() {
165164
166165 # Check the presence using both MAC Addr and BLE Local Name
167166 log_debug " BLTCTL_OUT:$( echo " $BLTCTL_OUT " | grep -E " ($BLE_MAC |$BLE_LN )" ) "
168- macAddr=$( check_presence " BLE LN & MAC " $BLE_LN $BLE_MAC )
167+ macAddr=$( check_presence $BLE_LN $BLE_MAC )
169168
170169 # Add the MAC address to BLE_MAC_LIST if it's not already present at the position
171170 if [ " $macAddr " != " $BLE_MAC " ]; then
0 commit comments