Skip to content

# Python API

### API for controlling blueSPY from Python.

Provides functions for connecting to a moreph and loading existing captures. Also provides a `packets` object, which behaves like a list and can be used to access the packets in the current file.
`len(packets)` shows the number of available packets; `packets[0]` accesses the first packet.
The queries documented in the GUI can be accessed with attribute syntax, e.g. `packets[0].summary`.

### Examples

To connect to a moreph with serial 00010100 and capture CL and LE:

    python
    import bluespy
    from time import sleep

    bluespy.connect(0x00010100)
    bluespy.capture("example.pcapng", CL=True, LE=True)
    sleep(20)
    bluespy.stop_capture()
    bluespy.disconnect()
    print(f"Captured {len(bluespy.packets)} packets")
    bluespy.close_file()

To load an existing capture and print the summary strings of all packets:

    import bluespy
    bluespy.load_file("example.pcapng")

    for p in bluespy.packets:
        print(p.summary)

    bluespy.close_file()

## audiostreams `module-attribute`

    audiostreams = Audiostreams()

Iterable over all audio streams

## connections `module-attribute`

    connections = Connections()

Iterable over all connections

## devices `module-attribute`

    devices = Devices()

Iterable over all devices

## packets `module-attribute`

    packets = Packets()

Iterable over all packets

## BluespyError

Bases: `RuntimeError`

Exception showing why an operation failed.

Source code in `application/bluespy.py`

    127
    128
    129
    130
    131
    132
    class BluespyError(RuntimeError):
        """Exception showing why an operation failed."""

        def get_error(self):
            """Return the underlying error object."""
            return self.args[0]

### get_error

    get_error()

Return the underlying error object.

Source code in `application/bluespy.py`

    130
    131
    132
    def get_error(self):
        """Return the underlying error object."""
        return self.args[0]

## Packets

Bases: `object`

List-like object representing the currently loaded baseband packets.

Source code in `application/bluespy.py`

    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    class Packets(object):
        """List-like object representing the currently loaded baseband packets."""

        def __len__(self):
            """Current number of baseband packets captured"""
            return _libbluespy.bluespy_packet_count()

        def __getitem__(self, i: int) -> event_id:
            """
            Get an event_id for a packet

            :param i: Index of packet, 0 <= i < __len__()
            :return: An event_id

            :exception IndexError: Index out of bounds.
            """
            i = int(i)
            if i < 0 or i >= _libbluespy.bluespy_packet_count():
                raise IndexError()
            return _libbluespy.bluespy_get_baseband(i)

### __getitem__

    __getitem__(i)

Get an event_id for a packet

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`i` | `int` | Index of packet, 0 <= i < len() | required

Returns:

Type | Description
--- | ---
`event_id` | An event_id

Raises:

Type | Description
--- | ---
`IndexError` | Index out of bounds.

Source code in `application/bluespy.py`

    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    def __getitem__(self, i: int) -> event_id:
        """
        Get an event_id for a packet

        :param i: Index of packet, 0 <= i < __len__()
        :return: An event_id

        :exception IndexError: Index out of bounds.
        """
        i = int(i)
        if i < 0 or i >= _libbluespy.bluespy_packet_count():
            raise IndexError()
        return _libbluespy.bluespy_get_baseband(i)

### __len__

    __len__()

Current number of baseband packets captured

Source code in `application/bluespy.py`

    786
    787
    788
    def __len__(self):
        """Current number of baseband packets captured"""
        return _libbluespy.bluespy_packet_count()

## audiopod_options

Bases: `object`

Audiopod capture options

Source code in `application/bluespy.py`

    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    class audiopod_options(object):
        """Audiopod capture options"""
        def __init__(self,
            channels: audio_channel=audio_channel.STEREO,
            output: audio_connect=audio_connect.NOAUDIO,
            input: audio_connect=audio_connect.NOAUDIO,
            bias: audio_bias=audio_bias.OFF,
            sample_rate: int=0,
            current_probe: bool=False,
            LA_low_voltage: float= 0.0,
            LA_high_voltage: float= 0.0,
            power_supply_V: float=0.0,
            VIO_dV: float= 0.0,
            second_I2S_input: bool=False,
            AGC: bool=False,
            DRC: bool=False,
            vol_in_left: float= 0.0,
            vol_in_right: float= 0.0,
            vol_out_left: float= 0.0,
            vol_out_right: float= 0.0,
        ):
            """
            :param channels: Audiopod Channels
            :param output: Which audiopod port is used for output
            :param input: Which audiopod port is used for intput
            :param bias: Audiopod bias
            :param sample_rate: Audiopod sample rate
                Allowed values are: 8'000, 11'025, 16'000, 22'050, 32'000, 44'100, 48'000, 88'200, 96'000, 176'400, 192'000
            :param current_probe: Enable current probe
            :param LA_low_voltage: Logic Low Voltage. Must be within the [0.0, 3.3] range.
            :param LA_high_voltage: Logic High Voltage. Must be within the [0.0, 3.3] range.
                Allowed values for Audiopod_Logic(Low/High)Voltage are from 0.0 to 3.3
            :param power_supply_V: Power supply in volts
                Allowed values are from 0.6 to 5.0
            :param VIO_dV: VIO in deciVolts
            :param second_I2S_input: Enable a second I2S input, output must be set to BLUESPY_NO_AUDIO
            :param AGC: AGC
            :param DRC: DRC
            :param vol_in_left: Input volume (Left)
            :param vol_in_right: Input volume (Right)
            :param vol_out_left: Output volume (Left)
            :param vol_out_right: Output volume (Right)
            """
            object.__setattr__(self, "p", _libbluespy.bluespy_capture_audiopod_options_alloc())
            self.p.contents.sample_rate = sample_rate
            self.p.contents.channels = channels
            self.p.contents.output = output
            self.p.contents.input = input
            self.p.contents.bias = bias
            self.p.contents.current_probe = current_probe
            self.p.contents.LA_low_voltage = LA_low_voltage
            self.p.contents.LA_high_voltage = LA_high_voltage
            self.p.contents.power_supply_V = power_supply_V
            self.p.contents.VIO_dV = VIO_dV
            self.p.contents.second_I2S_input = second_I2S_input
            self.p.contents.AGC = AGC
            self.p.contents.DRC = DRC
            self.p.contents.vol_in_left = vol_in_left
            self.p.contents.vol_in_right = vol_in_right
            self.p.contents.vol_out_left = vol_out_left
            self.p.contents.vol_out_right = vol_out_right
        def __del__(self):
            _libbluespy.bluespy_delete(self.p)
        def __getattr__(self, name):
            if name == "p":
                return self.__getattribute__("p")
            return getattr(self.p.contents, name)
        def __setattr__(self, name, val):
            self.p.contents.__setattr__(name,val)

### __init__

    __init__(channels=audio_channel.STEREO, output=audio_connect.NOAUDIO, input=audio_connect.NOAUDIO, bias=audio_bias.OFF, sample_rate=0, current_probe=False, LA_low_voltage=0.0, LA_high_voltage=0.0, power_supply_V=0.0, VIO_dV=0.0, second_I2S_input=False, AGC=False, DRC=False, vol_in_left=0.0, vol_in_right=0.0, vol_out_left=0.0, vol_out_right=0.0)

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`channels` | `audio_channel` | Audiopod Channels | `STEREO`
`output` | `audio_connect` | Which audiopod port is used for output | `NOAUDIO`
`input` | `audio_connect` | Which audiopod port is used for intput | `NOAUDIO`
`bias` | `audio_bias` | Audiopod bias | `OFF`
`sample_rate` | `int` | Audiopod sample rate Allowed values are: 8'000, 11'025, 16'000, 22'050, 32'000, 44'100, 48'000, 88'200, 96'000, 176'400, 192'000 | `0`
`current_probe` | `bool` | Enable current probe | `False`
`LA_low_voltage` | `float` | Logic Low Voltage. Must be within the [0.0, 3.3] range. | `0.0`
`LA_high_voltage` | `float` | Logic High Voltage. Must be within the [0.0, 3.3] range. Allowed values for Audiopod_Logic(Low/High)Voltage are from 0.0 to 3.3 | `0.0`
`power_supply_V` | `float` | Power supply in volts Allowed values are from 0.6 to 5.0 | `0.0`
`VIO_dV` | `float` | VIO in deciVolts | `0.0`
`second_I2S_input` | `bool` | Enable a second I2S input, output must be set to BLUESPY_NO_AUDIO | `False`
`AGC` | `bool` | AGC | `False`
`DRC` | `bool` | DRC | `False`
`vol_in_left` | `float` | Input volume (Left) | `0.0`
`vol_in_right` | `float` | Input volume (Right) | `0.0`
`vol_out_left` | `float` | Output volume (Left) | `0.0`
`vol_out_right` | `float` | Output volume (Right) | `0.0`

