digi.ccble.peripheral module

class digi.ccble.peripheral.ConnectCoreBLEPeripheral(adapter_address)[source]

Bases: Peripheral

Class used to represent a Bluetooth Low Energy UART peripheral.

The peripheral offers a UART service with two characteristics:
  • TX Characteristic: Used to allow connected devices to send data.

  • RX Characteristic: Used to allow connected devices to read/receive data.

Class constructor. Instantiates a new ConnectCoreBLEPeripheral object with the given adapter address.

Parameters:

adapter_address (String) – local adapter address.

start()[source]

Starts the peripheral.

stop()[source]

Stops the peripheral.

send_rx_data(data)[source]

Sends new data to the RX Characteristic.

Parameters:

data (Byterray) – data to be sent to the RX Characteristic.

Raises:

DBusException – if there is any error writing in the RX characteristic.

get_advertising_name()[source]

Returns the advertising device name.

Returns:

the advertising name.

Return type:

String

configure_advertising_name(device_name)[source]

Modifies the advertising device name.

Parameters:

device_name (String) – new advertising name.

is_device_connected()[source]

Returns whether there is any device connected or not.

Returns:

True if there is any device connected, False otherwise.

Return type:

Boolean

add_connection_changed_callback(callback)[source]

Adds a new callback to be notified when the connection status changes.

Parameters:

callback (Function) – the callback function to add. Receives a Boolean object.

del_connection_changed_callback(callback)[source]

Removes the given callback from the list.

Parameters:

callback (Function) – the callback function to remove.

add_data_received_callback(callback)[source]

Adds a new callback to be notified when data is written to the TX characteristic.

Parameters:

callback (Function) – the callback function to add. Receives a Byterray object.

del_data_received_callback(callback)[source]

Removes the given callback from the list.

Parameters:

callback (Function) – the callback function to remove.