This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

gap_params_init and connection parameter issue

Hello,

I'm working on a firmware for a device that is created using ble proximity example. It is power constrain device and required a connection interval of 30 sec between a master (Android phone only) and slave nRF52810.

I’m using the following version and device.

  1. SDK v17.0.2
  2. 2. s112_nrf52_7.2.0_softdevice
  3. Basically I’m using Android phones as my central or master device and nRF52810 as peripheral or slave.

Basic feature of the firmware

                The architecture is based on Application Timer Event callbacks.

                The firmware was prepared using the BLE Peripheral Proximity example.

In order to minimize power consumption the device runs a minimum of active GATT services listed below:

  1. TX Power
  2. Instant Alert Service (IAS)
  3. Instant Alert Service Client (IAS-C)
  4. Connection is BLE_PERIPHERAL

To get the desire interval I'm changing the following parameters. I have used different values for these parameters without violating the following two constrain but seem I'm not able to go beyond 15 sec interval ( 30 sec is desired). Is there anything I'm not doing correct. 

                   //constrains

    1. conn_sup_timeout * 4 > (1 + slave_latency) * max_conn_interval
    2. (1 + Conn_Latency) * Conn_Interval_Max * 2 < conn_sup_timeout

                   // Parameters

    1. MIN_CONN_INTERVAL               MSEC_TO_UNITS(800, UNIT_1_25_MS)
    2. MAX_CONN_INTERVAL               MSEC_TO_UNITS(830, UNIT_1_25_MS)
    3. SLAVE_LATENCY                   18
    4. CONN_SUP_TIMEOUT                MSEC_TO_UNITS(32000, UNIT_10_MS)

I'm getting the following error whenever I try to increase slave latency.

  • gap_params_init();
    • APP_ERROR_CHECK(err_code);
      • I think It might help you “void app_error_handler_bare(ret_code_t error_code)” here error_code = 0x00000007.
