Go to the documentation of this file.
43 #ifdef PREINIT_SUPPORTED
47 #ifdef MikroCCoreVersion
48 #if MikroCCoreVersion >= 1
65 #define BLE9_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
67 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX );
82 #define BLE9_RSP_READY 1
83 #define BLE9_RSP_NOT_READY 0
92 #define BLE9_CMD_SYSTEM_HELLO_ID 0x00010020ul
93 #define BLE9_CMD_SYSTEM_DATA_BUFFER_CLEAR_ID 0x14010020ul
94 #define BLE9_CMD_SYSTEM_RESET_ID 0x01010020ul
95 #define BLE9_CMD_SYSTEM_HALT_ID 0x2001010Cul
96 #define BLE9_CMD_SYSTEM_SET_TX_POWER_ID 0x17010020ul
97 #define BLE9_CMD_SYSTEM_GET_VERSION_ID 0x1B010020ul
98 #define BLE9_CMD_SYSTEM_SET_SOFT_TIMER_ID 0x19010020ul
99 #define BLE9_CMD_SYSTEM_SET_LAZY_SOFT_TIMER_ID 0x1A010020ul
100 #define BLE9_CMD_SYSTEM_SET_IDENTITY_ADDRESS_ID 0x13010020ul
101 #define BLE9_CMD_SYSTEM_GET_IDENTITY_ADDRESS_ID 0x15010020ul
102 #define BLE9_CMD_SYSTEM_DATA_BUFFER_WRITE_ID 0x12010020ul
105 #define BLE9_CMD_GAP_SET_PRIVACY_MODE_ID 0x01020020ul
106 #define BLE9_CMD_GAP_ENABLE_WHITELISTING_ID 0x03020020ul
109 #define BLE9_CMD_ADVERTISER_CREATE_ID 0x01040020ul
110 #define BLE9_CMD_ADVERTISER_DELETE_SET_ID 0x02040020ul
111 #define BLE9_CMD_ADVERTISER_START_ID 0x09040320ul
112 #define BLE9_CMD_ADVERTISER_STOP_ID 0x0A040020ul
113 #define BLE9_CMD_ADVERTISER_SET_TIMING_ID 0x03040020ul
114 #define BLE9_CMD_ADVERTISER_SET_PHY_ID 0x06040020ul
115 #define BLE9_CMD_ADVERTISER_SET_CHANNEL_MAP_ID 0x04040020ul
116 #define BLE9_CMD_ADVERTISER_SET_TX_POWER_ID 0x0B040020ul
117 #define BLE9_CMD_ADVERTISER_SET_REPORT_SCAN_REQUEST_ID 0x05040020ul
118 #define BLE9_CMD_ADVERTISER_SET_CONFIGURATION_ID 0x07040020ul
119 #define BLE9_CMD_ADVERTISER_CLEAR_CONFIGURATION_ID 0x08040020ul
120 #define BLE9_CMD_ADVERTISER_SET_DATA_ID 0x0F040020ul
121 #define BLE9_CMD_ADVERTISER_SET_LONG_DATA_ID 0x0E040020ul
122 #define BLE9_CMD_ADVERTISER_START_PERIODIC_ADVERTISING_ID 0x0C040020ul
123 #define BLE9_CMD_ADVERTISER_STOP_PERIODIC_ADVERTISING_ID 0x0D040020ul
126 #define BLE9_CMD_NULL 0
127 #define BLE9_SYSTEM_RESUME 0
128 #define BLE9_SYSTEM_HALT 1
134 #define DRV_RX_BUFFER_SIZE 100
135 #define DRV_TX_BUFFER_SIZE 100
593 uint16_t duration, uint8_t maxevents );
716 uint16_t adv_data_len, uint8_t *adv_data );
uart_t uart
Definition: ble9.h:284
#define DRV_RX_BUFFER_SIZE
Definition: ble9.h:134
err_t ble9_sys_halt(ble9_t *ctx, uint8_t halt)
Force radio to idle state and allow device to sleep. Advertising, scanning, connections,...
uart_data_bits_t data_bit
Definition: ble9.h:303
@ BLE9_DFU_RESET_MODE_OTA
Definition: ble9.h:150
ble9_version_t ble9_version
Definition: ble9.h:282
@ BLE9_ADVERTISER_MODE_CONNECTABLE_NONE
Non-connectable non-scannable.
Definition: ble9.h:218
void ble9_sys_set_id_addr(ble9_t *ctx, uint8_t *address, uint8_t type)
Set the device's Bluetooth identity address. The address can be a public device address or a static d...
@ BLE9_CHANNEL_ALL
Definition: ble9.h:164
@ BLE9_ADVERTISER_MODE_DISCOVERABLE_GENERAL
Device is not discoverable in either limited or generic discovery procedure but may be discovered usi...
Definition: ble9.h:203
uart_stop_bits_t stop_bit
Definition: ble9.h:305
err_t ble9_sys_hello(ble9_t *ctx)
Verify whether the communication between the host and the device is functional.
err_t ble9_adv_set_phy(ble9_t *ctx, ble9_phy_type_t primary_phy, ble9_phy_type_t secondary_phy)
Set advertising PHYs of the given advertising set. This setting will take effect next time that adver...
@ BLE9_ADVERTISER_MODE_DISCOVERABLE_USER_DATA
Definition: ble9.h:211
void ble9_generic_write(ble9_t *ctx, uint8_t *data_buf, uint16_t len)
Generic write function.
err_t ble9_sys_get_id_address(ble9_t *ctx, uint8_t *data_buf, uint8_t type)
Read the Bluetooth identity address used by the device, which can be a public or random static device...
ble9_dfu_reset_mode_t
Definition: ble9.h:144
void ble9_sys_reset(ble9_t *ctx, ble9_dfu_reset_mode_t reset_mode)
Reset the system. The command does not have a response but it triggers one of the boot events (normal...
@ BLE9_ADVERTISER_MODE_CONNECTABLE_SCANNABLE
Undirected scannable (Non-connectable but responds to scan requests)
Definition: ble9.h:224
@ BLE9_ADVERTISER_MODE_DISCOVERABLE_LIMITED
Discoverable using general discovery procedure.
Definition: ble9.h:200
uint16_t version_major
Major release version.
Definition: ble9.h:241
void ble9_send_command(ble9_t *ctx, uint32_t command)
Function for transmiting commands.
err_t ble9_gap_set_privacy_mode(ble9_t *ctx, uint8_t privacy, uint8_t interval_in_minutes)
Enable or disable the privacy feature on all GAP roles. New privacy mode will take effect for adverti...
@ BLE9_CHANNEL_37_39
Definition: ble9.h:162
err_t ble9_adv_start_per_adv(ble9_t *ctx, uint16_t interval_min, uint16_t interval_max, uint8_t flags)
Start periodic advertising on the given advertising set. The stack enables the advertising set automa...
void ble9_cfg_setup(ble9_cfg_t *cfg)
Config Object Initialization function.
uart_parity_t parity_bit
Definition: ble9.h:304
uint32_t ble9_timer_slack
Definition: ble9.h:272
uint32_t version_bootloader
Version hash.
Definition: ble9.h:249
int32_t ble9_generic_read(ble9_t *ctx, uint8_t *data_buf, uint16_t max_len)
Generic read function.
uint16_t version_build
Bootloader version.
Definition: ble9.h:247
uint32_t ble9_timer_time
Slack time in hardware clock ticks.
Definition: ble9.h:270
@ BLE9_PHY_TYPE_2M
(0x4) Coded PHY, 125k (S=8) or 500k (S=2).
Definition: ble9.h:173
@ BLE9_PHY_TYPE_CODED
(0xFF) Any PHYs the device supports.
Definition: ble9.h:176
@ BLE9_ADVERTISER_MODE_CONNECTABLE_DIRECTED
Undirected connectable scannable. This mode can only be used in legacy advertising PDUs.
Definition: ble9.h:221
@ BLE9_PACKAGE_TYPE_PERIODIC_ADVERTISING
Definition: ble9.h:190
@ BLE9_CHANNEL_37
Definition: ble9.h:158
@ BLE9_CHANNEL_38
Definition: ble9.h:159
@ BLE9_PHY_TYPE_1M
(0x1) 1M PHY.
Definition: ble9.h:171
Click configuration structure definition.
Definition: ble9.h:295
err_t ble9_adv_set_tx_power(ble9_t *ctx, int16_t power, int16_t *set_power)
Limit the maximum advertising TX power on the given advertising set. The maximum TX power of legacy a...
Click ctx object definition.
Definition: ble9.h:280
uint16_t version_patch
Build number.
Definition: ble9.h:245
@ BLE9_PHY_TYPE_ANY
Definition: ble9.h:179
@ BLE9_CHANNEL_39
Definition: ble9.h:161
uint32_t baud_rate
Definition: ble9.h:301
uint8_t ble9_adv_handle
Definition: ble9.h:281
ble9_package_type_t
Definition: ble9.h:184
@ BLE9_CHANNEL_37_38
Definition: ble9.h:160
err_t ble9_adv_stop_per_adv(ble9_t *ctx)
Stop the periodic advertising on the given advertising set. Counterpart with ble9_adv_start_per_adv....
err_t ble9_adv_set_report_scan_req(ble9_t *ctx, uint8_t report_scan_req)
Enable or disable the scan request notification of a given advertising set. This setting will take ef...
err_t ble9_adv_set_channel_map(ble9_t *ctx, ble9_channel_t channel_map)
Set the primary advertising channel map of the given advertising set. This setting will take effect n...
err_t ble9_sys_set_lazy_soft_timer(ble9_t *ctx, ble9_timer_t *ble9_timer)
Start a software timer with slack. The slack parameter allows the stack to optimize wakeups and save ...
uint8_t ble9_timer_single_shot
Frequency interval of events, which indicates how often to send events in hardware clock ticks (1 sec...
Definition: ble9.h:263
err_t ble9_adv_create_id(ble9_t *ctx)
Create an advertising ID. The handle of the created advertising ID is returned in response.
err_t ble9_adv_set_data(ble9_t *ctx, ble9_package_type_t packet_type, uint16_t adv_data_len, uint8_t *adv_data)
Set user-defined data in advertising packets, scan response packets, or periodic advertising packets....
err_t ble9_adv_set_configuration(ble9_t *ctx, uint8_t configurations)
Enable advertising configuration flags on the given advertising set. The configuration change will ta...
@ BLE9_PACKAGE_TYPE_ADVERTISING
Advertising packets.
Definition: ble9.h:186
err_t ble9_sys_data_buf_clear(ble9_t *ctx)
Remove all data from the system data buffer.
@ BLE9_ADVERTISER_MODE_CONNECTABLE_NONE_SCANABLE
Definition: ble9.h:230
err_t ble9_adv_start(ble9_t *ctx, ble9_adv_mode_discoverable_t discover, ble9_adv_mode_connectable_t connect)
Start advertising of a given advertising set with specified discoverable and connectable modes....
@ BLE9_CHANNEL_38_39
Definition: ble9.h:163
pin_name_t tx_pin
Definition: ble9.h:298
ble9_phy_type_t
Definition: ble9.h:169
ble9_adv_mode_discoverable_t
Definition: ble9.h:195
uint32_t version_hash
Definition: ble9.h:251
err_t ble9_gap_en_wlist(ble9_t *ctx, uint8_t enable)
Enable or disable whitelisting. The setting will be effective the next time that scanning is enabled.
uint8_t ble9_timer_handle
Timer handle to use, which is returned in timeout event.
Definition: ble9.h:258
pin_name_t rx_pin
Definition: ble9.h:297
err_t ble9_init(ble9_t *ctx, ble9_cfg_t *cfg)
Initialization function.
void ble9_sys_set_tx_power(ble9_t *ctx, int16_t min_power, int16_t max_power)
Set the global minimum and maximum radiated TX power levels for Bluetooth. This returns selected powe...
#define DRV_TX_BUFFER_SIZE
Definition: ble9.h:135
err_t ble9_sys_set_soft_timer(ble9_t *ctx, ble9_timer_t *ble9_timer)
Start a software timer. Multiple concurrent timers can be running simultaneously. 256 unique timer ha...
err_t ble9_adv_set_timing(ble9_t *ctx, uint16_t interval_min, uint16_t interval_max, uint16_t duration, uint8_t maxevents)
Set the advertising timing parameters of the given advertising set. This setting will take effect nex...
bool uart_blocking
Definition: ble9.h:302
err_t ble9_adv_clear_configuration(ble9_t *ctx, uint8_t configurations)
Disable advertising configuration flags on the given advertising set. The configuration change will t...
ble9_adv_mode_connectable_t
Definition: ble9.h:216
err_t ble9_sys_get_version(ble9_t *ctx)
Get the firmware version information.
ble9_channel_t
Definition: ble9.h:157
@ BLE9_DFU_RESET_MODE_UART
Boot to OTA DFU mode.
Definition: ble9.h:148
uint16_t version_minor
Patch release version.
Definition: ble9.h:243
err_t ble9_adv_set_long_data(ble9_t *ctx, ble9_package_type_t packet_type)
Set advertising data for a specified packet type and advertising set. Data currently in the system da...
@ BLE9_ADVERTISER_MODE_DISCOVERABLE_BROADCAST
Send advertising and/or scan response data defined by the user. The limited/general discoverable flag...
Definition: ble9.h:207
err_t ble9_adv_stop(ble9_t *ctx)
Stop the advertising of the given advertising set. Counterpart with ble9_adv_start....
@ BLE9_DFU_RESET_MODE_NORMAL
Boot to normal mode.
Definition: ble9.h:146
@ BLE9_PACKAGE_TYPE_SCAN_RESPONSE
Periodic advertising packets.
Definition: ble9.h:188
@ BLE9_ADVERTISER_MODE_CONNECTABLE_NONE_CONNECTABLE
Undirected connectable non-scannable. This mode can only be used in extended advertising PDUs.
Definition: ble9.h:227
err_t ble9_sys_data_buf_write(ble9_t *ctx, uint16_t data_len, uint8_t *wr_data)
Write data into the system data buffer. Data will be appended to the end of existing data.
@ BLE9_ADVERTISER_MODE_DISCOVERABLE_NONE
Not discoverable.
Definition: ble9.h:197
err_t ble9_adv_delete_id(ble9_t *ctx)
Delete an advertising ID.