This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Light Switch Design

We are working on the BLE Smart Switch.  The requirements are pretty generic:

  • Low Power consumption
  • To be used by multiple smartphones within the house

The obvious configuration is to have the smartphone as the Client and the NRF device (i.e. the switch) as the server.  Because we are still new to BLE technology, we are wondering:

    When a Smartphone is nearby, should the mobile App connect to the devices automatically and stay "Connected" (with the BLE connection)?

The problem with "staying connected" is that:

  • Staying connected will probably cause the device to consume more power than necessary.
  • How can multiple smartphones connect to the same switch at the same time?

I suppose all BLE switches would have these same issues.  So I would assume someone else must have already solved this.

The only solution we can think of is to have the switches stay unconnected, and will only connect when the user clicks "On" or "Off" in the mobile app.  This means the mobile app would have to first connect, then update the specific characteristic.  Wouldn't this cause a longer delay to switch the light on or off?

Any advise would be greatly appreciated!

Joe

  • Yes, Exactly.  "Anyone can access the device, but only one at a time.  All your BLE devices probably should have the same 'device name' which is programmed in".

    That's why I said, we will cannot keep the connection between phone & device forever.  It must disconnect from time to time to allow other phone to access the device.  Thus, the suggestion to disconnect immediately after every button click.

    I guess we will experiment with the speed of BLE connection, and see if reconnect every button click is acceptable or not.

    Another option I see is that, our Mobile App will try to connect to the BLE device (and keep connected) whenever our Mobile App goes to the foreground.  It will disconnect as soon as the Mobile App goes to background, or when the phone is turned off.  This means once a phone grabs the connection to the BLE device, another phone will not be able to access that device until the original phone switches to another app or have the phone turned off.

  • Sorry, a mistake, but it is difficult because I do not know exactly what you are doing.  If you have several BLE devices in a vicinity which are discoverable and they all have the same device name, you will have problems.  All BLE devices within range which you wish to connect to, must have different device names.

  • I wonder what the typical and worst-case response time for making a Connection to the BLE device is.  Will it add significant delay if the mobile needs to Connect first, before updating the characteristic value?

  • It al depends on the Rx dBm value, and there does not seem to be a set formula.  It could even depend on other unrelated BLE devices within range, but my experience of about -60 dBm, the connect time is from 5-30 seconds.

  • To make an informed decision I think you should read up on the concept of BLE GAP roles. It is particularly important to understand the roles of the peripheral and central, how they connect, and how your system configuration will affect your current consumption and latency. Here are two relevant articles:

    1. Introduction to Bluetooth Low Energy: GAP
    2. How GAP and GATT Work

    Staying connected will probably cause the device to consume more power than necessary.
    Probably (but not necessarily). When you are advertising you probably want to send out advertising packets at least a couple of times a second to keep the latency low. These packets (probably) need to include some data bytes to identify the switch. When you are in a connection, the only thing you need to do to stay connected is to exchange empty packets "once in a while". Probably a couple of times a second as well. Once again it will be a trade off between current consumption and latency. But the packets can be empty which means it will require less energy to transmit them. There are also mechanisms you can use to skip packets altogether (slave latency).

    How can multiple smartphones connect to the same switch at the same time?
    It is not true that a peripheral can maintain only one link at the time. It used to be true, but in the past couple of years we have developed BLE stacks that allow you to run up to 20 concurrent links in any peripheral-central role configuration you want. We even have dedicated examples in the SDK for this. You can read more about how it works here

    EDIT:
    More useful blogs:

    1. https://devzone.nordicsemi.com/b/blog/posts/bluetooth-smart-and-the-nordics-softdevices-part-1
    2. https://devzone.nordicsemi.com/b/blog/posts/bluetooth-smart-and-the-nordics-softdevices-part-2
Related