{"action":"created","issue":{"url":"https://api.github.com/repos/espressif/esp-idf/issues/429","repository_url":"https://api.github.com/repos/espressif/esp-idf","labels_url":"https://api.github.com/repos/espressif/esp-idf/issues/429/labels{/name}","comments_url":"https://api.github.com/repos/espressif/esp-idf/issues/429/comments","events_url":"https://api.github.com/repos/espressif/esp-idf/issues/429/events","html_url":"https://github.com/espressif/esp-idf/issues/429","id":214297394,"number":429,"title":"can't get `examples/bluetooth/gatt_server` to work?","user":{"login":"edmund-huber","id":345424,"avatar_url":"https://avatars3.githubusercontent.com/u/345424?v=3","gravatar_id":"","url":"https://api.github.com/users/edmund-huber","html_url":"https://github.com/edmund-huber","followers_url":"https://api.github.com/users/edmund-huber/followers","following_url":"https://api.github.com/users/edmund-huber/following{/other_user}","gists_url":"https://api.github.com/users/edmund-huber/gists{/gist_id}","starred_url":"https://api.github.com/users/edmund-huber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edmund-huber/subscriptions","organizations_url":"https://api.github.com/users/edmund-huber/orgs","repos_url":"https://api.github.com/users/edmund-huber/repos","events_url":"https://api.github.com/users/edmund-huber/events{/privacy}","received_events_url":"https://api.github.com/users/edmund-huber/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-03-15T06:43:08Z","updated_at":"2017-03-15T22:21:53Z","closed_at":null,"body":"I built and flashed the `examples/bluetooth/gatt_server` to the ESP32. I'm using the ESP32 Sparkfun \"Thing\", for reference. The startup from reset looks (?) fine:\r\n\r\n```\r\nets Jun  8 2016 00:22:57\r\n\r\nrst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)\r\nets Jun  8 2016 00:22:57\r\n\r\nrst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)\r\nconfigsip: 0, SPIWP:0x00\r\nclk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00\r\nmode:DIO, clock div:2\r\nload:0x3fff0008,len:8\r\nload:0x3fff0010,len:3464\r\nload:0x40078000,len:7828\r\nload:0x40080000,len:252\r\nentry 0x40080034\r\nI (28) boot: ESP-IDF v2.0-rc1-258-g0bbf02b 2nd stage bootloader\r\nI (28) boot: compile time 12:24:22\r\nI (62) boot: Enabling RNG early entropy source...\r\nI (62) boot: SPI Speed      : 40MHz\r\nI (62) boot: SPI Mode       : DIO\r\nI (73) boot: SPI Flash Size : 4MB\r\nI (86) boot: Partition Table:\r\nI (97) boot: ## Label            Usage          Type ST Offset   Length\r\nI (119) boot:  0 nvs              WiFi data        01 02 00009000 00006000\r\nI (143) boot:  1 phy_init         RF data          01 01 0000f000 00001000\r\nI (166) boot:  2 factory          factory app      00 00 00010000 00100000\r\nI (189) boot: End of partition table\r\nI (202) boot: Disabling RNG early entropy source...\r\nI (219) boot: Loading app partition at offset 00010000\r\nI (1259) boot: segment 0: paddr=0x00010018 vaddr=0x00000000 size=0x0ffe8 ( 65512) \r\nI (1260) boot: segment 1: paddr=0x00020008 vaddr=0x3f400010 size=0x2abc4 (175044) map\r\nI (1276) boot: segment 2: paddr=0x0004abd4 vaddr=0x3ffc0000 size=0x01edc (  7900) load\r\nI (1306) boot: segment 3: paddr=0x0004cab8 vaddr=0x40080000 size=0x00400 (  1024) load\r\nI (1330) boot: segment 4: paddr=0x0004cec0 vaddr=0x40080400 size=0x12290 ( 74384) load\r\nI (1391) boot: segment 5: paddr=0x0005f158 vaddr=0x400c0000 size=0x00000 (     0) load\r\nI (1392) boot: segment 6: paddr=0x0005f160 vaddr=0x00000000 size=0x00ea8 (  3752) \r\nI (1414) boot: segment 7: paddr=0x00060010 vaddr=0x400d0018 size=0x629ec (403948) map\r\nI (1442) heap_alloc_caps: Initializing. RAM available for dynamic allocation:\r\nI (1464) heap_alloc_caps: At 3FFCB9A0 len 00014660 (81 KiB): DRAM\r\nI (1485) heap_alloc_caps: At 3FFE8000 len 00018000 (96 KiB): D/IRAM\r\nI (1507) heap_alloc_caps: At 40092690 len 0000D970 (54 KiB): IRAM\r\nI (1527) cpu_start: Pro cpu up.\r\nI (1539) cpu_start: Starting app cpu, entry point is 0x40080d38\r\nI (0) cpu_start: App cpu up.\r\nI (1571) cpu_start: Pro cpu start user code\r\nI (1632) cpu_start: Starting scheduler on PRO CPU.\r\nBTDM CONTROLLER VERSION: 010101\r\nbtip start\r\n Sta .bss scheduom  ffb800  tU.3[0mff70, len 00007f70\r\nBTDM ROM VERSION 0101\r\nBD_ADDR: 24:0A:C4:00:96:72\r\nNVDS MAGIC FAILED\r\nRF Init OK with coex\r\nI (311) phy: phy_version: 329, Feb 22 2017, 15:58:07, 1, 0\r\nEnable Classic BT\r\nEnable Low Energy\r\nE (311) BT: Startup BTU\r\n\r\nE (311) BT: GATTS_CreateService:  handle of service handle1\r\nE (331) BT: bta_dm_co_ble_load_local_keys: func not ported\r\n\r\nI (341) GATTS_DEMO: REGISTER_APP_EVT, status 0, app_id 0\r\n\r\nE (351) BT: Partial data write into ADV\r\nI (351) GATTS_DEMO: CREATE_SERVICE_EVT, status 0,  service_handle 40\r\n\r\nI (351) GATTS_DEMO: SERVICE_START_EVT, status 0, service_handle 40\r\n\r\nI (361) GATTS_DEMO: ADD_CHAR_EVT, status 0,  attr_handle 42, service_handle 40\r\n\r\nI (371) GATTS_DEMO: the gatts demo char length = 3\r\n\r\nI (371) GATTS_DEMO: prf_char[0] =11\r\n\r\nI (381) GATTS_DEMO: prf_char[1] =22\r\n\r\nI (381) GATTS_DEMO: prf_char[2] =33\r\n\r\nI (381) GATTS_DEMO: ADD_DESCR_EVT, status 0, attr_handle 43, service_handle 40\r\n\r\nI (391) GATTS_DEMO: REGISTER_APP_EVT, status 0, app_id 1\r\n\r\nI (401) GATTS_DEMO: CREATE_SERVICE_EVT, status 0,  service_handle 44\r\n\r\nI (411) GATTS_DEMO: SERVICE_START_EVT, status 0, service_handle 44\r\n\r\nI (411) GATTS_DEMO: ADD_CHAR_EVT, status 0,  attr_handle 46, service_handle 44\r\n\r\nI (421) GATTS_DEMO: ADD_DESCR_EVT, status 0, attr_handle 47, service_handle 44\r\n```\r\n\r\nI open up `bluetoothctl`, and attempt to pair with the device:\r\n\r\n```\r\n$ bluetoothctl \r\n[NEW] Controller 88:1F:A1:19:FF:DF laptop [default]\r\n[NEW] Device 24:0A:C4:00:96:72 ESP_GATTS_DEMO\r\n[bluetooth]# power on\r\n[CHG] Controller 88:1F:A1:19:FF:DF Class: 0x00010c\r\nChanging power on succeeded\r\n[CHG] Controller 88:1F:A1:19:FF:DF Powered: yes\r\n[bluetooth]# agent on\r\nAgent registered\r\n[bluetooth]# default-agent\r\nDefault agent request successful\r\n[bluetooth]# pair 24:0A:C4:00:96:72 \r\nAttempting to pair with 24:0A:C4:00:96:72\r\n[CHG] Device 24:0A:C4:00:96:72 Connected: yes\r\n```\r\n\r\nAfter the `pair` command in `bluetoothctl`, I get new output from the ESP32:\r\n\r\n```\r\nE (36651) BT: smp_br_connect_callback is called on unexpected transport 2\r\n\r\nE (36651) BT: MTU request PDU with MTU size 517\r\n\r\nE (36651) BT: Call back not found for application conn_id=3\r\nI (36661) GATTS_DEMO: SERVICE_START_EVT, conn_id 0, remote 88:1f:a1:19:ff:df:, is_conn 1\r\n\r\nI (36661) GATTS_DEMO: SERVICE_START_EVT, conn_id 0, remote 88:1f:a1:19:ff:df:, is_conn 1\r\n```\r\n\r\nThere is a pause of about 10 seconds. Then I get this new output in `bluetoothctl`:\r\n\r\n```\r\nFailed to pair: org.bluez.Error.AuthenticationFailed\r\n[CHG] Device 24:0A:C4:00:96:72 Connected: no\r\n```\r\n\r\nAnd this new output over serial from the ESP32:\r\n\r\n```\r\nE (68641) BT: bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0013\r\nE (68641) BT: btm_sec_disconnected clearing pending flag handle:0 reason:19\r\n\r\nE (68641) BT: bta_gattc_mark_bg_conn unable to find the bg connection mask for: 88:1f:a1:19:ff:d\r\n```\r\n\r\nI tested `bluetoothctl` by pairing with my Android phone -- this worked fine. Am I missing something about how I should be setting things up in order for this example to work?\r\n\r\nThe error `E (68641) BT: bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0013` seems to indicate (HCI_ERR_PEER_USER) that the `laptop` device closed the connection. The `bluetoothctl` output seems to further indicate that `laptop` closed the connection because auth failed. But I have no idea if I am interpreting this correctly."},"comment":{"url":"https://api.github.com/repos/espressif/esp-idf/issues/comments/286898304","html_url":"https://github.com/espressif/esp-idf/issues/429#issuecomment-286898304","issue_url":"https://api.github.com/repos/espressif/esp-idf/issues/429","id":286898304,"user":{"login":"edmund-huber","id":345424,"avatar_url":"https://avatars3.githubusercontent.com/u/345424?v=3","gravatar_id":"","url":"https://api.github.com/users/edmund-huber","html_url":"https://github.com/edmund-huber","followers_url":"https://api.github.com/users/edmund-huber/followers","following_url":"https://api.github.com/users/edmund-huber/following{/other_user}","gists_url":"https://api.github.com/users/edmund-huber/gists{/gist_id}","starred_url":"https://api.github.com/users/edmund-huber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edmund-huber/subscriptions","organizations_url":"https://api.github.com/users/edmund-huber/orgs","repos_url":"https://api.github.com/users/edmund-huber/repos","events_url":"https://api.github.com/users/edmund-huber/events{/privacy}","received_events_url":"https://api.github.com/users/edmund-huber/received_events","type":"User","site_admin":false},"created_at":"2017-03-15T22:21:53Z","updated_at":"2017-03-15T22:21:53Z","body":"Thanks, good suggestion:\r\n```\r\n[bluetooth]# power on\r\nChanging power on succeeded\r\n[bluetooth]# devices\r\nDevice 24:0A:C4:00:96:72 ESP_GATTS_DEMO\r\nDevice 4C:A5:6D:F0:B4:38 SAMSUNG-SM-G900V\r\n[bluetooth]# connect 24:0A:C4:00:96:72 \r\nAttempting to connect to 24:0A:C4:00:96:72\r\nFailed to connect: org.bluez.Error.Failed\r\n```\r\n\r\nThere's no additional output in the service log."}}
{"actor":{"display_login":"edmund-huber"}}