A POC Code of doing ANCS with nrf51822-mKit. See README.txt for details.

Dependencies:   BLE_API mbed nRF51822

A sample code implementing ANCS client accessory with nRF51822-mKit. This is just a proof that this thing is indeed doable.

The code itself is complete mess. I'm not planing to furnish this, as the purpose (make sure it is doable) was achieved.

The next step possible step is (no timeline) 1. Implementing Gatt Client API in BLE API (forking?) 2. Do ANCS with that.

Please see README.txt for details.

Committer:
devsar
Date:
Tue Jun 03 04:25:33 2014 +0000
Revision:
0:1f985a7c0a8b
Working code!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
devsar 0:1f985a7c0a8b 1 INTRODUCTION
devsar 0:1f985a7c0a8b 2 ============
devsar 0:1f985a7c0a8b 3 This is a POC (Proof of Concept) for implementing
devsar 0:1f985a7c0a8b 4 ANCS (Apple Notification Center Service)with
devsar 0:1f985a7c0a8b 5 NRF51822-mKit (mbed) platform.
devsar 0:1f985a7c0a8b 6
devsar 0:1f985a7c0a8b 7 The code is not meant to be use for implementation,
devsar 0:1f985a7c0a8b 8 whatsoever.
devsar 0:1f985a7c0a8b 9
devsar 0:1f985a7c0a8b 10 I'm not intent to further enhancing this code.
devsar 0:1f985a7c0a8b 11 The sole purpose is to show that we can use
devsar 0:1f985a7c0a8b 12 SoftDevice client api for doing ANCS with NRF51822-mkit.
devsar 0:1f985a7c0a8b 13 (At this time, BLE API doesn't expose Gatt Client API)
devsar 0:1f985a7c0a8b 14
devsar 0:1f985a7c0a8b 15 This program code are bypassing mbed BLE API and use
devsar 0:1f985a7c0a8b 16 Soft Device (S110) Gatt Client API directly.
devsar 0:1f985a7c0a8b 17
devsar 0:1f985a7c0a8b 18 If you want to explore the code, S110 API Reference will
devsar 0:1f985a7c0a8b 19 be handy.
devsar 0:1f985a7c0a8b 20
devsar 0:1f985a7c0a8b 21 I know, there are many bugs, and things not implemented
devsar 0:1f985a7c0a8b 22 correctly. But again, the purpose of this code is just
devsar 0:1f985a7c0a8b 23 to show thant Gatt Client API is indeed doable.
devsar 0:1f985a7c0a8b 24
devsar 0:1f985a7c0a8b 25
devsar 0:1f985a7c0a8b 26 WHAT NEXT?
devsar 0:1f985a7c0a8b 27 ==========
devsar 0:1f985a7c0a8b 28 Since with this code, ANCS with mbed (NRF51822-mkit) is
devsar 0:1f985a7c0a8b 29 doable, the next step is to implement GATT CLIENT API on
devsar 0:1f985a7c0a8b 30 mbed BLE API.
devsar 0:1f985a7c0a8b 31 That should make programming more understandable (and
devsar 0:1f985a7c0a8b 32 perhaps portable to other platform) than using SD API
devsar 0:1f985a7c0a8b 33 directly.
devsar 0:1f985a7c0a8b 34
devsar 0:1f985a7c0a8b 35
devsar 0:1f985a7c0a8b 36 HOW TO TEST THIS OUT?
devsar 0:1f985a7c0a8b 37 =====================
devsar 0:1f985a7c0a8b 38 You gonna need:
devsar 0:1f985a7c0a8b 39 1. iOS7 (iPhone/iPad)
devsar 0:1f985a7c0a8b 40 *recomended: iPush Test, free app to generate test notification.
devsar 0:1f985a7c0a8b 41 but if you can generate notification by yourself
devsar 0:1f985a7c0a8b 42 anything will be sufficient.
devsar 0:1f985a7c0a8b 43 2. NRF51822-mKIT, connected to PC
devsar 0:1f985a7c0a8b 44 (debug log and the notification itself will
devsar 0:1f985a7c0a8b 45 be print out via usb com port).
devsar 0:1f985a7c0a8b 46 *teraterm etc is needed to access com port.
devsar 0:1f985a7c0a8b 47 (depend on your platform)
devsar 0:1f985a7c0a8b 48
devsar 0:1f985a7c0a8b 49 Ready for the action!
devsar 0:1f985a7c0a8b 50 1. Compile the code, transfer the binary file to mkit.
devsar 0:1f985a7c0a8b 51 2. Use teraterm etc, to connect to mkit com port.
devsar 0:1f985a7c0a8b 52 3. Press reset. LED1(advertise) should turn on.
devsar 0:1f985a7c0a8b 53 You should see Appendix 1 Log.
devsar 0:1f985a7c0a8b 54 4. On iOS7, select "Settings", "Bluetooth".
devsar 0:1f985a7c0a8b 55 You should see "ANCC" on the devices list.
devsar 0:1f985a7c0a8b 56 Click it to connect. LED2(connected) should turn on.
devsar 0:1f985a7c0a8b 57 5. A Dialog will appear: "Bluetooth Pairing Request"
devsar 0:1f985a7c0a8b 58 Press "Pair"
devsar 0:1f985a7c0a8b 59 You should see Appendix 2 Log.
devsar 0:1f985a7c0a8b 60
devsar 0:1f985a7c0a8b 61 That's it you ready to receive notification.
devsar 0:1f985a7c0a8b 62 There's a free app on app store for generating
devsar 0:1f985a7c0a8b 63 push notification. Search "push test" on app store.
devsar 0:1f985a7c0a8b 64
devsar 0:1f985a7c0a8b 65 6. Run iPush Test app
devsar 0:1f985a7c0a8b 66 7. Click "Local Push Test"
devsar 0:1f985a7c0a8b 67 8. You will receive notification in about 1 minute.
devsar 0:1f985a7c0a8b 68
devsar 0:1f985a7c0a8b 69
devsar 0:1f985a7c0a8b 70
devsar 0:1f985a7c0a8b 71 Appendix 1 (Program Start Log)
devsar 0:1f985a7c0a8b 72 ==============================
devsar 0:1f985a7c0a8b 73 Program started
devsar 0:1f985a7c0a8b 74 timers_init()
devsar 0:1f985a7c0a8b 75 ble_stack_init()
devsar 0:1f985a7c0a8b 76 gap_params_init()
devsar 0:1f985a7c0a8b 77 set_128_uuid()
devsar 0:1f985a7c0a8b 78 advertising_init()
devsar 0:1f985a7c0a8b 79 conn_params_init()
devsar 0:1f985a7c0a8b 80 sec_params_init()
devsar 0:1f985a7c0a8b 81 advertising_start()
devsar 0:1f985a7c0a8b 82
devsar 0:1f985a7c0a8b 83 Appendix 2 (iOS Connect and Pairing)
devsar 0:1f985a7c0a8b 84 ====================================
devsar 0:1f985a7c0a8b 85 Event: BLE_GAP_EVT_CONNECTED (Connection established.)
devsar 0:1f985a7c0a8b 86 Event: BLE_GATTC_EVT_PRIM_SRVC_DISC_RSP (Primary Service Discovery Response event.)
devsar 0:1f985a7c0a8b 87 Found ANCS service, start handle: 15, end handle: 24
devsar 0:1f985a7c0a8b 88 Event: BLE_GATTC_EVT_CHAR_DISC_RSP (Characteristic Discovery Response event.)
devsar 0:1f985a7c0a8b 89 Found char: Control PointEvent: BLE_GATTS_EVT_WRITE (Write operation performed.)
devsar 0:1f985a7c0a8b 90 Event: BLE_GATTC_EVT_CHAR_DISC_RSP (Characteristic Discovery Response event.)
devsar 0:1f985a7c0a8b 91 Found char: Notification SourceEvent: BLE_GATTC_EVT_CHAR_DISC_RSP (Characteristic Discovery Response event.)
devsar 0:1f985a7c0a8b 92 Found char: Data SourceEvent: BLE_GATTC_EVT_CHAR_DISC_RSP (Characteristic Discovery Response event.)
devsar 0:1f985a7c0a8b 93 Event: BLE_GATTC_EVT_DESC_DISC_RSP (Descriptor Discovery Response event.)
devsar 0:1f985a7c0a8b 94 Found NS CCC
devsar 0:1f985a7c0a8b 95 Event: BLE_GATTC_EVT_DESC_DISC_RSP (Descriptor Discovery Response event.)
devsar 0:1f985a7c0a8b 96 Found DS CCC
devsar 0:1f985a7c0a8b 97 Event: BLE_GAP_EVT_SEC_PARAMS_REQUEST (Request to provide security parameters.)
devsar 0:1f985a7c0a8b 98 Event: BLE_GAP_EVT_AUTH_STATUS (Authentication procedure completed with status.)
devsar 0:1f985a7c0a8b 99 Event: BLE_GAP_EVT_CONN_SEC_UPDATE (Connection security updated.)
devsar 0:1f985a7c0a8b 100 Event: BLE_GATTC_EVT_WRITE_RSP (Write Response event.)
devsar 0:1f985a7c0a8b 101 NS subscribe success.
devsar 0:1f985a7c0a8b 102 Event: BLE_GATTC_EVT_WRITE_RSP (Write Response event.)
devsar 0:1f985a7c0a8b 103 DS subscribe success.
devsar 0:1f985a7c0a8b 104
devsar 0:1f985a7c0a8b 105 Appendix 3 (Receiving Notification)
devsar 0:1f985a7c0a8b 106 ===================================
devsar 0:1f985a7c0a8b 107 Event: BLE_GATTC_EVT_HVX (Handle Value Notification or Indication event.)
devsar 0:1f985a7c0a8b 108 Event ID: 0 (Notification Added)
devsar 0:1f985a7c0a8b 109 Event Flags: 0 ((no flags))
devsar 0:1f985a7c0a8b 110 Category ID: 0 (Other)
devsar 0:1f985a7c0a8b 111 Category Count: 1
devsar 0:1f985a7c0a8b 112 Notification ID: 6 0 0 0
devsar 0:1f985a7c0a8b 113 Event: BLE_GATTC_EVT_WRITE_RSP (Write Response event.)
devsar 0:1f985a7c0a8b 114 CP write success.
devsar 0:1f985a7c0a8b 115 Event: BLE_GATTC_EVT_HVX (Handle Value Notification or Indication event.)
devsar 0:1f985a7c0a8b 116 Title:(10)iPush Test
devsar 0:1f985a7c0a8b 117
devsar 0:1f985a7c0a8b 118 Link
devsar 0:1f985a7c0a8b 119 ====
devsar 0:1f985a7c0a8b 120 1. ANCS
devsar 0:1f985a7c0a8b 121 https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Introduction/Introduction.html
devsar 0:1f985a7c0a8b 122