Source code in `application/bluespy.py`

    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    def __init__(self,
        channels: audio_channel=audio_channel.STEREO,
        output: audio_connect=audio_connect.NOAUDIO,
        input: audio_connect=audio_connect.NOAUDIO,
        bias: audio_bias=audio_bias.OFF,
        sample_rate: int=0,
        current_probe: bool=False,
        LA_low_voltage: float= 0.0,
        LA_high_voltage: float= 0.0,
        power_supply_V: float=0.0,
        VIO_dV: float= 0.0,
        second_I2S_input: bool=False,
        AGC: bool=False,
        DRC: bool=False,
        vol_in_left: float= 0.0,
        vol_in_right: float= 0.0,
        vol_out_left: float= 0.0,
        vol_out_right: float= 0.0,
    ):
        """
        :param channels: Audiopod Channels
        :param output: Which audiopod port is used for output
        :param input: Which audiopod port is used for intput
        :param bias: Audiopod bias
        :param sample_rate: Audiopod sample rate
            Allowed values are: 8'000, 11'025, 16'000, 22'050, 32'000, 44'100, 48'000, 88'200, 96'000, 176'400, 192'000
        :param current_probe: Enable current probe
        :param LA_low_voltage: Logic Low Voltage. Must be within the [0.0, 3.3] range.
        :param LA_high_voltage: Logic High Voltage. Must be within the [0.0, 3.3] range.
            Allowed values for Audiopod_Logic(Low/High)Voltage are from 0.0 to 3.3
        :param power_supply_V: Power supply in volts
            Allowed values are from 0.6 to 5.0
        :param VIO_dV: VIO in deciVolts
        :param second_I2S_input: Enable a second I2S input, output must be set to BLUESPY_NO_AUDIO
        :param AGC: AGC
        :param DRC: DRC
        :param vol_in_left: Input volume (Left)
        :param vol_in_right: Input volume (Right)
        :param vol_out_left: Output volume (Left)
        :param vol_out_right: Output volume (Right)
        """
        object.__setattr__(self, "p", _libbluespy.bluespy_capture_audiopod_options_alloc())
        self.p.contents.sample_rate = sample_rate
        self.p.contents.channels = channels
        self.p.contents.output = output
        self.p.contents.input = input
        self.p.contents.bias = bias
        self.p.contents.current_probe = current_probe
        self.p.contents.LA_low_voltage = LA_low_voltage
        self.p.contents.LA_high_voltage = LA_high_voltage
        self.p.contents.power_supply_V = power_supply_V
        self.p.contents.VIO_dV = VIO_dV
        self.p.contents.second_I2S_input = second_I2S_input
        self.p.contents.AGC = AGC
        self.p.contents.DRC = DRC
        self.p.contents.vol_in_left = vol_in_left
        self.p.contents.vol_in_right = vol_in_right
        self.p.contents.vol_out_left = vol_out_left
        self.p.contents.vol_out_right = vol_out_right

## audiostream_id

Bases: `id`

An object referencing a audio stream.

Do not make your own, only get these from the audio stream id functions. Audio Stream IDs are ordered arbitrarily After running close_file(), do not call any methods on any existing audiostream_id objects.

Source code in `application/bluespy.py`

    755
    756
    757
    758
    759
    760
    761
    762
    class audiostream_id(id):
        """
        An object referencing a audio stream.

        Do not make your own, only get these from the audio stream id functions.
        Audio Stream IDs are ordered arbitrarily
        After running close_file(), do not call any methods on any existing audiostream_id objects.
        """

## connection_id

Bases: `id`

An object referencing a connection.

Do not make your own, only get these from the connection id functions. Connection IDs are ordered arbitrarily After running close_file(), do not call any methods on any existing connection_id objects.

Source code in `application/bluespy.py`

    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    class connection_id(id):
        """
        An object referencing a connection.

        Do not make your own, only get these from the connection id functions.
        Connection IDs are ordered arbitrarily
        After running close_file(), do not call any methods on any existing connection_id objects.
        """
        def get_audio_streams(self) -> list['audiostream_id']:
            """Get the audio streams
            :return: Array of audio streams IDs"""
            stream_id_span = _libbluespy.bluespy_get_audiostreams(self)
            return [stream_id_span.data[i] for i in range(stream_id_span.size)]

### get_audio_streams

    get_audio_streams()

Get the audio streams

Returns:

Type | Description
--- | ---
`list[audiostream_id]` | Array of audio streams IDs

Source code in `application/bluespy.py`

    749
    750
    751
    752
    753
    def get_audio_streams(self) -> list['audiostream_id']:
        """Get the audio streams
        :return: Array of audio streams IDs"""
        stream_id_span = _libbluespy.bluespy_get_audiostreams(self)
        return [stream_id_span.data[i] for i in range(stream_id_span.size)]

## device_id

Bases: `id`

An object referencing a device.

Do not make your own, only get these from the device id functions. Device IDs are ordered arbitrarily After running close_file(), do not call any methods on any existing device_id objects.

Source code in `application/bluespy.py`

    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    class device_id(id):
        """
        An object referencing a device.

        Do not make your own, only get these from the device id functions.
        Device IDs are ordered arbitrarily
        After running close_file(), do not call any methods on any existing device_id objects.
        """
        def get_connections(self) -> list['connection_id']:
            """Get the connections
            :return: Array of connection IDs"""
            conn_id_span = _libbluespy.bluespy_get_connections(self)
            return [conn_id_span.data[i] for i in range(conn_id_span.size)]

        def get_audio_streams(self) -> list['audiostream_id']:
            """Get the audio streams
            :return: Array of audio streams IDs"""
            stream_id_span = _libbluespy.bluespy_get_audiostreams(self)
            return [stream_id_span.data[i] for i in range(stream_id_span.size)]

### get_audio_streams

    get_audio_streams()

Get the audio streams

Returns:

Type | Description
--- | ---
`list[audiostream_id]` | Array of audio streams IDs

Source code in `application/bluespy.py`

    735
    736
    737
    738
    739
    def get_audio_streams(self) -> list['audiostream_id']:
        """Get the audio streams
        :return: Array of audio streams IDs"""
        stream_id_span = _libbluespy.bluespy_get_audiostreams(self)
        return [stream_id_span.data[i] for i in range(stream_id_span.size)]

### get_connections

    get_connections()

Get the connections

Returns:

Type | Description
--- | ---
`list[connection_id]` | Array of connection IDs

Source code in `application/bluespy.py`

    729
    730
    731
    732
    733
    def get_connections(self) -> list['connection_id']:
        """Get the connections
        :return: Array of connection IDs"""
        conn_id_span = _libbluespy.bluespy_get_connections(self)
        return [conn_id_span.data[i] for i in range(conn_id_span.size)]

## error

Bases: `c_int`

Return type showing why an operation failed.

Evaluates to True if the operation succeeded, else False. str() and repr() give an error string, .value gives an error code.

Source code in `application/bluespy.py`

     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    class error(_ct.c_int):
        """Return type showing why an operation failed.

        Evaluates to True if the operation succeeded, else False.
        str() and repr() give an error string, .value gives an error code.
        """

        def __str__(self):
            return _libbluespy.bluespy_error_string(self.value).decode("utf-8")

        def __repr__(self):
            return "{}: {}".format(self.value, self.__str__()) if self.value else ""

        def __bool__(self):
            return self.value == 0

## event_id

Bases: `id`

An object referencing a loaded packet.

Do not make your own, only get these from the 'packets' object. After running close_file(), do not call any methods on any existing event_id objects.

Any query (see the documentation or Help->Query List in the GUI) can be accessed as an attribute on this object

Source code in `application/bluespy.py`

    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    class event_id(id):
        """
        An object referencing a loaded packet.

        Do not make your own, only get these from the 'packets' object.
        After running close_file(), do not call any methods on any existing event_id objects.

        Any query (see the documentation or Help->Query List in the GUI) can be accessed as an attribute on this object
        """

        def parent(self) -> 'event_id':
            """Get the a higher layer packet that contains this one.
            e.g. if this is a baseband data packet get the L2CAP packet it is part of.

            :return: event_id"""
            return _libbluespy.bluespy_get_parent(self)

        def children(self) -> list['event_id']:
            """Get all constituent packets of this packet.
            e.g. if this is an L2CAP packet

            :return: List of event_ids"""
            count = _ct.c_uint32()
            c = _libbluespy.bluespy_get_children(self, _ct.byref(count))
            return (
                list(_ct.cast(c, _ct.POINTER(event_id * count.value)).contents)
                if count.value > 0
                else []
            )

### children

    children()

Get all constituent packets of this packet. e.g. if this is an L2CAP packet

Returns:

Type | Description
--- | ---
`list[event_id]` | List of event_ids

Source code in `application/bluespy.py`

    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    def children(self) -> list['event_id']:
        """Get all constituent packets of this packet.
        e.g. if this is an L2CAP packet

        :return: List of event_ids"""
        count = _ct.c_uint32()
        c = _libbluespy.bluespy_get_children(self, _ct.byref(count))
        return (
            list(_ct.cast(c, _ct.POINTER(event_id * count.value)).contents)
            if count.value > 0
            else []
        )

### parent

    parent()

Get the a higher layer packet that contains this one. e.g. if this is a baseband data packet get the L2CAP packet it is part of.

Returns:

Type | Description
--- | ---
`event_id` | event_id

Source code in `application/bluespy.py`

    701
    702
    703
    704
    705
    706
    def parent(self) -> 'event_id':
        """Get the a higher layer packet that contains this one.
        e.g. if this is a baseband data packet get the L2CAP packet it is part of.

        :return: event_id"""
        return _libbluespy.bluespy_get_parent(self)

## file_id

Bases: `c_uint64`

An object referencing a loaded file.

Do not make your own, only get these from the 'files' object.

