This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

iPhone 4S Sample Project - Connects and interacts with the CC2540 keyfob

Guru 57865 points
Other Parts Discussed in Thread: CC2540, CC2564

 

Hi all,

We have a new sample project, IPhone4SBLEDemo,  which can connect and interact with our CC2540 keyfob. This is an iOS project and source code can be downloaded from the Texas Instruments Wiki;

http://processors.wiki.ti.com/index.php/Category:IPhone4SBLEDemo

The Application interacts with the CC2540 keyfob and can,

  • Connects to keyfob
  • Shows live accelerometer data
  • Shows live battery level data
  • Shows live button data
  • Can sound buzzer when button is pressed

This is a first demo and we have not fully tested it, we just simply want to get you going as soon as possible.

Note that you would need to join the iOS Developer Program in order to build and download the App to your iPhone 4S. 

Thanks and good luck

 

  • Thanks !

    This is very usefull.

    I have a few questions about the iPhone side :

    1. Where is the command to start scanning for devices issued ?

    2. Where you define the desired connection parameters (connection interval, slave latency, supervision timeout) for the master (which is the iPhone) ?

    Thanks.

  • Hi Sasha,

    In the TIBLECBKeyfob.m you will find the answer for your first question. The scanning is initiated with scanForPeripheralsWithServices. The second question is a really good one ,unfortunately I dont have the answer. I believe we use some kind of default value for the connection parameters.

    Please feel free to correct me or find an answer :)

    BR

  • Dear Nick,

     

    1. I can"t download the demo.zip. Is there problem with it

    2. Does the 4S support BLE (from the OS side not the HW) or do you run the BLE stock in the app?

     

    Regards

    Oded 

  • Hi Oded,

    Oded Globerman said:
    I can"t download the demo.zip. Is there problem with it

    Should work fine, just verified it.

    Oded Globerman said:
    Does the 4S support BLE (from the OS side not the HW) or do you run the BLE stock in the app?

    There is an API (Core Bluetooth) for basic stuff such as scan, connect and exchange data (GATT).

    BR

  • have you guys tried that if the screen is locked or the application is not in the forground could a BLE still send data to the iphone? if I want to design something that keep transmitting discret data to iphone4s through BLE, the application that receives the data must be always alive. But as far as I know you can't do that by classic Bluetooth on iPhone since there is no background task in iOS unless you declear your device to be four kinds of application such as musci playing to geo related. I am not sure if Apple has changed that in iOS5 yet.

  • Hi Jie,

    I am pretty sure that BLE data can be received when the application runs in the background. What I can tell you for sure is that, when application is running in the background or screen is locked, the application notifies the user if something has changed (for example BLE data has been recieved). So that could prove the theory :) But we haven't done any long term testing on this... yet.

    BR 

  • thank you very much! by "application" do you mean the demo application showned in the video?

  • How could a device invoke the proper application which is associated with it? In the demo video the last part shows that the device is asking the phone to run the helloworld application. I know that it is possible to do it through classic bluetooth by using wirelessiAP. But there seems to be no mention of it in the coreBluetooth about this function. Is BLE also part of Accessory framework of iOS?

  • Hi Jie,

    jie liu36614 said:
    the device is asking the phone to run the helloworld application

    No, the device is already running in the background :) The iOS application has simply been "minimized" and the screen locked before we send BLE data.

  • Does any body know if there any theoretical limitations to the number of BLE devices that can be paired with the CoreBluetooth.framework ?

  • Dear Sir,

     

    Does it mean that just the IOS development licence is enough for using this demo?

     

    Regards,

     

    Tony

  • Hi Tony,

    Tony Siu said:
    Does it mean that just the IOS development licence is enough for using this demo?

    Yes, and the hardware of course (iPhone 4S and CC2540DK-MINI)

    BR

  • Dear sir

    1. Does using BLE requires Apple chip on the board, like it used to be with the former bluetooth solution? (connecting iPhone to a bluetooth device, required an apple chip added to the chipset, as well as being a member in the MFI (made for iPod programm).

    2. Does using BLE requires MFI membership (or only apple developer)

    3. Is it possible that BLE event will "wake up" the application (bring it to forground) or at least will enable some background process (like navigation apps)? (I saw it was asked, but didn't see a confirmed answer)

     

    Thanks a lot

  • Hi Amit,

    the answer to your question is in:

    http://e2e.ti.com/support/low_power_rf/f/538/t/148268.aspx

    Please, do not post the same thing in two places :) And please press the "verify" button in the answer Nick has given you in the other post in order to other people can learn of your experience.

  • Hi guys,

    just a question. If the new iPhone 4S is implementing BLE and classical BR/EDR, is this cellphone carrying a dual chip? Or the whole thing has been implemented by placing two chips?

    I'm not an Apple guy, sorry :)

  • The iphone 4s has a broadcom dual mode chip 

  • Thanks berms.

    Is the chip you are referring to in the following list?

    http://www.broadcom.com/products/Bluetooth/Bluetooth-RF-Silicon-and-Software-Solutions

    Perhaps is the BCM20702?

    Thanks for answering.

     

    I've checked this. Both Broadcom (BCM20702) and CSR (CSR8000) have a dual-mode chip :) Thanks.

  • http://www.broadcom.com/products/Wireless-LAN/802.11-Wireless-LAN-Solutions/BCM4330

     

     Not 100% Sure if this is the IC they are using, but it would be my guess.  If you are looking for a Dual mode Module, BlueRadios has a Dual Mode Bluetooth Module that contains both a dual mode bluetooth baseband (TI CC2564) and an MSP430.  You can find more information at http://blueradios.com/hardware_LE4.0-D2.htm

  • Thanks for the link! :)

    I think this website clarifies the Broadcom chip Apple is using:

    http://www.wicentric.com/news/2011_10_06.html

    Bye!

  • Hi Nick,

    Thank you very much for posting this.

    I am able to get the sample app loaded on my 4S but can not collect accelerometer data or buzz the speaker after pairing. Pushing the keyfob's buttons works fine and the App reacts appropriately.

    Is this a known issue?

    I'm currently using IOS 5.0.1 and CC2540 KeyFob 1.1 firmware.

    Best,

    -Paul

  • Hi Paul,

    That could be a known issue.

    Make sure that you program the CC2540 keyfob with the "KeyFob" project (\BLE-CC2540-1.1a\Projects\ble\KeyFob) and not the cc2540_ble1.1_keyfob_SimpleBLEPeripheral.hex found in the Hex_Files directory (there is no accelerometer functionality implemented in that). 

    Please let me know if this solved your issue.

    BR

  • Hi Nick,

    Yes, that did the trick. I was unaware I needed a copy of IAR Embedded Workbench to get this running. Once I compiled the sample project everything worked. Thanks again!

    Best,

    -Paul

  • Hi everyone,

    "How many end devices can be connected to an iPhone 4S at the same time?"

    I am trying to get an answer to the same question as well.

    I know this is a question more related to the iPhone side of things, but I think still very relevant for everyone who tries to use CC2540 in end devices, and use an iPhone 4S as the central node to talk to multiple devices at a time.

    So any information on this would be very very helpful, even if it is more of an educated guess than facts.

    Here are some specific questions:

    1) How many End-devices (CC2540) can an iPhone 4S have in one star network? With standard Bluetooth, this would be 7, with the TI stack it seems to be 3, in THEORY BLE should not have any such limitations, but what is it actually in the iPhone 4S implementation, or what is it most likely?

    2) Could this be done sequentially, as in, connect 3 devices now, transfer data, close the connection, connect to other 3 devices, etc...?

    Many thanks for any hints,

    John

  • Hi,

    Sorry to disturb. Am trying to run the demo with the CC2540 hardware. Is the iPhone 4S essential?

    Am trying to run it on my Mac Lion OS 10.7.2 on Xcode 4.2 but it seems unable to work. Has anyone else been able to get it working on an emulator?

    Thank you

    Best

    D

  • Hi Donny,

    At the moment, looking at Apple, only iPhone 4S and the latest Macbook Air and Mac mini has hardware support (BT 4.0) to use Bluetooth Low Energy. Although I dont think the iPhone simulator can access any hardware anyway. So to answer your question I would say, Yes, the iPhone 4S is essential.

    But, I might be wrong, you will have to direct this question to Apple.

    BR

  • The demo is working fine but I can not make the Proximity feature working...

    It seems the feature is implemented in the XCode project:

    - enableTXPower and disableTXPower

    - a "callback" is implemented: didUpdateValueForCharacteristic

    case TI_KEYFOB_PROXIMITY_TX_PWR_NOTIFICATION_UUID:

                {

                    char TXLevel;

                    [characteristic.value getBytes:&TXLevel length:TI_KEYFOB_PROXIMITY_TX_PWR_NOTIFICATION_READ_LEN];

                    self.TXPwrLevel = TXLevel;

                    [[self delegateTXPwrLevelUpdated:TXLevel];

                }

    This "callback" is never called when i move the keyfob from my iPhone4S BUT the callback is called when I click on the left button on the keyfob :( 

    Is is a bug ?

    Where is the issue ? in the XCode project or in the HEX file I'm using (from the http://e2e.ti.com/support/low_power_rf/f/538/t/155248.aspx#567250)

    Can you please advice ?

    -Fred

  • I am very interested in this as well.

    Can anyone comment on this?

    Thanks,

    HT

  • Hi Nick,

    I recently posted a question on the apple BT forum about the long time required to discover services/characteristics....  Just to make sure I wasn't doing anything wrong, I ran the Demo app on my iPhone4S to verify whether you have  the same problem...

    Bottom line -- it's takes a fraction of a second to connect; but it takes about 6 secs (!!!!) to discover the necessary services/characteristics....

    Though connect time in BLE is indeed "fast", realistically until the services/characteristics are (re-)discovered each time the app can't really do anything....  Doesn't this defeat one of the advantages of BLE of classic BT -- that is, "fast" connect time???

    Are you aware of any technique by which these services/characteristics can be persisted???

    Bob.

  • I have several TI demo kits and I do not have the keyfob kit used in the TI iPhone demo.  I need the demo board to be able to connect as a peripheral. What do I need to change on the demo kit side. can I change the keyfob or simpleBLEperipheral project to be able to connect to an iPhone.? What do I need to change on the iPhone side in the TI-BLE-iphone Xcode project.

    I am running the simpleBLEPeripheral which is saying advertising (all works fine with the simpleBLE Central). On my iPhone from general settings -> Bluetooth it does not find the device. When I run the TI demo it does not connect. I know there is no accelerometer on the demo board. I just want to connect and go from there to develop my own application.

    I purchased a MAC mini because it has Bluetooth 4.0. In the system preferences -> bluetooth it does not find the TI demo kit device either when it is "advertising".

    I am new to this so I am sure there is operator error involved somewhere but any help would be appreciated. i have a very tight schedule.

  • I believe on the Mac Mini's traditional Bluetooth is used when performing a scan.  If you want to use the BLE portion of it, I believe you have to use the SDK and right a seperate App for it

  • mai i use it with iTouch 4 or iPhone 4, or iPad 2?

  • no, the only devices that have bluetooth 4.0 from apple is the IPhone 4S, the New mac mini, the new mac book air, and the IPad 3

  • Thanks, this was my first problem.

    Is there any reason why a HEX file isn't provided with the CC2540 Dev Kit software?  It's kind of annoying to have to set up an IAR environment just to get example's running.  Perhaps I just missed the hex file.

    Thanks,
    Colin 

  • hi,

    with IPhone4SBLEDemo ,&TI Keyfob,

    the 4S can't connect the Keyfob,

    below is the 4S losg,


    Mar 31 09:55:46 unknown SpringBoard[15] <Warning>: BTM: received BT_LOCAL_DEVICE_DISCOVERY_STARTED/STOPPED event
    Mar 31 09:55:46 unknown SpringBoard[15] <Warning>: BTM: posting notification BluetoothDiscoveryStateChangedNotification
    >
    Mar 31 09:55:48 unknown SpringBoard[15] <Warning>: BTM: received BT_LOCAL_DEVICE_DISCOVERY_STARTED/STOPPED event
    Mar 31 09:55:48 unknown SpringBoard[15] <Warning>: BTM: posting notification BluetoothDiscoveryStateChangedNotification
    Mar 31 09:55:48 unknown com.apple.BTServer[66] <Notice>: GattCommands.cpp:996      readName             ATT        Error      Failed to locate GAP primary service on device "Public 90:D7:EB:B1:26:03"
    Mar 31 09:55:48 unknown com.apple.BTServer[66] <Notice>: OI_SLOG_ERROR: 68,1242,65535
    Mar 31 09:55:48 unknown com.apple.BTServer[66] <Notice>: GattCommands.cpp:64       discoverResponse     ATT        Error      No primary services found on device "Public 90:D7:EB:B1:26:03"
    Mar 31 09:55:49 unknown SpringBoard[15] <Warning>: BTM: received BT_LOCAL_DEVICE_CONNECTION_STATUS_CHANGED event
    >
    Mar 31 09:55:49 unknown SpringBoard[15] <Warning>: BTM: posting notification BluetoothConnectionStatusChangedNotification
    Mar 31 09:55:49 unknown SpringBoard[15] <Warning>: BTM: BTLocalDeviceGetPairedDevices returned 0 devices
    Mar 31 09:55:49 unknown SpringBoard[15] <Warning>: BTM: BTLocalDeviceGetConnectedDevices returned 0 devices
    >
    Mar 31 09:55:56 unknown SpringBoard[15] <Warning>: BTM: received BT_LOCAL_DEVICE_CONNECTION_STATUS_CHANGED event
    Mar 31 09:55:56 unknown SpringBoard[15] <Warning>: BTM: posting notification BluetoothConnectionStatusChangedNotification
    Mar 31 09:55:56 unknown SpringBoard[15] <Warning>: BTM: BTLocalDeviceGetPairedDevices returned 0 devices
    Mar 31 09:55:56 unknown SpringBoard[15] <Warning>: BTM: BTLocalDeviceGetConnectedDevices returned 0 devices

    why this happen?

    thanks!

  • Hi Bob,

    Any update regarding this interesting question ? I'm very interested to find a way to avoid asking characteristics after each re-connection.

    Fred

  • hi fred,

    according to apple, "caching" of characteristics is something they are investigating for the future....  as it turns *connect time* in general has been problem for a variety a reason besides having to re-discover characteristics....

    you might consider posting a question on the apple bluetooth email list and/or a new forum apple has recently established....  perhaps you can find out a timeframe for such a change....

    bob.

  • HI,

    I checked with CB , that i don't  see any API, to create secured connected to the device ?.. Or before we create a connection to the device, do we have to use any iOS infrastructure to do the BLE pairing/authentication?.. Pretty confusion. Kindly advice. 

  • is it possible to detect nearest BLE ios devices using the keyfob code?

  • I have tried the sample app and I can get all the accelerometer data. The xyz data is in the range of 0 to 100. Does that correspond to -1g to 1g? 

  • Thank you very much.

    For me, neither the Accelerator (for all directions) nor the battery detection are working. Is there any but. 

    I am using the Wireless Connectivity Dev. Kit with CC2540DK-Mini (http://www.ti.com/lit/ml/swru272a/swru272a.pdf) with the standard software, witch was already include on the Dev. Kit.

    My iPhone is a iPhone 5, iOS 7.1.

    Thanks a lot.

    Cheery

    isicom