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.

CC2540 Broadcasting status of a I/O pin

Expert 1595 points
Other Parts Discussed in Thread: CC2540

Hi all,

I am fairly new to using the CC2540 and would like some suggestions on how I can get started with this simple project I am working on.

Basically, I would like to broadcast the status of an I/O pin on the CC2540 every 1 second to a mobile phone and I need this to be as energy efficient as possible. So I have a few questions:

  1. Can I use SImpleBLEBroadcaster? Since I don't need the phone send any data back.
  2.  Do I need scan response data or I can just put the status of the I/O pin inside advertData?
  3. I read that the less number of bytes you send, the less power you consume. So I could be just sending 1 byte of advertData every one second?
  4. I was thinking the I/O pin should be interrupt triggered and will set a variable. This variable will be broadcast and cleared after that.

Thanks in advance for helping!

Cheers,

Kian

  • I realised I have another question. On my mobile phone, I need to have an app to receive the broadcast message. Does it mean that my phone needs to be continuously scanning all the time?  Isn't that going to waste a lot of battery on the phone? How do I ensure that the broadcaster and central device (phone) is in sync so that when it send and receive at the right interval?

    Or it would make sense to use Peripheral mode and enable notifications through a GATT service? And have the phone subscribe to the service?

    But I want multiple central devices to be able to see the CC2540 and the status of the I/O pin. 

  • Hi Kian,

    1. Yes, I think you can follow SimpleBLEBroadcaster to start with.

    2. The scan response data is the response of the ScanRequest received from the central device. And in your case you're broadcasting, so you don't need it.

    3. Also you can reduce the Transmission Power, by setting required value in TXPOWER, based upon your application. As reducing the transmission power will reduce the range of the BLE.

    4. Yes, you can configure the I/O pin for the interrupt and write down the suitable ISR.

    Thanks,

    Dhaval

  • I was looking at the Keyfob example and I thought it might even make sense to broadcast only if the I/O pin is set to high. That way I can reduce even more power. For example, if I/O pin is high, broadcast for 5 seconds at 100ms interval. After 5 seconds stop broadcasting until I/O pin goes high again.