Source code in `application/bluespy.py`

    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
    class file_id(_ct.c_uint64):
        """
        An object referencing a loaded file.

        Do not make your own, only get these from the 'files' object.
        """

        def __bool__(self):
            """Returns true if this is a valid packet"""
            return self.value != 0xFFFFFFFFFFFFFFFF

        def __str__(self):
            """Returns root filename"""
            return _libbluespy.bluespy_get_filter_file_name(self).decode("utf-8")

### __bool__

    __bool__()

Returns true if this is a valid packet

Source code in `application/bluespy.py`

    862
    863
    864
    def __bool__(self):
        """Returns true if this is a valid packet"""
        return self.value != 0xFFFFFFFFFFFFFFFF

### __str__

    __str__()

Returns root filename

Source code in `application/bluespy.py`

    866
    867
    868
    def __str__(self):
        """Returns root filename"""
        return _libbluespy.bluespy_get_filter_file_name(self).decode("utf-8")

## i2s_options

Bases: `object`

I2S capture options

Source code in `application/bluespy.py`

    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    class i2s_options(object):
        """I2S capture options"""
        def __init__(self,
            SCLK_line: int=0,
            WS_line: int=0,
            SD_line: int=0,
            n_channels: int=0,
            bits_per_ch: int=0,
            sample_on_rising_edge: bool=False,
            first_chan_follows_WS_high: bool=False,
            one_sample_delay: bool=False,
            MSB_first: bool=False,
            DSP_Mode: bool=False,
            master: bool=False,
        ):
            """
            :param SCLK_line: SCLK line for each interface. Valid values are [0,15]
            :param WS_line: WS line for each interface. Valid values are [0,15]
            :param SD_line: SD line for each interface. Valid values are [0,15]
            :param n_channels: Number of channels. Valid values are [1,16]
            :param bits_per_ch: Number of bits per channel. Valid values are [1,32]
            :param sample_on_rising_edge: Whether to sample on rising edges
            :param first_chan_follows_WS_high: Whether the first channel follows WS High
            :param one_sample_delay: Whether to delay by one sample
            :param MSB_first: MSB first
            :param DSP_Mode: DSP Mode
            :param master: Master
            """
            object.__setattr__(self, "p", _libbluespy.bluespy_capture_i2s_options_alloc())
            self.p.contents.SCLK_line = SCLK_line
            self.p.contents.WS_line = WS_line
            self.p.contents.SD_line = SD_line
            self.p.contents.n_channels = n_channels
            self.p.contents.bits_per_ch = bits_per_ch
            self.p.contents.sample_on_rising_edge = sample_on_rising_edge
            self.p.contents.first_chan_follows_WS_high = first_chan_follows_WS_high
            self.p.contents.one_sample_delay = one_sample_delay
            self.p.contents.MSB_first = MSB_first
            self.p.contents.DSP_mode = DSP_Mode
            self.p.contents.master = master
        def __del__(self):
            _libbluespy.bluespy_delete(self.p)
        def __getattr__(self, name):
            if name == "p":
                return self.__getattribute__("p")
            return getattr(self.p.contents, name)
        def __setattr__(self, name, val):
            self.p.contents.__setattr__(name,val)

### __init__

    __init__(SCLK_line=0, WS_line=0, SD_line=0, n_channels=0, bits_per_ch=0, sample_on_rising_edge=False, first_chan_follows_WS_high=False, one_sample_delay=False, MSB_first=False, DSP_Mode=False, master=False)

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`SCLK_line` | `int` | SCLK line for each interface. Valid values are [0,15] | `0`
`WS_line` | `int` | WS line for each interface. Valid values are [0,15] | `0`
`SD_line` | `int` | SD line for each interface. Valid values are [0,15] | `0`
`n_channels` | `int` | Number of channels. Valid values are [1,16] | `0`
`bits_per_ch` | `int` | Number of bits per channel. Valid values are [1,32] | `0`
`sample_on_rising_edge` | `bool` | Whether to sample on rising edges | `False`
`first_chan_follows_WS_high` | `bool` | Whether the first channel follows WS High | `False`
`one_sample_delay` | `bool` | Whether to delay by one sample | `False`
`MSB_first` | `bool` | MSB first | `False`
`DSP_Mode` | `bool` | DSP Mode | `False`
`master` | `bool` | Master | `False`

Source code in `application/bluespy.py`

    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    def __init__(self,
        SCLK_line: int=0,
        WS_line: int=0,
        SD_line: int=0,
        n_channels: int=0,
        bits_per_ch: int=0,
        sample_on_rising_edge: bool=False,
        first_chan_follows_WS_high: bool=False,
        one_sample_delay: bool=False,
        MSB_first: bool=False,
        DSP_Mode: bool=False,
        master: bool=False,
    ):
        """
        :param SCLK_line: SCLK line for each interface. Valid values are [0,15]
        :param WS_line: WS line for each interface. Valid values are [0,15]
        :param SD_line: SD line for each interface. Valid values are [0,15]
        :param n_channels: Number of channels. Valid values are [1,16]
        :param bits_per_ch: Number of bits per channel. Valid values are [1,32]
        :param sample_on_rising_edge: Whether to sample on rising edges
        :param first_chan_follows_WS_high: Whether the first channel follows WS High
        :param one_sample_delay: Whether to delay by one sample
        :param MSB_first: MSB first
        :param DSP_Mode: DSP Mode
        :param master: Master
        """
        object.__setattr__(self, "p", _libbluespy.bluespy_capture_i2s_options_alloc())
        self.p.contents.SCLK_line = SCLK_line
        self.p.contents.WS_line = WS_line
        self.p.contents.SD_line = SD_line
        self.p.contents.n_channels = n_channels
        self.p.contents.bits_per_ch = bits_per_ch
        self.p.contents.sample_on_rising_edge = sample_on_rising_edge
        self.p.contents.first_chan_follows_WS_high = first_chan_follows_WS_high
        self.p.contents.one_sample_delay = one_sample_delay
        self.p.contents.MSB_first = MSB_first
        self.p.contents.DSP_mode = DSP_Mode
        self.p.contents.master = master

## id

Bases: `c_uint64`

An object referencing a loaded event, device, connection, or audio stream.

Do not make your own, only get these from the bluespy functions. After running close_file(), do not call any methods on any existing event_id objects.

Any query (see the documentation or Help->Query List in the GUI) can be accessed as an attribute on this object

Source code in `application/bluespy.py`

    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    class id(_ct.c_uint64):
        """
        An object referencing a loaded event, device, connection, or audio stream.

        Do not make your own, only get these from the bluespy functions.
        After running close_file(), do not call any methods on any existing event_id objects.

        Any query (see the documentation or Help->Query List in the GUI) can be accessed as an attribute on this object
        """
        def __bool__(self):
            """Returns true if this is a valid ID"""
            return self.value != 0xFFFFFFFFFFFFFFFF

        def __eq__(self, other):
            return isinstance(other, type(self)) and self.value == other.value

        def __hash__(self):
            return hash(self.value)

        def __lt__(self, other):
            return isinstance(other, type(self)) and self.value < other.value

        def query(self, name: str) -> "None | bool | int | str | bytes | float | id":
            """
            Get a query from this object, and return it in its preferred form

            :param name: A query string, e.g. "summary"
            :return: A string, int or bool depending on the query

            :exception AttributeError: """
            r = _libbluespy.bluespy_query_get(self.value, name.encode("utf-8"))

            if r.type == query_type.none:
                return None
            if r.type == query_type.bool_:
                return r.b
            if r.type == query_type.int_:
                return r.i
            if r.type == query_type.string:
                return r.s.decode("utf-8")
            if r.type == query_type.bytes_:
                return _ct.string_at(r.bytes.data, r.bytes.size)
            if r.type == query_type.double:
                return r.d
            if r.type == query_type.id:
                return id(r.id)

            raise AttributeError()

        def __getattr__(self, name):
            """Access queries as attributes"""
            return self.query(name)

        def query_str(self, name: str) -> str:
            """
            Get a query from this object, and return it as a string

            :param name: A query string, e.g. "summary"
            :return: The string result of the query. Returns an empty string if there is no string result."""
            return _libbluespy.bluespy_query(self.value, name.encode("utf-8")).decode(
                "utf-8"
            )

        def query_int(self, name: str) -> int:
            """
            Get a query from this object, and return it as an integer if possible

            :param name: A query string, e.g. "summary"
            :return: The integer result of the query. Returns 0 if there is no integer result."""
            return _libbluespy.bluespy_query_int(self.value, name.encode("utf-8"))

        def query_bool(self, name: str) -> bool:
            """
            Get a query from this object, and return it as a bool if possible

            :param name: A query string, e.g. "acked"
            :return: The boolean result of the query. Returns False if there is no boolean result."""
            return _libbluespy.bluespy_query_bool(self.value, name.encode("utf-8"))

### __bool__

    __bool__()

Returns true if this is a valid ID

Source code in `application/bluespy.py`

    616
    617
    618
    def __bool__(self):
        """Returns true if this is a valid ID"""
        return self.value != 0xFFFFFFFFFFFFFFFF

### __getattr__

    __getattr__(name)

Access queries as attributes

Source code in `application/bluespy.py`

    656
    657
    658
    def __getattr__(self, name):
        """Access queries as attributes"""
        return self.query(name)

### query

    query(name)

Get a query from this object, and return it in its preferred form

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`name` | `str` | A query string, e.g. "summary" | required

Returns:

Type | Description
--- | ---
`None | bool | int | str | bytes | float | id` | A string, int or bool depending on the query

Raises:

Type | Description
--- | ---
`AttributeError` |

