2020-07-14 20:54:14 +02:00
|
|
|
// Copyright 2020 Lukas Haubaum
|
|
|
|
//
|
|
|
|
// Licensed under the GNU Affero General Public License, Version 3;
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
|
|
|
// https://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2020-07-27 16:54:51 +02:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
*
|
|
|
|
* @brief handles scanned data by storing temporary beacons, check for threshold and store beacons permanently
|
|
|
|
*
|
|
|
|
*/
|
2020-07-15 22:22:54 +02:00
|
|
|
#ifndef _ena_BEACON_H_
|
|
|
|
#define _ena_BEACON_H_
|
2020-07-11 12:11:34 +02:00
|
|
|
|
2020-07-27 16:54:51 +02:00
|
|
|
#define ENA_BEACON_LOG "ESP-ENA-beacon" // TAG for Logging
|
|
|
|
#define ENA_BEACON_TRESHOLD (CONFIG_ENA_BEACON_TRESHOLD) // meet for longer than 5 minutes
|
|
|
|
#define ENA_BEACON_CLEANUP_TRESHOLD (CONFIG_ENA_BEACON_CLEANUP_TRESHOLD) // threshold (in days) for stored beacons to be removed
|
2020-07-11 12:11:34 +02:00
|
|
|
|
2020-07-14 20:54:14 +02:00
|
|
|
/**
|
2020-07-15 22:22:54 +02:00
|
|
|
* @brief check temporary beacon for threshold or expiring
|
2020-07-14 20:54:14 +02:00
|
|
|
*
|
2020-07-15 22:22:54 +02:00
|
|
|
* This function checks all current temporary beacons if the contact threshold is
|
2020-07-14 20:54:14 +02:00
|
|
|
* reached or if the temporary contact can be discarded.
|
|
|
|
*
|
2020-07-27 16:54:51 +02:00
|
|
|
* @param[in] unix_timestamp current time as UNIX timestamp to compare
|
2020-07-14 20:54:14 +02:00
|
|
|
*
|
|
|
|
*/
|
2020-07-15 22:22:54 +02:00
|
|
|
void ena_beacons_temp_refresh(uint32_t unix_timestamp);
|
2020-07-11 12:11:34 +02:00
|
|
|
|
2020-07-27 16:54:51 +02:00
|
|
|
/**
|
|
|
|
* @brief check stored beacons to expire
|
|
|
|
*
|
|
|
|
* This function checks for all stored beacons if the last timestamp is over a threshold to remove the beacon.
|
|
|
|
*
|
|
|
|
* @param[in] unix_timestamp current time as UNIX timestamp to compate
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void ena_beacons_cleanup(uint32_t unix_timestamp);
|
|
|
|
|
2020-07-14 20:54:14 +02:00
|
|
|
/**
|
2020-07-15 22:22:54 +02:00
|
|
|
* @brief handle new beacon received from a BLE scan
|
2020-07-14 20:54:14 +02:00
|
|
|
*
|
|
|
|
* This function gets called when a running BLE scan received a new ENA payload.
|
|
|
|
* On already detected RPI this will update just the timestamp and RSSI.
|
|
|
|
*
|
2020-07-15 22:22:54 +02:00
|
|
|
* @param[in] unix_timestamp UNIX timestamp when beacon was made
|
2020-07-14 20:54:14 +02:00
|
|
|
* @param[in] rpi received RPI from scanned payload
|
|
|
|
* @param[in] aem received AEM from scanned payload
|
|
|
|
* @param[in] rssi measured RSSI on scan
|
|
|
|
*
|
|
|
|
*/
|
2020-07-15 22:22:54 +02:00
|
|
|
void ena_beacon(uint32_t unix_timestamp, uint8_t *rpi, uint8_t *aem, int rssi);
|
2020-07-11 12:11:34 +02:00
|
|
|
|
|
|
|
#endif
|