mirror of
https://github.com/micropython/micropython.git
synced 2026-01-05 03:30:14 +01:00
extmod/modbluetooth: Implement configuration of address modes.
Changes `BLE.config('mac')` to return a tuple (addr_mode, addr).
Adds `BLE.config(addr_mode=...)` to set the addressing mode.
This commit is contained in:
committed by
Damien George
parent
1b1b22905e
commit
c4af714d58
@@ -79,15 +79,6 @@
|
||||
#define MP_BLUETOOTH_UUID_TYPE_32 (4)
|
||||
#define MP_BLUETOOTH_UUID_TYPE_128 (16)
|
||||
|
||||
// Address types (for the addr_type params).
|
||||
// Ports will need to map these to their own values.
|
||||
#define MP_BLUETOOTH_ADDR_PUBLIC (0x00) // Public (identity) address. (Same as NimBLE and NRF SD)
|
||||
#define MP_BLUETOOTH_ADDR_RANDOM_STATIC (0x01) // Random static (identity) address. (Same as NimBLE and NRF SD)
|
||||
#define MP_BLUETOOTH_ADDR_PUBLIC_ID (0x02) // (Same as NimBLE)
|
||||
#define MP_BLUETOOTH_ADDR_RANDOM_ID (0x03) // (Same as NimBLE)
|
||||
#define MP_BLUETOOTH_ADDR_RANDOM_PRIVATE_RESOLVABLE (0x12) // Random private resolvable address. (NRF SD 0x02)
|
||||
#define MP_BLUETOOTH_ADDR_RANDOM_PRIVATE_NON_RESOLVABLE (0x13) // Random private non-resolvable address. (NRF SD 0x03)
|
||||
|
||||
// Event codes for the IRQ handler.
|
||||
#define MP_BLUETOOTH_IRQ_CENTRAL_CONNECT (1)
|
||||
#define MP_BLUETOOTH_IRQ_CENTRAL_DISCONNECT (2)
|
||||
@@ -110,6 +101,11 @@
|
||||
#define MP_BLUETOOTH_IRQ_GATTC_INDICATE (19)
|
||||
#define MP_BLUETOOTH_IRQ_GATTS_INDICATE_DONE (20)
|
||||
|
||||
#define MP_BLUETOOTH_ADDRESS_MODE_PUBLIC (0)
|
||||
#define MP_BLUETOOTH_ADDRESS_MODE_RANDOM (1)
|
||||
#define MP_BLUETOOTH_ADDRESS_MODE_RPA (2)
|
||||
#define MP_BLUETOOTH_ADDRESS_MODE_NRPA (3)
|
||||
|
||||
/*
|
||||
These aren't included in the module for space reasons, but can be used
|
||||
in your Python code if necessary.
|
||||
@@ -173,8 +169,11 @@ void mp_bluetooth_deinit(void);
|
||||
// Returns true when the Bluetooth stack is active.
|
||||
bool mp_bluetooth_is_active(void);
|
||||
|
||||
// Gets the MAC addr of this device in big-endian format.
|
||||
void mp_bluetooth_get_device_addr(uint8_t *addr);
|
||||
// Gets the current address of this device in big-endian format.
|
||||
void mp_bluetooth_get_current_address(uint8_t *addr_type, uint8_t *addr);
|
||||
|
||||
// Sets the addressing mode to use.
|
||||
void mp_bluetooth_set_address_mode(uint8_t addr_mode);
|
||||
|
||||
// Get or set the GAP device name that will be used by service 0x1800, characteristic 0x2a00.
|
||||
size_t mp_bluetooth_gap_get_device_name(const uint8_t **buf);
|
||||
|
||||
Reference in New Issue
Block a user