Source code in `application/bluespy.py`

    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    def query(self, name: str) -> "None | bool | int | str | bytes | float | id":
        """
        Get a query from this object, and return it in its preferred form

        :param name: A query string, e.g. "summary"
        :return: A string, int or bool depending on the query

        :exception AttributeError: """
        r = _libbluespy.bluespy_query_get(self.value, name.encode("utf-8"))

        if r.type == query_type.none:
            return None
        if r.type == query_type.bool_:
            return r.b
        if r.type == query_type.int_:
            return r.i
        if r.type == query_type.string:
            return r.s.decode("utf-8")
        if r.type == query_type.bytes_:
            return _ct.string_at(r.bytes.data, r.bytes.size)
        if r.type == query_type.double:
            return r.d
        if r.type == query_type.id:
            return id(r.id)

        raise AttributeError()

### query_bool

    query_bool(name)

Get a query from this object, and return it as a bool if possible

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`name` | `str` | A query string, e.g. "acked" | required

Returns:

Type | Description
--- | ---
`bool` | The boolean result of the query. Returns False if there is no boolean result.

Source code in `application/bluespy.py`

    678
    679
    680
    681
    682
    683
    684
    def query_bool(self, name: str) -> bool:
        """
        Get a query from this object, and return it as a bool if possible

        :param name: A query string, e.g. "acked"
        :return: The boolean result of the query. Returns False if there is no boolean result."""
        return _libbluespy.bluespy_query_bool(self.value, name.encode("utf-8"))

### query_int

    query_int(name)

Get a query from this object, and return it as an integer if possible

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`name` | `str` | A query string, e.g. "summary" | required

Returns:

Type | Description
--- | ---
`int` | The integer result of the query. Returns 0 if there is no integer result.

Source code in `application/bluespy.py`

    670
    671
    672
    673
    674
    675
    676
    def query_int(self, name: str) -> int:
        """
        Get a query from this object, and return it as an integer if possible

        :param name: A query string, e.g. "summary"
        :return: The integer result of the query. Returns 0 if there is no integer result."""
        return _libbluespy.bluespy_query_int(self.value, name.encode("utf-8"))

### query_str

    query_str(name)

Get a query from this object, and return it as a string

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`name` | `str` | A query string, e.g. "summary" | required

Returns:

Type | Description
--- | ---
`str` | The string result of the query. Returns an empty string if there is no string result.

Source code in `application/bluespy.py`

    660
    661
    662
    663
    664
    665
    666
    667
    668
    def query_str(self, name: str) -> str:
        """
        Get a query from this object, and return it as a string

        :param name: A query string, e.g. "summary"
        :return: The string result of the query. Returns an empty string if there is no string result."""
        return _libbluespy.bluespy_query(self.value, name.encode("utf-8")).decode(
            "utf-8"
        )

## latency_status

Bases: `c_int`

Return log level

Source code in `application/bluespy.py`

    967
    968
    969
    970
    971
    972
    973
    974
    975
    976
    977
    class latency_status(_ct.c_int):
        """Return log level"""
        def __str__(self):

            return _libbluespy.bluespy_latency_status_string(self.value).decode("utf-8")

        def __repr__(self):
            return "{}: {}".format(self.value, self.__str__()) if self.value else ""

        def __bool__(self):
            return self.value == 0

## log_level

Bases: `c_int`

Represents log level

Source code in `application/bluespy.py`

    113
    114
    115
    116
    117
    118
    119
    class log_level(_ct.c_int):
        """Represents log level"""
        PASS = 0x00
        WARN = 0x20
        INFO = 0x40
        DEBUG = 0x60
        ERROR = 0x80

## logic_rate

Bases: `c_int`

Represents logic rate

Source code in `application/bluespy.py`

    121
    122
    123
    124
    125
    class logic_rate(_ct.c_int):
        """Represents logic rate"""
        high = 0
        medium = 1
        rate = 2

## time_point

Bases: `c_int64`

Represents the time in nanoseconds since epoch 1970/01/01 00:00 UTC

Source code in `application/bluespy.py`

    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    class time_point(_ct.c_int64):
        """Represents the time in nanoseconds since epoch 1970/01/01 00:00 UTC"""

        def __init__(self, ts=0x7fffffffffffffff):
            self.value = ts

        def __bool__(self):
            """Returns if it's a valid time"""
            return self.value != 0x7fffffffffffffff

        def __str__(self):
            """Returns the string representation of the time"""
            return _libbluespy.bluespy_print_time(self).decode("utf-8")

### __bool__

    __bool__()

Returns if it's a valid time

Source code in `application/bluespy.py`

    212
    213
    214
    def __bool__(self):
        """Returns if it's a valid time"""
        return self.value != 0x7fffffffffffffff

### __str__

    __str__()

Returns the string representation of the time

Source code in `application/bluespy.py`

    216
    217
    218
    def __str__(self):
        """Returns the string representation of the time"""
        return _libbluespy.bluespy_print_time(self).decode("utf-8")

## add_link_key

    add_link_key(key, addr0=0, addr1=0)

Add a link key for decryption

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`key` | `bytes` | Link key as a 16-byte bytes object | required
`addr0` | `int` | (Optional) MAC address of central as a 64-bit integer | `0`
`addr1` | `int` | (Optional) MAC address of peripheral as a 64-bit integer | `0`

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    945
    946
    947
    948
    949
    950
    951
    952
    953
    954
    def add_link_key(key: bytes, addr0: int=0, addr1: int=0):
        """Add a link key for decryption

        :param key: Link key as a 16-byte bytes object
        :param addr0: (Optional) MAC address of central as a 64-bit integer
        :param addr1: (Optional) MAC address of peripheral as a 64-bit integer

        :exception BluespyError: Exception in the bluespy library
        """
        _handle_error(_libbluespy.bluespy_add_link_key(key, addr0, addr1))

## add_log_message

    add_log_message(level, message, ts=invalid_time())

Adds a log message into the running capture

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`level` | `log_level` | The Log Level. | required
`message` | `str` | The log message content. | required
`ts` | `time_point` | The time of the log message. ts=invalid means the time will be set to the present. | `invalid_time()`

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    226
    227
    228
    229
    230
    231
    232
    233
    234
    def add_log_message(level: log_level, message: str, ts: time_point=invalid_time()):
        """Adds a log message into the running capture

        :param level: The Log Level.
        :param message: The log message content.
        :param ts: The time of the log message. ts=invalid means the time will be set to the present.

        :exception BluespyError: Exception in the bluespy library"""
        _handle_error(_libbluespy.bluespy_add_log_message(level, message.encode("utf-8"), ts))

## add_to_filter_file

    add_to_filter_file(file_, event_)

Add an event to a filter file

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`file_` | `file_id` | File ID | required
`event_` | `event_id` | Event ID | required

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    892
    893
    894
    895
    896
    897
    898
    899
    def add_to_filter_file(file_: file_id, event_: event_id):
        """Add an event to a filter file

        :param file_: File ID
        :param event_: Event ID

        :exception BluespyError: Exception in the bluespy library"""
        _handle_error(_libbluespy.bluespy_add_to_filter_file(file_, event_))

## audiopod_current

    audiopod_current(start=0, end=invalid_time())

Get the Audiopod current values in mA.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`start` | `time_point` | Start of range to return. Use 0 for start of capture | `0`
`end` | `time_point` | End of range to return. Use invalid_time() for end of capture Call set_pin_current first to ensure the values returned by this function are correctly scaled Sampling rate is 125kHz | `invalid_time()`

Source code in `application/bluespy.py`

    1188
    1189
    1190
    1191
    1192
    1193
    1194
    1195
    1196
    1197
    1198
    1199
    1200
    def audiopod_current(start: time_point = 0, end: time_point = invalid_time()) -> list[float]:
        """ Get the Audiopod current values in mA.

        :param start: Start of range to return. Use 0 for start of capture
        :param end: End of range to return. Use invalid_time() for end of capture

        Call set_pin_current first to ensure the values returned by this function are correctly scaled
        Sampling rate is 125kHz
        """
        data = _libbluespy.bluespy_audiopod_current(start, end)
        if data.count == 0:
            return []
        return list(_ct.cast(data.data, _ct.POINTER(_ct.c_double * data.count)).contents)

## capture

    capture(filename, CL=False, LE=False, QHS=False, _15_4=False, wifi=False, MHDT_CL=False, MHDT_LE=False, Dukosi=False, Varjo=False, CS=False, Audiopod=None, I2S=[None, None], spectrum=0, logic_mask=0, logic_use_external_vref=True, logic_rate=0, HDT=False, Proprietary_1=False, Proprietary_2=False, mask_payloads=False, disable_HDT_dewhitening=False, disable_AGC=False, maximum_input_signal_dbm=-100)

