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

Which SDK example should I use to setup the NRF51822 to only receive data from a Central, in this case a smart phone.

Hello,

I would like to configure the NRF51822 as a Peripheral to receive data from a smart phone, and then call a routine when the receive process has been terminated.

I have this working with the RF Digital Simblee chip, but now I need to do this with the Raytac MDBT40 so I can not use the internal routines in the Simblee of course.

I am thinking that the UART example would do it but I do not understand the various routines at this point, or even if this is the best example to use.

All I want is for the NRF51822 to receive a string of data from the phone and put it into an array, and upon termination of the receive process, call a routine where I will call some of my existing working code to appropriately process it from there. I do not need to send any data out of the NRF51822 back to the phone. Simplex communication only, phone only to transmit to the NRF51822.

Thank-you for your assistance.

  • Hello, Brian.

    > Which SDK?

    ICVersion

    I hope I'm looking at the correct MDBT40's datasheet. This says that the IC version 3 is used.

    Looking at the Nordic's Compatibility matrix, choose SDK 8 ~ 12. You can download the SDK from this webpage. Note that SDK 13 or above runs on nRF52 devices, not nRF51 devices.

    Contact Raytac to check whether the MDBT40 uses the IC version 3 nRF51 series, please.

    > All I want is for the NRF51822 to receive a string of data from the phone and put it into an array

    > I am thinking that the UART example would do it

    As you mentioned, I agree that E:\NordicSDK\nRF5_SDK_xxxx\examples\ble_peripheral\ble_app_uart example will the suitable for you.

    As mentioned in the Nordic Infocenter page (SDK 12 based), if your smartphone (central) app sends a string via NUS (Nordic UART Service), nus_data_handler is called. This function handles the received data.

    -Regards, MANGO

  • Thanks, at this point I am using nRF5_SDK_11.0.0 but I can use a higher version if you think it will be better.

    The Java code in my Android app is taken from the Bluetooth Application Accelerator.

    After all the preliminaries are done, the code is sent by the following:

    BluetoothGattCharacteristic mCharacteristic ; mCharacteristic = gatt.getService(UUID_SIMBLEE_SERVICE).getCharacteristic(UUID_SIMBLEE_CHARACTERISTIC_2) ; // eleven bytes sent for newValue // "00 0001" includes '00' for a start byte, and '0001' for the mode control for the Z8 time setter interrupt. // '0001' is for time setter mode // The first "00" is disregarded by the Simblee newValue = "00 0001" + h_nibble_h + h_nibble_l + m_nibble_h + m_nibble_l + s_nibble_h + s_nibble_l + ap_nibble_h + ap_nibble_l + byte_5_h + byte_5_l + byte_6_h + byte_6_l + byte_7_h + byte_7_l + byte_8_h + byte_8_l + byte_9_h + byte_9_l + byte_10_h + byte_10_l + byte_11_h + byte_11_l ; byte[] dataToWrite = parseHexStringToBytes(newValue) ; mBleWrapper.writeDataToCharacteristic(mCharacteristic, dataToWrite ) ;

  • Sorry, the above looks really ugly. Anyway, there is nothing specifically Nordic about the above, the important stuff is standard code from the Bluetooth Application Accelerator. The above works perfectly with the Simblee chip which uses the ARM Cortex M0 processor.

  • We will always have a fixed known length of data sent via BLE from the phone. Am I correct in assuming that in the routine nus_data_handler , the array p_data can be read at the routine on_ble_evt in the second case statement assuming that it is called when the packet of BLE data has been received in it's entirety?

  • Hi, Brian.

    • I can use a higher version if you think it will be better. Hmm, Nordic devteam says that Do not judge the quality of SDK based on number of entries here. For instance, check this page and hope this helps for choosing the SDK.

    • Java code. I have no experience with Android app projects. How about checking Nordic's GitHub page? I think this will help you.

    • the array p_data can be read at the routine on_ble_evt in the second case statement assuming that I haven't understood your last question;

    are you trying to check the p_data array before the program counter points nus_data_handler?

    -Regards, MANGO

Related