Advertisement
Guest User

app_connect(), central, da14580

a guest
Dec 21st, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.22 KB | None | 0 0
  1. ///**
  2. // ****************************************************************************************
  3. // * @brief Send Connect request to GAPM task.
  4. // *
  5. // * @param[in] indx  Peer device's index in discovered devices list.
  6. // *
  7. // * @return void.
  8. // ****************************************************************************************
  9. // */
  10. void app_connect(unsigned char indx)
  11. {
  12.   struct gapm_start_connection_cmd *msg;
  13.  
  14.   if (app_env.devices[indx].free == true)
  15.   {
  16.     return;
  17.   }
  18.  
  19.   msg =
  20.     (struct gapm_start_connection_cmd *)BleMsgAlloc
  21.     (
  22.       GAPM_START_CONNECTION_CMD, TASK_GAPM,
  23.       TASK_GTL, sizeof(struct gapm_start_connection_cmd)
  24.     );
  25.  
  26.   msg->nb_peers = 1;
  27.   memcpy
  28.   (
  29.     (void *)&msg->peers[0].addr, (void *)&app_env.devices[indx].adv_addr.addr,
  30.     BD_ADDR_LEN
  31.   );
  32.   msg->con_intv_min = (6);
  33.   msg->con_intv_max = (200);
  34.   msg->ce_len_min = 0x0;
  35.   msg->ce_len_max = (0x5);
  36.   msg->con_latency = (BLE_LATENCY);
  37.   msg->op.addr_src = GAPM_PUBLIC_ADDR;
  38.   msg->peers[0].addr_type = GAPM_PUBLIC_ADDR;
  39.   msg->superv_to = (1000); // 0x7D0;
  40.   msg->scan_interval = (0x180);
  41.   msg->scan_window = (0x160);
  42.   msg->op.code = GAPM_CONNECTION_DIRECT;
  43.  
  44.   BleSendMsg((void *)msg);
  45.   return;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement