app_main.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* main.c - Application main entry point */
  2. /*
  3. * Copyright (c) 2015-2016 Intel Corporation
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. */
  7. #include <errno.h>
  8. #include <stddef.h>
  9. #include <string.h>
  10. #include "base/byteorder.h"
  11. #include "base/types.h"
  12. #include <bluetooth/bluetooth.h>
  13. #include <bluetooth/conn.h>
  14. #include <bluetooth/gatt.h>
  15. #include <bluetooth/hci.h>
  16. #include <bluetooth/uuid.h>
  17. #include <logging/bt_log_impl.h>
  18. #include "common\timer.h"
  19. static void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
  20. struct net_buf_simple *ad)
  21. {
  22. char addr_str[BT_ADDR_LE_STR_LEN];
  23. bt_addr_le_to_str(addr, addr_str, sizeof(addr_str));
  24. printk("Device found: %s (RSSI %d)\n", addr_str, rssi);
  25. }
  26. void bt_ready(int err)
  27. {
  28. struct bt_le_scan_param scan_param = {
  29. .type = BT_LE_SCAN_TYPE_PASSIVE,
  30. .options = BT_LE_SCAN_OPT_FILTER_DUPLICATE,
  31. .interval = BT_GAP_SCAN_FAST_INTERVAL,
  32. .window = BT_GAP_SCAN_FAST_WINDOW,
  33. };
  34. if (err)
  35. {
  36. printk("Bluetooth init failed (err %d)\n", err);
  37. return;
  38. }
  39. printk("Bluetooth initialized\n");
  40. printk("Starting Observer\n");
  41. err = bt_le_scan_start(&scan_param, device_found);
  42. printk("\n");
  43. if (err)
  44. {
  45. printk("Starting scanning failed (err %d)\n", err);
  46. return;
  47. }
  48. }
  49. void app_polling_work(void)
  50. {
  51. }