" Wi-Fi Bluetooth", , Bluetooth-, ( ). , Bluetooth , . Wi-Fi- MAC- , , , Bluetooth (, ).
Bluetooth- (, ), (, ).
Automate, 15 Bluetooth- ,
Flow Automate
( ).
:
,
, :
import pandas as pd
import csv
#
input_file = "btlog.txt"
# ,
output_file = "formatted_file.csv"
with open(input_file, 'r', encoding='utf-8') as inp, open(output_file, 'w', newline='', encoding='utf-8') as out:
writer = csv.writer(out)
writer.writerow(["device name", "device address", "advertiser", "location", "datetime"])
for row in csv.reader(inp, delimiter=';'):
device_names = row[0].split(", ")
device_addresses = row[1].split(", ")
advertisers = row[2].split(", ")
location = f"{row[3]}, {row[4]}"
datetime = row[5]
min_len = min(len(device_names), len(device_addresses), len(advertisers))
for i in range(min_len):
writer.writerow([device_names[i], device_addresses[i], advertisers[i], location, datetime])
, , .
Google Colab, CSV- , .
:
!pip install pandas folium ipywidgets
import pandas as pd
import folium
from ipywidgets import interact
:
df = pd.read_csv('formatted_file.csv', sep=',')
df['location'] = df['location'].apply(lambda x: [float(i) for i in x.split(',')])
df['datetime'] = pd.to_datetime(df['datetime'])
df['device address'] = df['device address'].str.strip() #
df['device name'] = df['device name'].str.strip() #
df['frequency'] = df.groupby('device address')['device address'].transform('count')
df = df.sort_values(by='frequency', ascending=False)
# 'device_info', 'device name' 'device address'
df['device_info'] = df['device name'].fillna('unknown') + ' - ' + df['device address']
:
@interact
def search_device(device=list(df['device_info'].unique())):
return df[df['device_info'] == device]
:
def visualize_on_map(device_info):
device_data = df[df['device_info'] == device_info]
m = folium.Map(location=device_data['location'].iloc[0], zoom_start=13)
for _, row in device_data.iterrows():
folium.Marker(
location=row['location'],
popup=folium.Popup(': ' + str(row['datetime']), max_width=300)
).add_to(m)
return m
@interact
def interact_map(device=list(df['device_info'].unique())):
return visualize_on_map(device)
. , , , :
Flipper ,
. Por exemplo, 60- , . , . , , .
proof of concept .
, . , Bluetooth . , , , (não , ), ( Bluetooth- MAC- ).
. , Bluetooth, .
, , Bluetooth- . . .
george_gDev
habr.com