ESP32

ESP32, Bluetooth, ble_ibeacon

CoyoteUgly 2018. 8. 20. 14:11

ESP32, Bluetooth, ble_ibeacon



0. 참고 사이트


1. 모듈


2. 보드 연결


3. 소스 설명

  • esp_ibeacon_api.h
Sendor Mode 또는 Receiver Mode 설정

/* Because current ESP IDF version doesn't support scan and adv simultaneously,
 * so iBeacon sender and receiver should not run simultaneously */
#define IBEACON_SENDER      0
#define IBEACON_RECEIVER    1
#define IBEACON_MODE IBEACON_SENDER


UUID, Major, Minor 값


#define ESP_UUID    {0xFD, 0xA5, 0x06, 0x93, 0xA4, 0xE2, 0x4F, 0xB1, 0xAF, 0xCF, 0xC6, 0xEB, 0x07, 0x64, 0x78, 0x25}


#define ESP_MAJOR   10167
#define ESP_MINOR   61958


  • esp_ibeacon_api.c
BLE 패킷 구조를 확인하기 때문에
만일 여러 종류의 BLE 보드를 사용한다면
아래 구조를 참고해야 합니다.

bool esp_ble_is_ibeacon_packet (uint8_t *adv_data, uint8_t adv_data_len){
    bool result = false;

    if ((adv_data != NULL) && (adv_data_len == 0x1E)){
        if (!memcmp(adv_data, (uint8_t*)&ibeacon_common_head, sizeof(ibeacon_common_head))){
            result = true;
        }
    }

    return result;
}



4. 소스



5. 결과 확인

    • ESP32 Reveiver Mode
ESP32 보드 2개를 사용하여
하나는 Sendor 모드, 다른 하나는 Receiver 모드로 설정하여
테스트를 진행하였습니다.


I (0) cpu_start: App cpu up.
I (401) heap_init: Initializing. RAM available for dynamic allocation:
I (407) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (413) heap_init: At 3FFCCC88 len 00013378 (76 KiB): DRAM
I (420) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (426) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (432) heap_init: At 40090DF4 len 0000F20C (60 KiB): IRAM
I (439) cpu_start: Pro cpu start user code
I (121) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (166) BTDM_INIT: BT controller compile version [00f6998]

I (166) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (466) phy: phy_version: 3910, c0c45a3, May 21 2018, 18:07:06, 0, 0
I (506) IBEACON_DEMO: register callback
I (506) IBEACON_DEMO: esp_gap_cb: 0x2
I (506) IBEACON_DEMO: ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT
I (516) IBEACON_DEMO: esp_gap_cb: 0x7
I (516) IBEACON_DEMO: ESP_GAP_BLE_SCAN_START_COMPLETE_EVT
I (20696) IBEACON_DEMO: esp_gap_cb: 0x3
I (20696) IBEACON_DEMO: ESP_GAP_BLE_SCAN_RESULT_EVT: 0x0
I (20696) IBEACON_DEMO: ----------iBeacon Found----------
I (20696) IBEACON_DEMO: Device address:: 84 0d 8e 17 12 6a
I (20706) IBEACON_DEMO: Proximity UUID:: fd a5 06 93 a4 e2 4f b1 af cf c6 eb 07 64 78 25
I (20716) IBEACON_DEMO: Major: 0x27b7 (10167)
I (20716) IBEACON_DEMO: Minor: 0xf206 (61958)
I (20726) IBEACON_DEMO: Measured power (RSSI at a 1m distance):-59 dbm
I (20736) IBEACON_DEMO: RSSI of packet:-54 dbm
I (20746) IBEACON_DEMO: esp_gap_cb: 0x3
I (20746) IBEACON_DEMO: ESP_GAP_BLE_SCAN_RESULT_EVT: 0x0


    • ESP32 Sendor Mode

    아이폰에서 테스트를 진행하였으며

    Locate Beacon App을 사용하였습니다.

    Sendor 입장이기 때문에 아래 로그 이외에 실시간 로그는 없습니다.


    App에서 UUID, MAJOR, MINOR 값을 지정해야

    beacon 기능을 테스트할 수 있습니다.



    I (0) cpu_start: App cpu up.
    I (401) heap_init: Initializing. RAM available for dynamic allocation:
    I (407) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
    I (413) heap_init: At 3FFCCC88 len 00013378 (76 KiB): DRAM
    I (419) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
    I (426) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
    I (432) heap_init: At 40090DF4 len 0000F20C (60 KiB): IRAM
    I (438) cpu_start: Pro cpu start user code
    I (121) cpu_start: Starting scheduler on PRO CPU.
    I (0) cpu_start: Starting scheduler on APP CPU.
    I (143) BTDM_INIT: BT controller compile version [00f6998]

    I (143) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
    I (433) phy: phy_version: 3910, c0c45a3, May 21 2018, 18:07:06, 0, 0
    I (473) IBEACON_DEMO: register callback
    I (473) IBEACON_DEMO: esp_gap_cb: 0x2
    I (473) IBEACON_DEMO: ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT
    I (483) IBEACON_DEMO: esp_gap_cb: 0x7
    I (483) IBEACON_DEMO: ESP_GAP_BLE_SCAN_START_COMPLETE_EVT















'ESP32' 카테고리의 다른 글

ESP32, 리눅스 개발 환경 설정  (0) 2018.08.20
ESP32, Wi-Fi, wifi_scan  (1) 2018.08.20
ESP32, UART, uart_nonblocking_select  (0) 2018.08.19
ESP32, UART, uart_queue_events  (0) 2018.08.19
ESP32, I2C, SSD1306 OLED  (0) 2018.08.17