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

nRF51822

Hi everybody, i am working with a nrf51822 chip and i would like to use it only in slave mode. is it possible? and how can we do it? Thanks

  • Hello,

    with slave mode do you meen that the nrf51822 is the sensor and eg. a smartphone connect to the sensor to read/write some data? For that use case the S110 softdevice and the sample code are ready to go.

    Hint: If you are in test stage only then from LAIRD you get a certified Module with Basic Scripts....

    • At first to have an easy startup use a developent kit from NORDIC

    • The development kit contains the needed jtag debugger device to program and debug the chip

    • With the product code on the package on the website download the SDK

    • Download the free version from Keil uVision4

    • Install Nordic SDK (after installing Keil)

    • Use nRFgo Studio to flash the S110 Library to the chip

    • Open with KEIL the sample code from eg. ble\ble_app_hrs

    • Compile and flash the code with KEIL to the Chip

    • Download the Nordic App nRF Utility for iPhone or Samsung Galagy S3/S4 (and some else)

    • Connect from the App to the nordic chip

    • Now in the code check mail.c and ble__bas.c

    • in main.c see at "advertising_init()" this prepare structures to do advertising "advertising_start()" here the advertising ist started

    • the file ble_bas.c initializes a BTLE Battery service and the characteristic check ble_bas_init() here the BTLE service is prepared check battery_level_char_add() here the BTLE characteristics for the service is prepared check ble_bas_battery_level_update() here a new value of the characteristic is set (and send with notify)

    • If you need to write a value from the smartphone to the chip check the code ble\ble_app_hids_mouse where many characteristics are enabled to change the value

    • Check the File "ble_hids.c" .... service and the characteristics form the HID service¨

    • Check code lines where you find a write in it char_md.char_props.read = 1; char_md.char_props.write_wo_resp = 1; char_md.char_props.write = 1; --> For every characteristic which must be write enabled you have to define that it can be written (with or without a respons back to the smartphone after write operation)

    • See the lines attr_md.read_perm = p_rep_ref_attr_md->read_perm; attr_md.write_perm = p_rep_ref_attr_md->write_perm;

    ---> You must also enable the right to write!!! eg. use following for your first tests: BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);

    Best regards, Lukas

  • To clean up a few of the unresolved questions on this site, I'm working through old ones. If you found the answer from Lukas below useful, I'd recommend that you click the "Accept this answer" button, to show appreciation. :-)

  • by the way,which BLE_STACK EVENT can let us know the phone has written the characteristics?

  • It seems this would have been much better off as a separate question, since it has nothing to do with what was originally asked here.

    However, when a peer device writes to a characteristic, you'll get a BLE_GATTS_EVT_WRITE event.

Related