BTSMP1 EYE Pairing Needed?

Hi,
I’ve read the wiki and cannot figure this out.

UPDATE: Do I need to pair with the device to get magnet (or temperature) data? The docs are unclear

I am trying to do something that is very simple. I want to extract the presence/absence of a magnet for the EYE sensor. I am using an ESP32s3 microcontroller to gather this data via BLE. This is a new EYE device without any additional configuration. The simple application code for the esp32s3 is written in c (see code below).

No matter what I try, active or passive scanning, I always get data like this:

Advertisement Data (len=31): 02 01 06 03 03 aa fe 17 16 aa fe 00 e2 00 00 00 00 00 00 00 00 00 00 7c d9 f4 10 bf 8f 00 00
Eddystone-UID: TxPower=-30 dBm, Namespace=00000000000000000000, Instance=7cd9f410bf8f

In other words, I get the Eddystone-UUID, but nothing I can interpret to gather the magnet info. What am I doing wrong?

For completeness, here is a test snippet that looks at specific EYE mac address:

#include <esp_gap_ble_api.h>
#include <string.h>
#include <stdio.h>

static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) {
    if (event == ESP_GAP_BLE_SCAN_RESULT_EVT) {
        esp_ble_gap_cb_param_t *scan_result = param;
        // Filter by MAC address: 7c:d9:f4:10:bf:8f
        uint8_t target_mac[6] = {0x7c, 0xd9, 0xf4, 0x10, 0xbf, 0x8f};
        if (memcmp(scan_result->scan_rst.bda, target_mac, 6) == 0) {
            // Process inquiry result event
            if (scan_result->scan_rst.search_evt == ESP_GAP_SEARCH_INQ_RES_EVT) {
                uint8_t *adv_data = scan_result->scan_rst.ble_adv;
                uint32_t adv_data_len = scan_result->scan_rst.adv_data_len;

                // Debug: Print raw data
                printf("Advertisement Data (len=%u):", adv_data_len);
                for (uint32_t i = 0; i < adv_data_len; i++) {
                    printf(" %02x", adv_data[i]);
                }
                printf("\n");

                // Parse BLE advertisement fields
                int offset = 0;
                bool found_magnet_data = false;
                while (offset + 1 < adv_data_len) {
                    uint8_t field_len = adv_data[offset];
                    uint8_t field_type = adv_data[offset + 1];
                    if (field_len == 0 || offset + field_len + 1 > adv_data_len) {
                        printf("Error: Invalid field length %u at offset %d\n", field_len, offset);
                        break;
                    }

                    // Manufacturer-specific data (type 0xFF, Teltonika ID 0x089A)
                    if (field_type == 0xFF && field_len >= 4 && offset + 5 < adv_data_len) {
                        if (adv_data[offset + 2] == 0x9A && adv_data[offset + 3] == 0x08 &&
                            adv_data[offset + 4] == 0x01) { // Teltonika ID + protocol version
                            uint8_t flags = adv_data[offset + 5]; // Flags byte
                            printf("Teltonika Sensors data found: Flags=0x%02x\n", flags);
                            found_magnet_data = true;
                            if (flags & (1 << 2)) { // Bit 2: Magnet sensor active
                                if (flags & (1 << 3)) {
                                    printf("Magnet ON (magnetic field detected)\n");
                                } else {
                                    printf("Magnet OFF (no magnetic field detected)\n");
                                }
                            } else {
                                printf("Magnet sensor inactive (Bit 2=0)\n");
                            }
                            break; // Found magnet data
                        }
                    }
                    // Eddystone-UID (type 0x16, UUID 0xFEAA)
                    else if (field_type == 0x16 && offset + 4 < adv_data_len &&
                             adv_data[offset + 2] == 0xaa && adv_data[offset + 3] == 0xfe) {
                        if (offset + 21 < adv_data_len && adv_data[offset + 4] == 0x00) { // Eddystone-UID
                            printf("Eddystone-UID: TxPower=%d dBm, Namespace=", 
                                   (int8_t)adv_data[offset + 5]);
                            for (int i = 0; i < 10; i++) {
                                printf("%02x", adv_data[offset + 6 + i]);
                            }
                            printf(", Instance=");
                            for (int i = 0; i < 6; i++) {
                                printf("%02x", adv_data[offset + 16 + i]);
                            }
                            printf("\n");
                        }
                    }
                    offset += field_len + 1;
                }

                if (!found_magnet_data) {
                    printf("No Teltonika sensor data found in advertisement. Try active scanning for Scan Response or verify sensor configuration.\n");
                }
            }
        }
    }
}

void app_main() {
    esp_ble_scan_params_t scan_params = {
        .scan_type = BLE_SCAN_TYPE_PASSIVE, // Use passive scanning
        .own_addr_type = BLE_ADDR_TYPE_PUBLIC,
        .scan_interval = 0x100, // 256ms
        .scan_window = 0x100    // 256ms (match interval for continuous scanning)
    };
    esp_ble_gap_set_scan_params(&scan_params);
    esp_ble_gap_register_callback(esp_gap_cb);
    esp_ble_gap_start_scanning(0); // Scan indefinitely
}```

Hello @gamename,

I hope you are doing well. Eye sensor generally broadcasts its Beacon and Sensor Data, suggesting you to try to receive all the data from the sensor first before applying some parsing from your controller.

For more information about the sensor advertising data, kindly refer on this link: EYE SENSOR / BTSMP1 - Teltonika Telematics Wiki

Regards,
Patrick S.

This topic was automatically closed after 60 days. New replies are no longer allowed.