| BlueNRG-1 Master/Central Library

- Main Page
- Classes
- Files

- File List
- File Members

master_basic_profile.h
Go to the documentation of this file.
1
21 /* Define to prevent recursive inclusion -------------------------------------*/
22 #ifndef __MASTER_BASIC_PROFILE_H
23 #define __MASTER_BASIC_PROFILE_H
24
25 /* Includes ------------------------------------------------------------------*/
26 #include "sm.h"
27
28 /* Defines -------------------------------------------------------------------*/
29
30 /********* Device Discovery Procedure *********/
31
36 #define LIMITED_DISCOVERY_PROCEDURE 0x01
37
42 #define GENERAL_DISCOVERY_PROCEDURE 0x02
43
48 #define DEVICE_DISCOVERED 0x01
49
55 #define DEVICE_DISCOVERY_PROCEDURE_ENDED 0x02
56
61 #define DEVICE_DISCOVERY_PROCEDURE_TIMEOUT 0x03
62
63 /******** Connection Procedure *********/
69 #define DIRECT_CONNECTION_PROCEDURE 0x03
70
76 #define AUTO_CONNECTION_PROCEDURE 0x04
77
84 #define CONNECTION_ESTABLISHED_EVT 0x01
85
92 #define CONNECTION_FAILED_EVT 0x02
93
98 #define DISCONNECTION_EVT 0x03
99
106 #define STOP_CONNECTION_PROCEDURE_EVT 0x04
107
114 #define CONNECTION_UPDATE_PARAMETER_REQUEST_EVT 0x05
115
116 /********* Services & Characteristics Management *********/
117
122 #define PRIMARY_SERVICE_DISCOVERY 0x01
123
129 #define GET_CHARACTERISTICS_OF_A_SERVICE 0x02
130
135 #define FIND_INCLUDED_SERVICES 0x03
136
142 #define FIND_CHARAC_DESCRIPTORS 0x04
143
144 /********* Data Exchange Procedure *********/
152 #define NOTIFICATION_INDICATION_CHANGE_STATUS 0x05
153
160 #define READ_VALUE_STATUS 0x06
161
168 #define WRITE_VALUE_STATUS 0x07
169
176 #define READ_LONG_VALUE_STATUS 0x08
177
183 #define NOTIFICATION_DATA_RECEIVED 0x09
184
190 #define INDICATION_DATA_RECEIVED 0x0A
191
197 #define ATTRIBUTE_MODIFICATION_RECEIVED 0x0B
198
207 #define WRITE_PERMIT_REQUEST 0x0C
208
217 #define READ_PERMIT_REQUEST 0x0D
218
219 /********* Master Basic Profile Error Code *********/
220
228 #define ERROR_INSUFFICIENT_AUTHENTICATION 0x05
229
237 #define ERROR_INSUFFICIENT_AUTHORIZATION 0x08
238
246 #define ERROR_INSUFFICIENT_ENCRYPTION 0x0F
247
248 /********* Security *********/
249
256 #define PASS_KEY_REQUEST 0x10
257
258 /* Typedef Definition --------------------------------------------------------*/
259
263 typedef struct initDevS {
265 uint8_t public_addr[6];
268 uint8_t device_name_len;
270 uint8_t *device_name;
282 uint8_t txPowerLevel;
283 } initDevType;
284
288 typedef struct securitySetS {
290 uint8_t ioCapability;
292 uint8_t mitm_mode;
294 uint8_t oob_enable;
296 uint8_t oob_data[16];
298 uint8_t bonding_mode;
300 uint8_t use_fixed_pin;
305 uint32_t fixed_pin;
306 } securitySetType;
307
311 typedef struct devDiscoveryS {
316 uint8_t procedure;
322 uint16_t scanInterval;
328 uint16_t scanWindow;
330 uint8_t own_address_type;
331 } devDiscoveryType;
332
336 typedef struct connDevS {
341 uint8_t procedure;
346 uint32_t fastScanDuration;
353 uint16_t fastScanInterval;
360 uint16_t fastScanWindow;
367 uint16_t reducedPowerScanInterval;
374 uint16_t reducedPowerScanWindow;
376 uint8_t peer_addr_type;
378 uint8_t peer_addr[6];
380 uint8_t own_addr_type;
387 uint16_t conn_min_interval;
394 uint16_t conn_max_interval;
398 uint16_t conn_latency;
404 uint16_t supervision_timeout;
409 uint16_t min_conn_length;
414 uint16_t max_conn_length;
415 } connDevType;
416
421 typedef struct connUpdateParamS {
426 uint8_t identifier;
433 uint16_t interval_min;
440 uint16_t interval_max;
444 uint16_t slave_latency;
450 uint16_t timeout_mult;
455 uint16_t min_conn_length;
460 uint16_t max_conn_length;
461 } connUpdateParamType;
462
467 typedef struct dataReceivedS {
469 uint16_t attr_handle;
471 uint8_t data_length;
473 uint8_t *data_value;
474 } dataReceivedType;
475
480 typedef struct dataPermitExchangeS {
482 uint16_t attr_handle;
484 uint8_t data_length;
486 uint8_t *data;
488 uint8_t offset;
489 } dataPermitExchangeType;
490
491 /* Function Prototypes -------------------------------------------------------*/
492
505 uint8_t Master_Init(initDevType *param);
506
508
522 uint8_t Master_DeviceDiscovery(devDiscoveryType *param);
523
528 uint8_t Master_TerminateDiscovery(void);
529
545 extern void Master_DeviceDiscovery_CB(uint8_t *status, uint8_t *addr_type, uint8_t *addr,
546 uint8_t *data_length, uint8_t *data,
547 uint8_t *RSSI);
548
550
561 uint8_t Master_DeviceConnection(connDevType *param);
562
577 extern void Master_Connection_CB(uint8_t *connection_evt, uint8_t *status,
578 uint16_t *connection_handle, connUpdateParamType *param);
579
587 uint8_t Master_TerminateGAPConnectionProcedure(void);
588
594 uint8_t Master_CloseConnection(uint16_t handle);
595
608 uint8_t Master_ConnectionUpdateParamResponse(uint16_t conn_handle, uint8_t accepted, connUpdateParamType *param);
609
611
635 uint8_t Master_GetPrimaryServices(uint16_t conn_handle, uint8_t *numPrimaryService, uint8_t *primaryService, uint16_t size);
636
658 uint8_t Master_GetCharacOfService(uint16_t conn_handle, uint16_t start_service_handle, uint16_t end_service_handle,
659 uint8_t *numCharac, uint8_t *charac, uint16_t size);
660
682 uint8_t Master_GetIncludeServices(uint16_t conn_handle, uint16_t start_service_handle, uint16_t end_service_handle,
683 uint8_t *numIncludedServices, uint8_t *includedServices, uint16_t size);
684
704 uint8_t Master_GetCharacDescriptors(uint16_t conn_handle, uint16_t start_value_charac_handle, uint16_t end_charac_handle,
705 uint8_t *numCharacDesc, uint8_t *characDesc, uint16_t size);
706
719 extern void Master_ServiceCharacPeerDiscovery_CB(uint8_t *procedure, uint8_t *status, uint16_t *connection_handle);
720
722
738 uint8_t Master_NotifIndic_Status(uint16_t conn_handle, uint16_t config_desc_handle,
739 uint8_t notification_enable, uint8_t indication_enable);
740
755 uint8_t Master_Read_Value(uint16_t conn_handle, uint16_t attr_value_handle,
756 uint16_t *data_length, uint8_t *data, uint16_t size);
757
758
774 uint8_t Master_Read_Long_Value(uint16_t conn_handle, uint16_t attr_value_handle,
775 uint16_t *data_length, uint8_t *data,
776 uint8_t offset, uint16_t size);
777
788 uint8_t Master_Write_Value(uint16_t conn_handle, uint16_t attr_value_handle,
789 uint8_t value_len, uint8_t *attr_value);
790
801 uint8_t Master_WriteWithoutResponse_Value(uint16_t conn_handle, uint16_t attr_value_handle,
802 uint8_t value_len, uint8_t* attr_value);
803
816 uint8_t Master_WriteResponse(uint16_t conn_handle, uint16_t attr_value_handle, uint8_t write_status, uint8_t err_code,
817 uint8_t attr_value_len, uint8_t *attr_value);
818
825 uint8_t Master_AllowRead(uint16_t conn_handle);
826
844 extern void Master_PeerDataExchange_CB(uint8_t *procedure, uint8_t *status,
845 uint16_t *connection_handle, dataReceivedType *data);
846
857 extern void Master_PeerDataPermitExchange_CB(uint8_t *procedure, uint16_t *connection_handle, dataPermitExchangeType *data);
858
860
871 uint8_t Master_SecuritySet(securitySetType *param);
872
880 uint8_t Master_Start_Pairing_Procedure(uint16_t conn_handle, uint8_t force_rebond);
881
890 uint8_t Master_Passkey_Response(uint16_t conn_handle, uint32_t key);
891
897 uint8_t Master_ClearSecurityDatabase(void);
898
916 extern void Master_Pairing_CB(uint16_t *conn_handle, uint8_t *status);
917
919
935 uint32_t Master_Process(void);
936
952 uint8_t Master_SetTxPower(uint8_t level);
953
959 uint8_t Master_HostExitTimeoutPowerSave(void);
960
962
963 #endif /* __MASTER_BASIC_PROFILE_H */
Master_GetPrimaryServices
uint8_t Master_GetPrimaryServices(uint16_t conn_handle, uint8_t *numPrimaryService, uint8_t *primaryService, uint16_t size)
Gets all primary service from the peer device. The primary service allocated on the connected peer de...
Master_DeviceConnection
uint8_t Master_DeviceConnection(connDevType *param)
Starts the connection procedure.
securitySetS::oob_data
uint8_t oob_data[16]
Definition: master_basic_profile.h:296
initDevS::device_name
uint8_t * device_name
Definition: master_basic_profile.h:270
initDevType
struct initDevS initDevType
Master initialization parameters.
connDevType
struct connDevS connDevType
Connection Device parameters.
securitySetS::oob_enable
uint8_t oob_enable
Definition: master_basic_profile.h:294
Master_AllowRead
uint8_t Master_AllowRead(uint16_t conn_handle)
This function allows the master to send a response to a read reqeust from the peer device...
dataPermitExchangeS::offset
uint8_t offset
Definition: master_basic_profile.h:488
securitySetS::bonding_mode
uint8_t bonding_mode
Definition: master_basic_profile.h:298
Master_TerminateGAPConnectionProcedure
uint8_t Master_TerminateGAPConnectionProcedure(void)
Terminates the GAP connection procedure ongoing.
securitySetS::mitm_mode
uint8_t mitm_mode
Definition: master_basic_profile.h:292
dataPermitExchangeS::data_length
uint8_t data_length
Definition: master_basic_profile.h:484
Master_PeerDataExchange_CB
void Master_PeerDataExchange_CB(uint8_t *procedure, uint8_t *status, uint16_t *connection_handle, dataReceivedType *data)
This callback will be called at the end of the following procedure:
connUpdateParamS::max_conn_length
uint16_t max_conn_length
Definition: master_basic_profile.h:460
Master_GetCharacOfService
uint8_t Master_GetCharacOfService(uint16_t conn_handle, uint16_t start_service_handle, uint16_t end_service_handle, uint8_t *numCharac, uint8_t *charac, uint16_t size)
Gets all characteristics of a service from the peer device. The characteristics of a service allocate...
securitySetS::ioCapability
uint8_t ioCapability
Definition: master_basic_profile.h:290
Master_ClearSecurityDatabase
uint8_t Master_ClearSecurityDatabase(void)
Clear the security database.
connDevS::conn_min_interval
uint16_t conn_min_interval
Definition: master_basic_profile.h:387
devDiscoveryType
struct devDiscoveryS devDiscoveryType
Device discovery parameters.
Master_HostExitTimeoutPowerSave
uint8_t Master_HostExitTimeoutPowerSave(void)
This function signals at the master that the host micro exits from a power save with timeout as advis...
connDevS::conn_latency
uint16_t conn_latency
Definition: master_basic_profile.h:398
connUpdateParamS::min_conn_length
uint16_t min_conn_length
Definition: master_basic_profile.h:455
connUpdateParamS::identifier
uint8_t identifier
Definition: master_basic_profile.h:426
connUpdateParamS::timeout_mult
uint16_t timeout_mult
Definition: master_basic_profile.h:450
Master_ConnectionUpdateParamResponse
uint8_t Master_ConnectionUpdateParamResponse(uint16_t conn_handle, uint8_t accepted, connUpdateParamType *param)
This function shall be called by the master when it receives a connection parameter update request fr...
connDevS::conn_max_interval
uint16_t conn_max_interval
Definition: master_basic_profile.h:394
devDiscoveryS::scanInterval
uint16_t scanInterval
Definition: master_basic_profile.h:322
Master_ServiceCharacPeerDiscovery_CB
void Master_ServiceCharacPeerDiscovery_CB(uint8_t *procedure, uint8_t *status, uint16_t *connection_handle)
This callback will be called at the end of the following procedure:
dataReceivedS::attr_handle
uint16_t attr_handle
Definition: master_basic_profile.h:469
Master_NotifIndic_Status
uint8_t Master_NotifIndic_Status(uint16_t conn_handle, uint16_t config_desc_handle, uint8_t notification_enable, uint8_t indication_enable)
This function sets the notification and indication status on the peer BLE device. ...
Master_Process
uint32_t Master_Process(void)
This function needs to be called inside a main loop to run the Master state machines.
connDevS::supervision_timeout
uint16_t supervision_timeout
Definition: master_basic_profile.h:404
Master_Read_Value
uint8_t Master_Read_Value(uint16_t conn_handle, uint16_t attr_value_handle, uint16_t *data_length, uint8_t *data, uint16_t size)
This function starts a read procedure on the peer BLE device.
connDevS::max_conn_length
uint16_t max_conn_length
Definition: master_basic_profile.h:414
dataPermitExchangeS::data
uint8_t * data
Definition: master_basic_profile.h:486
devDiscoveryS::procedure
uint8_t procedure
Definition: master_basic_profile.h:316
dataReceivedType
struct dataReceivedS dataReceivedType
Data received from the peer peripheral device during notification, indication and write request...
dataReceivedS
Data received from the peer peripheral device during notification, indication and write request...
Definition: master_basic_profile.h:467
connUpdateParamS::interval_min
uint16_t interval_min
Definition: master_basic_profile.h:433
dataPermitExchangeS::attr_handle
uint16_t attr_handle
Definition: master_basic_profile.h:482
initDevS
Master initialization parameters.
Definition: master_basic_profile.h:263
Master_SecuritySet
uint8_t Master_SecuritySet(securitySetType *param)
Sets the security parameter on the master device.
Master_WriteResponse
uint8_t Master_WriteResponse(uint16_t conn_handle, uint16_t attr_value_handle, uint8_t write_status, uint8_t err_code, uint8_t attr_value_len, uint8_t *attr_value)
This function allows or rejects a write reqeust from the peer device.
initDevS::device_name_len
uint8_t device_name_len
Definition: master_basic_profile.h:268
Master_WriteWithoutResponse_Value
uint8_t Master_WriteWithoutResponse_Value(uint16_t conn_handle, uint16_t attr_value_handle, uint8_t value_len, uint8_t *attr_value)
This function executes a write without response on the peer BLE device.
connDevS::fastScanDuration
uint32_t fastScanDuration
Definition: master_basic_profile.h:346
connDevS::peer_addr
uint8_t peer_addr[6]
Definition: master_basic_profile.h:378
dataReceivedS::data_length
uint8_t data_length
Definition: master_basic_profile.h:471
securitySetS
Master security parameter settings.
Definition: master_basic_profile.h:288
Master_DeviceDiscovery
uint8_t Master_DeviceDiscovery(devDiscoveryType *param)
Starts the device discovery procedure. The procedure is terminated when either the upper layers issue...
connDevS::fastScanInterval
uint16_t fastScanInterval
Definition: master_basic_profile.h:353
securitySetS::fixed_pin
uint32_t fixed_pin
Definition: master_basic_profile.h:305
connDevS::procedure
uint8_t procedure
Definition: master_basic_profile.h:341
connDevS::own_addr_type
uint8_t own_addr_type
Definition: master_basic_profile.h:380
dataReceivedS::data_value
uint8_t * data_value
Definition: master_basic_profile.h:473
initDevS::txPowerLevel
uint8_t txPowerLevel
Definition: master_basic_profile.h:282
dataPermitExchangeType
struct dataPermitExchangeS dataPermitExchangeType
Data received from the peer peripheral device when a write or a read request is received and the appl...
Master_Init
uint8_t Master_Init(initDevType *param)
Initializes the Device in Master mode, sets the public address and the TX otuput power.
connDevS::reducedPowerScanInterval
uint16_t reducedPowerScanInterval
Definition: master_basic_profile.h:367
Master_GetCharacDescriptors
uint8_t Master_GetCharacDescriptors(uint16_t conn_handle, uint16_t start_value_charac_handle, uint16_t end_charac_handle, uint8_t *numCharacDesc, uint8_t *characDesc, uint16_t size)
Starts the procedure to find all the characteristic descirptors from the peer device. The characteristic descriptors are available when the Master_ServiceCharacPeerDiscovery_CB() is raised with the procedure value euqal to FIND_CHARAC_DESCRIPTORS.
devDiscoveryS::own_address_type
uint8_t own_address_type
Definition: master_basic_profile.h:330
Master_Write_Value
uint8_t Master_Write_Value(uint16_t conn_handle, uint16_t attr_value_handle, uint8_t value_len, uint8_t *attr_value)
This function starts a write procedure on the peer BLE device.
connUpdateParamS::interval_max
uint16_t interval_max
Definition: master_basic_profile.h:440
connDevS::fastScanWindow
uint16_t fastScanWindow
Definition: master_basic_profile.h:360
connDevS::min_conn_length
uint16_t min_conn_length
Definition: master_basic_profile.h:409
Master_Read_Long_Value
uint8_t Master_Read_Long_Value(uint16_t conn_handle, uint16_t attr_value_handle, uint16_t *data_length, uint8_t *data, uint8_t offset, uint16_t size)
This function starts a read long procedure on the peer BLE device.
Master_PeerDataPermitExchange_CB
void Master_PeerDataPermitExchange_CB(uint8_t *procedure, uint16_t *connection_handle, dataPermitExchangeType *data)
This callback will be called when a read or write operation procedure is required from the peer devic...
Master_TerminateDiscovery
uint8_t Master_TerminateDiscovery(void)
Forces the end of the GAP device discovery procedure.
connDevS::peer_addr_type
uint8_t peer_addr_type
Definition: master_basic_profile.h:376
connDevS::reducedPowerScanWindow
uint16_t reducedPowerScanWindow
Definition: master_basic_profile.h:374
Master_GetIncludeServices
uint8_t Master_GetIncludeServices(uint16_t conn_handle, uint16_t start_service_handle, uint16_t end_service_handle, uint8_t *numIncludedServices, uint8_t *includedServices, uint16_t size)
Starts the procedure to find all the included sevices from the peer device. The included services are...
connDevS
Connection Device parameters.
Definition: master_basic_profile.h:336
connUpdateParamType
struct connUpdateParamS connUpdateParamType
Connection Parameters received from peer peripheral device during an l2cap connection parameter updat...
dataPermitExchangeS
Data received from the peer peripheral device when a write or a read request is received and the appl...
Definition: master_basic_profile.h:480
Master_CloseConnection
uint8_t Master_CloseConnection(uint16_t handle)
Close the connection with the peer device connected.
Master_Start_Pairing_Procedure
uint8_t Master_Start_Pairing_Procedure(uint16_t conn_handle, uint8_t force_rebond)
This function starts the pairing and bonding procedure with the peer BLE device.
Master_Pairing_CB
void Master_Pairing_CB(uint16_t *conn_handle, uint8_t *status)
This callback returns the pairing procedure status.
Master_SetTxPower
uint8_t Master_SetTxPower(uint8_t level)
Sets the TX output power level used during the communication Default value is -2.1 dBm...
connUpdateParamS::slave_latency
uint16_t slave_latency
Definition: master_basic_profile.h:444
securitySetType
struct securitySetS securitySetType
Master security parameter settings.
devDiscoveryS::scanWindow
uint16_t scanWindow
Definition: master_basic_profile.h:328
securitySetS::use_fixed_pin
uint8_t use_fixed_pin
Definition: master_basic_profile.h:300
Master_Connection_CB
void Master_Connection_CB(uint8_t *connection_evt, uint8_t *status, uint16_t *connection_handle, connUpdateParamType *param)
This callback returns the connection procedure status.
Master_Passkey_Response
uint8_t Master_Passkey_Response(uint16_t conn_handle, uint32_t key)
This command should be sent by the Host in response to PASS_KEY_REQUEST received from the Master_Pair...
connUpdateParamS
Connection Parameters received from peer peripheral device during an l2cap connection parameter updat...
Definition: master_basic_profile.h:421
devDiscoveryS
Device discovery parameters.
Definition: master_basic_profile.h:311
Master_DeviceDiscovery_CB
void Master_DeviceDiscovery_CB(uint8_t *status, uint8_t *addr_type, uint8_t *addr, uint8_t *data_length, uint8_t *data, uint8_t *RSSI)
This callback returns the remote device's information discovered during the scan. ...
initDevS::public_addr
uint8_t public_addr[6]
Definition: master_basic_profile.h:265