Start a new capture in filename

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`filename` | `str` | Path to store capture in | required
`CL` | `bool` | Enable Bluetooth Classic capture | `False`
`LE` | `bool` | Enable Bluetooth LE capture | `False`
`QHS` | `bool` | Enable Qualcomm High Speed capture | `False`
`_15_4` | `bool` | Enable 802.15.4 capture | `False`
`wifi` | `bool` | Enable WiFi capture | `False`
`MHDT_CL` | `bool` | Enable MediaTek mHDT Classic capture | `False`
`MHDT_LE` | `bool` | Enable MediaTek mHDT LE capture | `False`
`Dukosi` | `bool` | Enable Dukosi capture | `False`
`Varjo` | `bool` | Enable Varjo capture | `False`
`CS` | `bool` | Enable Channel-Sounding capture | `False`
`Audiopod` | `None | audiopod_options` | Audiopod options. Providing an audiopod_options struct will enable audiopod | `None`
`I2S` | `list[None | i2s_options]` | I2S options. Providing i2s_options structs will enable I2S | `[None, None]`
`spectrum` | `int` | Spectrum capture interval in microseconds. 0 means disabled. Allowed values are: 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000. | `0`
`logic_mask` | `int` | 32-bit mask enabling logic lines | `0`
`logic_use_external_vref` | `bool` | Use External or Internal vref | `True`
`logic_rate` | `logic_rate` | Low, Medium, or High logic rate | `0`
`HDT` | `bool` | Enable HDT capture | `False`
`Proprietary_1` | `bool` | Enable Proprietary_1 capture | `False`
`Proprietary_2` | `bool` | Enable Proprietary_2 capture | `False`
`mask_payloads` | `bool` | Enable payload masking (replace non-public payloads with 0s) | `False`
`disable_HDT_dewhitening` | `bool` | Disable dewhitening of HDT packets. Normally should only be used when capturing Test packets. | `False`
`disable_AGC` | `bool` | Disables the automatic gain control | `False`
`maximum_input_signal_dbm` | `int` | Only valid when AGC is disabled. Sets the maximum dBm you want to receive | `-100`

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    def capture(
        filename: str,
        CL: bool=False,
        LE: bool=False,
        QHS: bool=False,
        _15_4: bool=False,
        wifi: bool=False,
        MHDT_CL: bool=False,
        MHDT_LE: bool=False,
        Dukosi: bool=False,
        Varjo: bool=False,
        CS: bool=False,
        Audiopod: None | audiopod_options=None,
        I2S: list[None | i2s_options]= [None,None],
        spectrum: int=0,
        logic_mask: int=0x0000,
        logic_use_external_vref: bool=True,
        logic_rate: logic_rate=0,
        HDT: bool=False,
        Proprietary_1: bool=False,
        Proprietary_2: bool=False,
        mask_payloads: bool=False,
        disable_HDT_dewhitening: bool=False,
        disable_AGC: bool=False,
        maximum_input_signal_dbm: int=-100,
    ):
        """Start a new capture in filename

        :param filename: Path to store capture in
        :param CL: Enable Bluetooth Classic capture
        :param LE: Enable Bluetooth LE capture
        :param QHS: Enable Qualcomm High Speed capture
        :param _15_4: Enable 802.15.4 capture
        :param wifi: Enable WiFi capture
        :param MHDT_CL: Enable MediaTek mHDT Classic capture
        :param MHDT_LE: Enable MediaTek mHDT LE capture
        :param Dukosi: Enable Dukosi capture
        :param Varjo: Enable Varjo capture
        :param CS: Enable Channel-Sounding capture

        :param Audiopod: Audiopod options. Providing an audiopod_options struct will enable audiopod
        :param I2S: I2S options. Providing i2s_options structs will enable I2S

        :param spectrum: Spectrum capture interval in microseconds. 0 means disabled.
            Allowed values are: 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000.
        :param logic_mask: 32-bit mask enabling logic lines
        :param logic_use_external_vref: Use External or Internal vref
        :param logic_rate: Low, Medium, or High logic rate

        :param HDT: Enable HDT capture

        :param Proprietary_1: Enable Proprietary_1 capture
        :param Proprietary_2: Enable Proprietary_2 capture
        :param mask_payloads: Enable payload masking (replace non-public payloads with 0s)
        :param disable_HDT_dewhitening: Disable dewhitening of HDT packets. Normally should only be used when capturing Test packets.

        :param disable_AGC: Disables the automatic gain control
        :param maximum_input_signal_dbm: Only valid when AGC is disabled.
               Sets the maximum dBm you want to receive

        :exception BluespyError: Exception in the bluespy library"""
        opts = _libbluespy.bluespy_capture_options_alloc()
        opts.contents.enable_CL = CL
        opts.contents.enable_LE = LE
        opts.contents.enable_HDT = HDT
        opts.contents.enable_QHS = QHS
        opts.contents.enable_15_4 = _15_4
        opts.contents.enable_wifi = wifi
        opts.contents.enable_MHDT_CL = MHDT_CL
        opts.contents.enable_MHDT_LE = MHDT_LE
        opts.contents.enable_Dukosi = Dukosi
        opts.contents.enable_Varjo = Varjo
        opts.contents.enable_Channel_Sounding = CS
        opts.contents.spectrum_period = spectrum
        opts.contents.logic_mask = logic_mask
        opts.contents.logic_use_external_vref = logic_use_external_vref
        opts.contents.logic_rate = logic_rate
        opts.contents.enable_Proprietary_1 = Proprietary_1
        opts.contents.enable_Proprietary_2 = Proprietary_2
        opts.contents.mask_payloads = mask_payloads
        opts.contents.disable_HDT_dewhitening = disable_HDT_dewhitening
        opts.contents.disable_AGC = disable_AGC
        opts.contents.maximum_input_signal_dbm = maximum_input_signal_dbm

        if Audiopod != None:
            opts.contents.audiopod_opts = Audiopod.p

        for i in range(2):
            if I2S[i] != None:
                opts.contents.i2s_opts[i] = I2S[i].p

        _handle_error(
            _libbluespy.bluespy_capture(
                filename.encode("utf-8"), opts,
            )
        )
        _libbluespy.bluespy_delete(opts)
        atexit.register(close_file)
        atexit.register(stop_capture)

## capture_multiple

    capture_multiple(filename, CL=[], LE=[], wifi=[], QHS=False, _15_4=False, MHDT_CL=False, MHDT_LE=False, Dukosi=False, Varjo=False, CS=False, Audiopod=None, I2S=[None, None], spectrum=0, logic_mask=0, logic_use_external_vref=True, logic_rate=0, HDT=[], Proprietary_1=False, Proprietary_2=False, mask_payloads=False)

Start a new capture in filename

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`filename` | `str` | Path to store capture in | required
`CL` | `list[bool]` | Enable Bluetooth Classic capture, list of bools, one for each Moreph | `[]`
`LE` | `list[bool]` | Enable Bluetooth LE capture, list of bools, one for each Moreph | `[]`
`wifi` | `list[bool]` | Enable WiFi capture, list of bools, one for each Moreph | `[]`
`QHS` | `bool` | Enable Qualcomm High Speed capture | `False`
`_15_4` | `bool` | Enable 802.15.4 capture | `False`
`MHDT_CL` | `bool` | Enable MediaTek mHDT Classic capture | `False`
`MHDT_LE` | `bool` | Enable MediaTek mHDT LE capture | `False`
`Dukosi` | `bool` | Enable Dukosi capture | `False`
`Varjo` | `bool` | Enable Varjo capture | `False`
`CS` | `bool` | Enable Channel-Sounding capture | `False`
`Audiopod` | `None | audiopod_options` | Audiopod options. Providing an audiopod_options struct will enable audiopod | `None`
`I2S` | `list[None | i2s_options]` | I2S options. Providing i2s_options structs will enable I2S | `[None, None]`
`spectrum` | `int` | Spectrum capture interval in microseconds. 0 means disabled. Allowed values are: 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000. | `0`
`logic_mask` | `int` | 32-bit mask enabling logic lines | `0`
`logic_use_external_vref` | `bool` | Use External or Internal vref | `True`
`logic_rate` | `logic_rate` | Low, Medium, or High logic rate | `0`
`HDT` | `list[bool]` | Enable HDT capture, list of bools, one for each Moreph | `[]`
`Proprietary_1` | `bool` | Enable Proprietary_1 capture | `False`
`Proprietary_2` | `bool` | Enable Proprietary_2 capture | `False`
`mask_payloads` | `bool` | Enable payload masking (replace non-public payloads with 0s) | `False`

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    def capture_multiple(

        filename: str,
        CL: list[bool]=[],
        LE: list[bool]=[],
        wifi: list[bool]=[],
        QHS: bool=False,
        _15_4: bool=False,
        MHDT_CL: bool=False,
        MHDT_LE: bool=False,
        Dukosi: bool=False,
        Varjo: bool=False,
        CS: bool=False,
        Audiopod: None | audiopod_options=None,
        I2S: list[None | i2s_options]= [None,None],
        spectrum: int=0,
        logic_mask: int=0x0000,
        logic_use_external_vref: bool=True,
        logic_rate: logic_rate=0,
        HDT: list[bool]=[],
        Proprietary_1: bool=False,
        Proprietary_2: bool=False,
        mask_payloads: bool=False,
    ):
        """Start a new capture in filename

        :param filename: Path to store capture in
        :param CL: Enable Bluetooth Classic capture, list of bools, one for each Moreph
        :param LE: Enable Bluetooth LE capture, list of bools, one for each Moreph
        :param wifi: Enable WiFi capture, list of bools, one for each Moreph
        :param QHS: Enable Qualcomm High Speed capture
        :param _15_4: Enable 802.15.4 capture
        :param MHDT_CL: Enable MediaTek mHDT Classic capture
        :param MHDT_LE: Enable MediaTek mHDT LE capture
        :param Dukosi: Enable Dukosi capture
        :param Varjo: Enable Varjo capture
        :param CS: Enable Channel-Sounding capture

        :param Audiopod: Audiopod options. Providing an audiopod_options struct will enable audiopod
        :param I2S: I2S options. Providing i2s_options structs will enable I2S

        :param spectrum: Spectrum capture interval in microseconds. 0 means disabled.
            Allowed values are: 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000.

        :param logic_mask: 32-bit mask enabling logic lines
        :param logic_use_external_vref: Use External or Internal vref
        :param logic_rate: Low, Medium, or High logic rate

        :param HDT: Enable HDT capture, list of bools, one for each Moreph

        :param Proprietary_1: Enable Proprietary_1 capture
        :param Proprietary_2: Enable Proprietary_2 capture
        :param mask_payloads: Enable payload masking (replace non-public payloads with 0s)

        :exception BluespyError: Exception in the bluespy library"""

        opts = _libbluespy.bluespy_capture_options_alloc()

        if len(CL) > 0:
            opts.contents.enable_CL = CL[0]
            for i in range(1,min(len(CL),32)):
                opts.contents.multi_moreph_opts[i-1].enable_CL = CL[i]
        if len(LE) > 0:
            opts.contents.enable_LE = LE[0]
            for i in range(1,min(len(LE),32)):
                opts.contents.multi_moreph_opts[i-1].enable_LE = LE[i]
        if len(HDT) > 0:
            opts.contents.enable_HDT = HDT[0]
            for i in range(1,min(len(HDT),32)):
                opts.contents.multi_moreph_opts[i-1].enable_HDT = HDT[i]
        if len(wifi) > 0:
            opts.contents.enable_wifi = wifi[0]
            for i in range(1,min(len(wifi),32)):
                opts.contents.multi_moreph_opts[i-1].enable_wifi = wifi[i]

        opts.contents.enable_QHS = QHS
        opts.contents.enable_15_4 = _15_4
        opts.contents.enable_MHDT_CL = MHDT_CL
        opts.contents.enable_MHDT_LE = MHDT_LE
        opts.contents.enable_Dukosi = Dukosi
        opts.contents.enable_Varjo = Varjo
        opts.contents.enable_Channel_Sounding = CS
        opts.contents.spectrum_period = spectrum
        opts.contents.logic_mask = logic_mask
        opts.contents.logic_use_external_vref = logic_use_external_vref
        opts.contents.logic_rate = logic_rate
        opts.contents.enable_Proprietary_1 = Proprietary_1
        opts.contents.enable_Proprietary_2 = Proprietary_2
        opts.contents.mask_payloads = mask_payloads

        if Audiopod != None:
            opts.contents.audiopod_opts = Audiopod.p

        for i in range(2):
            if I2S[i] != None:
                opts.contents.i2s_opts[i] = I2S[i].p

        _handle_error(
            _libbluespy.bluespy_capture(
                filename.encode("utf-8"), opts,
            )
        )

        _libbluespy.bluespy_delete(opts)
        atexit.register(close_file)
        atexit.register(stop_capture)

