summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLevi Oliver <levio@google.com>2016-08-09 15:22:36 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-08-11 14:46:33 -0700
commit25c7cc0e4f62633660c8204f527fe19933c6b1ea (patch)
tree8698c45d0b52323f06bea4c46c5d52a54c538e30
parentbf302b55e9973a5c6e3e59722a9d3062e7936832 (diff)
downloadchrome-ec-25c7cc0e4f62633660c8204f527fe19933c6b1ea.tar.gz
btle: Cleanup: Moved constants, renamed functions
Moved link layer-specific constants into link layer .h file. Renamed data channel function to better represent its function. TEST=make BOARD=hadoken BUG=None BRANCH=None Change-Id: I239d535cf3725bf003443fc211fc802bc8aee13f Signed-off-by: Levi Oliver <levio@google.com> Reviewed-on: https://chromium-review.googlesource.com/367805 Commit-Ready: Myles Watson <mylesgw@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--common/bluetooth_le.c3
-rw-r--r--include/bluetooth_le.h20
-rw-r--r--include/bluetooth_le_ll.h32
3 files changed, 38 insertions, 17 deletions
diff --git a/common/bluetooth_le.c b/common/bluetooth_le.c
index 5627a8de74..bbc035a49d 100644
--- a/common/bluetooth_le.c
+++ b/common/bluetooth_le.c
@@ -65,8 +65,7 @@ void fill_remapping_table(struct remapping_table *rt, uint8_t map[5],
}
/* BLE 4.1 Vol 6 4.5.8 */
-
-int select_data_channel(struct remapping_table *rt)
+uint8_t get_next_data_channel(struct remapping_table *rt)
{
rt->last_unmapped_channel =
(rt->last_unmapped_channel + rt->hop_increment) % 37;
diff --git a/include/bluetooth_le.h b/include/bluetooth_le.h
index 46c17ac0bc..07a0dde5df 100644
--- a/include/bluetooth_le.h
+++ b/include/bluetooth_le.h
@@ -137,19 +137,6 @@ struct ble_adv_header {
#define BLE_MAX_ADV_PAYLOAD_OCTETS 37
-/* BLE 4.1 Vol 6 2.3.3.1 */
-struct ble_ll_data {
- uint8_t aa[4]; /* Access Address */
- uint8_t crc_init[3];
- uint8_t win_size; /* Transmit Window Size */
- uint16_t win_offset; /* Transmit Window Offset */
- uint16_t interval; /* Connection Interval */
- uint16_t latency; /* Connection Slave Latency */
- uint16_t timeout; /* Connection Supervision Timeout */
- uint8_t chm[5]; /* 37-bit Channel Map */
- uint8_t hop_and_sca; /* Hop Increment and Sleep-clock Accuracy */
-} __packed;
-
/* LL SCA Values. They are shifted left 5 bits for Hop values */
#define BLE_LL_SCA_251_PPM_TO_500_PPM (0 << 5)
#define BLE_LL_SCA_151_PPM_TO_250_PPM (1 << 5)
@@ -369,8 +356,11 @@ int ble_rx(struct ble_pdu *pdu, int timeout, int adv);
int ble_radio_init(uint32_t access_address, uint32_t crc_init_val);
-/* BLE 4.1 Vol 6 4.5.8 */
-int select_data_channel(struct remapping_table *rt);
+/*
+ * Uses the algorithm defined in the BLE core specifcation
+ * 4.1 Vol 6 4.5.8 to select the next data channel
+ */
+uint8_t get_next_data_channel(struct remapping_table *rt);
/* BLE 4.1 Vol 3 Part C 11 */
uint8_t *pack_adv(uint8_t *dest, int length, int type, const uint8_t *data);
diff --git a/include/bluetooth_le_ll.h b/include/bluetooth_le_ll.h
index 14520f1139..e6a94a6cfc 100644
--- a/include/bluetooth_le_ll.h
+++ b/include/bluetooth_le_ll.h
@@ -78,6 +78,38 @@ enum ll_state_t {
#define LL_PING_REQ 0x12
#define LL_PING_RSP 0x13
+/* BLE 4.1 Vol 6 2.3.3.1 Connection information */
+#define CONNECT_REQ_INITA_LEN 6
+#define CONNECT_REQ_ADVA_LEN 6
+#define CONNECT_REQ_ACCESS_ADDR_LEN 4
+#define CONNECT_REQ_CRC_INIT_VAL_LEN 3
+#define CONNECT_REQ_WIN_SIZE_LEN 1
+#define CONNECT_REQ_WIN_OFFSET_LEN 2
+#define CONNECT_REQ_INTERVAL_LEN 2
+#define CONNECT_REQ_LATENCY_LEN 2
+#define CONNECT_REQ_TIMEOUT_LEN 2
+#define CONNECT_REQ_CHANNEL_MAP_LEN 5
+#define CONNECT_REQ_HOP_INCREMENT_AND_SCA_LEN 1
+struct ble_connection_params {
+ uint8_t init_a[CONNECT_REQ_INITA_LEN];
+ uint8_t adv_a[CONNECT_REQ_ADVA_LEN];
+ uint32_t access_addr;
+ uint32_t crc_init_val;
+ uint8_t win_size;
+ uint16_t win_offset;
+ uint16_t interval;
+ uint16_t latency;
+ uint16_t timeout;
+ uint64_t channel_map;
+ uint8_t hop_increment;
+ uint8_t sleep_clock_accuracy;
+ uint32_t transmitWindowOffset;
+ uint32_t transmitWindowSize;
+ uint32_t connInterval;
+ uint16_t connSlaveLatency;
+ uint32_t connSupervisionTimeout;
+};
+
uint8_t ll_reset(void);
uint8_t ll_set_tx_power(uint8_t *params);