//doordu_bluetooth.c
/*
* doordu_bluetooth.c - Open the door by bluetooth.
*
* Copyright (C) 2016-2019, LomboTech Co.Ltd.
* Author: lomboswer <lomboswer@lombotech.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <pthread.h>
#include <signal.h>
#include "doordu_bluetooth.h"
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>
//#include "doordu_open_door.h"
#include "dd_util.h"
#include "ddble.h"
#include "db_config.h"
#include "time_conv.h"
#include "face.h"
#include "db_punch_record.h"
#include "common_record_info.h"
#define LOG_TAG "doordu_bluetooth"
#include <log/log.h>
#define EIR_FLAGS 0x01 /* flags */
#define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */
#define EIR_UUID16_ALL 0x03 /* 16-bit UUID, all listed */
#define EIR_UUID32_SOME 0x04 /* 32-bit UUID, more available */
#define EIR_UUID32_ALL 0x05 /* 32-bit UUID, all listed */
#define EIR_UUID128_SOME 0x06 /* 128-bit UUID, more available */
#define EIR_UUID128_ALL 0x07 /* 128-bit UUID, all listed */
#define EIR_NAME_SHORT 0x08 /* shortened local name */
#define EIR_NAME_COMPLETE 0x09 /* complete local name */
#define EIR_TX_POWER 0x0A /* transmit power level */
#define EIR_DEVICE_ID 0x10 /* device ID */
#define EIR_DATA_MANU 0xFF /* manufacturer specific data */
static volatile int signal_received;
char filter_src[256];
static unsigned int time_tramp;
#define RESERVED_ID_LEN 2
#define RESERVED_ID "5243"
#define BLE_MAC_LEN 6
#define TEMPERATURE_DATA_LEN 8
#define BLE_INVALID_LEN 0
#define BLE_MAX_LEN 17
typedef struct ble_temperature_tag {
char reserved_id[RESERVED_ID_LEN * 2 + 1];
char ble_mac[BLE_MAC_LEN * 2 + 1];
float temperature_data;
char ble_invalid[BLE_INVALID_LEN * 2 + 1];
int valid_count;
} ble_temperature_t;
static ble_temperature_t global_temperature;
static void sigint_handler(int sig)
{
signal_received = sig;
}
float get_bt_rand_temp()
{
return 35.5 + (float)(rand() % 10) / 10;
}
float getK(float env_temp){
float x1 = 36.1f;
float x2 = 36.2f;
float y1 = 0.982726f;
float y2 = 0.982551f;
float a = (y1 - y2) / (x1 - x2);
float b = y1 - x1 * a;
float value = a * env_temp + b;
return value;
}
setting_show_temp_ui_cb m_setting_temp_ui_cb;
void factorytest_setting_show_temp_ui_cb(setting_show_temp_ui_cb cb)
{
m_setting_temp_ui_cb = cb;
}
bt_show_temp_ui_cb m_show_temp_ui_cb;
void bt_face_show_temp_ui_cb(show_temp_ui_cb cb)
{
m_show_temp_ui_cb = cb;
}
bt_hide_temp_ui_cb m_hide_temp_ui_cb;
void bt_face_hide_temp_ui_cb(hide_temp_ui_cb cb)
{
m_hide_temp_ui_cb = cb;
}
punch_record_t punch_record;
void bt_set_punch_record(punch_record_t record)
{
punch_record = record;
}
void ble_reset_temp(void)
{
memset(
RTL8723WIFI 蓝牙(待修改)
最新推荐文章于 2025-03-03 09:42:19 发布