## close_file

    close_file()

Close an existing capture

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    600
    601
    602
    603
    604
    605
    def close_file():
        """Close an existing capture

        :exception BluespyError: Exception in the bluespy library"""
        atexit.unregister(close_file)
        _handle_error(_libbluespy.bluespy_close_file())

## close_filter_file

    close_filter_file(file_)

Close a filter file

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`file_` | `file_id` | File ID | required

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    901
    902
    903
    904
    905
    906
    907
    def close_filter_file(file_: file_id):
        """Close a filter file

        :param file_: File ID

        :exception BluespyError: Exception in the bluespy library"""
        _handle_error(_libbluespy.bluespy_close_filter_file(file_))

## connect

    connect(serial=-1)

Connect to Moreph hardware via USB or Ethernet.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`serial` | `int` | A serial number as an integer, or -1 to connect to the first device. The serial number shown in the software and on the MiniMoreph is hexadecimal, so should be entered as 0xNNNNNN. There is a serial number on the bottom of some Moreph30s is of the form AYYYY-XXXXX, the XXXXX is the required serial number in decimal. | `-1`

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library You should run disconnect() later if this is successful.

Source code in `application/bluespy.py`

    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    def connect(serial: int=-1):
        """Connect to Moreph hardware via USB or Ethernet.

        :param serial: A serial number as an integer, or -1 to connect to the first device.
        The serial number shown in the software and on the MiniMoreph is hexadecimal, so should be entered as 0xNNNNNN.
        There is a serial number on the bottom of some Moreph30s is of the form AYYYY-XXXXX, the XXXXX is the required serial number in decimal.

        :exception BluespyError: Exception in the bluespy library

        You should run disconnect() later if this is successful.
        """

        _handle_error(_libbluespy.bluespy_connect(serial))

## connect_multiple

    connect_multiple(serials)

Connect to multiple Moreph hardware devices via USB or Ethernet.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`serials` | `list[int]` | An array of serial numbers as integers. The first serial number in the array is considered that of the primary device. The serial numbers shown in the software and on the MiniMoreph are hexadecimal, so should be entered as 0xNNNNNN. There is a serial number on the bottom of some Moreph30s is of the form AYYYY-XXXXX, the XXXXX is the required serial number in decimal. | required

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library You should run disconnect() later if this is successful.

Source code in `application/bluespy.py`

    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    def connect_multiple(serials: list[int]):
        """Connect to multiple Moreph hardware devices via USB or Ethernet.

        :param serials: An array of serial numbers as integers.

        The first serial number in the array is considered that of the primary device.

        The serial numbers shown in the software and on the MiniMoreph are hexadecimal, so should be entered as 0xNNNNNN.

        There is a serial number on the bottom of some Moreph30s is of the form AYYYY-XXXXX, the XXXXX is the required serial number in decimal.

        :exception BluespyError: Exception in the bluespy library

        You should run disconnect() later if this is successful.
        """
        u32list = _ct.c_uint32 * len(serials)
        serial_span = u32list()
        for i in range(len(serials)):
            serial_span[i] = serials[i]
        _handle_error(_libbluespy.bluespy_connect_multiple(serial_span, len(serials)))

## connected_morephs

    connected_morephs()

Get the serial numbers of connected moreph devices.

Returns:

Type | Description
--- | ---
`list[int]` | Array of serial numbers

Source code in `application/bluespy.py`

    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    def connected_morephs() -> list[int]:
        """Get the serial numbers of connected moreph devices.

        :return: Array of serial numbers
        """
        uint32_ptr = _ct.POINTER(_ct.c_uint32)
        hw_data = uint32_ptr()
        hw_count = _libbluespy.bluespy_morephs_connected(_ct.byref(hw_data))

        return [hw_data[i] for i in range(hw_count)]

## create_filter_file

    create_filter_file(filename, range_start=invalid_time(), keep_spec=True, keep_logic=True, keep_uart=True, keep_i2s_and_audiopod=True)

Creates a filter file

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`filename` | `str` | File name | required
`range_start` | `time_point` | Start time to add spectrum/logic/etc | `invalid_time()`
`keep_spec` | `bool` | Enable copying spectrum | `True`
`keep_logic` | `bool` | Enable copying logic | `True`
`keep_uart` | `bool` | Enable copying UART | `True`
`keep_i2s_and_audiopod` | `bool` | Enable copying I2S and Audiopod | `True`

Returns:

Type | Description
--- | ---
`file_id` | file_id of filter file. -1 = invalid

Source code in `application/bluespy.py`

    870
    871
    872
    873
    874
    875
    876
    877
    878
    879
    880
    881
    882
    883
    884
    885
    886
    887
    888
    889
    890
    def create_filter_file(filename: str, range_start: time_point = invalid_time(), keep_spec: bool = True, keep_logic: bool = True, keep_uart: bool = True, keep_i2s_and_audiopod: bool = True) -> file_id:
        """Creates a filter file

        :param filename: File name
        :param range_start: Start time to add spectrum/logic/etc
        :param keep_spec: Enable copying spectrum
        :param keep_logic: Enable copying logic
        :param keep_uart: Enable copying UART
        :param keep_i2s_and_audiopod: Enable copying I2S and Audiopod

        :return: file_id of filter file. -1 = invalid"""
        opts = _libbluespy.bluespy_filter_file_options_alloc()
        opts.contents.range_start = range_start
        opts.contents.keep_spectrum = keep_spec
        opts.contents.keep_logic = keep_logic
        opts.contents.keep_uart = keep_uart
        opts.contents.keep_i2s_and_audiopod = keep_i2s_and_audiopod

        id_ = _libbluespy.bluespy_create_filter_file(filename.encode("utf-8"), opts)
        _libbluespy.bluespy_filter_file_options_delete(opts)
        return id_

## custom_decoders_status

    custom_decoders_status()

Returns custom decoders status

Returns:

Type | Description
--- | ---
`(bool, list[str])` | A dictionary ("enabled", "names")

- "enabled"(bool) is whether custom decoders are enabled.
- "names"(list[str]) is the list of custom decoder names.

Source code in `application/bluespy.py`

    1114
    1115
    1116
    1117
    1118
    1119
    1120
    1121
    1122
    1123
    1124
    1125
    1126
    1127
    def custom_decoders_status() -> (bool, list[str]):
        """
        Returns custom decoders status

        :return (bool, list[str]): A dictionary ("enabled", "names")

        * "enabled"(bool) is whether custom decoders are enabled.
        * "names"(list[str]) is the list of custom decoder names.
        """
        status = _libbluespy.bluespy_custom_decoders_status()
        names = []
        for i in range(status.count):
            names.append(status.names[i].decode("utf-8"))
        return {"enabled": status.enabled, "names": names}