Parents
  • Thank you for your reply, 

    I agree with your statement. 

    You can't have 30ms connection interval. You can have maximum 4 seconds (you can find the limits in ble_gap.h. Search for BLE_GAP_CP_LIMITS).

    But my connection interval is 830 ms and I'm taking advantage of slave latency to achieve effective connection interval 30 sec.

    But I think (1 + connSlaveLatency) * connInterval * 2 constrain don't allow to go beyond 15 sec. Or do we have any other way to get the better result. 

    Do we have a way to disconnection and reconnect the peripheral with the 30 sec interval and transfer packets. but it is important to slave to sleep during that period of time.

    Thanks

  • Thank you so much for the your help. We think about your suggestion regarding  more power consumption in disconnect and connect method and agree with you and dropping that idea.

    We wanted that spec. because of our battery life need to be more than 180 days. After doing some math we come up with that number. But if its impossible to do, we can compromise over there.  

    you mention about Bluetooth specification, Vol6, part B, section 4.5.2:. Do you have link for this PDF. I have a PDF for Apple BLE spec., does something similar exist for Android I looked for it but didn't find any. It will be a great help if you can give me a link for that.

  • HaiderRPM said:
    We have a piezo buzzer (3 mA) and a led (2 mA). 

     In that case, the current from a 4second connection interval is negligible, so you don't need to spend time trying to increase the connection interval.

    Whether the radio uses 3µA or 1.5µA doesn't matter when you are drawing 5mA on top of that. Then your current consumption is 5mA, or 5.003mA if you like, but I assume the 5mA is not a 5.000mA. 

    In your case, the LED is on 1/5th of the time, and the buzzer is on 1/5th of the time, so you have 3/5 + 2/5 mA = 1mA on average. Maybe less if the LED and buzzer are not used simultaneously.

    0.99*3µA
    + 0.005*1000µA
    + 0.005*38µA


    2.97µA
    + 5µA
    + 0.19µA

    = 8.16µA on average. 

    This makes your 110mAh last 13480 hours = 561 days. 

    Reducing the connection interval to 30 seconds if that was possible would take the average current consumption to 6.865µA, which would last 667 days. It is an increase, but you have a lot more to save by reducing the alarm time (shorter on for the LED and the buzzer). 

    If that is not an option, I am afraid you need to look into a bigger battery.

    BR,

    Edvin

  • Hello,

    I hope you had a great weekend, now I'm following all restrictions you mentioned here. I'm using following new parameters. But it still disconnect after one or two day. I'm using nRF connect app in android (this project is only for android). Can you tell me where I'm going wrong. You mentioned about Bluetooth specification, Vol6, part B, section 4.5.2: in your previous reply, would you please forward me the link for this pdf.

    #define MIN_CONN_INTERVAL MSEC_TO_UNITS(900, UNIT_1_25_MS)
    #define MAX_CONN_INTERVAL MSEC_TO_UNITS(1000, UNIT_1_25_MS)

    #define SLAVE_LATENCY 12 
    #define CONN_SUP_TIMEOUT MSEC_TO_UNITS(32000, UNIT_10_MS) 
    #define APP_ADV_INTERVAL MSEC_TO_UNITS(250, UNIT_0_625_MS)
    #define APP_ADV_DURATION 30000 // originally value was: 18000 

    Thank you

  • Hi,

    HaiderRPM said:
    You mentioned about Bluetooth specification, Vol6, part B, section 4.5.2: in your previous reply, would you please forward me the link for this pdf.

    You can download the Bluetooth core specification here.

    HaiderRPM said:
    But it still disconnect after one or two day.

    What is the disconnect reason? Based on this discussion I assume it is supervision timeout, but I do not see it clearly stated so it would be good to know. Also, have you only tested one Android device, or do you see the same with other devices?

    And also, is there a problem with these disconnects? Normally the peripheral would start advertise on a disconnect and the phone would connect again without the user ever notising a difference. Depending on the RF environment etc it may not be possible to ensure that you never get any disconnects.

  • Hello Einar,
    Thank you for your kind response

    Error I can see on my nRF Connect app is Error 133, defined as: #define GATT_ERROR 0x85 

    I believe supervision timeout is not the reason for the disconnection. As last night I changed my connection parameters to the default values accept advertisement interval. 

    #define MIN_CONN_INTERVAL MSEC_TO_UNITS(500, UNIT_1_25_MS) /**< Minimum acceptable connection interval (0.5 seconds). */
    #define MAX_CONN_INTERVAL MSEC_TO_UNITS(1000, UNIT_1_25_MS) /**< Maximum acceptable connection interval (1 second). */

    #define SLAVE_LATENCY 0 /**< Slave latency. */
    #define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS) /**< Connection supervisory timeout (4 seconds). */

    // change by Haider: old value APP_ADV_INTERVAL 40 {Range can be 20ms to 10.24 sec} /**< The advertising interval (in units of 0.625 ms. This value corresponds to 25 ms). */
    #define APP_ADV_INTERVAL MSEC_TO_UNITS(250, UNIT_0_625_MS)
    #define APP_ADV_DURATION 30000 // originally: 18000 

    I'm using it with the similar device but does it matter? I also notice it do not connect after disconnection even if I manually tap the connect button on the app. I have to restart my peripheral and connect it.

  • Hi,

    HaiderRPM said:
    Error I can see on my nRF Connect app is Error 133, defined as: #define GATT_ERROR 0x85 

    I see. That is very useful information. Unfortunately GATT error 133 is a quite generic error so it is difficult to say what causes it.

    HaiderRPM said:
    I'm using it with the similar device but does it matter?

    It would be interesting to know if this only happens with some specific peer devices. Which phones have you tested with (phone model and Android version), and do you see the same behaviour with all?

    HaiderRPM said:
    I also notice it do not connect after disconnection even if I manually tap the connect button on the app. I have to restart my peripheral and connect it.

    that is interesting. Do you do some debug logging on the nRF side to understand what happens? It would be very useful to see what happens seen form the nRF, bot before the disconnect and which disconnect reason the nRF sees.

    Lastly, a sniffer trace could be very useful, though it may be difficult to produce as the disconnect happens so seldomly. In any case logging and a trace of the failed reconnect attempts before the nRF is reset would also be useful.

Reply
  • Hi,

    HaiderRPM said:
    Error I can see on my nRF Connect app is Error 133, defined as: #define GATT_ERROR 0x85 

    I see. That is very useful information. Unfortunately GATT error 133 is a quite generic error so it is difficult to say what causes it.

    HaiderRPM said:
    I'm using it with the similar device but does it matter?

    It would be interesting to know if this only happens with some specific peer devices. Which phones have you tested with (phone model and Android version), and do you see the same behaviour with all?

    HaiderRPM said:
    I also notice it do not connect after disconnection even if I manually tap the connect button on the app. I have to restart my peripheral and connect it.

    that is interesting. Do you do some debug logging on the nRF side to understand what happens? It would be very useful to see what happens seen form the nRF, bot before the disconnect and which disconnect reason the nRF sees.

    Lastly, a sniffer trace could be very useful, though it may be difficult to produce as the disconnect happens so seldomly. In any case logging and a trace of the failed reconnect attempts before the nRF is reset would also be useful.

Children
No Data
Related