Previous version which works for my stm32f401 Nucleo board
Fork of X_NUCLEO_IDB0XA1 by
Revision 128:46ae62a90136, committed 2015-10-06
- Comitter:
- Wolfgang Betz
- Date:
- Tue Oct 06 12:12:37 2015 +0200
- Parent:
- 127:66ab06ee67e0
- Parent:
- 126:32039585a969
- Commit message:
- Merge branch 'master' of hg::http://wobetz@developer.mbed.org/teams/ST/code/X_NUCLEO_IDB0XA1 into idb0xa1-split
Changed in this revision
diff -r 66ab06ee67e0 -r 46ae62a90136 BlueNRGDevice.h --- a/BlueNRGDevice.h Thu Sep 17 10:32:34 2015 +0200 +++ b/BlueNRGDevice.h Tue Oct 06 12:12:37 2015 +0200 @@ -62,7 +62,7 @@ virtual GattServer& getGattServer(); virtual const GattServer& getGattServer() const; virtual void waitForEvent(void); - + virtual GattClient& getGattClient() { return *gattClient; } @@ -90,7 +90,7 @@ DigitalOut nCS_; DigitalOut rst_; InterruptIn irq_; - + //FIXME: TBI (by now just placeholders to let build /*** betzw: placeholders ***/ GattClient *gattClient;
diff -r 66ab06ee67e0 -r 46ae62a90136 BlueNRG_HCI/hci/controller/bluenrg_gap_aci.c --- a/BlueNRG_HCI/hci/controller/bluenrg_gap_aci.c Thu Sep 17 10:32:34 2015 +0200 +++ b/BlueNRG_HCI/hci/controller/bluenrg_gap_aci.c Tue Oct 06 12:12:37 2015 +0200 @@ -27,11 +27,10 @@ #define MIN(a,b) ((a) < (b) )? (a) : (b) #define MAX(a,b) ((a) > (b) )? (a) : (b) -#ifdef BLUENRG_MS -tBleStatus aci_gap_init(uint8_t role, uint8_t privacy_enabled, uint8_t device_name_char_len, uint16_t* service_handle, uint16_t* dev_name_char_handle, uint16_t* appearance_char_handle) +tBleStatus aci_gap_init_IDB05A1(uint8_t role, uint8_t privacy_enabled, uint8_t device_name_char_len, uint16_t* service_handle, uint16_t* dev_name_char_handle, uint16_t* appearance_char_handle) { struct hci_request rq; - gap_init_cp cp; + gap_init_cp_IDB05A1 cp; gap_init_rp resp; cp.role = role; @@ -61,11 +60,10 @@ return 0; } -#else -tBleStatus aci_gap_init(uint8_t role, uint16_t* service_handle, uint16_t* dev_name_char_handle, uint16_t* appearance_char_handle) +tBleStatus aci_gap_init_IDB04A1(uint8_t role, uint16_t* service_handle, uint16_t* dev_name_char_handle, uint16_t* appearance_char_handle) { struct hci_request rq; - gap_init_cp cp; + gap_init_cp_IDB04A1 cp; gap_init_rp resp; cp.role = role; @@ -93,7 +91,6 @@ return 0; } -#endif tBleStatus aci_gap_set_non_discoverable(void) { @@ -121,7 +118,7 @@ uint8_t status; uint8_t buffer[40]; uint8_t indx = 0; - + if((unsigned int)(LocalNameLen + ServiceUUIDLen + 14) > sizeof(buffer)) return BLE_STATUS_INVALID_PARAMS; @@ -243,20 +240,38 @@ return 0; } -#if BLUENRG_MS -tBleStatus aci_gap_set_direct_connectable(uint8_t own_addr_type, uint8_t directed_adv_type, uint8_t initiator_addr_type, const uint8_t *initiator_addr) -#else -tBleStatus aci_gap_set_direct_connectable(uint8_t own_addr_type, uint8_t initiator_addr_type, const uint8_t *initiator_addr) -#endif +tBleStatus aci_gap_set_direct_connectable_IDB05A1(uint8_t own_addr_type, uint8_t directed_adv_type, uint8_t initiator_addr_type, const uint8_t *initiator_addr) { struct hci_request rq; - gap_set_direct_conectable_cp cp; + gap_set_direct_conectable_cp_IDB05A1 cp; uint8_t status; cp.own_bdaddr_type = own_addr_type; -#if BLUENRG_MS cp.directed_adv_type = directed_adv_type; -#endif + cp.direct_bdaddr_type = initiator_addr_type; + Osal_MemCpy(cp.direct_bdaddr, initiator_addr, 6); + + Osal_MemSet(&rq, 0, sizeof(rq)); + rq.ogf = OGF_VENDOR_CMD; + rq.ocf = OCF_GAP_SET_DIRECT_CONNECTABLE; + rq.cparam = &cp; + rq.clen = sizeof(cp); + rq.rparam = &status; + rq.rlen = 1; + + if (hci_send_req(&rq, FALSE) < 0) + return BLE_STATUS_TIMEOUT; + + return status; +} + +tBleStatus aci_gap_set_direct_connectable_IDB04A1(uint8_t own_addr_type, uint8_t initiator_addr_type, const uint8_t *initiator_addr) +{ + struct hci_request rq; + gap_set_direct_conectable_cp_IDB04A1 cp; + uint8_t status; + + cp.own_bdaddr_type = own_addr_type; cp.direct_bdaddr_type = initiator_addr_type; Osal_MemCpy(cp.direct_bdaddr, initiator_addr, 6); @@ -406,20 +421,35 @@ return status; } -#if BLUENRG_MS -tBleStatus aci_gap_set_non_connectable(uint8_t adv_type, uint8_t own_address_type) -#else -tBleStatus aci_gap_set_non_connectable(uint8_t adv_type) -#endif +tBleStatus aci_gap_set_non_connectable_IDB05A1(uint8_t adv_type, uint8_t own_address_type) { struct hci_request rq; - gap_set_non_connectable_cp cp; + gap_set_non_connectable_cp_IDB05A1 cp; uint8_t status; cp.advertising_event_type = adv_type; -#if BLUENRG_MS cp.own_address_type = own_address_type; -#endif + Osal_MemSet(&rq, 0, sizeof(rq)); + rq.ogf = OGF_VENDOR_CMD; + rq.ocf = OCF_GAP_SET_NON_CONNECTABLE; + rq.cparam = &cp; + rq.clen = sizeof(cp); + rq.rparam = &status; + rq.rlen = 1; + + if (hci_send_req(&rq, FALSE) < 0) + return BLE_STATUS_TIMEOUT; + + return status; +} + +tBleStatus aci_gap_set_non_connectable_IDB04A1(uint8_t adv_type) +{ + struct hci_request rq; + gap_set_non_connectable_cp_IDB04A1 cp; + uint8_t status; + + cp.advertising_event_type = adv_type; Osal_MemSet(&rq, 0, sizeof(rq)); rq.ogf = OGF_VENDOR_CMD; @@ -623,11 +653,10 @@ return status; } -#if BLUENRG_MS -tBleStatus aci_gap_allow_rebond(uint16_t conn_handle) +tBleStatus aci_gap_allow_rebond_IDB05A1(uint16_t conn_handle) { struct hci_request rq; - gap_allow_rebond_cp cp; + gap_allow_rebond_cp_IDB05A1 cp; uint8_t status; cp.conn_handle = conn_handle; @@ -645,8 +674,7 @@ return status; } -#else -tBleStatus aci_gap_allow_rebond(void) +tBleStatus aci_gap_allow_rebond_IDB04A1(void) { struct hci_request rq; uint8_t status; @@ -662,7 +690,6 @@ return status; } -#endif tBleStatus aci_gap_start_limited_discovery_proc(uint16_t scanInterval, uint16_t scanWindow, uint8_t own_address_type, uint8_t filterDuplicates) @@ -757,9 +784,7 @@ return status; } -#if BLUENRG_MS - -tBleStatus aci_gap_start_auto_conn_establish_proc(uint16_t scanInterval, uint16_t scanWindow, +tBleStatus aci_gap_start_auto_conn_establish_proc_IDB05A1(uint16_t scanInterval, uint16_t scanWindow, uint8_t own_bdaddr_type, uint16_t conn_min_interval, uint16_t conn_max_interval, uint16_t conn_latency, uint16_t supervision_timeout, uint16_t min_conn_length, @@ -831,9 +856,7 @@ return status; } -#else - -tBleStatus aci_gap_start_auto_conn_establish_proc(uint16_t scanInterval, uint16_t scanWindow, +tBleStatus aci_gap_start_auto_conn_establish_proc_IDB04A1(uint16_t scanInterval, uint16_t scanWindow, uint8_t own_bdaddr_type, uint16_t conn_min_interval, uint16_t conn_max_interval, uint16_t conn_latency, uint16_t supervision_timeout, uint16_t min_conn_length, @@ -913,14 +936,11 @@ return status; } -#endif - -#if BLUENRG_MS -tBleStatus aci_gap_start_general_conn_establish_proc(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, +tBleStatus aci_gap_start_general_conn_establish_proc_IDB05A1(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, uint8_t own_address_type, uint8_t filter_duplicates) { struct hci_request rq; - gap_start_general_conn_establish_proc_cp cp; + gap_start_general_conn_establish_proc_cp_IDB05A1 cp; uint8_t status; cp.scan_type = scan_type; @@ -943,12 +963,11 @@ return status; } -#else -tBleStatus aci_gap_start_general_conn_establish_proc(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, +tBleStatus aci_gap_start_general_conn_establish_proc_IDB04A1(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, uint8_t own_address_type, uint8_t filter_duplicates, uint8_t use_reconn_addr, const tBDAddr reconn_addr) { struct hci_request rq; - gap_start_general_conn_establish_proc_cp cp; + gap_start_general_conn_establish_proc_cp_IDB04A1 cp; uint8_t status; cp.scan_type = scan_type; @@ -973,7 +992,6 @@ return status; } -#endif tBleStatus aci_gap_start_selective_conn_establish_proc(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, uint8_t own_address_type, uint8_t filter_duplicates, uint8_t num_whitelist_entries, @@ -1124,8 +1142,7 @@ return status; } -#if BLUENRG_MS -tBleStatus aci_gap_resolve_private_address(const tBDAddr private_address, tBDAddr actual_address) +tBleStatus aci_gap_resolve_private_address_IDB05A1(const tBDAddr private_address, tBDAddr actual_address) { struct hci_request rq; gap_resolve_private_address_cp cp; @@ -1151,8 +1168,7 @@ return 0; } -#else -tBleStatus aci_gap_resolve_private_address(const tBDAddr address) +tBleStatus aci_gap_resolve_private_address_IDB04A1(const tBDAddr address) { struct hci_request rq; gap_resolve_private_address_cp cp; @@ -1173,7 +1189,6 @@ return status; } -#endif tBleStatus aci_gap_set_broadcast_mode(uint16_t adv_interv_min, uint16_t adv_interv_max, uint8_t adv_type, uint8_t own_addr_type, uint8_t adv_data_length, const uint8_t *adv_data, uint8_t num_whitelist_entries,
diff -r 66ab06ee67e0 -r 46ae62a90136 BlueNRG_HCI/hci/controller/bluenrg_gatt_aci.c --- a/BlueNRG_HCI/hci/controller/bluenrg_gatt_aci.c Thu Sep 17 10:32:34 2015 +0200 +++ b/BlueNRG_HCI/hci/controller/bluenrg_gatt_aci.c Tue Oct 06 12:12:37 2015 +0200 @@ -1438,8 +1438,7 @@ return 0; } -#if BLUENRG_MS -tBleStatus aci_gatt_read_handle_value_offset(uint16_t attr_handle, uint8_t offset, uint16_t data_len, uint16_t *data_len_out_p, uint8_t *data) +tBleStatus aci_gatt_read_handle_value_offset_IDB05A1(uint16_t attr_handle, uint8_t offset, uint16_t data_len, uint16_t *data_len_out_p, uint8_t *data) { struct hci_request rq; gatt_read_handle_val_offset_cp cp; @@ -1471,5 +1470,3 @@ return 0; } -#endif -
diff -r 66ab06ee67e0 -r 46ae62a90136 BlueNRG_HCI/hci/controller/bluenrg_l2cap_aci.c --- a/BlueNRG_HCI/hci/controller/bluenrg_l2cap_aci.c Thu Sep 17 10:32:34 2015 +0200 +++ b/BlueNRG_HCI/hci/controller/bluenrg_l2cap_aci.c Tue Oct 06 12:12:37 2015 +0200 @@ -55,15 +55,14 @@ return status; } -#if BLUENRG_MS -tBleStatus aci_l2cap_connection_parameter_update_response(uint16_t conn_handle, uint16_t interval_min, +tBleStatus aci_l2cap_connection_parameter_update_response_IDB05A1(uint16_t conn_handle, uint16_t interval_min, uint16_t interval_max, uint16_t slave_latency, uint16_t timeout_multiplier, uint16_t min_ce_length, uint16_t max_ce_length, uint8_t id, uint8_t accept) { struct hci_request rq; uint8_t status; - l2cap_conn_param_update_resp_cp cp; + l2cap_conn_param_update_resp_cp_IDB05A1 cp; cp.conn_handle = htobs(conn_handle); cp.interval_min = htobs(interval_min); @@ -88,14 +87,13 @@ return status; } -#else -tBleStatus aci_l2cap_connection_parameter_update_response(uint16_t conn_handle, uint16_t interval_min, +tBleStatus aci_l2cap_connection_parameter_update_response_IDB04A1(uint16_t conn_handle, uint16_t interval_min, uint16_t interval_max, uint16_t slave_latency, uint16_t timeout_multiplier, uint8_t id, uint8_t accept) { struct hci_request rq; uint8_t status; - l2cap_conn_param_update_resp_cp cp; + l2cap_conn_param_update_resp_cp_IDB04A1 cp; cp.conn_handle = htobs(conn_handle); cp.interval_min = htobs(interval_min); @@ -118,4 +116,3 @@ return status; } -#endif
diff -r 66ab06ee67e0 -r 46ae62a90136 BlueNRG_HCI/hci/controller/bluenrg_utils.c --- a/BlueNRG_HCI/hci/controller/bluenrg_utils.c Thu Sep 17 10:32:34 2015 +0200 +++ b/BlueNRG_HCI/hci/controller/bluenrg_utils.c Tue Oct 06 12:12:37 2015 +0200 @@ -120,25 +120,25 @@ /*********************************************************************** * Erase and Program sectors - ************************************************************************/ + ************************************************************************/ for(unsigned int i = FW_OFFSET; i < (number_sectors * SECTOR_SIZE); i += SECTOR_SIZE) { - num_erase_retries = 0; - while (num_erase_retries++ < MAX_ERASE_RETRIES) { - aci_updater_erase_sector(BASE_ADDRESS + i); - if ((i/SECTOR_SIZE) < (unsigned int)(number_sectors-1)) - data_size = DATA_SIZE; - else - data_size = MIN_WRITE_BLOCK_SIZE; - for (j=i; ((j<SECTOR_SIZE+i)&&(j<fw_size)); j += data_size) { - RETRY_COMMAND(aci_updater_program_data_block(BASE_ADDRESS+j, data_size, fw_image+j), MAX_WRITE_RETRIES, status); - if (status != BLE_STATUS_SUCCESS) - break; - } - if (status == BLE_STATUS_SUCCESS) - break; + num_erase_retries = 0; + while (num_erase_retries++ < MAX_ERASE_RETRIES) { + aci_updater_erase_sector(BASE_ADDRESS + i); + if ((i/SECTOR_SIZE) < (unsigned int)(number_sectors-1)) + data_size = DATA_SIZE; + else + data_size = MIN_WRITE_BLOCK_SIZE; + for (j=i; ((j<SECTOR_SIZE+i)&&(j<fw_size)); j += data_size) { + RETRY_COMMAND(aci_updater_program_data_block(BASE_ADDRESS+j, data_size, fw_image+j), MAX_WRITE_RETRIES, status); + if (status != BLE_STATUS_SUCCESS) + break; } - if (num_erase_retries == MAX_ERASE_RETRIES) - return BLE_UTIL_ACI_ERROR; + if (status == BLE_STATUS_SUCCESS) + break; + } + if (num_erase_retries == MAX_ERASE_RETRIES) + return BLE_UTIL_ACI_ERROR; } /***********************************************************************
diff -r 66ab06ee67e0 -r 46ae62a90136 BlueNRG_HCI/includes/bluenrg_aci_const.h --- a/BlueNRG_HCI/includes/bluenrg_aci_const.h Thu Sep 17 10:32:34 2015 +0200 +++ b/BlueNRG_HCI/includes/bluenrg_aci_const.h Tue Oct 06 12:12:37 2015 +0200 @@ -115,14 +115,18 @@ #define OCF_GAP_SET_DISCOVERABLE 0x0083 #define OCF_GAP_SET_DIRECT_CONNECTABLE 0x0084 -typedef __packed struct _gap_set_direct_conectable_cp{ +typedef __packed struct _gap_set_direct_conectable_cp_IDB05A1{ uint8_t own_bdaddr_type; -#if BLUENRG_MS uint8_t directed_adv_type; -#endif uint8_t direct_bdaddr_type; tBDAddr direct_bdaddr; -} PACKED gap_set_direct_conectable_cp; +} PACKED gap_set_direct_conectable_cp_IDB05A1; + +typedef __packed struct _gap_set_direct_conectable_cp_IDB04A1{ + uint8_t own_bdaddr_type; + uint8_t direct_bdaddr_type; + tBDAddr direct_bdaddr; +} PACKED gap_set_direct_conectable_cp_IDB04A1; #define GAP_SET_DIRECT_CONNECTABLE_CP_SIZE 8 #define OCF_GAP_SET_IO_CAPABILITY 0x0085 @@ -166,23 +170,17 @@ #define GAP_AUTHORIZATION_RESPONSE_CP_SIZE 3 #define OCF_GAP_INIT 0x008A -#ifdef BLUENRG_MS -///@cond BLUENRG_MS -typedef __packed struct _gap_init_cp{ +typedef __packed struct _gap_init_cp_IDB05A1{ uint8_t role; uint8_t privacy_enabled; uint8_t device_name_char_len; -} PACKED gap_init_cp; -#define GAP_INIT_CP_SIZE 3 -///@endcond -#else -///@cond BLUENRG -typedef __packed struct _gap_init_cp{ +} PACKED gap_init_cp_IDB05A1; +#define GAP_INIT_CP_SIZE_IDB05A1 3 + +typedef __packed struct _gap_init_cp_IDB04A1{ uint8_t role; -} PACKED gap_init_cp; -#define GAP_INIT_CP_SIZE 1 -///@endcond -#endif +} PACKED gap_init_cp_IDB04A1; +#define GAP_INIT_CP_SIZE_IDB04A1 1 typedef __packed struct _gap_init_rp{ uint8_t status; uint16_t service_handle; @@ -192,14 +190,15 @@ #define GAP_INIT_RP_SIZE 7 #define OCF_GAP_SET_NON_CONNECTABLE 0x008B -typedef __packed struct _gap_set_non_connectable_cp{ +typedef __packed struct _gap_set_non_connectable_cp_IDB05A1{ uint8_t advertising_event_type; -#if BLUENRG_MS -///@cond BLUENRG_MS uint8_t own_address_type; -///@endcond #endif -} PACKED gap_set_non_connectable_cp; +} PACKED gap_set_non_connectable_cp_IDB05A1; + +typedef __packed struct _gap_set_non_connectable_cp_IDB04A1{ + uint8_t advertising_event_type; +} PACKED gap_set_non_connectable_cp_IDB04A1; #define OCF_GAP_SET_UNDIRECTED_CONNECTABLE 0x008C typedef __packed struct _gap_set_undirected_connectable_cp{ @@ -252,14 +251,10 @@ #define OCF_GAP_CLEAR_SECURITY_DB 0x0094 #define OCF_GAP_ALLOW_REBOND_DB 0x0095 -#if BLUENRG_MS -///@cond BLUENRG_MS - typedef __packed struct _gap_allow_rebond_cp{ + +typedef __packed struct _gap_allow_rebond_cp_IDB05A1{ uint16_t conn_handle; -} PACKED gap_allow_rebond_cp; -///@endcond -#endif - +} PACKED gap_allow_rebond_cp_IDB05A1; #define OCF_GAP_START_LIMITED_DISCOVERY_PROC 0x0096 typedef __packed struct _gap_start_limited_discovery_proc_cp{ @@ -298,19 +293,15 @@ #define OCF_GAP_START_AUTO_CONN_ESTABLISH_PROC 0x0099 #define OCF_GAP_START_GENERAL_CONN_ESTABLISH_PROC 0x009A -#if BLUENRG_MS -///@cond BLUENRG_MS -typedef __packed struct _gap_start_general_conn_establish_proc_cp{ +typedef __packed struct _gap_start_general_conn_establish_proc_cp_IDB05A1{ uint8_t scan_type; uint16_t scan_interval; uint16_t scan_window; uint8_t own_address_type; uint8_t filter_duplicates; -} PACKED gap_start_general_conn_establish_proc_cp; -///@endcond -#else -///@cond BLUENRG -typedef __packed struct _gap_start_general_conn_establish_proc_cp{ +} PACKED gap_start_general_conn_establish_proc_cp_IDB05A1; + +typedef __packed struct _gap_start_general_conn_establish_proc_cp_IDB04A1{ uint8_t scan_type; uint16_t scan_interval; uint16_t scan_window; @@ -318,9 +309,7 @@ uint8_t filter_duplicates; uint8_t use_reconn_addr; tBDAddr reconn_addr; -} PACKED gap_start_general_conn_establish_proc_cp; -///@endcond -#endif +} PACKED gap_start_general_conn_establish_proc_cp_IDB04A1; #define OCF_GAP_START_SELECTIVE_CONN_ESTABLISH_PROC 0x009B #define GAP_START_SELECTIVE_CONN_ESTABLISH_PROC_CP_SIZE 8 @@ -376,14 +365,10 @@ tBDAddr address; } PACKED gap_resolve_private_address_cp; #define GAP_RESOLVE_PRIVATE_ADDRESS_CP_SIZE 6 -#if BLUENRG_MS -///@cond BLUENRG_MS typedef __packed struct _gap_resolve_private_address_rp{ uint8_t status; tBDAddr address; } PACKED gap_resolve_private_address_rp; -///@endcond -#endif #define OCF_GAP_SET_BROADCAST_MODE 0x00A1 #define GAP_SET_BROADCAST_MODE_CP_SIZE 6 @@ -736,9 +721,7 @@ #define L2CAP_CONN_PARAM_UPDATE_REQ_CP_SIZE 10 #define OCF_L2CAP_CONN_PARAM_UPDATE_RESP 0x0182 -#if BLUENRG_MS -///@cond BLUENRG_MS -typedef __packed struct _l2cap_conn_param_update_resp_cp{ +typedef __packed struct _l2cap_conn_param_update_resp_cp_IDB05A1{ uint16_t conn_handle; uint16_t interval_min; uint16_t interval_max; @@ -748,11 +731,9 @@ uint16_t max_ce_length; uint8_t id; uint8_t accept; -} PACKED l2cap_conn_param_update_resp_cp; -///@endcond -#else -///@cond BLUENRG -typedef __packed struct _l2cap_conn_param_update_resp_cp{ +} PACKED l2cap_conn_param_update_resp_cp_IDB05A1; + +typedef __packed struct _l2cap_conn_param_update_resp_cp_IDB04A1{ uint16_t conn_handle; uint16_t interval_min; uint16_t interval_max; @@ -760,11 +741,7 @@ uint16_t timeout_multiplier; uint8_t id; uint8_t accept; -} PACKED l2cap_conn_param_update_resp_cp; -///@endcond -#endif - -#endif /* DOXYGEN_SHOULD_SKIP_THIS */ +} PACKED l2cap_conn_param_update_resp_cp_IDB04A1; /** * @defgroup BlueNRG_Events BlueNRG events (vendor specific)
diff -r 66ab06ee67e0 -r 46ae62a90136 BlueNRG_HCI/includes/bluenrg_gap.h --- a/BlueNRG_HCI/includes/bluenrg_gap.h Thu Sep 17 10:32:34 2015 +0200 +++ b/BlueNRG_HCI/includes/bluenrg_gap.h Tue Oct 06 12:12:37 2015 +0200 @@ -185,21 +185,15 @@ * @name GAP Roles * @{ */ -#ifdef BLUENRG_MS -///@cond BLUENRG_MS -#define GAP_PERIPHERAL_ROLE (0x01) -#define GAP_BROADCASTER_ROLE (0x02) -#define GAP_CENTRAL_ROLE (0x04) -#define GAP_OBSERVER_ROLE (0x08) -///@endcond -#else -///@cond BLUENRG -#define GAP_PERIPHERAL_ROLE (0x01) -#define GAP_BROADCASTER_ROLE (0x02) -#define GAP_CENTRAL_ROLE (0x03) -#define GAP_OBSERVER_ROLE (0x04) -///@endcond -#endif +#define GAP_PERIPHERAL_ROLE_IDB05A1 (0x01) +#define GAP_BROADCASTER_ROLE_IDB05A1 (0x02) +#define GAP_CENTRAL_ROLE_IDB05A1 (0x04) +#define GAP_OBSERVER_ROLE_IDB05A1 (0x08) + +#define GAP_PERIPHERAL_ROLE_IDB04A1 (0x01) +#define GAP_BROADCASTER_ROLE_IDB04A1 (0x02) +#define GAP_CENTRAL_ROLE_IDB04A1 (0x03) +#define GAP_OBSERVER_ROLE_IDB04A1 (0x04) /** * @} */ @@ -218,11 +212,7 @@ #define GAP_GENERAL_CONNECTION_ESTABLISHMENT_PROC (0x10) #define GAP_SELECTIVE_CONNECTION_ESTABLISHMENT_PROC (0x20) #define GAP_DIRECT_CONNECTION_ESTABLISHMENT_PROC (0x40) -#if BLUENRG_MS -///@cond BLUENRG_MS -#define GAP_OBSERVATION_PROC (0x80) -///@endcond -#endif +#define GAP_OBSERVATION_PROC_IDB05A1 (0x80) /** * @} */
diff -r 66ab06ee67e0 -r 46ae62a90136 BlueNRG_HCI/includes/bluenrg_gap_aci.h --- a/BlueNRG_HCI/includes/bluenrg_gap_aci.h Thu Sep 17 10:32:34 2015 +0200 +++ b/BlueNRG_HCI/includes/bluenrg_gap_aci.h Tue Oct 06 12:12:37 2015 +0200 @@ -28,8 +28,6 @@ *@{ */ -#ifdef BLUENRG_MS -///@cond BLUENRG_MS /** * @brief Initialize the GAP layer. * @note Register the GAP service with the GATT. @@ -42,7 +40,7 @@ tBleStatus ret; uint16_t service_handle, dev_name_char_handle, appearance_char_handle; - ret = aci_gap_init(1, 0, 0x07, &service_handle, &dev_name_char_handle, &appearance_char_handle); + ret = aci_gap_init_IDB05A1(1, 0, 0x07, &service_handle, &dev_name_char_handle, &appearance_char_handle); if(ret){ PRINTF("GAP_Init failed.\n"); reboot(); @@ -61,14 +59,11 @@ * @param[out] appearance_char_handle Appearance Characteristic handle * @retval tBleStatus Value indicating success or error code. */ -tBleStatus aci_gap_init(uint8_t role, uint8_t privacy_enabled, +tBleStatus aci_gap_init_IDB05A1(uint8_t role, uint8_t privacy_enabled, uint8_t device_name_char_len, uint16_t* service_handle, uint16_t* dev_name_char_handle, uint16_t* appearance_char_handle); -///@endcond -#else -///@cond BLUENRG /** * @brief Initialize the GAP layer. * @note Register the GAP service with the GATT. @@ -83,7 +78,7 @@ tBleStatus ret; uint16_t service_handle, dev_name_char_handle, appearance_char_handle; - ret = aci_gap_init(1, &service_handle, &dev_name_char_handle, &appearance_char_handle); + ret = aci_gap_init_IDB04A1(1, &service_handle, &dev_name_char_handle, &appearance_char_handle); if(ret){ PRINTF("GAP_Init failed.\n"); reboot(); @@ -100,12 +95,10 @@ * @param[out] appearance_char_handle Appearance Characteristic handle * @retval tBleStatus Value indicating success or error code. */ -tBleStatus aci_gap_init(uint8_t role, +tBleStatus aci_gap_init_IDB04A1(uint8_t role, uint16_t* service_handle, uint16_t* dev_name_char_handle, uint16_t* appearance_char_handle); -///@endcond -#endif /** * @brief Set the Device in non-discoverable mode. @@ -300,8 +293,6 @@ const char *LocalName, uint8_t ServiceUUIDLen, uint8_t* ServiceUUIDList, uint16_t SlaveConnIntervMin, uint16_t SlaveConnIntervMax); -#if BLUENRG_MS -///@cond BLUENRG_MS /** * @brief Set the Device in direct connectable mode (as defined in GAP specification Volume 3, Section 9.3.3). * @note If the privacy is enabled, the reconnection address is used for advertising, otherwise the address @@ -317,7 +308,7 @@ * tBleStatus ret; * * const uint8_t central_address[] = {0x43,0x27,0x84,0xE1,0x80,0x02}; - * ret = aci_gap_set_direct_connectable(PUBLIC_ADDR, HIGH_DUTY_CYCLE_DIRECTED_ADV, PUBLIC_ADDR, central_address); + * ret = aci_gap_set_direct_connectable_IDB05A1(PUBLIC_ADDR, HIGH_DUTY_CYCLE_DIRECTED_ADV, PUBLIC_ADDR, central_address); * @endcode * * @@ -328,10 +319,7 @@ * @param InitiatorAddr Initiator's address (Little Endian). * @return Value indicating success or error code. */ -tBleStatus aci_gap_set_direct_connectable(uint8_t own_addr_type, uint8_t directed_adv_type, uint8_t initiator_addr_type, const uint8_t *initiator_addr); -///@endcond -#else -///@cond BLUENRG +tBleStatus aci_gap_set_direct_connectable_IDB05A1(uint8_t own_addr_type, uint8_t directed_adv_type, uint8_t initiator_addr_type, const uint8_t *initiator_addr); /** * @brief Set the Device in direct connectable mode (as defined in GAP specification Volume 3, Section 9.3.3). * @note If the privacy is enabled, the reconnection address is used for advertising, otherwise the address @@ -347,7 +335,7 @@ * tBleStatus ret; * * const uint8_t central_address = {0x43,0x27,0x84,0xE1,0x80,0x02}; - * ret = aci_gap_set_direct_connectable(PUBLIC_ADDR, PUBLIC_ADDR, central_address); + * ret = aci_gap_set_direct_connectable_IDB04A1(PUBLIC_ADDR, PUBLIC_ADDR, central_address); * @endcode * * @@ -357,9 +345,7 @@ * @param InitiatorAddr Initiator's address (Little Endian). * @return Value indicating success or error code. */ -tBleStatus aci_gap_set_direct_connectable(uint8_t own_addr_type, uint8_t initiator_addr_type, const uint8_t *initiator_addr); -///@endcond -#endif +tBleStatus aci_gap_set_direct_connectable_IDB04A1(uint8_t own_addr_type, uint8_t initiator_addr_type, const uint8_t *initiator_addr); /** * @brief Set the IO capabilities of the device. @@ -443,8 +429,6 @@ */ tBleStatus aci_gap_authorization_response(uint16_t conn_handle, uint8_t authorize); -#if BLUENRG_MS -///@cond BLUENRG_MS /** * @brief Put the device into non-connectable mode. * @param adv_type One of the allowed advertising types: @@ -458,10 +442,7 @@ * @arg @ref NON_RESOLVABLE_PRIVATE_ADDR * @return Value indicating success or error code. */ -tBleStatus aci_gap_set_non_connectable(uint8_t adv_type, uint8_t own_address_type); -///@endcond -#else -///@cond BLUENRG +tBleStatus aci_gap_set_non_connectable_IDB05A1(uint8_t adv_type, uint8_t own_address_type); /** * @brief Put the device into non-connectable mode. * @param adv_type One of the allowed advertising types: @@ -469,9 +450,7 @@ * @arg @ref ADV_NONCONN_IND : Non-connectable undirected advertising * @return Value indicating success or error code. */ -tBleStatus aci_gap_set_non_connectable(uint8_t adv_type); -///@endcond -#endif +tBleStatus aci_gap_set_non_connectable_IDB04A1(uint8_t adv_type); /** * @brief Put the device into undirected connectable mode. @@ -479,18 +458,16 @@ * as the advertiser's address. If not, the address of the type specified in own_addr_type * is used for advertising. * @param own_addr_type Type of our address used during advertising: - * @cond BLUENRG + * if BLUENRG (IDB04A1) * @arg @ref PUBLIC_ADDR. * @arg @ref STATIC_RANDOM_ADDR. - * @endcond - * @cond BLUENRG_MS + * else if BLUENRG_MS (IDB05A1) * If Privacy is disabled: * @arg @ref PUBLIC_ADDR. * @arg @ref STATIC_RANDOM_ADDR. * If Privacy is enabled: * @arg @ref RESOLVABLE_PRIVATE_ADDR * @arg @ref NON_RESOLVABLE_PRIVATE_ADDR - * @endcond * @param adv_filter_policy Filter policy: * @arg @ref NO_WHITE_LIST_USE * @arg @ref WHITE_LIST_FOR_ALL @@ -590,26 +567,19 @@ */ tBleStatus aci_gap_clear_security_database(void); -#if BLUENRG_MS -///@cond BLUENRG_MS /** * @brief Allows the security manager to complete the pairing procedure and re-bond with the master. * @note This command can be issued by the application if a @ref EVT_BLUE_GAP_BOND_LOST event is generated. * @param conn_handle * @return Value indicating success or error code. */ -tBleStatus aci_gap_allow_rebond(uint16_t conn_handle); -///@endcond -#else -///@cond BLUENRG +tBleStatus aci_gap_allow_rebond_IDB05A1(uint16_t conn_handle); /** * @brief Allows the security manager to complete the pairing procedure and re-bond with the master. * @note This command can be issued by the application if a @ref EVT_BLUE_GAP_BOND_LOST event is generated. * @return Value indicating success or error code. */ -tBleStatus aci_gap_allow_rebond(void); -///@endcond -#endif +tBleStatus aci_gap_allow_rebond_IDB04A1(void); /** * @brief Start the limited discovery procedure. @@ -670,8 +640,8 @@ /** * @brief Start the name discovery procedure. * @note A LE_Create_Connection call will be made to the controller by GAP with the initiator filter - * policy set to ignore whitelist and process connectable advertising packets only for the - * specified device. Once a connection is established, GATT procedure is started to read the + * policy set to Âignore whitelist and process connectable advertising packets only for the + * specified deviceÂ. Once a connection is established, GATT procedure is started to read the * device name characteristic. When the read is completed (successfully or unsuccessfully), * a @ref EVT_BLUE_GAP_PROCEDURE_COMPLETE event is given to the upper layer. The event also * contains the name of the device if the device name was read successfully. @@ -721,7 +691,7 @@ * @brief Start the auto connection establishment procedure. * @note The devices specified are added to the white list of the controller and a LE_Create_Connection * call will be made to the controller by GAP with the initiator filter policy set to - * use whitelist to determine which advertiser to connect to. When a command is issued to + * Âuse whitelist to determine which advertiser to connect toÂ. When a command is issued to * terminate the procedure by upper layer, a LE_Create_Connection_Cancel call will be made to the * controller by GAP. * The procedure is terminated when either a connection is successfully established with one of @@ -775,19 +745,14 @@ * @endcode * @return Value indicating success or error code. */ -#if BLUENRG_MS -///@cond BLUENRG_MS - tBleStatus aci_gap_start_auto_conn_establish_proc(uint16_t scanInterval, uint16_t scanWindow, +tBleStatus aci_gap_start_auto_conn_establish_proc_IDB05A1(uint16_t scanInterval, uint16_t scanWindow, uint8_t own_bdaddr_type, uint16_t conn_min_interval, uint16_t conn_max_interval, uint16_t conn_latency, uint16_t supervision_timeout, uint16_t min_conn_length, uint16_t max_conn_length, uint8_t num_whitelist_entries, const uint8_t *addr_array); -///@endcond -#else -///@cond BLUENRG -tBleStatus aci_gap_start_auto_conn_establish_proc(uint16_t scanInterval, uint16_t scanWindow, +tBleStatus aci_gap_start_auto_conn_establish_proc_IDB04A1(uint16_t scanInterval, uint16_t scanWindow, uint8_t own_bdaddr_type, uint16_t conn_min_interval, uint16_t conn_max_interval, uint16_t conn_latency, uint16_t supervision_timeout, uint16_t min_conn_length, @@ -796,13 +761,11 @@ const tBDAddr reconn_addr, uint8_t num_whitelist_entries, const uint8_t *addr_array); -///@endcond -#endif /** * @brief Start a general connection establishment procedure. * @note The host enables scanning in the controller with the scanner filter policy set - * to accept all advertising packets and from the scanning results all the devices + * to Âaccept all advertising packets and from the scanning results all the devices * are sent to the upper layer using the event @ref EVT_BLUE_GAP_DEVICE_FOUND. * The upper layer then has to select one of the devices to which it wants to connect * by issuing the command aci_gap_create_connection(). The procedure is terminated @@ -832,23 +795,16 @@ * * @return Value indicating success or error code. */ -#if BLUENRG_MS -///@cond BLUENRG_MS -tBleStatus aci_gap_start_general_conn_establish_proc(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, +tBleStatus aci_gap_start_general_conn_establish_proc_IDB05A1(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, uint8_t own_address_type, uint8_t filter_duplicates); -///@endcond -#else -///@cond BLUENRG -tBleStatus aci_gap_start_general_conn_establish_proc(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, +tBleStatus aci_gap_start_general_conn_establish_proc_IDB04A1(uint8_t scan_type, uint16_t scan_interval, uint16_t scan_window, uint8_t own_address_type, uint8_t filter_duplicates, uint8_t use_reconn_addr, const tBDAddr reconn_addr); -///@endcond -#endif /** * @brief Start a selective connection establishment procedure. * @note The GAP adds the specified device addresses into white list and enables scanning in - * the controller with the scanner filter policy set to accept packets only from - * devices in whitelist. All the devices found are sent to the upper layer by the + * the controller with the scanner filter policy set to Âaccept packets only from + * devices in whitelistÂ. All the devices found are sent to the upper layer by the * event @ref EVT_BLUE_GAP_DEVICE_FOUND. The upper layer then has to select one of the * devices to which it wants to connect by issuing the command aci_gap_create_connection(). * On completion of the procedure a @ref EVT_BLUE_GAP_PROCEDURE_COMPLETE event is generated @@ -887,8 +843,8 @@ /** * @brief Start the direct connection establishment procedure. * @note A LE_Create_Connection call will be made to the controller by GAP with the initiator filter - * policy set to ignore whitelist and process connectable advertising packets only for the - * specified device. The procedure can be terminated explicitly by the upper layer by issuing + * policy set to Âignore whitelist and process connectable advertising packets only for the + * specified deviceÂ. The procedure can be terminated explicitly by the upper layer by issuing * the command aci_gap_terminate_gap_procedure(). When a command is issued to terminate the * procedure by upper layer, a LE_Create_Connection_Cancel call will be made to the controller * by GAP. @@ -1000,20 +956,20 @@ * the address is resolved successfully with any one of the IRKs present in the database, it * returns success. * @param address Address to be resolved. - * @cond BLUENRG_MS * @param[in] actual_address The public or static random address of the peer device, distributed during pairing phase. - * @endcond * @return Value indicating success or error code. */ -#if BLUENRG_MS -///@cond BLUENRG_MS -tBleStatus aci_gap_resolve_private_address(const tBDAddr private_address, tBDAddr actual_address); -///@endcond -#else -///@cond BLUENRG -tBleStatus aci_gap_resolve_private_address(const tBDAddr private_address); -///@endcond -#endif +tBleStatus aci_gap_resolve_private_address_IDB05A1(const tBDAddr private_address, tBDAddr actual_address); + +/** + * @brief Resolve a private address. + * @note This command tries to resolve the address provided with the IRKs present in its database. If + * the address is resolved successfully with any one of the IRKs present in the database, it + * returns success. + * @param address Address to be resolved. + * @return Value indicating success or error code. + */ +tBleStatus aci_gap_resolve_private_address_IDB04A1(const tBDAddr private_address); /** * @brief This command gets the list of bonded devices. @@ -1039,8 +995,6 @@ */ tBleStatus aci_gap_get_bonded_devices(uint8_t *num_devices, uint8_t *device_list, uint8_t device_list_size); -#if BLUENRG_MS -///@cond BLUENRG_MS /** * @brief Puts the device into broadcast mode * @note A privacy enabled device uses either a resolvable private address or a non-resolvable private address @@ -1074,7 +1028,7 @@ * @endcode * @return Value indicating success or error code. */ -tBleStatus aci_gap_set_broadcast_mode(uint16_t adv_interv_min, uint16_t adv_interv_max, uint8_t adv_type, +tBleStatus aci_gap_set_broadcast_mode_IDB05A1(uint16_t adv_interv_min, uint16_t adv_interv_max, uint8_t adv_type, uint8_t own_addr_type, uint8_t adv_data_length, const uint8_t *adv_data, uint8_t num_whitelist_entries, const uint8_t *addr_array); @@ -1101,7 +1055,7 @@ * @arg 0x01: Filter duplicates * @return Value indicating success or error code. */ -tBleStatus aci_gap_start_observation_procedure(uint16_t scan_interval, uint16_t scan_window, uint8_t scan_type, +tBleStatus aci_gap_start_observation_procedure_IDB05A1(uint16_t scan_interval, uint16_t scan_window, uint8_t scan_type, uint8_t own_address_type, uint8_t filter_duplicates); /** @@ -1114,9 +1068,7 @@ * @param peer_address Address used by the peer device while advertising. * @return Value indicating success or error code. */ -tBleStatus aci_gap_is_device_bonded(uint8_t peer_address_type, const tBDAddr peer_address); -///@endcond -#endif +tBleStatus aci_gap_is_device_bonded_IDB05A1(uint8_t peer_address_type, const tBDAddr peer_address); /** @@ -1226,19 +1178,14 @@ uint8_t data[VARIABLE_SIZE]; } PACKED evt_gap_procedure_complete; -#if BLUENRG_MS -///@cond BLUENRG_MS /** * This event is sent only by a privacy enabled Peripheral. The event is sent to the upper layers when the peripheral * is not able to resolve the private address of the peer device after connecting to it. */ -#define EVT_BLUE_GAP_ADDR_NOT_RESOLVED (0x0408) -typedef __packed struct _evt_gap_addr_not_resolved{ +#define EVT_BLUE_GAP_ADDR_NOT_RESOLVED_IDB05A1 (0x0408) +typedef __packed struct _evt_gap_addr_not_resolved_IDB05A1{ uint16_t conn_handle; /**< Connection handle for which the private address could not be resolved with any of the stored IRK's. */ -} PACKED evt_gap_addr_not_resolved; -///@endcond -#else -///@cond BLUENRG +} PACKED evt_gap_addr_not_resolved_IDB05A1; /** * This event is raised when the reconnection address is generated during the general connection * establishment procedure. The same address is set into the peer device also as a part of the general @@ -1247,12 +1194,10 @@ * as its own address as well as the peer address to which it wants to connect. See aci_gap_start_general_conn_establish_proc() * and aci_gap_start_auto_conn_establish_proc(). */ -#define EVT_BLUE_GAP_RECONNECTION_ADDRESS (0x0408) -typedef __packed struct _evt_gap_reconnection_addr{ +#define EVT_BLUE_GAP_RECONNECTION_ADDRESS_IDB04A1 (0x0408) +typedef __packed struct _evt_gap_reconnection_addr_IDB04A1{ uint8_t reconnection_address[6]; /**< 6 bytes of reconnection address that has been generated */ -} PACKED evt_gap_reconnection_addr; -///@endcond -#endif +} PACKED evt_gap_reconnection_addr_IDB04A1; /** * @}
diff -r 66ab06ee67e0 -r 46ae62a90136 BlueNRG_HCI/includes/bluenrg_gatt_aci.h --- a/BlueNRG_HCI/includes/bluenrg_gatt_aci.h Thu Sep 17 10:32:34 2015 +0200 +++ b/BlueNRG_HCI/includes/bluenrg_gatt_aci.h Tue Oct 06 12:12:37 2015 +0200 @@ -719,8 +719,6 @@ */ tBleStatus aci_gatt_read_handle_value(uint16_t attr_handle, uint16_t data_len, uint16_t *data_len_out_p, uint8_t *data); -#if BLUENRG_MS -///@cond BLUENRG_MS /** * @brief Reads the value of the attribute handle specified from the local GATT database, starting from a given offset. * @param attr_handle Handle of the attribute to read @@ -733,9 +731,7 @@ * attribute (in data_len_out_p). * @return Value indicating success or error code. */ -tBleStatus aci_gatt_read_handle_value_offset(uint16_t attr_handle, uint8_t offset, uint16_t data_len, uint16_t *data_len_out_p, uint8_t *data); -///@endcond -#endif +tBleStatus aci_gatt_read_handle_value_offset_IDB05A1(uint16_t attr_handle, uint8_t offset, uint16_t data_len, uint16_t *data_len_out_p, uint8_t *data); /** * @} @@ -750,20 +746,24 @@ /** * This event is raised to the application by the GATT server when a client modifies any attribute on the server, - * if event is enabled (see @ref Gatt_Event_Mask "Gatt Event Mask"). See @ref _evt_gatt_attr_modified. + * if event is enabled (see @ref Gatt_Event_Mask "Gatt Event Mask"). + * See @ref _evt_gatt_attr_modified_IDB04A1 or @ref _evt_gatt_attr_modified__IDB05A1. */ #define EVT_BLUE_GATT_ATTRIBUTE_MODIFIED (0x0C01) -typedef __packed struct _evt_gatt_attr_modified{ +typedef __packed struct _evt_gatt_attr_modified_IDB05A1{ uint16_t conn_handle; /**< The connection handle which modified the attribute. */ uint16_t attr_handle; /**< Handle of the attribute that was modified. */ uint8_t data_length; /**< The length of the data */ -#if BLUENRG_MS -///@cond BLUENRG_MS uint16_t offset; /**< Offset from which the write has been performed by the peer device */ -///@endcond -#endif uint8_t att_data[VARIABLE_SIZE]; /**< The new value (length is data_length) */ -} PACKED evt_gatt_attr_modified; +} PACKED evt_gatt_attr_modified_IDB05A1; + +typedef __packed struct _evt_gatt_attr_modified_IDB04A1{ + uint16_t conn_handle; /**< The connection handle which modified the attribute. */ + uint16_t attr_handle; /**< Handle of the attribute that was modified. */ + uint8_t data_length; /**< The length of the data */ + uint8_t att_data[VARIABLE_SIZE]; /**< The new value (length is data_length) */ +} PACKED evt_gatt_attr_modified_IDB04A1; /** * This event is generated by the client/server to the application on a GATT timeout (30 seconds).
diff -r 66ab06ee67e0 -r 46ae62a90136 BlueNRG_HCI/includes/bluenrg_l2cap_aci.h --- a/BlueNRG_HCI/includes/bluenrg_l2cap_aci.h Thu Sep 17 10:32:34 2015 +0200 +++ b/BlueNRG_HCI/includes/bluenrg_l2cap_aci.h Tue Oct 06 12:12:37 2015 +0200 @@ -54,33 +54,38 @@ * @param interval_max The maximum connection interval parameter as received in the l2cap connection update request event. * @param slave_latency The slave latency parameter as received in the l2cap connection update request event. * @param timeout_multiplier The supervision connection timeout parameter as received in the l2cap connection update request event. - * @cond BLUENRG_MS * @param min_ce_length Minimum length of connection event needed for the LE connection.\n * Range: 0x0000 - 0xFFFF\n * Time = N x 0.625 msec. * @param max_ce_length Maximum length of connection event needed for the LE connection.\n * Range: 0x0000 - 0xFFFF\n * Time = N x 0.625 msec. - * @endcond * @param id Identifier received in @ref EVT_BLUE_L2CAP_CONN_UPD_REQ event. * @param accept @arg 0x00: The connection update parameters are not acceptable. * @arg 0x01: The connection update parameters are acceptable. * @return Value indicating success or error code. */ -#if BLUENRG_MS -///@cond BLUENRG_MS -tBleStatus aci_l2cap_connection_parameter_update_response(uint16_t conn_handle, uint16_t interval_min, +tBleStatus aci_l2cap_connection_parameter_update_response_IDB05A1(uint16_t conn_handle, uint16_t interval_min, uint16_t interval_max, uint16_t slave_latency, uint16_t timeout_multiplier, uint16_t min_ce_length, uint16_t max_ce_length, uint8_t id, uint8_t accept); -///@endcond -#else -///@cond BLUENRG -tBleStatus aci_l2cap_connection_parameter_update_response(uint16_t conn_handle, uint16_t interval_min, + /** + * @brief Accept or reject a connection update. + * @note This command should be sent in response to a @ref EVT_BLUE_L2CAP_CONN_UPD_REQ event from the controller. + * The accept parameter has to be set if the connection parameters given in the event are acceptable. + * @param conn_handle Handle received in @ref EVT_BLUE_L2CAP_CONN_UPD_REQ event. + * @param interval_min The connection interval parameter as received in the l2cap connection update request event + * @param interval_max The maximum connection interval parameter as received in the l2cap connection update request event. + * @param slave_latency The slave latency parameter as received in the l2cap connection update request event. + * @param timeout_multiplier The supervision connection timeout parameter as received in the l2cap connection update request event. + * @param id Identifier received in @ref EVT_BLUE_L2CAP_CONN_UPD_REQ event. + * @param accept @arg 0x00: The connection update parameters are not acceptable. + * @arg 0x01: The connection update parameters are acceptable. + * @return Value indicating success or error code. + */ +tBleStatus aci_l2cap_connection_parameter_update_response_IDB04A1(uint16_t conn_handle, uint16_t interval_min, uint16_t interval_max, uint16_t slave_latency, uint16_t timeout_multiplier, uint8_t id, uint8_t accept); -///@endcond -#endif /** * @}
diff -r 66ab06ee67e0 -r 46ae62a90136 platform/src/btle.cpp --- a/platform/src/btle.cpp Thu Sep 17 10:32:34 2015 +0200 +++ b/platform/src/btle.cpp Tue Oct 06 12:12:37 2015 +0200 @@ -55,6 +55,7 @@ #include "bluenrg_aci.h" #include "bluenrg_hal_aci.h" #include "bluenrg_gap.h" +#include "bluenrg_utils.h" #include "hal_types.h" #include "hal.h" @@ -67,6 +68,8 @@ } #endif +#define IDB04A1 0 +#define IDB05A1 1 // static void btle_handler(/*ble_evt_t * p_ble_evt*/); void HCI_Input(tHciDataPacket * hciReadPacket); @@ -81,6 +84,8 @@ /* Private variables ---------------------------------------------------------*/ volatile uint8_t set_connectable = 1; // ANDREA +uint8_t bnrg_expansion_board = IDB04A1; /* at startup, suppose the X-NUCLEO-IDB04A1 is used */ + Gap::Address_t bleAddr; Gap::AddressType_t addr_type = Gap::ADDR_TYPE_PUBLIC; @@ -99,6 +104,8 @@ DEBUG("btle_init>>\n\r"); int ret; + uint8_t hwVersion; + uint16_t fwVersion; uint16_t service_handle, dev_name_char_handle, appearance_char_handle; /* Delay needed only to be able to acces the JTAG interface after reset @@ -111,6 +118,21 @@ /* Reset BlueNRG SPI interface */ BlueNRG_RST(); + /* get the BlueNRG HW and FW versions */ + getBlueNRGVersion(&hwVersion, &fwVersion); + + /* + * Reset BlueNRG again otherwise we won't + * be able to change its MAC address. + * aci_hal_write_config_data() must be the first + * command after reset otherwise it will fail. + */ + BlueNRG_RST(); + + if (hwVersion > 0x30) { /* X-NUCLEO-IDB05A1 expansion board is used */ + bnrg_expansion_board = IDB05A1; + } + /* The Nucleo board must be configured as SERVER */ //check if isSetAddress is set than set address. // ANDREA @@ -139,11 +161,12 @@ PRINTF("GATT_Init failed.\n"); } //GAP is always in PERIPHERAL _ROLE as mbed does not support Master role at the moment -#ifdef BLUENRG_MS - ret = aci_gap_init(GAP_PERIPHERAL_ROLE, 0, 0x07, &service_handle, &dev_name_char_handle, &appearance_char_handle); -#else - ret = aci_gap_init(GAP_PERIPHERAL_ROLE, &service_handle, &dev_name_char_handle, &appearance_char_handle); -#endif + if (bnrg_expansion_board == IDB05A1) { + ret = aci_gap_init_IDB05A1(GAP_PERIPHERAL_ROLE_IDB05A1, 0, 0x07, &service_handle, &dev_name_char_handle, &appearance_char_handle); + } else { + ret = aci_gap_init_IDB04A1(GAP_PERIPHERAL_ROLE_IDB04A1, &service_handle, &dev_name_char_handle, &appearance_char_handle); + } + if(ret != BLE_STATUS_SUCCESS){ PRINTF("GAP_Init failed.\n"); } @@ -228,6 +251,65 @@ //HAL_GPIO_EXTI_Callback_Poll(BNRG_SPI_EXTI_PIN); return; } + +void Attribute_Modified_CB(uint16_t attr_handle, uint8_t data_length, uint8_t *att_data, uint8_t offset) +{ + //Extract the GattCharacteristic from p_characteristics[] and find the properties mask + GattCharacteristic *p_char = BlueNRGGattServer::getInstance().getCharacteristicFromHandle(attr_handle); + if(p_char!=NULL) { + GattAttribute::Handle_t charHandle = p_char->getValueAttribute().getHandle(); + BlueNRGGattServer::HandleEnum_t currentHandle = BlueNRGGattServer::CHAR_HANDLE; + DEBUG("CharHandle %d, length: %d, Data: %d\n\r", charHandle, data_length, (uint16_t)att_data[0]); + DEBUG("getProperties 0x%x\n\r",p_char->getProperties()); + if(attr_handle == charHandle+CHAR_VALUE_OFFSET) { + currentHandle = BlueNRGGattServer::CHAR_VALUE_HANDLE; + } + + if(attr_handle == charHandle+CHAR_DESC_OFFSET) { + currentHandle = BlueNRGGattServer::CHAR_DESC_HANDLE; + } + DEBUG("currentHandle %d\n\r", currentHandle); + if((p_char->getProperties() & + (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE)) && + currentHandle == BlueNRGGattServer::CHAR_DESC_HANDLE) { + + DEBUG("*****NOTIFICATION CASE\n\r"); + //Now Check if data written in Enable or Disable + if((uint16_t)att_data[0]==1) { + //DEBUG("Notify ENABLED\n\r"); + BlueNRGGattServer::getInstance().HCIEvent(GattServerEvents::GATT_EVENT_UPDATES_ENABLED, p_char->getValueAttribute().getHandle()); + } else { + //DEBUG("Notify DISABLED\n\r"); + BlueNRGGattServer::getInstance().HCIEvent(GattServerEvents::GATT_EVENT_UPDATES_DISABLED, p_char->getValueAttribute().getHandle()); + } + } + + //Check is attr handle property is WRITEABLE, if yes, generate GATT_EVENT_DATA_WRITTEN Event + if((p_char->getProperties() & + (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE)) && + currentHandle == BlueNRGGattServer::CHAR_VALUE_HANDLE) { + + DEBUG("*****WRITE CASE\n\r"); + + GattWriteCallbackParams writeParams; + writeParams.handle = p_char->getValueAttribute().getHandle(); + writeParams.writeOp = GattWriteCallbackParams::OP_WRITE_REQ;//Where to find this property in BLUENRG? + writeParams.len = data_length; + writeParams.data = att_data; + if (bnrg_expansion_board == IDB05A1) { + writeParams.offset = offset; + } + BlueNRGGattServer::getInstance().HCIDataWrittenEvent(&writeParams); + + //BlueNRGGattServer::getInstance().handleEvent(GattServerEvents::GATT_EVENT_DATA_WRITTEN, evt->attr_handle); + //Write the actual Data to the Attr Handle? (uint8_1[])att_data contains the data + if ((p_char->getValueAttribute().getValuePtr() != NULL) && (p_char->getValueAttribute().getInitialLength() > 0)) { + BlueNRGGattServer::getInstance().write(p_char->getValueAttribute().getHandle(), (uint8_t*)att_data, data_length, false); + } + } + } + +} #ifdef __cplusplus extern "C" { @@ -244,7 +326,6 @@ */ /**************************************************************************/ extern void HCI_Event_CB(void *pckt) { - hci_uart_pckt *hci_pckt = (hci_uart_pckt*)pckt; hci_event_pckt *event_pckt = (hci_event_pckt*)hci_pckt->data; @@ -319,67 +400,15 @@ case EVT_BLUE_GATT_ATTRIBUTE_MODIFIED: { + DEBUG("EVT_BLUE_GATT_ATTRIBUTE_MODIFIED\n\r"); /* this callback is invoked when a GATT attribute is modified extract callback data and pass to suitable handler function */ - evt_gatt_attr_modified *evt = (evt_gatt_attr_modified*)blue_evt->data; - DEBUG("EVT_BLUE_GATT_ATTRIBUTE_MODIFIED\n\r"); - - //Extract the GattCharacteristic from p_characteristics[] and find the properties mask - GattCharacteristic *p_char = BlueNRGGattServer::getInstance().getCharacteristicFromHandle(evt->attr_handle); - if(p_char!=NULL) { - GattAttribute::Handle_t charHandle = p_char->getValueAttribute().getHandle(); - BlueNRGGattServer::HandleEnum_t currentHandle = BlueNRGGattServer::CHAR_HANDLE; - DEBUG("CharHandle %d, length: %d, Data: %d\n\r",charHandle, evt->data_length, (uint16_t)evt->att_data[0]); - DEBUG("getProperties 0x%x\n\r",p_char->getProperties()); - if(evt->attr_handle == charHandle+CHAR_VALUE_OFFSET) { - currentHandle = BlueNRGGattServer::CHAR_VALUE_HANDLE; - } - if(evt->attr_handle == charHandle+CHAR_DESC_OFFSET) { - currentHandle = BlueNRGGattServer::CHAR_DESC_HANDLE; - } - DEBUG("currentHandle %d\n\r", currentHandle); - if((p_char->getProperties() & - (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_INDICATE)) && - currentHandle == BlueNRGGattServer::CHAR_DESC_HANDLE) { - - DEBUG("*****NOTIFICATION CASE\n\r"); - //Now Check if data written in Enable or Disable - if((uint16_t)evt->att_data[0]==1) { - //DEBUG("Notify ENABLED\n\r"); - BlueNRGGattServer::getInstance().HCIEvent(GattServerEvents::GATT_EVENT_UPDATES_ENABLED, p_char->getValueAttribute().getHandle()); - } - else { - //DEBUG("Notify DISABLED\n\r"); - BlueNRGGattServer::getInstance().HCIEvent(GattServerEvents::GATT_EVENT_UPDATES_DISABLED, p_char->getValueAttribute().getHandle()); - } - } - - //Check is attr handle property is WRITEABLE, if yes, generate GATT_EVENT_DATA_WRITTEN Event - if((p_char->getProperties() & - (GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE)) && - currentHandle == BlueNRGGattServer::CHAR_VALUE_HANDLE) { - - DEBUG("*****WRITE CASE\n\r"); - - GattWriteCallbackParams writeParams; - writeParams.handle=p_char->getValueAttribute().getHandle(); - writeParams.writeOp=GattWriteCallbackParams::OP_WRITE_REQ;//Where to find this property in BLUENRG? - writeParams.len=evt->data_length; - writeParams.data=evt->att_data; - #ifdef BLUENRG_MS - writeParams.offset=evt->offset;//Not used in BlueNRG? - #endif - BlueNRGGattServer::getInstance().HCIDataWrittenEvent(&writeParams); - - //BlueNRGGattServer::getInstance().handleEvent(GattServerEvents::GATT_EVENT_DATA_WRITTEN, evt->attr_handle); - //Write the actual Data to the Attr Handle? (uint8_1[])evt->att_data contains the data - if ((p_char->getValueAttribute().getValuePtr() != NULL) && (p_char->getValueAttribute().getInitialLength() > 0)) { - BlueNRGGattServer::getInstance().write(p_char->getValueAttribute().getHandle(), - (uint8_t*)evt->att_data, - evt->data_length, - false /* localOnly */); - } - } + if (bnrg_expansion_board == IDB05A1) { + evt_gatt_attr_modified_IDB05A1 *evt = (evt_gatt_attr_modified_IDB05A1*)blue_evt->data; + Attribute_Modified_CB(evt->attr_handle, evt->data_length, evt->att_data, evt->offset); + } else { + evt_gatt_attr_modified_IDB04A1 *evt = (evt_gatt_attr_modified_IDB04A1*)blue_evt->data; + Attribute_Modified_CB(evt->attr_handle, evt->data_length, evt->att_data, 0); } } break;