## disable_custom_decoders

    disable_custom_decoders()

Disables custom decoders.

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    1103
    1104
    1105
    1106
    1107
    1108
    1109
    def disable_custom_decoders():
        """
        Disables custom decoders.

        :exception BluespyError: Exception in the bluespy library
        """
        _handle_error(_libbluespy.bluespy_disable_custom_decoders())

## disconnect

    disconnect()

Disconnect from the connected Morephs

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    184
    185
    186
    187
    188
    189
    190
    def disconnect():
        """Disconnect from the connected Morephs

        :exception BluespyError: Exception in the bluespy library"""
        atexit.unregister(stop_capture)
        atexit.unregister(disconnect)
        _handle_error(_libbluespy.bluespy_disconnect())

## enable_custom_decoders

    enable_custom_decoders()

Enables custom decoders.

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    1095
    1096
    1097
    1098
    1099
    1100
    1101
    def enable_custom_decoders():
        """
        Enables custom decoders.

        :exception BluespyError: Exception in the bluespy library
        """
        _handle_error(_libbluespy.bluespy_enable_custom_decoders())

## enable_key_storage

    enable_key_storage(enable)

Control loading/saving of keys in local storage.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`enable` |  | Enable loading/saving of keys; default value is enabled if this function has not been called. Encryption keys and IRKs are saved to your local storage and reused when loading/capturing. To disable this behaviour (e.g. for repeatable behaviour in a test system), use this function to disable loading and saving of keys.

Calling bluespy_enable_key_storage(false) removes all keys from blueSPY's list of keys.

required

Source code in `application/bluespy.py`

    1210
    1211
    1212
    1213
    1214
    1215
    1216
    1217
    1218
    1219
    1220
    1221
    def enable_key_storage(enable):
        """Control loading/saving of keys in local storage.

        :param enable: Enable loading/saving of keys; default value is enabled if this function has not been called.

        Encryption keys and IRKs are saved to your local storage and reused when loading/capturing.
        To disable this behaviour (e.g. for repeatable behaviour in a test system), use this function to
        disable loading and saving of keys.

        Calling bluespy_enable_key_storage(false) removes all keys from blueSPY's list of keys.
        """
        _libbluespy.bluespy_enable_key_storage(enable)

## export_logic

    export_logic(filename)

Export logic data to a file

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`filename` | `str` | File to export logic to. | required

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    1151
    1152
    1153
    1154
    1155
    1156
    1157
    1158
    def export_logic(filename: str):
        """ Export logic data to a file

        :param filename: File to export logic to.

        :exception BluespyError: Exception in the bluespy library
        """
        _handle_error(_libbluespy.bluespy_export_logic(filename.encode("utf-8")))

## get_audiostreams

    get_audiostreams(id_=invalid_id())

Get the ids of the audio streams from 'id'

- If id is device_id: Streams which a device is creating.
- If id is connection_id: Streams which are part of a connection.
- If id is invalid_id(): Streams not associated with any device, e.g. audiopod streams.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`id_` | `id` | a Device ID or a Connection ID, or invalid_id() for audiopod streams. | `invalid_id()`

Returns:

Type | Description
--- | ---
`list[audiostream_id]` | Array of audio stream IDs

Source code in `application/bluespy.py`

    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    def get_audiostreams(id_: id = invalid_id()) -> list[audiostream_id]:
        """Get the ids of the audio streams from 'id'

        * If id is device_id: Streams which a device is creating.
        * If id is connection_id: Streams which are part of a connection.
        * If id is invalid_id(): Streams not associated with any device, e.g. audiopod streams.

        :param id_: a Device ID or a Connection ID, or invalid_id() for audiopod streams.
        :return: Array of audio stream IDs"""
        stream_id_span = _libbluespy.bluespy_get_audiostreams(id_)
        return [stream_id_span.data[i] for i in range(stream_id_span.size)]

## get_device_id

    get_device_id(addr)

Get the Device ID from an address

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`addr` | `bytes` | Six bytes representing an address | required

Returns:

Type | Description
--- | ---
`device_id` | Device ID. -1 = no device

Source code in `application/bluespy.py`

    764
    765
    766
    767
    768
    769
    def get_device_id(addr: bytes) -> device_id:
        """Get the Device ID from an address

        :param addr: Six bytes representing an address
        :return: Device ID. -1 = no device"""
        return _libbluespy.bluespy_get_device_id(addr)

## get_logic_at_time

    get_logic_at_time(ts)

Get the logic state at ts

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`ts` | `time_point` | Timestamp | required

Returns:

Type | Description
--- | ---
`int` | 32 bit integer. The i'th bit represents the state of the i'th logic line

Source code in `application/bluespy.py`

    909
    910
    911
    912
    913
    914
    915
    def get_logic_at_time(ts: time_point) -> int:
        """Get the logic state at ts

        :param ts: Timestamp

        :return: 32 bit integer. The i'th bit represents the state of the i'th logic line"""
        return _libbluespy.bluespy_get_logic_at_time(ts)

## get_next_logic_change

    get_next_logic_change(ts, mask)

Get the next logic state after ts

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`ts` | `time_point` | Timestamp | required
`mask` | `int` | 32 integer mask. logic lines corresponding to zero bits are ignored | required

Returns:

Type | Description
--- | ---
`_logic_change` | A struct containing a 32 integer mask representing the next logic state, and the time of transition

Source code in `application/bluespy.py`

    924
    925
    926
    927
    928
    929
    930
    931
    932
    def get_next_logic_change(ts: time_point,  mask: int) -> _logic_change:
        """Get the next logic state after ts

        :param ts: Timestamp
        :param mask: 32 integer mask. logic lines corresponding to zero bits are ignored

        :return: A struct containing a 32 integer mask representing the next logic state, and the time of transition"""

        return _libbluespy.bluespy_get_next_logic_change(ts,  mask)

## get_spectrum

    get_spectrum(start=0, end=invalid_time())

Get the spectrum values

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`start` | `time_point` | Start of range to return. Use 0 for start of capture | `0`
`end` | `time_point` | End of range to return. Use invalid_time() for end of capture | `invalid_time()`

Returns:

Type | Description
--- | ---
`(list[list[int]], int)` | Inner lists have 79 values over the frequencies. Also returns the interval in nanoseconds

Source code in `application/bluespy.py`

    1136
    1137
    1138
    1139
    1140
    1141
    1142
    1143
    1144
    1145
    1146
    1147
    1148
    1149
    def get_spectrum(start: time_point = 0, end: time_point = invalid_time()) -> (list[list[int]], int):
        """ Get the spectrum values

        :param start: Start of range to return. Use 0 for start of capture
        :param end: End of range to return. Use invalid_time() for end of capture

        :return (list[list[float]], float): Inner lists have 79 values over the frequencies.
          Also returns the interval in nanoseconds
        """
        data: _BluespySpectrumData = _libbluespy.bluespy_get_spectrum(start, end)
        out = []
        for i in range(data.count):
            out.append(list(data.data[i]))
        return (out, data.interval)

## invalid_id

    invalid_id()

Invalid ID

Returns:

Type | Description
--- | ---
`id` | invalid ID

Source code in `application/bluespy.py`

    686
    687
    688
    689
    690
    def invalid_id() -> id:
        """Invalid ID

        :return: invalid ID"""
        return id(0xFFFFFFFFFFFFFFFF)

## invalid_time

    invalid_time()

Invalid time point

Returns:

Type | Description
--- | ---
`time_point` | invalid time point

Source code in `application/bluespy.py`

    220
    221
    222
    223
    224
    def invalid_time() -> time_point:
        """Invalid time point

        :return: invalid time point"""
        return time_point()

## list_keys

    list_keys()

List the keys from the security tab

Returns:

Type | Description
--- | ---
`dict(str, bytes)` | Keys

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    1077
    1078
    1079
    1080
    1081
    1082
    1083
    1084
    1085
    1086
    1087
    1088
    1089
    1090
    1091
    1092
    1093
    def list_keys() -> dict(str, bytes):
        """List the keys from the security tab

        :return (dict(str, bytes)): Keys
        :exception BluespyError: Exception in the bluespy library
        """
        keys_ptr = _ct.POINTER(_BluespyKey)()
        length = _ct.c_size_t()
        _handle_error(_libbluespy.bluespy_list_keys(_ct.byref(keys_ptr), _ct.byref(length)))
        results = {}
        for i in range(length.value):
            key = keys_ptr[i]
            key_bytes = _ct.string_at(key.key, key.length)
            key_label = _ct.string_at(key.label).decode("utf-8")
            results[key_label] = key_bytes;
        _handle_error(_libbluespy.bluespy_free_keys(keys_ptr, length))
        return results

## load_file

    load_file(filename)

Load an existing capture

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    593
    594
    595
    596
    597
    598
    def load_file(filename: str):
        """Load an existing capture

        :exception BluespyError: Exception in the bluespy library"""
        _handle_error(_libbluespy.bluespy_load_file(filename.encode("utf-8")))
        atexit.register(close_file)

## mark_key_used

    mark_key_used(key)

Marks an encryption key as used

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`key` | `bytes` | Encryption key as bytes object | required

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    1063
    1064
    1065
    1066
    1067
    1068
    1069
    1070
    1071
    1072
    def mark_key_used(key: bytes):
        """Marks an encryption key as used

        :param key: Encryption key as bytes object

        :exception BluespyError: Exception in the bluespy library
        """
        _handle_error(
            _libbluespy.bluespy_mark_key_used(key, len(key))
        )

