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

how to transmitt encryption data with nRF51 SDK9 hrm example?

I just want to understand concept. For example, I need transmit battery level, heart rate level and other.. in closed (encrypted characteristic). I use S130 nRF51 SDK9. HRS example. If I run this example, on my smartfone I can see all of this data. But data not crypted. I use s130 in advertise mode.

I need underastand concept what I sould do to crypted it? Is it necessary add to

static void gap_params_init(void) ()

uint8_t passkey[] = "123456";

ble_opt_t static_pin_option;
static_pin_option.gap_opt.passkey.p_passkey = passkey;
err_code = sd_ble_opt_set(BLE_GAP_OPT_PASSKEY, &static_pin_option);
APP_ERROR_CHECK(err_code);

Or I need add another fields more? With those added lines, I don't see crypted data on smartfone. Why?

Parents
  • Hi Mikhail,

    Do did you check if the data was encrypted or not ?

    The easiest way is to encrypt data is to pair/bond your phone with the device. After pairing/bonding, the communication between the phone and the device is encrypted with AES128.

    The passkey configuration is part of the pairing process when you want to have MITM protection.

    But you need to start pairing first. Please try to test with our proximity example where bonding is required to read a characteristic.

    I would suggest you to have a look at a BLE book to have a rough overview of how BLE security works for example "Bluetooth Low Energy: The Developer's Handbook" , "Getting Started with Bluetooth Low Energy: Tools and Techniques for Low-Power Networking" or have a look here.

  • If you set BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM() to the characteristic, encryption will be required when the central want to read your data. And then you will get a popup on the phone to ask for pairing.

    After you pair, the link will be encrypted. But note that, the application will still show the normal data value when you read the characteristic, just because the encryption happens on lower layer and it's transparent to the application.

Reply
  • If you set BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM() to the characteristic, encryption will be required when the central want to read your data. And then you will get a popup on the phone to ask for pairing.

    After you pair, the link will be encrypted. But note that, the application will still show the normal data value when you read the characteristic, just because the encryption happens on lower layer and it's transparent to the application.

Children
No Data
Related