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

Sending commands to nRF52840 via React Native mobile application

Hi, I've been tasked with sending commands to an nRF52840 Board via a React Native mobile application I've developed, but have no idea how to do so. Our company uses:

  • SEGGER Embedded Studio
  • nRF5 SDK v15.2.0
  • nRF5 SDK for Mesh v 3.0.0
  • S140 and S132 SoftDevices
  • nRF52840 DK
  • nRF52832DK
  • nRF52840 Dongle

I'm developing the React Native application on a Windows 10 machine, and I've installed two different libraries for implementing BLE communication:

  • react-native-ble-manager
  • react-native-ble-plx

I've used both to scan and connect to an nRF52840 device. However once connected, I'm not sure how I can send commands to the board. Additionally, the only time the board shows up on a scan is when I've downloaded an example program to it via SEGGER studio. I'm wondering, is there a generic program I can load onto the board that accepts commands, without security or the need to create a bond or any of the extras. I just want to create a connectable device that receives commands and sends back status information, and I'd like to send commands via one of the BLE communication libraries listed above (react-native-ble-plx or react-native-ble-manager).

Both of these React Native libraries have write functions that take the device ID (typically MAC address), service UUID, and characteristic UUID. I've tried using these libraries to discover the service UUIDs available and the characteristic UUIDs available, and then use those in a write function to attempt writing to the device, but these fail, as the device is loaded with example code from the SDK. I'm pretty sure I can't just send code to, say, a board loaded with the light switch example from the SDK, however the device doesn't even show up in a scan without having example code loaded onto the board... I would greatly appreciate if someone could explain to me how to get a board that is connectable and writeable as described above.

Parents
  • Hi Morrison,

    Please clarify which firmware you run on the nRF5 devices ? 

    When you mentioned "unsuccessfully on the Dongle" what happened ? How did you prepare and program the dongle, which dongle ? 

    My understanding is that you want to connect to a nRF5 from the phone and send some data/commands to the nRF5 ? 

    If you are new to the app development, I would strongly suggest you to get started with the examples in the nRF5 SDK first before you try with the mesh SDK proxy example. 

  • Yes I'm very new to Embedded Development. I've tested the examples in the nRF5 SDK, but creating my own examples is another matter. I guess my question is, how do I create custom services and characteristics, which I found a tutorial on yesterday. 

    When I successfully wrote to the boards, the process was as follows:

    1. Plug nRF52840 or nRF52832 or nRF52840 Dongle into my PC via USB.

    2. Open nRF Connect BLE App. Select the connected board from the dropdown. I'm presented with a prompt saying "Device must be programmed. Do you want to proceed?". I assume this loads some type of firmware onto the board? Not sure which firmware though.

    3. Click on Server Setup in the top navigation bar, then add a new Service with custom 16 bit UUID and a characteristic with custom 16 bit UUID. Click Apply to Device.

    4. Click on the COG icon next to the device in nRF Connect and then click Start Advertising. Once the device is advertising, I'm able to scan for it via my React Native app and write to that custom service and characteristic via react-native-ble-manager write() function, which takes the device ID, service UUID, characteristic UUID and the data.

    When I tried these steps with the Dongle, I would complete steps 1-3, but then when I advertise from the Dongle it doesn't show up in scans. The other two boards do. 

    Also, I'm not sure where you got Mesh SDK proxy example from, as I haven't mentioned that here.

    In any case, I've run through the tutorial on  https://devzone.nordicsemi.com/tutorials/b/bluetooth-low-energy/posts/ble-services-a-beginners-tutorial and successfully created a custom service but that is for SDK v15.0.0, while we're on the latest SDK version (15.2.0). I attempted to run the same tutorial with v15.2.0 but it seems entire directories have been renamed from v15.0.0 to v15.2.0 and I'm not sure of all the locations those directories are referenced. I would get a file or directory doesnt exist error, which referenced header files found in SDK_Root/components/libraries/experimental_log. This directory seems to have been renamed in v15.2.0, but I'm not sure where in the ble app template these files are referenced in order to run the same tutorial on v15.2.0.

Reply
  • Yes I'm very new to Embedded Development. I've tested the examples in the nRF5 SDK, but creating my own examples is another matter. I guess my question is, how do I create custom services and characteristics, which I found a tutorial on yesterday. 

    When I successfully wrote to the boards, the process was as follows:

    1. Plug nRF52840 or nRF52832 or nRF52840 Dongle into my PC via USB.

    2. Open nRF Connect BLE App. Select the connected board from the dropdown. I'm presented with a prompt saying "Device must be programmed. Do you want to proceed?". I assume this loads some type of firmware onto the board? Not sure which firmware though.

    3. Click on Server Setup in the top navigation bar, then add a new Service with custom 16 bit UUID and a characteristic with custom 16 bit UUID. Click Apply to Device.

    4. Click on the COG icon next to the device in nRF Connect and then click Start Advertising. Once the device is advertising, I'm able to scan for it via my React Native app and write to that custom service and characteristic via react-native-ble-manager write() function, which takes the device ID, service UUID, characteristic UUID and the data.

    When I tried these steps with the Dongle, I would complete steps 1-3, but then when I advertise from the Dongle it doesn't show up in scans. The other two boards do. 

    Also, I'm not sure where you got Mesh SDK proxy example from, as I haven't mentioned that here.

    In any case, I've run through the tutorial on  https://devzone.nordicsemi.com/tutorials/b/bluetooth-low-energy/posts/ble-services-a-beginners-tutorial and successfully created a custom service but that is for SDK v15.0.0, while we're on the latest SDK version (15.2.0). I attempted to run the same tutorial with v15.2.0 but it seems entire directories have been renamed from v15.0.0 to v15.2.0 and I'm not sure of all the locations those directories are referenced. I would get a file or directory doesnt exist error, which referenced header files found in SDK_Root/components/libraries/experimental_log. This directory seems to have been renamed in v15.2.0, but I'm not sure where in the ble app template these files are referenced in order to run the same tutorial on v15.2.0.

Children
No Data
Related