## measure_latency

    measure_latency(channel0, channel1, include_pres_delay, ts)

Measures the latency between two audio streams

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`channel0` | `_audio_channel_t` | Audio channel 0 | required
`channel1` | `_audio_channel_t` | Audio channel 1 | required
`include_pres_delay` | `bool` | Include presentation delay | required
`ts` | `time_point` | Timestamp | required

Returns:

Type | Description
--- | ---
`_latency_result` | Array of latency results

Source code in `application/bluespy.py`

    1000
    1001
    1002
    1003
    1004
    1005
    1006
    1007
    1008
    1009
    1010
    1011
    def measure_latency(channel0: _audio_channel_t, channel1: _audio_channel_t, include_pres_delay: bool, ts: time_point) -> _latency_result:
        """Measures the latency between two audio streams

        :param channel0: Audio channel 0
        :param channel1: Audio channel 1
        :param include_pres_delay: Include presentation delay
        :param ts: Timestamp

        :return: Array of latency results
        """
        res_data = _libbluespy.bluespy_measure_latency(channel0,channel1,include_pres_delay,ts)
        return res_data

## play_to_audiopod_output

    play_to_audiopod_output(filename, loop=False)

Playback audio file to audiopod

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`filename` | `str` | Audio file | required
`loop` | `bool` | Loop audio | `False`

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    1044
    1045
    1046
    1047
    1048
    1049
    1050
    1051
    1052
    1053
    def play_to_audiopod_output(filename: str, loop: bool = False):
        """Playback audio file to audiopod

        :param filename: Audio file
        :param loop: Loop audio

        :exception BluespyError: Exception in the bluespy library"""
        _handle_error(
            _libbluespy.bluespy_play_to_audiopod_output(filename.encode("utf-8"), loop)
        )

## reboot_moreph

    reboot_moreph(serial=-1)

Reboot Moreph hardware via USB or Ethernet.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`serial` | `int` | A serial number as an integer, or -1 to connect to the first device. The serial number shown in the software and on the MiniMoreph is hexadecimal, so should be entered as 0xNNNNNN. There is a serial number on the bottom of some Moreph30s is of the form AYYYY-XXXXX, the XXXXX is the required serial number in decimal. | `-1`

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library This function will cause the specified Moreph to disconnect - bluespy.connect(serial) needs to be called afterwards to talk to the Moreph again

Source code in `application/bluespy.py`

    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    def reboot_moreph(serial: int=-1):
        """Reboot Moreph hardware via USB or Ethernet.

        :param serial: A serial number as an integer, or -1 to connect to the first device.
        The serial number shown in the software and on the MiniMoreph is hexadecimal, so should be entered as 0xNNNNNN.
        There is a serial number on the bottom of some Moreph30s is of the form AYYYY-XXXXX, the XXXXX is the required serial number in decimal.

        :exception BluespyError: Exception in the bluespy library

        This function will cause the specified Moreph to disconnect - bluespy.connect(serial) needs to be called
        afterwards to talk to the Moreph again
        """
        _handle_error(_libbluespy.bluespy_moreph_reboot(serial))

## set_cis_lc3_config

    set_cis_lc3_config(audio_id, codec_frames_per_SDU=1, presentation_delay_us=40000, octets_per_codec_frame=120, frame_duration_us=10000, sampling_frequency_Hz=48000, audio_channel_allocation=256)

Set the config of a CIS stream

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`audio_id` | `audiostream_id` | CIS stream ID | required
`codec_frames_per_SDU` | `int` | Codec Frames per SDU | `1`
`presentation_delay_us` | `int` | Presentation Delay in μs | `40000`
`octets_per_codec_frame` | `int` | Octets per Codec Frame | `120`
`frame_duration_us` | `int` | Frame Duration in μs | `10000`
`sampling_frequency_Hz` | `int` | Sample Rate in Hz | `48000`
`audio_channel_allocation` | `int` | Audio Channel Allocation mask | `256`

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    1013
    1014
    1015
    1016
    1017
    1018
    1019
    1020
    1021
    1022
    1023
    1024
    1025
    1026
    1027
    1028
    1029
    1030
    1031
    1032
    1033
    1034
    1035
    1036
    1037
    1038
    1039
    1040
    1041
    1042
    def set_cis_lc3_config(
            audio_id: audiostream_id,
            codec_frames_per_SDU: int=1,
            presentation_delay_us: int= 40000,
            octets_per_codec_frame: int= 120,
            frame_duration_us: int= 10000,
            sampling_frequency_Hz: int= 48000,
            audio_channel_allocation: int = 0x100
            ):
        """Set the config of a CIS stream

        :param audio_id: CIS stream ID
        :param codec_frames_per_SDU: Codec Frames per SDU
        :param presentation_delay_us: Presentation Delay in μs
        :param octets_per_codec_frame: Octets per Codec Frame
        :param frame_duration_us: Frame Duration in μs
        :param sampling_frequency_Hz: Sample Rate in Hz
        :param audio_channel_allocation: Audio Channel Allocation mask

        :exception BluespyError: Exception in the bluespy library"""
        conf = _cis_lc3_config()
        conf.codec_frames_per_SDU = codec_frames_per_SDU
        conf.presentation_delay_us = presentation_delay_us
        conf.octets_per_codec_frame = octets_per_codec_frame
        conf.frame_duration_us = frame_duration_us
        conf.sampling_frequency_Hz = sampling_frequency_Hz
        conf.audio_channel_allocation = audio_channel_allocation
        _handle_error(
            _libbluespy.bluespy_set_cis_lc3_config(audio_id, _ct.byref(conf))
        )

## set_pin_current

    set_pin_current(current)

Set this based on the pins you are using.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`current` | `str` | The pins you are using. "1mA", "10mA", "100mA", or "1A" The value is only used to return correctly scale mA values in audiopod_current | required

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    1160
    1161
    1162
    1163
    1164
    1165
    1166
    1167
    1168
    1169
    1170
    1171
    1172
    1173
    1174
    1175
    1176
    1177
    1178
    1179
    1180
    def set_pin_current(current: str):
        """ Set this based on the pins you are using.

        :param current: The pins you are using. "1mA", "10mA", "100mA", or "1A"

        The value is only used to return correctly scale mA values in audiopod_current

        :exception BluespyError: Exception in the bluespy library
        """
        current_i = 1
        if (current == "1mA"):
            current_i = 1
        elif (current == "10mA"):
            current_i = 10
        elif (current == "100mA"):
            current_i = 100
        elif (current == "1A"):
            current_i = 1000
        else:
            raise ValueError("Invalid current selection")
        _handle_error(_libbluespy.bluespy_set_pin_current(current_i))

## start_gui

    start_gui()

Spawn an instance of the user interface

Source code in `application/bluespy.py`

    956
    957
    958
    def start_gui():
        """Spawn an instance of the user interface"""
        _libbluespy.bluespy_start_gui()

## stop_audio

    stop_audio()

Stop file in playback

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    1055
    1056
    1057
    1058
    1059
    1060
    1061
    def stop_audio():
        """Stop file in playback

        :exception BluespyError: Exception in the bluespy library"""
        _handle_error(
            _libbluespy.bluespy_stop_audio()
        )

## stop_capture

    stop_capture()

Stop the current capture

Raises:

Type | Description
--- | ---
`BluespyError` | Exception in the bluespy library

Source code in `application/bluespy.py`

    586
    587
    588
    589
    590
    591
    def stop_capture():
        """Stop the current capture

        :exception BluespyError: Exception in the bluespy library"""
        atexit.unregister(stop_capture)
        _handle_error(_libbluespy.bluespy_stop_capture())

## version

    version()

Returns the blueSPY version as an integer. e.g. 260328 for 26.03.28

Returns:

Type | Description
--- | ---
`int` | Version number

Source code in `application/bluespy.py`

    1202
    1203
    1204
    1205
    1206
    1207
    1208
    def version() -> int:
        """ Returns the blueSPY version as an integer.
        e.g. 260328 for 26.03.28

        :return int: Version number
        """
        return _libbluespy.bluespy_version()

## wait_until_next_logic_change

    wait_until_next_logic_change(mask, timeout, ts)

Waits until a logic line in the specified mask changes or until the given timeout period passes

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`mask` | `int` | 32 integer mask. logic lines corresponding to zero bits are ignored | required
`timeout` | `int` | Timeout in ns | required
`ts` | `time_point` | Time to wait from | required

Returns:

Type | Description
--- | ---
`_logic_change` | A struct containing the new state, the line which switched, the time of the switch, and whether the logic state changed or the function timed out. True = Logic changed. False = Timeout

Source code in `application/bluespy.py`

    934
    935
    936
    937
    938
    939
    940
    941
    942
    943
    def wait_until_next_logic_change(mask: int, timeout: int, ts: time_point) -> _logic_change:
        """Waits until a logic line in the specified mask changes or until the given timeout period passes

        :param mask: 32 integer mask. logic lines corresponding to zero bits are ignored
        :param timeout: Timeout in ns
        :param ts: Time to wait from

        :return: A struct containing the new state, the line which switched, the time of the switch, and whether the logic state changed or the function timed out. True = Logic changed. False = Timeout"""

        return _libbluespy.bluespy_wait_until_next_logic_change(mask, timeout, ts)