cancel
Showing results for 
Search instead for 
Did you mean: 

Getting STEVAL-BCN002V1B Mems Microphone Streamming Data using Ble protocol on Win10 PC python.

KOO
Associate

I'm working on a code for streaming STEVAL-BCN002V1B-BlueTile on Windows 10 PC Python.

The microphone data is notify property, and when I saw the BLE_SensorDemo.c file through StmIDE, the signal transmission of the microphone was configured as a state machine.

If I run my Python code alone on the PC, the microphone signal does not send to the PC. But

If you force the app to shut down while receiving microphone signals from the ST_BLE_Sensor app and execute Python code on your PC, you will be able to receive microphone signals.

So I want to modify the C file of BLE_SensorDemo so that the STEVAL-BCN002V1B chip itself can send a microphone signal as soon as Bluetooth is connected.

I want to put STEVAL-BCN002V1B into Bluetooth microphone streaming mode when it is powered on.

So I revised the C file several times, but it didn't work out, so I asked you a question. Give me some advice on what to do.

Here is Python test Code

------------------------------------------------------------------------------------------------------------

import asyncio

import bleak # bleak

from bleak import BleakClient

address = "D9:D4:30:7E:59:89" #you should change

# service uuid: 00000000-0001-11e1-9ab4-0002a5d5c51b

notity_charcteristic_uuid = "08000000-0001-11e1-ac36-0002a5d5c51b"

def notify_callback(sender: int, data: bytearray):

print('sender: ', sender, 'data: ', data)

async def run(address):

async with BleakClient(address, timeout=5.0) as client:

print('connected')

services = await client.get_services()

for service in services:

for characteristic in service.characteristics:

print(' uuid:', characteristic.uuid)

print(' handle:', characteristic.handle)

print(' properties: ', characteristic.properties)

if characteristic.uuid == "08000000-0001-11e1-ac36-0002a5d5c51b":

print('try to activate notify.')

while(1):

await client.start_notify(characteristic, notify_callback)

if client.is_connected:

print('try try try')

await asyncio.sleep(1)

print('try to deactivate notify.')

await client.stop_notify(notity_charcteristic_uuid)

print('disconnect')

loop = asyncio.get_event_loop()

loop.run_until_complete(run(address))

print('done')

----------------------------------------------------------------------------------------------------------

0 REPLIES 0