mirror of
https://github.com/colonelpanichacks/flock-you.git
synced 2026-06-15 00:03:33 -07:00
Add files via upload
This commit is contained in:
+187
@@ -81,6 +81,48 @@ static const char* device_name_patterns[] = {
|
||||
"Pigvision" // Pigvision surveillance systems
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// RAVEN SURVEILLANCE DEVICE UUID PATTERNS
|
||||
// ============================================================================
|
||||
// These UUIDs are specific to Raven surveillance devices (acoustic gunshot detection)
|
||||
// Source: raven_configurations.json - firmware versions 1.1.7, 1.2.0, 1.3.1
|
||||
|
||||
// Raven Device Information Service (used across all firmware versions)
|
||||
#define RAVEN_DEVICE_INFO_SERVICE "0000180a-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
// Raven GPS Location Service (firmware 1.2.0+)
|
||||
#define RAVEN_GPS_SERVICE "00003100-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
// Raven Power/Battery Service (firmware 1.2.0+)
|
||||
#define RAVEN_POWER_SERVICE "00003200-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
// Raven Network Status Service (firmware 1.2.0+)
|
||||
#define RAVEN_NETWORK_SERVICE "00003300-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
// Raven Upload Statistics Service (firmware 1.2.0+)
|
||||
#define RAVEN_UPLOAD_SERVICE "00003400-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
// Raven Error/Failure Service (firmware 1.2.0+)
|
||||
#define RAVEN_ERROR_SERVICE "00003500-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
// Health Thermometer Service (firmware 1.1.7)
|
||||
#define RAVEN_OLD_HEALTH_SERVICE "00001809-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
// Location and Navigation Service (firmware 1.1.7)
|
||||
#define RAVEN_OLD_LOCATION_SERVICE "00001819-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
// Known Raven service UUIDs for detection
|
||||
static const char* raven_service_uuids[] = {
|
||||
RAVEN_DEVICE_INFO_SERVICE, // Device info (all versions)
|
||||
RAVEN_GPS_SERVICE, // GPS data (1.2.0+)
|
||||
RAVEN_POWER_SERVICE, // Battery/Solar (1.2.0+)
|
||||
RAVEN_NETWORK_SERVICE, // LTE/WiFi status (1.2.0+)
|
||||
RAVEN_UPLOAD_SERVICE, // Upload stats (1.2.0+)
|
||||
RAVEN_ERROR_SERVICE, // Error tracking (1.2.0+)
|
||||
RAVEN_OLD_HEALTH_SERVICE, // Old health service (1.1.7)
|
||||
RAVEN_OLD_LOCATION_SERVICE // Old location service (1.1.7)
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// GLOBAL VARIABLES
|
||||
// ============================================================================
|
||||
@@ -338,6 +380,100 @@ bool check_device_name_pattern(const char* name)
|
||||
return false;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// RAVEN UUID DETECTION
|
||||
// ============================================================================
|
||||
|
||||
// Check if a BLE device advertises any Raven surveillance service UUIDs
|
||||
bool check_raven_service_uuid(NimBLEAdvertisedDevice* device, char* detected_service_out = nullptr)
|
||||
{
|
||||
if (!device) return false;
|
||||
|
||||
// Check if device has service UUIDs
|
||||
if (!device->haveServiceUUID()) return false;
|
||||
|
||||
// Get the number of service UUIDs
|
||||
int serviceCount = device->getServiceUUIDCount();
|
||||
if (serviceCount == 0) return false;
|
||||
|
||||
// Check each advertised service UUID against known Raven UUIDs
|
||||
for (int i = 0; i < serviceCount; i++) {
|
||||
NimBLEUUID serviceUUID = device->getServiceUUID(i);
|
||||
std::string uuidStr = serviceUUID.toString();
|
||||
|
||||
// Compare against each known Raven service UUID
|
||||
for (int j = 0; j < sizeof(raven_service_uuids)/sizeof(raven_service_uuids[0]); j++) {
|
||||
if (strcasecmp(uuidStr.c_str(), raven_service_uuids[j]) == 0) {
|
||||
// Match found! Store the detected service UUID if requested
|
||||
if (detected_service_out != nullptr) {
|
||||
strncpy(detected_service_out, uuidStr.c_str(), 40);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get a human-readable description of the Raven service
|
||||
const char* get_raven_service_description(const char* uuid)
|
||||
{
|
||||
if (!uuid) return "Unknown Service";
|
||||
|
||||
if (strcasecmp(uuid, RAVEN_DEVICE_INFO_SERVICE) == 0)
|
||||
return "Device Information (Serial, Model, Firmware)";
|
||||
if (strcasecmp(uuid, RAVEN_GPS_SERVICE) == 0)
|
||||
return "GPS Location Service (Lat/Lon/Alt)";
|
||||
if (strcasecmp(uuid, RAVEN_POWER_SERVICE) == 0)
|
||||
return "Power Management (Battery/Solar)";
|
||||
if (strcasecmp(uuid, RAVEN_NETWORK_SERVICE) == 0)
|
||||
return "Network Status (LTE/WiFi)";
|
||||
if (strcasecmp(uuid, RAVEN_UPLOAD_SERVICE) == 0)
|
||||
return "Upload Statistics Service";
|
||||
if (strcasecmp(uuid, RAVEN_ERROR_SERVICE) == 0)
|
||||
return "Error/Failure Tracking Service";
|
||||
if (strcasecmp(uuid, RAVEN_OLD_HEALTH_SERVICE) == 0)
|
||||
return "Health/Temperature Service (Legacy)";
|
||||
if (strcasecmp(uuid, RAVEN_OLD_LOCATION_SERVICE) == 0)
|
||||
return "Location Service (Legacy)";
|
||||
|
||||
return "Unknown Raven Service";
|
||||
}
|
||||
|
||||
// Estimate firmware version based on detected service UUIDs
|
||||
const char* estimate_raven_firmware_version(NimBLEAdvertisedDevice* device)
|
||||
{
|
||||
if (!device || !device->haveServiceUUID()) return "Unknown";
|
||||
|
||||
bool has_new_gps = false;
|
||||
bool has_old_location = false;
|
||||
bool has_power_service = false;
|
||||
|
||||
int serviceCount = device->getServiceUUIDCount();
|
||||
for (int i = 0; i < serviceCount; i++) {
|
||||
NimBLEUUID serviceUUID = device->getServiceUUID(i);
|
||||
std::string uuidStr = serviceUUID.toString();
|
||||
|
||||
if (strcasecmp(uuidStr.c_str(), RAVEN_GPS_SERVICE) == 0)
|
||||
has_new_gps = true;
|
||||
if (strcasecmp(uuidStr.c_str(), RAVEN_OLD_LOCATION_SERVICE) == 0)
|
||||
has_old_location = true;
|
||||
if (strcasecmp(uuidStr.c_str(), RAVEN_POWER_SERVICE) == 0)
|
||||
has_power_service = true;
|
||||
}
|
||||
|
||||
// Firmware version heuristics based on service presence
|
||||
if (has_old_location && !has_new_gps)
|
||||
return "1.1.x (Legacy)";
|
||||
if (has_new_gps && !has_power_service)
|
||||
return "1.2.x";
|
||||
if (has_new_gps && has_power_service)
|
||||
return "1.3.x (Latest)";
|
||||
|
||||
return "Unknown Version";
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// WIFI PROMISCUOUS MODE HANDLER
|
||||
// ============================================================================
|
||||
@@ -457,6 +593,57 @@ class AdvertisedDeviceCallbacks: public NimBLEAdvertisedDeviceCallbacks {
|
||||
last_detection_time = millis();
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for Raven surveillance device service UUIDs
|
||||
char detected_service_uuid[41] = {0};
|
||||
if (check_raven_service_uuid(advertisedDevice, detected_service_uuid)) {
|
||||
// Raven device detected! Get firmware version estimate
|
||||
const char* fw_version = estimate_raven_firmware_version(advertisedDevice);
|
||||
const char* service_desc = get_raven_service_description(detected_service_uuid);
|
||||
|
||||
// Create enhanced JSON output with Raven-specific data
|
||||
StaticJsonDocument<1024> doc;
|
||||
doc["protocol"] = "bluetooth_le";
|
||||
doc["detection_method"] = "raven_service_uuid";
|
||||
doc["device_type"] = "RAVEN_GUNSHOT_DETECTOR";
|
||||
doc["manufacturer"] = "SoundThinking/ShotSpotter";
|
||||
doc["mac_address"] = addrStr.c_str();
|
||||
doc["rssi"] = rssi;
|
||||
doc["signal_strength"] = rssi > -50 ? "STRONG" : (rssi > -70 ? "MEDIUM" : "WEAK");
|
||||
|
||||
if (!name.empty()) {
|
||||
doc["device_name"] = name.c_str();
|
||||
}
|
||||
|
||||
// Raven-specific information
|
||||
doc["raven_service_uuid"] = detected_service_uuid;
|
||||
doc["raven_service_description"] = service_desc;
|
||||
doc["raven_firmware_version"] = fw_version;
|
||||
doc["threat_level"] = "CRITICAL";
|
||||
doc["threat_score"] = 100;
|
||||
|
||||
// List all detected service UUIDs
|
||||
if (advertisedDevice->haveServiceUUID()) {
|
||||
JsonArray services = doc.createNestedArray("service_uuids");
|
||||
int serviceCount = advertisedDevice->getServiceUUIDCount();
|
||||
for (int i = 0; i < serviceCount; i++) {
|
||||
NimBLEUUID serviceUUID = advertisedDevice->getServiceUUID(i);
|
||||
services.add(serviceUUID.toString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// Output the detection
|
||||
serializeJson(doc, Serial);
|
||||
Serial.println();
|
||||
|
||||
if (!triggered) {
|
||||
triggered = true;
|
||||
flock_detected_beep_sequence();
|
||||
}
|
||||
// Always update detection time for heartbeat tracking
|
||||
last_detection_time = millis();
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user