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

Connection between two hidden NRF51822 modules

Hello

First of all, I would like to apologize if a similar question was already asked but all this BLE matter is so broad that it defeats me. I am planning to put two NRF51822 devices into my project. I want one of the devices to pull one of the GPIO pins down as soon as the other one is in the range of 10-30m. Also, I want it to be secure, I don't want anyone else to scan my devices, copy them and control the pin with another one. I want slave device to consume as low energy as possible.

My idea is:

  1. make both devices undiscoverable so it will be difficult to scan for them.
  2. The master device (the one that controls the GPIO pin) will advertise only to the slave one and it will be visible only for the slave one.
  3. The slave device will check if it is in range of 10-30-m and if so it will send back a message/password or whatever to master. If it is not in range it won't send any message.
  4. If master receives the message it pulls the pin down.
  5. Repeat points 2-4 each 1s.

Is it possible to implement such routine? Or are there any better ideas? I am a total newbie in BLE. I managed to run simple advertising example but nothing more. I would appreciate a guidance, not a readymade solution.

vldzero

Parents
  • sd_ble_gap_whitelist_set() is not supported by S130.

    The whitelist has be set when you start to advertise:

    /**@brief GAP advertising parameters.*/
    typedef struct
    {
      uint8_t               type;                 /**< See @ref BLE_GAP_ADV_TYPES. */
      ble_gap_addr_t       *p_peer_addr;          /**< For @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND mode only, known peer address. */
      uint8_t               fp;                   /**< Filter Policy, see @ref BLE_GAP_ADV_FILTER_POLICIES. */
      ble_gap_whitelist_t  *p_whitelist;          /**< Pointer to whitelist, NULL if no whitelist or the current active whitelist is to be used. */
      uint16_t              interval;             /**< Advertising interval between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s), see @ref BLE_GAP_ADV_INTERVALS.
                                                       - If type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, this parameter must be set to 0 for high duty cycle directed advertising.
                                                       - If type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, set @ref BLE_GAP_ADV_INTERVAL_MIN <= interval <= @ref BLE_GAP_ADV_INTERVAL_MAX for low duty cycle advertising.*/
      uint16_t              timeout;              /**< Advertising timeout between 0x0001 and 0x3FFF in seconds, 0x0000 disables timeout. See also @ref BLE_GAP_ADV_TIMEOUT_VALUES. If type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, this parameter must be set to 0 for High duty cycle directed advertising. */
      ble_gap_adv_ch_mask_t channel_mask;         /**< Advertising channel mask. See @ref ble_gap_adv_ch_mask_t. */
    } ble_gap_adv_params_t;
    

    You can also let the advertising module handle it.

    Add options.ble_adv_whitelist_enabled = true; in advertising_init().

    Then you need to handle the BLE_ADV_EVT_WHITELIST_REQUEST event that you get in on_adv_evt(), by replying with ble_advertising_whitelist_reply().

Reply
  • sd_ble_gap_whitelist_set() is not supported by S130.

    The whitelist has be set when you start to advertise:

    /**@brief GAP advertising parameters.*/
    typedef struct
    {
      uint8_t               type;                 /**< See @ref BLE_GAP_ADV_TYPES. */
      ble_gap_addr_t       *p_peer_addr;          /**< For @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND mode only, known peer address. */
      uint8_t               fp;                   /**< Filter Policy, see @ref BLE_GAP_ADV_FILTER_POLICIES. */
      ble_gap_whitelist_t  *p_whitelist;          /**< Pointer to whitelist, NULL if no whitelist or the current active whitelist is to be used. */
      uint16_t              interval;             /**< Advertising interval between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s), see @ref BLE_GAP_ADV_INTERVALS.
                                                       - If type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, this parameter must be set to 0 for high duty cycle directed advertising.
                                                       - If type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, set @ref BLE_GAP_ADV_INTERVAL_MIN <= interval <= @ref BLE_GAP_ADV_INTERVAL_MAX for low duty cycle advertising.*/
      uint16_t              timeout;              /**< Advertising timeout between 0x0001 and 0x3FFF in seconds, 0x0000 disables timeout. See also @ref BLE_GAP_ADV_TIMEOUT_VALUES. If type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, this parameter must be set to 0 for High duty cycle directed advertising. */
      ble_gap_adv_ch_mask_t channel_mask;         /**< Advertising channel mask. See @ref ble_gap_adv_ch_mask_t. */
    } ble_gap_adv_params_t;
    

    You can also let the advertising module handle it.

    Add options.ble_adv_whitelist_enabled = true; in advertising_init().

    Then you need to handle the BLE_ADV_EVT_WHITELIST_REQUEST event that you get in on_adv_evt(), by replying with ble_advertising_whitelist_reply().

Children
Related