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. 

  • Update: I've created a custom service and characteristic for the nRF52840 board with S140. The program compiles and I'm able to download the program to my nRF52840 board. When I download the program to my board, it begins advertising as indicated by LED1 blinking. I'm also able to scan and see the device in the list of discovered devices, with my custom name and 128 bit Vendor Specific UUID.

    The problem is, when I try to connect to it, it disconnects everytime, and I get the following error:

    Any help is greatly appreciated, it seems I am very close to where I need to be I just cannot for the life of me figure out why this is happening. Will gladly share my custom service's .c and .h files, as well as my main.c

  • Hi Morrison,

    Could you try again with the nRFConnect app on the phone ? 

    Which firmware did you base on to add your vendor specific services ? I would suggest you to test with the ble_app_uart example in our SDK. 

Reply Children
Related