diff options
| author | JF <jf@codingfield.com> | 2019-12-23 18:57:45 (GMT) |
|---|---|---|
| committer | JF <jf@codingfield.com> | 2019-12-23 18:57:45 (GMT) |
| commit | e8f9304d37751e0344da4bd62183145235e071b5 (patch) | |
| tree | cd122ecdb56800da077d20d453f465e74f878bc5 /src/BLE/BleManager.h | |
| parent | 981dc3fce1c63e79687307cbe5019c9116f7ab2d (diff) | |
Code cleaning, implement BT connection, advertising, discovery and CTS in ble_manager module.
Diffstat (limited to 'src/BLE/BleManager.h')
| -rw-r--r-- | src/BLE/BleManager.h | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/BLE/BleManager.h b/src/BLE/BleManager.h new file mode 100644 index 0000000..21a91e3 --- /dev/null +++ b/src/BLE/BleManager.h @@ -0,0 +1,44 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#define BLE_MANAGER_CONN_CFG_TAG 1 /* A tag identifying the SoftDevice BLE configuration. */ +#define BLE_MANAGER__OBSERVER_PRIO 3 /* Application's BLE observer priority. You shouldn't need to modify this value. */ +#define BLE_MANAGER_DEVICE_NAME "PineTime" /* Name of device. Will be included in the advertising data.*/ +#define BLE_MANAGER_MANUFACTURER_NAME "Codingfield" + +#define BLE_MANAGER_MIN_CONN_INTERVAL MSEC_TO_UNITS(400, UNIT_1_25_MS) /* Minimum acceptable connection interval (0.4 seconds).*/ +#define BLE_MANAGER_MAX_CONN_INTERVAL MSEC_TO_UNITS(650, UNIT_1_25_MS) /*Maximum acceptable connection interval (0.65 second).*/ +#define BLE_MANAGER_SLAVE_LATENCY 0 /* Slave latency.*/ +#define BLE_MANAGER_CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) /* Connection supervisory time-out (4 seconds).*/ + +#define BLE_MANAGER_ADV_INTERVAL 300 /* The advertising interval (in units of 0.625 ms. This value corresponds to 187.5 ms).*/ +#define BLE_MANAGER_ADV_DURATION 18000 /* The advertising duration (180 seconds) in units of 10 milliseconds.*/ + +#define BLE_MANAGER_SEC_PARAM_BOND 1 /* Perform bonding. */ +#define BLE_MANAGER_SEC_PARAM_MITM 0 /* Man In The Middle protection not required. */ +#define BLE_MANAGER_SEC_PARAM_LESC 0 /* LE Secure Connections not enabled. */ +#define BLE_MANAGER_SEC_PARAM_KEYPRESS 0 /* Keypress notifications not enabled. */ +#define BLE_MANAGER_SEC_PARAM_IO_CAPABILITIES BLE_GAP_IO_CAPS_NONE /* No I/O capabilities. */ +#define BLE_MANAGER_SEC_PARAM_OOB 0 /* Out Of Band data not available. */ +#define BLE_MANAGER_SEC_PARAM_MIN_KEY_SIZE 7 /* Minimum encryption key size. */ +#define BLE_MANAGER_SEC_PARAM_MAX_KEY_SIZE 16 /* Maximum encryption key size. */ + +#define FIRST_CONN_PARAMS_UPDATE_DELAY 5000 /* Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */ +#define NEXT_CONN_PARAMS_UPDATE_DELAY 30000 /* Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */ +#define MAX_CONN_PARAMS_UPDATE_COUNT 3 /* Number of attempts before giving up the connection parameter negotiation. */ + + +void ble_manager_init(); +void ble_manager_start_advertising(void *p_erase_bonds); + +// TODO use signals from RTOS to notify new time +void ble_manager_set_callback(void (*OnNewTime)(uint8_t minutes, uint8_t hours)); + + + +#ifdef __cplusplus +} +#endif
\ No newline at end of file |
