9#include "rwip_config.h"
16 struct gapm_reset_cmd *p_cmd =
17 KE_MSG_ALLOC(GAPM_RESET_CMD, TASK_GAPM, TASK_APP, gapm_reset_cmd);
19 p_cmd->operation = GAPM_RESET;
26 struct gapm_set_dev_config_cmd *p_cmd = KE_MSG_ALLOC(
27 GAPM_SET_DEV_CONFIG_CMD, TASK_GAPM, TASK_APP, gapm_set_dev_config_cmd);
29 memcpy(p_cmd, cfg_param,
sizeof(
struct gapm_set_dev_config_cmd));
30 p_cmd->operation = GAPM_SET_DEV_CONFIG;
37 struct gapm_get_dev_info_cmd *p_cmd = KE_MSG_ALLOC(
38 GAPM_GET_DEV_INFO_CMD, TASK_GAPM, TASK_APP, gapm_get_dev_info_cmd);
40 p_cmd->operation = cmd->operation;
47 struct gapm_resolv_addr_cmd *p_cmd = KE_MSG_ALLOC_DYN(
48 GAPM_RESOLV_ADDR_CMD, TASK_GAPM, TASK_APP, gapm_resolv_addr_cmd,
49 (nb_key *
sizeof(
struct gap_sec_key)));
51 memcpy(&p_cmd->addr.addr[0], &addr->addr[0], GAP_BD_ADDR_LEN);
52 memcpy(&p_cmd->irk[0].key[0], &irk[0], GAP_KEY_LEN * nb_key);
53 p_cmd->nb_key = nb_key;
55 p_cmd->operation = GAPM_RESOLV_ADDR;
62 struct gapm_gen_rand_addr_cmd *p_cmd = KE_MSG_ALLOC(
63 GAPM_GEN_RAND_ADDR_CMD, TASK_GAPM, TASK_APP, gapm_gen_rand_addr_cmd);
65 memcpy(p_cmd, p_param,
sizeof(
struct gapm_gen_rand_addr_cmd));
66 p_cmd->operation = GAPM_GEN_RAND_ADDR;
73 struct gapm_get_pub_key_cmd *p_cmd = KE_MSG_ALLOC(
74 GAPM_GET_PUB_KEY_CMD, TASK_GAPM, TASK_APP, gapm_get_pub_key_cmd);
76 p_cmd->operation = GAPM_GET_PUB_KEY;
83 struct gapm_gen_rand_nb_cmd *p_cmd = KE_MSG_ALLOC(
84 GAPM_GEN_RAND_NB_CMD, TASK_GAPM, TASK_APP, gapm_gen_rand_nb_cmd);
86 p_cmd->operation = GAPM_GEN_RAND_NB;
93 struct gapm_set_irk_cmd *p_cmd =
94 KE_MSG_ALLOC(GAPM_SET_IRK_CMD, TASK_GAPM, TASK_APP, gapm_set_irk_cmd);
96 p_cmd->operation = GAPM_SET_IRK;
97 memcpy(p_cmd->irk.key, irk->key, GAP_KEY_LEN);
104 struct gapm_get_ral_addr_cmd *p_cmd = KE_MSG_ALLOC(
105 GAPM_GET_RAL_ADDR_CMD, TASK_GAPM, TASK_APP, gapm_get_ral_addr_cmd);
107 memcpy(p_cmd, p_param,
sizeof(
struct gapm_get_ral_addr_cmd));
108 p_cmd->operation = p_param->operation;
115 struct gapm_list_set_ral_cmd *p_cmd = KE_MSG_ALLOC_DYN(
116 GAPM_LIST_SET_CMD, TASK_GAPM, TASK_APP, gapm_list_set_ral_cmd,
117 (size *
sizeof(
struct gap_ral_dev_info)));
120 memcpy(&p_cmd->ral_info, ral_info,
sizeof(
struct gap_ral_dev_info) * size);
121 p_cmd->operation = GAPM_SET_RAL;
128 struct gapm_list_set_wl_cmd *p_cmd = KE_MSG_ALLOC_DYN(
129 GAPM_LIST_SET_CMD, TASK_GAPM, TASK_APP, gapm_list_set_wl_cmd,
130 (size *
sizeof(
struct gap_bdaddr)));
133 memcpy(&p_cmd->wl_info, wl_info,
sizeof(
struct gap_bdaddr) * size);
134 p_cmd->operation = GAPM_SET_WL;
140 struct gapm_activity_create_adv_cmd *adv_creat_param)
142 struct gapm_activity_create_adv_cmd *p_cmd =
143 KE_MSG_ALLOC(GAPM_ACTIVITY_CREATE_CMD, TASK_GAPM, TASK_APP,
144 gapm_activity_create_adv_cmd);
146 memcpy(p_cmd, adv_creat_param,
sizeof(
struct gapm_activity_create_adv_cmd));
147 p_cmd->operation = GAPM_CREATE_ADV_ACTIVITY;
155 struct gapm_set_adv_data_cmd *p_cmd =
156 KE_MSG_ALLOC_DYN(GAPM_SET_ADV_DATA_CMD, TASK_GAPM, TASK_APP,
157 gapm_set_adv_data_cmd, adv_data_length);
159 p_cmd->operation = GAPM_SET_ADV_DATA;
160 p_cmd->actv_idx = actv_idx;
161 p_cmd->length = adv_data_length;
162 memcpy(&p_cmd->data[0], p_adv_data, adv_data_length);
168 uint8_t *p_scan_rsp_data)
170 struct gapm_set_adv_data_cmd *p_cmd =
171 KE_MSG_ALLOC_DYN(GAPM_SET_ADV_DATA_CMD, TASK_GAPM, TASK_APP,
172 gapm_set_adv_data_cmd, scan_rsp_data_length);
174 p_cmd->operation = GAPM_SET_SCAN_RSP_DATA;
175 p_cmd->actv_idx = actv_idx;
176 p_cmd->length = scan_rsp_data_length;
177 memcpy(&p_cmd->data[0], p_scan_rsp_data, scan_rsp_data_length);
184 struct gapm_activity_start_cmd *p_cmd = KE_MSG_ALLOC(
185 GAPM_ACTIVITY_START_CMD, TASK_GAPM, TASK_APP, gapm_activity_start_cmd);
187 memcpy(p_cmd, adv_start_param,
sizeof(
struct gapm_activity_start_cmd));
188 p_cmd->operation = GAPM_START_ACTIVITY;
195 struct gapm_activity_create_cmd *p_cmd =
196 KE_MSG_ALLOC(GAPM_ACTIVITY_CREATE_CMD, TASK_GAPM, TASK_APP,
197 gapm_activity_create_cmd);
199 memcpy(p_cmd, scan_creat_param,
sizeof(
struct gapm_activity_create_cmd));
200 p_cmd->operation = GAPM_CREATE_SCAN_ACTIVITY;
207 struct gapm_activity_start_cmd *p_cmd = KE_MSG_ALLOC(
208 GAPM_ACTIVITY_START_CMD, TASK_GAPM, TASK_APP, gapm_activity_start_cmd);
210 memcpy(p_cmd, scan_start_param,
sizeof(
struct gapm_activity_start_cmd));
211 p_cmd->operation = GAPM_START_ACTIVITY;
218 struct gapm_activity_create_cmd *p_cmd =
219 KE_MSG_ALLOC(GAPM_ACTIVITY_CREATE_CMD, TASK_GAPM, TASK_APP,
220 gapm_activity_create_cmd);
222 memcpy(p_cmd, init_creat_param,
sizeof(
struct gapm_activity_create_cmd));
223 p_cmd->operation = GAPM_CREATE_INIT_ACTIVITY;
230 struct gapm_activity_start_cmd *p_cmd = KE_MSG_ALLOC(
231 GAPM_ACTIVITY_START_CMD, TASK_GAPM, TASK_APP, gapm_activity_start_cmd);
233 memcpy(p_cmd, init_start_param,
sizeof(
struct gapm_activity_start_cmd));
234 p_cmd->operation = GAPM_START_ACTIVITY;
235 p_cmd->u_param.init_param.conn_param_1m.ce_len_min = CE_LEN_MIN;
236 p_cmd->u_param.init_param.conn_param_1m.ce_len_max = CE_LEN_MAX;
237 p_cmd->u_param.init_param.conn_param_2m.ce_len_min = CE_LEN_MIN;
238 p_cmd->u_param.init_param.conn_param_2m.ce_len_max = CE_LEN_MAX;
239 p_cmd->u_param.init_param.conn_param_coded.ce_len_min = CE_LEN_MIN;
240 p_cmd->u_param.init_param.conn_param_coded.ce_len_max = CE_LEN_MAX;
247 struct gapm_activity_stop_cmd *p_cmd = KE_MSG_ALLOC(
248 GAPM_ACTIVITY_STOP_CMD, TASK_GAPM, TASK_APP, gapm_activity_stop_cmd);
251 p_cmd->operation = GAPM_STOP_ACTIVITY;
253 p_cmd->operation = GAPM_STOP_ALL_ACTIVITIES;
255 p_cmd->actv_idx = actv_idx;
262 struct gapm_activity_delete_cmd *p_cmd =
263 KE_MSG_ALLOC(GAPM_ACTIVITY_DELETE_CMD, TASK_GAPM, TASK_APP,
264 gapm_activity_delete_cmd);
267 p_cmd->operation = GAPM_DELETE_ACTIVITY;
269 p_cmd->operation = GAPM_DELETE_ALL_ACTIVITIES;
271 p_cmd->actv_idx = actv_idx;
278 struct gapc_disconnect_cmd *p_cmd =
279 KE_MSG_ALLOC(GAPC_DISCONNECT_CMD, KE_BUILD_ID(TASK_GAPC, conidx),
280 TASK_APP, gapc_disconnect_cmd);
282 p_cmd->operation = GAPC_DISCONNECT;
283 p_cmd->reason = reason;
289 uint16_t latency, uint16_t time_out)
291 struct gapc_param_update_cmd *p_cmd =
292 KE_MSG_ALLOC(GAPC_PARAM_UPDATE_CMD, KE_BUILD_ID(TASK_GAPC, conidx),
293 TASK_APP, gapc_param_update_cmd);
295 p_cmd->operation = GAPC_UPDATE_PARAMS;
296 p_cmd->intv_min = intv_min;
297 p_cmd->intv_max = intv_max;
298 p_cmd->latency = latency;
299 p_cmd->time_out = time_out;
301 p_cmd->ce_len_min = CE_LEN_MIN;
303 p_cmd->ce_len_max = CE_LEN_MAX;
310 struct gapc_connection_cfm *p_cmd =
311 KE_MSG_ALLOC(GAPC_CONNECTION_CFM, KE_BUILD_ID(TASK_GAPC, conidx),
312 TASK_APP, gapc_connection_cfm);
314 memcpy(p_cmd, p_cfm,
sizeof(
struct gapc_connection_cfm));
321 struct gapc_get_info_cmd *p_cmd =
322 KE_MSG_ALLOC(GAPC_GET_INFO_CMD, KE_BUILD_ID(TASK_GAPC, conidx),
323 TASK_APP, gapc_get_info_cmd);
325 p_cmd->operation = get_info->operation;
331 struct gapc_param_update_cfm *update_cfm)
333 struct gapc_param_update_cfm *p_cmd =
334 KE_MSG_ALLOC(GAPC_PARAM_UPDATE_CFM, KE_BUILD_ID(TASK_GAPC, conidx),
335 TASK_APP, gapc_param_update_cfm);
337 memcpy(p_cmd, update_cfm,
sizeof(
struct gapc_param_update_cfm));
338 p_cmd->ce_len_min = CE_LEN_MIN;
339 p_cmd->ce_len_max = CE_LEN_MAX;
346 struct gapc_bond_cmd *p_cmd = KE_MSG_ALLOC(
347 GAPC_BOND_CMD, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP, gapc_bond_cmd);
349 memcpy(p_cmd, p_param,
sizeof(
struct gapc_bond_cmd));
350 p_cmd->operation = GAPC_BOND;
357 struct gapc_bond_cfm *p_cmd = KE_MSG_ALLOC(
358 GAPC_BOND_CFM, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP, gapc_bond_cfm);
360 memcpy(p_cmd, p_param,
sizeof(
struct gapc_bond_cfm));
367 if ((p_param->req == GAPC_DEV_NAME) ||
368 (p_param->req == GAPC_DEV_APPEARANCE) ||
369 (p_param->req == GAPC_DEV_SLV_PREF_PARAMS)) {
370 struct gapc_get_dev_info_cfm *p_cmd = KE_MSG_ALLOC_DYN(
371 GAPC_GET_DEV_INFO_CFM, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP,
372 gapc_get_dev_info_cfm, DEVICE_NAME_MAX_LEN);
374 memcpy(p_cmd, p_param,
sizeof(
struct gapc_get_dev_info_cfm));
384 struct gapc_set_dev_info_cfm *p_cmd =
385 KE_MSG_ALLOC(GAPC_SET_DEV_INFO_CFM, KE_BUILD_ID(TASK_GAPC, conidx),
386 TASK_APP, gapc_set_dev_info_cfm);
388 memcpy(p_cmd, p_param,
sizeof(
struct gapc_set_dev_info_cfm));
395 struct gapc_encrypt_cmd *p_cmd =
396 KE_MSG_ALLOC(GAPC_ENCRYPT_CMD, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP,
399 memcpy(p_cmd, p_param,
sizeof(
struct gapc_encrypt_cmd));
400 p_cmd->operation = GAPC_ENCRYPT;
408 struct gapc_encrypt_cfm *p_cmd =
409 KE_MSG_ALLOC(GAPC_ENCRYPT_CFM, KE_BUILD_ID(TASK_GAPC, conidx), TASK_APP,
412 memcpy(p_cmd, p_param,
sizeof(
struct gapc_encrypt_cfm));
420 struct gapc_security_cmd *p_cmd =
421 KE_MSG_ALLOC(GAPC_SECURITY_CMD, KE_BUILD_ID(TASK_GAPC, conidx),
422 TASK_APP, gapc_security_cmd);
424 p_cmd->operation = GAPC_SECURITY_REQ;
425 p_cmd->auth = sec_auth;
432 struct gapc_set_le_pkt_size_cmd *p_cmd =
433 KE_MSG_ALLOC(GAPC_SET_LE_PKT_SIZE_CMD, KE_BUILD_ID(TASK_GAPC, conidx),
434 TASK_APP, gapc_set_le_pkt_size_cmd);
436 p_cmd->operation = GAPC_SET_LE_PKT_SIZE;
437 p_cmd->tx_octets = tx_octets;
438 p_cmd->tx_time = tx_time;
446 struct gapc_set_max_rx_size_and_time_cmd *p_cmd = KE_MSG_ALLOC(
447 GAPC_SET_MAX_RX_SIZE_AND_TIME_CMD, KE_BUILD_ID(TASK_GAPC, conidx),
448 TASK_APP, gapc_set_max_rx_size_and_time_cmd);
450 p_cmd->operation = GAPC_SET_MAX_RX_SIZE_AND_TIME;
451 p_cmd->rx_octets = rx_octets;
452 p_cmd->rx_time = rx_time;
460 struct gapm_set_channel_map_cmd *p_cmd =
461 KE_MSG_ALLOC(GAPM_SET_CHANNEL_MAP_CMD, TASK_GAPM, TASK_APP,
462 gapm_set_channel_map_cmd);
464 memcpy(p_cmd, p_param,
sizeof(
struct gapm_set_channel_map_cmd));
465 p_cmd->operation = GAPM_SET_CHANNEL_MAP;
void xc_ble_gen_random_addr(struct gapm_gen_rand_addr_cmd *p_param)
Generate a random device address without starting any air operation. This can be useful for privacy i...
void xc_ble_gapm_reset(void)
Called only in the app_init(). It's used to reset the device but setting device configuration is sti...
void xc_ble_set_pkt_size(int conidx, uint16_t tx_octets, uint16_t tx_time)
This operation to define the preferred packet length to be used by the controller
void xc_ble_update_param(int conidx, uint16_t intv_min, uint16_t intv_max, uint16_t latency, uint16_t time_out)
Update connection paramters
void xc_ble_get_ral_addr(struct gapm_get_ral_addr_cmd *p_param)
Get local or peer resolvable private address
void xc_ble_scan_create(struct gapm_activity_create_cmd *scan_creat_param)
Create a scanning activity.
void xc_ble_bond_cfm(int conidx, struct gapc_bond_cfm *p_param)
Confirm bond request.
void xc_ble_advertise_create(struct gapm_activity_create_adv_cmd *adv_creat_param)
Create an advertising activity.
void xc_ble_activity_delete(int actv_idx)
Delete an activity or all activities
void xc_ble_get_pub_key(void)
Read the local P-256 Public Key. This key is renewed each time this command is called by requester a...
void xc_ble_conn_cfm(int conidx, struct gapc_connection_cfm *p_cfm)
Confirm connection request Set specific link security configuration and bonding data,...
void xc_ble_set_white_list(uint8_t size, gap_bdaddr_t *wl_info)
Request to set the content of the White List. The current content of the indicated list will be clear...
void xc_ble_set_ral_list(uint8_t size, struct gap_ral_dev_info *ral_info)
Request to set the content of the Resolving List. The current content of the indicated list will be c...
void xc_ble_set_rx_pkt_size(int conidx, uint16_t rx_octets, uint16_t rx_time)
void xc_ble_set_adv_data(uint8_t actv_idx, uint16_t adv_data_length, uint8_t *p_adv_data)
Set advertising data for a given previously created advertising activity identified by its activity ...
void xc_ble_set_channel_map(struct gapm_set_channel_map_cmd *p_param)
This operation can be requested only by master of the link in order to set the channel map of the dev...
void xc_ble_advertise_start(struct gapm_activity_start_cmd *adv_start_param)
Start an advertising activity.
void xc_ble_scan_start(struct gapm_activity_start_cmd *scan_start_param)
Start a scanning activity.
void xc_ble_get_dev_info_cfm(int conidx, struct gapc_get_dev_info_cfm *p_param)
Called when the peer device obtains information about the local device. Device Name,...
void xc_ble_set_dev_config(struct gapm_set_dev_config_cmd *cfg_param)
Set the device configuration such as: Device role Manage device address type: Public,...
void xc_ble_set_dev_info_cfm(int conidx, struct gapc_set_dev_info_cfm *p_param)
Send the write confirmation to the stack.
void xc_ble_req_security(int conidx, uint8_t sec_auth)
issue from slave
void xc_ble_encrypt(int conidx, struct gapc_encrypt_cmd *p_param)
This operation can be requested only by master of the link in order to initiate encryption procedure....
void xc_ble_activity_stop(int actv_idx)
Stop an activity or all activities.
void xc_ble_param_update_cfm(int conidx, struct gapc_param_update_cfm *update_cfm)
Used by to accept or refuse connection parameters proposed by peer device.
void xc_ble_set_scan_rsp_data(uint8_t actv_idx, uint16_t scan_rsp_data_length, uint8_t *p_scan_rsp_data)
Set Scan response data for a given previously created advertising activity identified by its activit...
void xc_ble_encrypt_cfm(int conidx, struct gapc_encrypt_cfm *p_param)
issue from master
void xc_ble_gen_random_nb(void)
Used to generate an 8-byte random number. This can be useful to generate LTK random number before di...
void xc_ble_init_start(struct gapm_activity_start_cmd *init_start_param)
Start a initiating activity.
void xc_ble_set_irk(gap_sec_key_t *irk)
Command to change the current IRK for a renewed one, it can be used every time no air operation is b...
void xc_ble_resolve_addr(uint8_t nb_key, gap_addr_t *addr, uint8_t *irk)
Resolve provided random address using array of Identity Resolution Key (IRK) exchanged and bonded wit...
void xc_ble_bond(int conidx, struct gapc_bond_cmd *p_param)
Requested by master of the link in order to initiate the bond procedure. It contains pairing require...
void xc_ble_get_dev_info(struct gapm_get_dev_info_cmd *cmd)
Get information about local device such as: Local Device Name Local Device Version Local Device Pu...
void xc_ble_get_peer_info(int conidx, struct gapc_get_info_cmd *get_info)
Retrieve information about peer device or about the current active link.
void xc_ble_disconnect(int conidx, uint32_t reason)
Request for disconnection of the link. This can be requested by master or slave of the connection.
void xc_ble_init_create(struct gapm_activity_create_cmd *init_creat_param)
Create a initiating activity.
GAP API. Copyright (c) 2022 - 2025, XinChip All rights reserved.