Here is the Cypress example that does what you are looking for on a BLE-level; I imagine it would be the same for the android app, but with the android app running one side of the connection.
The only problem is I don't know how to initiate the key pass exchange between android and the BLE Device
CyBle_GapAuthReq(connHandle.bdHandle, &cyBle_authInfo); Should work for initiating the key pass exchange on the cypress-chip side of the connection. I imagine android has something similar; Here is a related stack exchange post: http://stackoverflow.com/questions/17168263/how-to-pair-bluetooth-device-programmatically-android
Do you call CyBle_GapAuthReq(connHandle.bdHandle, &cyBle_authInfo) while advertising or once a connection has occured? Cause if it's after you're already connected it kind of seems pointless. How does one enable a passkey for the BLE in the settings?
You call it after connecting to the device. Since you can set the services and characteristics to be authentication or encryption protected, it is actually useful as a means of "privilege levels". If you set everything to authentication/encryption protected, then it won't allow any access until you pair/bond.
This example should demonstrate the process: http://www.cypress.com/blog/100-projects-100-days/project-015-bonding
It doesn't connect it to an "Android App", but since Bluetooth is a standard, they should be interfaceable. Under the BLE component there is a setting for security under the Gap settings (iirc).
Thank you e.pratt, After turning on the proper security settings in the GAP Settings as you stated
-> Security Mode: Mode 1
-> Security Level: Authenticated Pairing with Encryption
->I/O Capabilities: Display
->Bonding Requirement: Bonding
->Encryption Key Size (bytes) -> 16
On the android side you have to initiate a pairing (not the same as connecting). Everything should be taken care of afterwards.
Does that mean it was successful? :)
The cyblegapauthreq() should initiate the pairing when called (and successful).
Yeah, it was successful, I can connect using an android device with a keypass prompt. I've also tried reading directly from the device and it would not work unless pairing was successful. I didn't manually have to call "cyblegapauthreq()". I'm guessing it's being called somewhere in the exchange between the BLE devices.
Yeah; Most likely the android app is doing a bonding procedure when it does the pairing as well. Glad you got it working though! The cyblegapauthreq() is more for if you want to initiate the process from the cypress-chip side of the connection, if the android app starts the pairing/bonding process, then the cypress chip just needs to accept/verify the process is successful.