BLE Sniffing to resolve problems with Sylvac CalEvo (Pi 3 working, ESP32 not)

msebas
Posts: 1
Joined: Sun Jan 03, 2021 1:47 pm

BLE Sniffing to resolve problems with Sylvac CalEvo (Pi 3 working, ESP32 not)

Postby msebas » Sun Jan 03, 2021 2:51 pm

Hi everyone,

Short version:
I got one Sylvac S_CalEvo with an ISP091201 BLE module and I tried to read its values via BLE with an ESP32.
The ESP32 connects to the caliper, but when data is send the caliper displays an error message and nothing is reported on the ESP32.

Long version:
I got a Sylvac S_CalEvo with an ISP091201 BLE module (see https://www.sylvac.ch/download-en/manua ... e/download ) and build a talking caliper with it using a Pi Zero.
The Pi Zero empties the batteries in less than an hour which renders it unusable for a mobile solution.
I tried to do the same thing with an ESP32 based on the BLE_client sample sketch. The scanning and connecting to the device works fine without any problems. The next step is to register for a specific characteristic that sends an BLE indication contains the actual value as soon as a button on the caliper is pressed. The operation of registering seems to finish without any error (see attached debug output), but when I tried pushing the calipers button I got the error message 'No Data' ("no.dAtA" on the screen), which means that something transferring the data went wrong.

But the python script for the Pi is working fine and outputs the data as floats numbers terminated by a carriage return.

I am a little bit out of my league here. So down are the Arduino C++ code and the Python code working on the Pi (please ignore that the python code contains no pairing to shorten it, the pairing is done before starting the script and while the script is sleeping i pressed the data button on the caliper 4 times at different positions).

My next approach would be to buy a BLE sniffer and try to use it to get the actual details of the communication out of the devices, but this seems to be a non trivial task.
So if no one has any better idea I would like to ask if the nRF52840 Dongle ( https://www.nordicsemi.com/Software-and ... 840-Dongle ) would be able to sniff on a ESP32 and Pi3 using nRF Sniffer ( https://www.nordicsemi.com/Software-and ... d#infotabs ) or if there are better affordable solutions to sniffing those two.

Kind regards

The Arduino Sketch

Code: Select all

/*
  Example of connecting an ESP32 to the S_CalEvo with ISP091201

  Connect the WTV020SD16P to your ESP8266 and define the pins below.

  created by Noone711, 20.12.2020

  modified by Thomas A. Hirsch, 3 Nov 2019.
  original version created by ELECTRONOOBS, 14 Oct 2016.

  This example code is in the public domain.
*/

#include <Arduino.h>
#include <WTV020SD16P.h>

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>

#include "BLEDevice.h"

// The remote service we wish to connect to.
static BLEUUID serviceUUID("c1b25000-caaf-6d0e-4C33-7dae30052840");
// The characteristic of the remote service we are interested in.
static BLEUUID    charUUID("c1b25010-caaf-6d0e-4C33-7dae30052840");
static char deviceMAC[]="aa:bb:cc:dd:ee:ff";
static BLEAddress deviceAddress(deviceMAC);

static boolean doConnect = false;
static boolean connected = false;
static boolean doScan = false;
static BLERemoteCharacteristic* pRemoteCharacteristic;
static BLEAdvertisedDevice* myDevice;

class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
  void onResult(BLEAdvertisedDevice advertisedDevice) {
    if (!advertisedDevice.getAddress().equals(deviceAddress)){
    	Serial.printf("Found NOUT our searched device %s\n", advertisedDevice.getAddress().toString().c_str());
    	return;
    }
      BLEDevice::getScan()->stop();
      myDevice = new BLEAdvertisedDevice(advertisedDevice);
      doConnect = true;
      doScan = true;
  }
};

bool connectToServer();

void setup() {
	Serial.begin(115200);
	Serial.println("Serial started.");

	BLEDevice::init("");

	BLEScan* pBLEScan = BLEDevice::getScan();
	pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
	pBLEScan->setInterval(1349);
	pBLEScan->setWindow(449);
	pBLEScan->setActiveScan(true);
	pBLEScan->start(600, false);
}

void loop() {
	delay(2000);

	// If the flag "doConnect" is true then we have scanned for and found the desired
	// BLE Server with which we wish to connect.  Now we connect to it.  Once we are
	// connected we set the connected flag to be true.
	if (doConnect == true) {
		if (connectToServer()) {
		  Serial.println("We are now connected to the BLE Server.");
		} else {
		  Serial.println("We have failed to connect to the server; there is nothin more we will do.");
		}
		doConnect = false;
	}

	if(!connected && doScan){
		BLEDevice::getScan()->start(0);
	}
}

static void notifyCallback(
  BLERemoteCharacteristic* pBLERemoteCharacteristic,
  uint8_t* pData,  size_t length,  bool isNotify) {

    Serial.print("Notify callback for characteristic ");
    Serial.print(pBLERemoteCharacteristic->getUUID().toString().c_str());
    Serial.print(" of data length ");
    Serial.println(length);
    Serial.print("data: ");
    Serial.println((char*)pData);
}

class MyClientCallback : public BLEClientCallbacks {
  void onConnect(BLEClient* pclient) {
  }

  void onDisconnect(BLEClient* pclient) {
    connected = false;
    Serial.println("Disconnected.");
  }
};

bool connectToServer() {
    BLEClient*  pClient  = BLEDevice::createClient();
    pClient->setClientCallbacks(new MyClientCallback());

    if(!pClient->connect(myDevice)) {
    	Serial.println(" Failed to connected to server");
    	return false;
    }

    // Obtain a reference to the service we are after in the remote BLE server.
    BLERemoteService* pRemoteService = pClient->getService(serviceUUID);
    if (pRemoteService == nullptr) {
      Serial.print("Failed to find our service UUID: ");
      Serial.println(serviceUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }

    // Obtain a reference to the characteristic in the service of the remote BLE server.
    pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID);
    if (pRemoteCharacteristic == nullptr) {
      Serial.print("Failed to find our characteristic UUID: ");
      Serial.println(charUUID.toString().c_str());
      pClient->disconnect();
      return false;
    }

    if (pRemoteCharacteristic->canIndicate()){
		pRemoteCharacteristic->registerForNotify(notifyCallback, false);
	} else if(pRemoteCharacteristic->canNotify())
    	pRemoteCharacteristic->registerForNotify(notifyCallback, true);

    Serial.printf("Sucessfully connected to characteristic %s.\n"
    		"Properties: Read: %d\tWrite: %d\tNotify: %d\tIndicate %d\tBroadcast: %d\n",
			pRemoteCharacteristic->getUUID().toString().c_str(),
			pRemoteCharacteristic->canRead(),
			pRemoteCharacteristic->canWrite(),
			pRemoteCharacteristic->canNotify(),
			pRemoteCharacteristic->canIndicate(),
			pRemoteCharacteristic->canBroadcast());

    connected = true;
    return true;
}
The output of the ESP during pairing and a try to communicate by pushing the measure button on the caliper.
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
Serial started.
[V][BLEScan.cpp:195] start(): >> start(duration=600)
[D][FreeRTOS.cpp:189] take(): Semaphore taking: name: ScanEnd (0x3ffdd250), owner: <N/A> for start
[D][FreeRTOS.cpp:198] take(): Semaphore taken: name: ScanEnd (0x3ffdd250), owner: start
[V][BLEScan.cpp:227] start(): << start()
[V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: ScanEnd (0x3ffdd250), owner: start for start
[V][BLEUtils.cpp:1817] gapEventToString(): gapEventToString: Unknown event type 2 0x02
[V][BLEUtils.cpp:1049] dumpGapEvent(): Received a GAP event: Unknown event type
[V][BLEUtils.cpp:1264] dumpGapEvent(): *** dumpGapEvent: Logger not coded ***
[V][BLEUtils.cpp:1817] gapEventToString(): gapEventToString: Unknown event type 7 0x07
[V][BLEUtils.cpp:1049] dumpGapEvent(): Received a GAP event: Unknown event type
[V][BLEUtils.cpp:1264] dumpGapEvent(): *** dumpGapEvent: Logger not coded ***
[V][BLEUtils.cpp:1817] gapEventToString(): gapEventToString: Unknown event type 3 0x03
[V][BLEUtils.cpp:1049] dumpGapEvent(): Received a GAP event: Unknown event type
[V][BLEUtils.cpp:1264] dumpGapEvent(): *** dumpGapEvent: Logger not coded ***
[D][BLEAdvertisedDevice.cpp:418] setRSSI(): - setRSSI(): rssi: -86
[V][BLEUtils.cpp:746] advTypeToString(): adv data type: 0x1
[D][BLEAdvertisedDevice.cpp:247] parseAdvertisement(): Type: 0x01 (), length: 1, data: 05
[V][BLEUtils.cpp:746] advTypeToString(): adv data type: 0x9
[D][BLEAdvertisedDevice.cpp:247] parseAdvertisement(): Type: 0x09 (), length: 5, data: 5359323935
[D][BLEAdvertisedDevice.cpp:407] setName(): - setName(): name: SY295
[V][BLEScan.cpp:250] stop(): >> stop()
[V][FreeRTOS.cpp:143] give(): Semaphore giving: name: ScanEnd (0x3ffdd250), owner: start
[V][BLEScan.cpp:262] stop(): << stop()
[V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: ScanEnd (0x3ffdd250), owner: <N/A>
[V][BLEUtils.cpp:1817] gapEventToString(): gapEventToString: Unknown event type 18 0x12
[V][BLEUtils.cpp:1049] dumpGapEvent(): Received a GAP event: Unknown event type
[V][BLEUtils.cpp:1264] dumpGapEvent(): *** dumpGapEvent: Logger not coded ***
[V][BLEDevice.cpp:60] createClient(): >> createClient
[V][BLEDevice.cpp:66] createClient(): << createClient
[V][BLEClient.cpp:96] connect(): >> connect(aa:bb:cc:dd:ee:ff)
[BLEDevice.cpp:593] addPeerDevice(): add conn_id: 0, GATT role: client
[D][FreeRTOS.cpp:189] take(): Semaphore taking: name: RegEvt (0x3ffdd528), owner: <N/A> for connect
[D][FreeRTOS.cpp:198] take(): Semaphore taken: name: RegEvt (0x3ffdd528), owner: connect
[V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: RegEvt (0x3ffdd528), owner: connect for connect
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 0
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 0
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 0
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][FreeRTOS.cpp:143] give(): Semaphore giving: name: RegEvt (0x3ffdd528), owner: connect
[V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: RegEvt (0x3ffdd528), owner: <N/A>
[D][FreeRTOS.cpp:189] take(): Semaphore taking: name: OpenEvt (0x3ffdd3d8), owner: <N/A> for connect
[D][FreeRTOS.cpp:198] take(): Semaphore taken: name: OpenEvt (0x3ffdd3d8), owner: connect
[V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: OpenEvt (0x3ffdd3d8), owner: connect for connect
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 40
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 40
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 40
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[D][BLEDevice.cpp:577] updatePeerDevice(): update conn_id: 4, GATT role: client
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 2
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 2
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 2
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][FreeRTOS.cpp:143] give(): Semaphore giving: name: OpenEvt (0x3ffdd3d8), owner: connect
[V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: OpenEvt (0x3ffdd3d8), owner: <N/A>
[V][BLEClient.cpp:129] connect(): << connect(), rc=1
[V][BLEClient.cpp:377] getService(): >> getService: uuid: c1b25000-caaf-6d0e-4c33-7dae30052840
[V][BLEClient.cpp:413] getServices(): >> getServices
[V][BLEClient.cpp:71] clearServices(): >> clearServices
[V][BLEClient.cpp:78] clearServices(): << clearServices
[D][FreeRTOS.cpp:189] take(): Semaphore taking: name: SearchCmplEvt (0x3ffdd644), owner: <N/A> for getServices
[D][FreeRTOS.cpp:198] take(): Semaphore taken: name: SearchCmplEvt (0x3ffdd644), owner: getServices
[V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: SearchCmplEvt (0x3ffdd644), owner: getServices for getServices
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 7
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 7
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 7
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLERemoteService.cpp:26] BLERemoteService(): >> BLERemoteService()
[V][BLERemoteService.cpp:34] BLERemoteService(): << BLERemoteService()
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 7
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 7
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 7
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLERemoteService.cpp:26] BLERemoteService(): >> BLERemoteService()
[V][BLERemoteService.cpp:34] BLERemoteService(): << BLERemoteService()
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 7
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 7
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 7
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLERemoteService.cpp:26] BLERemoteService(): >> BLERemoteService()
[V][BLERemoteService.cpp:34] BLERemoteService(): << BLERemoteService()
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 6
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 6
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 6
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][FreeRTOS.cpp:143] give(): Semaphore giving: name: SearchCmplEvt (0x3ffdd644), owner: getServices
[V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: SearchCmplEvt (0x3ffdd644), owner: <N/A>
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 18
[V][BLEClient.cpp:430] getServices(): << getServices
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLEClient.cpp:390] getService(): << getService: found the service with uuid: c1b25000-caaf-6d0e-4c33-7dae30052840
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 18
[V][BLERemoteService.cpp:162] retrieveCharacteristics(): >> getCharacteristics() for service: c1b25000-caaf-6d0e-4c33-7dae30052840
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[D][BLERemoteService.cpp:193] retrieveCharacteristics(): Found a characteristic: Handle: 11, UUID: c1b25010-caaf-6d0e-4c33-7dae30052840
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 18
[V][BLERemoteCharacteristic.cpp:36] BLERemoteCharacteristic(): >> BLERemoteCharacteristic: handle: 11 0x11, uuid: c1b25010-caaf-6d0e-4c33-7dae30052840
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLERemoteCharacteristic.cpp:250] retrieveDescriptors(): >> retrieveDescriptors() for characteristic: c1b25010-caaf-6d0e-4c33-7dae30052840
[D][BLERemoteCharacteristic.cpp:280] retrieveDescriptors(): Found a descriptor: Handle: 12, UUID: 00002902-0000-1000-8000-00805f9b34fb
[V][BLERemoteCharacteristic.cpp:294] retrieveDescriptors(): << retrieveDescriptors(): Found 1 descriptors.
[V][BLERemoteCharacteristic.cpp:45] BLERemoteCharacteristic(): << BLERemoteCharacteristic
[D][BLERemoteService.cpp:193] retrieveCharacteristics(): Found a characteristic: Handle: 14, UUID: c1b25011-caaf-6d0e-4c33-7dae30052840
[V][BLERemoteCharacteristic.cpp:36] BLERemoteCharacteristic(): >> BLERemoteCharacteristic: handle: 14 0x14, uuid: c1b25011-caaf-6d0e-4c33-7dae30052840
[V][BLERemoteCharacteristic.cpp:250] retrieveDescriptors(): >> retrieveDescriptors() for characteristic: c1b25011-caaf-6d0e-4c33-7dae30052840
[E][BLERemoteCharacteristic.cpp:274] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[V][BLERemoteCharacteristic.cpp:294] retrieveDescriptors(): << retrieveDescriptors(): Found 0 descriptors.
[V][BLERemoteCharacteristic.cpp:45] BLERemoteCharacteristic(): << BLERemoteCharacteristic
[D][BLERemoteService.cpp:193] retrieveCharacteristics(): Found a characteristic: Handle: 16, UUID: c1b25012-caaf-6d0e-4c33-7dae30052840
[V][BLERemoteCharacteristic.cpp:36] BLERemoteCharacteristic(): >> BLERemoteCharacteristic: handle: 16 0x16, uuid: c1b25012-caaf-6d0e-4c33-7dae30052840
[V][BLERemoteCharacteristic.cpp:250] retrieveDescriptors(): >> retrieveDescriptors() for characteristic: c1b25012-caaf-6d0e-4c33-7dae30052840
[E][BLERemoteCharacteristic.cpp:274] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown
[V][BLERemoteCharacteristic.cpp:294] retrieveDescriptors(): << retrieveDescriptors(): Found 0 descriptors.
[V][BLERemoteCharacteristic.cpp:45] BLERemoteCharacteristic(): << BLERemoteCharacteristic
[D][BLERemoteService.cpp:193] retrieveCharacteristics(): Found a characteristic: Handle: 18, UUID: c1b25013-caaf-6d0e-4c33-7dae30052840
[V][BLERemoteCharacteristic.cpp:36] BLERemoteCharacteristic(): >> BLERemoteCharacteristic: handle: 18 0x18, uuid: c1b25013-caaf-6d0e-4c33-7dae30052840
[V][BLERemoteCharacteristic.cpp:250] retrieveDescriptors(): >> retrieveDescriptors() for characteristic: c1b25013-caaf-6d0e-4c33-7dae30052840
[D][BLERemoteCharacteristic.cpp:280] retrieveDescriptors(): Found a descriptor: Handle: 19, UUID: 00002902-0000-1000-8000-00805f9b34fb
[V][BLERemoteCharacteristic.cpp:294] retrieveDescriptors(): << retrieveDescriptors(): Found 1 descriptors.
[V][BLERemoteCharacteristic.cpp:45] BLERemoteCharacteristic(): << BLERemoteCharacteristic
[V][BLERemoteService.cpp:209] retrieveCharacteristics(): << getCharacteristics()
[V][BLERemoteCharacteristic.cpp:438] registerForNotify(): >> registerForNotify(): Characteristic: uuid: c1b25010-caaf-6d0e-4c33-7dae30052840, handle: 11 0x000b, props: broadcast: 0, read: 1, write_nr: 0, write: 0, notify: 0, indicate: 1, auth: 0
[D][FreeRTOS.cpp:189] take(): Semaphore taking: name: RegForNotifyEvt (0x3ffdedb0), owner: <N/A> for registerForNotify
[D][FreeRTOS.cpp:198] take(): Semaphore taken: name: RegForNotifyEvt (0x3ffdedb0), owner: registerForNotify
[V][BLERemoteCharacteristic.cpp:323] getDescriptor(): >> getDescriptor: uuid: 00002902-0000-1000-8000-00805f9b34fb
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 38
[V][BLERemoteCharacteristic.cpp:327] getDescriptor(): << getDescriptor: found
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][BLERemoteDescriptor.cpp:132] writeValue(): >> writeValue: handle: 12, uuid: 00002902-0000-1000-8000-00805f9b34fb
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 38
[V][BLERemoteDescriptor.cpp:151] writeValue(): << writeValue
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: RegForNotifyEvt (0x3ffdedb0), owner: registerForNotify for registerForNotify
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 38
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
[V][FreeRTOS.cpp:143] give(): Semaphore giving: name: RegForNotifyEvt (0x3ffdedb0), owner: registerForNotify
[V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: RegForNotifyEvt (0x3ffdedb0), owner: <N/A>
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 9
[V][BLERemoteCharacteristic.cpp:478] registerForNotify(): << registerForNotify()
[D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown
We are now connected to the BLE Server.[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 9
[V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 9
[D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown


The python code working on the Pi

Code: Select all

import pygatt
from pygatt.backends import BLEAddressType
import logging
from pygatt.backends.gatttool.gatttool import log
from time import sleep

d=None
recv=[]

handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
log.addHandler(handler)

log.setLevel(logging.DEBUG)

def btleCallback(dev,data):
    global recv
    recv.append(data)
        
def setupInstrument():
    try:
        if not d==None:
            d.disconnect()
    except:
        pass
    d=None
    d=adapter.connect("aa:bb:cc:dd:ee:ff",60,BLEAddressType.random)
    d.subscribe("C1B25010-CAAF-6D0E-4C33-7DAE30052840", btleCallback, indication=True)
    
setupInstrument()

#2020-12-25 21:32:00,552 - pygatt.backends.gatttool.gatttool - INFO - Connecting to aa:bb:cc:dd:ee:ff with timeout=60
#2020-12-25 21:32:02,067 - pygatt.backends.gatttool.gatttool - DEBUG - Found characteristic 00002a00-0000-1000-8000-00805f9b34fb, value handle: 0x3
#2020-12-25 21:32:02,071 - pygatt.backends.gatttool.gatttool - DEBUG - Found characteristic 00002a01-0000-1000-8000-00805f9b34fb, value handle: 0x5
#2020-12-25 21:32:02,091 - pygatt.backends.gatttool.gatttool - DEBUG - Found characteristic 00002a04-0000-1000-8000-00805f9b34fb, value handle: 0x7
#2020-12-25 21:32:02,104 - pygatt.backends.gatttool.gatttool - DEBUG - Found characteristic c1b25010-caaf-6d0e-4c33-7dae30052840, value handle: 0xb
#2020-12-25 21:32:02,113 - pygatt.backends.gatttool.gatttool - DEBUG - Found characteristic c1b25011-caaf-6d0e-4c33-7dae30052840, value handle: 0xe
#2020-12-25 21:32:02,119 - pygatt.backends.gatttool.gatttool - DEBUG - Found characteristic c1b25012-caaf-6d0e-4c33-7dae30052840, value handle: 0x10
#2020-12-25 21:32:02,122 - pygatt.backends.gatttool.gatttool - DEBUG - Found characteristic c1b25013-caaf-6d0e-4c33-7dae30052840, value handle: 0x12
#2020-12-25 21:32:03,222 - pygatt.backends.gatttool.gatttool - DEBUG - Sending cmd=char-write-req 0x0c 0200
#2020-12-25 21:32:03,338 - pygatt.backends.gatttool.gatttool - INFO - Sent cmd=char-write-req 0x0c 0200

sleep(60)

print(str(recv))
#[bytearray(b'+000.00\r'), bytearray(b'+007.11\r'), bytearray(b'+019.80\r'), bytearray(b'+034.94\r')]

Who is online

Users browsing this forum: No registered users and 63 guests