2025-05-15 7:37 AM
I am using a ST Sensor tile.box pro with FP-SNS-DATALOG2 function pack, I have already used the Python GUI software with USB connection and ST BLE Sensor app for data logging to save into the microSD card, which works fine.
Now , I would like to use python program to start the data logging process and possibly selecting the sensors for logging, for this, I am looking for the UUID related to these, and I can not find from the FP-SNS-DATALOG2 program. Where can I find related information for these?
I have used a BLE Sniffer app to look for the available UUID but little to no description I found from the FP-SNS-DATALOG2 code how it actually works with the app so that I can replicate for my needs.
Primary service/Unknown service 01:
COPY_CONSOLE_SERVICE_UUID 00 00 00 00 00 0E 11 e1 9a b4 00 02 a5 d5 c5 1b
Unknown Characteristics:
COPY_TERM_CHAR_UUID 00 00 00 01 00 0E 11 e1 ac 36 00 02 a5 d5 c5 1b
COPY_STDERR_CHAR_UUID 00 00 00 02 00 0E 11 e1 ac 36 00 02 a5 d5 c5 1b
Primary service/Unknown service 02:
COPY_FEATURES_SERVICE_UUID 00 00 00 00 00 01 11 e1 9a b4 00 02 a5 d5 c5 1b
Unknown Characteristics:
COPY_MACHINE_LEARNING_CORE_CHAR_UUID 00 00 00 0F 00 02 11 e1 ac 36 00 02 a5 d5 c5 1b
COPY_HIGH_SPEED_DATA_LOG_CHAR_UUID 00 00 00 11 00 02 11 e1 ac 36 00 02 a5 d5 c5 1b
COPY_EXT_CONFIG_CHAR_UUID 00 00 00 14 00 02 11 e1 ac 36 00 02 a5 d5 c5 1b
COPY_PNPLIKE_CHAR_UUID 00 00 00 1b 00 02 11 e1 ac 36 00 02 a5 d5 c5 1b
COPY_RAW_PNPL_CONTROLLED_CHAR_UUID 00 00 00 23 00 02 11 e1 ac 36 00 02 a5 d5 c5 1b
2025-06-20 1:43 AM
I could use USB to write commands to the device that works fine but BLE I could not.
I tried to write into this UUID
COPY_PNPLIKE_CHAR_UUID = "0000001b-0002-11e1-ac36-0002a5d5c51b"
These were my message
{\"stts22h_temp\":{\"enable\":true} {\"odr\": 1}}
{\"log_controller\": {\"start_log\": true}}
{\"log_controller\": {\"start_log\": false}}
according to packet headers
BLE_COMM_TP_START_PACKET = 0x00,
BLE_COMM_TP_START_END_PACKET = 0x20,
BLE_COMM_TP_MIDDLE_PACKET = 0x40,
BLE_COMM_TP_END_PACKET = 0x80,
BLE_COMM_TP_START_LONG_PACKET = 0x10
I then convert those messages to packets ( MTU = 20, packet = MTU-1 , 19bytes )
#temp setup packets
packet1 = "007b22737474733232685f74656d70223a7b2265"
packet2 = "406e61626c65223a747275657d207b226f647222"
packet3 = "803a20317d7d"
#log start packets
packet4 = "007b226c6f675f636f6e74726f6c6c6572223a20"
packet5 = "407b2273746172745f6c6f67223a20747275657d"
packet6 = "807d"
#log end packets
packet7 = "007b226c6f675f636f6e74726f6c6c6572223a20"
packet8 = "407b2273746172745f6c6f67223a2066616c7365"
packet9 = "807d7d"
Then I use this python code (note code is formed by Ai and online resources )
import asyncio
from bleak import BleakScanner, BleakClient
DEVICE_NAME = "HSD2v30"
WRITE_UUID = "0000001b-0002-11e1-ac36-0002a5d5c51b"
async def find_device_by_name(name):
print("Scanning for BLE devices...")
devices = await BleakScanner.discover(timeout=5.0)
for d in devices:
if d.name == name:
print(f"Found device: {d.name} ({d.address})")
return d.address
print(f"Device named '{name}' not found.")
return None
async def send_ble_packets():
address = await find_device_by_name(DEVICE_NAME)
if not address:
return
async with BleakClient(address) as client:
if not client.is_connected:
print("Failed to connect.")
return
print(f"Connected to {DEVICE_NAME} ({address})")
# temp setup packets
packet1 = bytes.fromhex("007b22737474733232685f74656d70223a7b2265")
packet2 = bytes.fromhex("406e61626c65223a747275657d207b226f647222")
packet3 = bytes.fromhex("803a20317d7d")
# log start packets
packet4 = bytes.fromhex("007b226c6f675f636f6e74726f6c6c6572223a20")
packet5 = bytes.fromhex("407b2273746172745f6c6f67223a20747275657d")
packet6 = bytes.fromhex("807d")
# log stop packets
packet7 = bytes.fromhex("007b226c6f675f636f6e74726f6c6c6572223a20")
packet8 = bytes.fromhex("407b2273746172745f6c6f67223a2066616c7365")
packet9 = bytes.fromhex("807d7d")
# send in order
for i, packet in enumerate([packet1, packet2, packet3]):
await client.write_gatt_char(WRITE_UUID, packet)
print(f"Sent setup packet {i+1}")
await asyncio.sleep(0.1)
for i, packet in enumerate([packet4, packet5, packet6]):
await client.write_gatt_char(WRITE_UUID, packet)
print(f"Sent start-log packet {i+1}")
await asyncio.sleep(10)
for i, packet in enumerate([packet7, packet8, packet9]):
await client.write_gatt_char(WRITE_UUID, packet)
print(f"Sent stop-log packet {i+1}")
asyncio.run(send_ble_packets())
so far this makes the Device unresponsive meaning BLE status Blink turned off. I was not sure about what the device is receiving and if I am writing at the correct UUID.
2025-06-25 7:57 AM - edited 2025-06-25 8:02 AM
Hi, @SimonePradolini so, apparently my above command messages were wrong to being with, to start the datalogging, I have checked the message in stdatalog_API_examples_HSDLink.py
{\"log_controller\": {\"start_log\": true}}
like this,
message = "{\"log_controller\": {\"start_log\": true}}"
print(hsd_link.send_command(hsd_link_instance, device_id, message))
( I want to start the logging onto the SD card, I believe, the interface has to be "0" , i do not know how to form that message )
here I get this output,
2025-06-25 16:36:04,353 - HSDatalogApp.stdatalog_core.HSD_link.communication.PnPL_HSD.hsd_dll - INFO - PnPL Response: {"PnPL_Error":"No writable Properties in DeviceInformation"}
{"PnPL_Error":"No writable Properties in DeviceInformation"}
In the stdatalog_API_examples_HSDLink.py start_log and stop_log is used directly but not through messages/command message, if I want to use BLE write, I would need these as a messages.
after looking at the python program (stdatalog_API_examples_HSDLink.py) it gets me nowhere to the bottom on how to form the message, it just ends at hsd_dll.py and finally wrapper file libhs_datalog_V2.dll which i cant check.
( Note that, I have added few prints to check what is the output, but the output does come from here but the python program takes me there )
def hs_datalog_send_message(self, dId : int, msg : str, msg_len : int) -> [bool, int, str]:
dIdC = ctypes.c_int(dId)
print(f'from hsd_dll dIdC {dIdC}')
msgC = ctypes.c_char_p(msg.encode('UTF-8'))
print(f'from hsd_dll msgC {msgC}')
msg_lenC = ctypes.c_int(msg_len)
print(f'from hsd_dll msg_lenC {msg_lenC}')
data_lenC = ctypes.c_int(0)
print(f'from hsd_dll data_lenC {data_lenC}')
dataC = ctypes.c_char_p()
print(f'from hsd_dll dataC/ctypes.c_char_p() {dataC}')
res = self.hsd_wrapper.hs_datalog_send_message(dIdC, msgC, msg_lenC, ctypes.byref(data_lenC), ctypes.byref(dataC))
print(f'from hsd_dll ctypes.byref(data_lenC) {ctypes.byref(data_lenC)}')
print("from hsd_dll {}".format(ctypes.byref(dataC)))
if res != ST_HS_DATALOG_ERROR:
if dataC.value is not None:
# data = dataC.value[:msg_len].decode('UTF-8')
data = dataC.value.decode('UTF-8')
print("from hsd_dll {}".format(data))
print("{} - HSDatauuulogApp.{} - INFO - PnPL Response: {}".format(logger.get_datetime(), __name__, data))
else:
data = "Command sent successfully!"
print(f'from hsd_dll {data}')
else:
return (False, 0, "[ERROR] - Command not sent correctly!")
self.__hs_datalog_free(dataC)
return (res == ST_HS_DATALOG_OK, data_lenC, data)
I would simply like to control few sensor tile box pro with datalog2 software using BLE and Python. Can you test at your end and describe it simply. I appreciate your time.