Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. /**
  2. * @brief Get the adv report of discovered devices
  3. * @param None
  4. * @retval None
  5. */
  6. void hci_le_advertising_report_event(uint8_t Num_Reports, Advertising_Report_t Advertising_Report[])
  7. {
  8. STBOX1_PRINTF("\rCalled 'hci_le_advertising_report_event'!\r\n");
  9.  
  10. /*
  11. * Check if it is a SaveMeNow.AI device in PERIPHERAL mode.
  12. */
  13.  
  14. for (int i = 0; i < Num_Reports; i++) {
  15.  
  16. if(Advertising_Report[i].Length_Data > 10) {
  17.  
  18. if(Advertising_Report[i].Data[5] == 0x53 && // S
  19. Advertising_Report[i].Data[6] == 0x4d && // M
  20. Advertising_Report[i].Data[7] == 0x4e && // N
  21. Advertising_Report[i].Data[8] == 0x5f) { // _
  22.  
  23. // STBOX1_PRINTF("ALM Result: %d \r\n", Advertising_Report[i].Data[14]);
  24. // STBOX1_PRINTF("NUM Result: %d \r\n", Advertising_Report[i].Data[15]);
  25. // STBOX1_PRINTF("NAS Result: %d \r\n", Advertising_Report[i].Data[16]);
  26. // STBOX1_PRINTF("ML0 Result: %d \r\n", Advertising_Report[i].Data[17]);
  27. // STBOX1_PRINTF("ML1 Result: %d \r\n", Advertising_Report[i].Data[18]);
  28. // STBOX1_PRINTF("ML2 Result: %d \r\n", Advertising_Report[i].Data[19]);
  29. // STBOX1_PRINTF("\r\n");
  30. //
  31. // STBOX1_PRINTF("\r\nSignal: %d \r\n", Advertising_Report[i].RSSI);
  32.  
  33. STBOX1_PRINTF("MAC = %x:%x:%x:%x:%x:%x\r\n",
  34. Advertising_Report[i].Address[5],
  35. Advertising_Report[i].Address[4],
  36. Advertising_Report[i].Address[3],
  37. Advertising_Report[i].Address[2],
  38. Advertising_Report[i].Address[1],
  39. Advertising_Report[i].Address[0]);
  40.  
  41. if(Advertising_Report[i].Data[14] == 0x01) {
  42. BSP_LED_Off(LED_BLUE);
  43. BSP_LED_On(LED_GREEN);
  44. STBOX1_PRINTF("\rALARM! Connecting to the device!\r\n")
  45. // ALARM on device!!
  46. // Create connection with device!
  47. /*ret= aci_gap_create_connection(
  48. LE_Scan_Interval=0x0010,
  49. LE_Scan_Window=0x0010,
  50. Peer_Address_Type= ”Slave_B address type”,
  51. Peer_Address= ”Slave_B address”,
  52. Own_Address_Type = 0x0;
  53. Conn_Interval_Min=0x6c,
  54. Conn_Interval_Max=0x6c,
  55. Conn_Latency=0x00,
  56. Supervision_Timeout=0xc80,
  57. Minimum_CE_Length=0x000c,
  58. Maximum_CE_Length=0x000c);*/
  59.  
  60. }
  61. }
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement