0

Bluefruit nRF52 dual_bleuart - Identifying data source
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Bluefruit nRF52 dual_bleuart - Identifying data source

by twonius on Sat Sep 18, 2021 1:50 am

I've got the dual_bleuart example working but i'm not able to differentiate which bytes are coming from which device.

Looking at the rx callback and the BLEClientUART wrapper I don't see how this information is available.

Code: Select all | TOGGLE FULL SIZE
void cent_bleuart_rx_callback(BLEClientUart& cent_uart)
{
  char str[20+1] = { 0 };
  cent_uart.read(str, 20);
   
  Serial.print("[Cent] RX: ");
  Serial.println(str);

  if ( bleuart.notifyEnabled() )
  {
    // Forward data from our peripheral to Mobile
    bleuart.print( str );
  }else
  {
    // response with no prph message
    clientUart.println("[Cent] Peripheral role not connected");
  } 
}


I'm also only seeing output from one of the devices however if I only connect to one at a time I will see data for either (they're both flashed with the same code)
22:46:58.968 -> [Cent] RX: 246622
22:46:58.968 -> [Cent] RX:

twonius
 
Posts: 9
Joined: Wed May 29, 2013 3:36 pm

Re: Bluefruit nRF52 dual_bleuart - Identifying data source

by mikeysklar on Sat Sep 18, 2021 4:21 pm

@twonius,

Would it make sense to modify the code between the two nodes to be slightly different as to identify them self with each RX string?

eg.

Code: Select all | TOGGLE FULL SIZE
Serial.print("[Cent] RX NODE1: ");


Code: Select all | TOGGLE FULL SIZE
Serial.print("[Cent] RX NODE2: ");

mikeysklar
 
Posts: 5844
Joined: Mon Aug 01, 2016 8:10 pm

Re: Bluefruit nRF52 dual_bleuart - Identifying data source

by twonius on Sat Sep 18, 2021 10:37 pm

wouldn't i need a different rx callback for each node?

Also it'd be unlikely that the peripherals would connect in the same order, so each time you'd have a different device using a different callback.

I really need to be able to do something like pull the UUID for the device so i can append it to the readings

I wonder if this just wouldn't be an issue if i would use one of the normal profiles instead of UART e.g. weight scale

twonius
 
Posts: 9
Joined: Wed May 29, 2013 3:36 pm

Re: Bluefruit nRF52 dual_bleuart - Identifying data source

by mikeysklar on Sun Sep 19, 2021 1:15 pm

@twonius,

Maybe something like this scanner chunk of code would help to determine the UUID of each of your peripherals.

Code: Select all | TOGGLE FULL SIZE
if ( Bluefruit.Scanner.checkReportForUuid(report, CUSTOM_SERVICE) )
  {
    Serial.printf("%14s %s\n", "CUSTOM_SERVICE", "UUID Found!");
  }


viewtopic.php?f=57&t=144086&p=711347&hilit=bleuart.uuid#p711347

mikeysklar
 
Posts: 5844
Joined: Mon Aug 01, 2016 8:10 pm

Re: Bluefruit nRF52 dual_bleuart - Identifying data source

by twonius on Sun Sep 26, 2021 1:23 am

Thanks

Looking at other examples the central_bleuart_multi example gets pretty close to what I want.
Honestly i could probably make this work and just flash my devices with individual names but it'd be nice to be able to use their UUIDs instead.

I just need to find out where this struct is defined so i can see which field is the UUID.

Code: Select all | TOGGLE FULL SIZE
void bleuart_rx_callback(BLEClientUart& uart_svc)
{
  // uart_svc is prphs[conn_handle].bleuart
  uint16_t conn_handle = uart_svc.connHandle();

  int id = findConnHandle(conn_handle);
  prph_info_t* peer = &prphs[id];
 
  // Print sender's name
  Serial.printf("[From %s]: ", peer->name);

  // Read then forward to all peripherals
  while ( uart_svc.available() )
  {
    // default MTU with an extra byte for string terminator
    char buf[20+1] = { 0 };
   
    if ( uart_svc.read(buf,sizeof(buf)-1) )
    {
      Serial.println(buf);
      sendAll(buf);
    }
  }
}

twonius
 
Posts: 9
Joined: Wed May 29, 2013 3:36 pm

Re: Bluefruit nRF52 dual_bleuart - Identifying data source

by mikeysklar on Mon Sep 27, 2021 12:14 pm

You must have found this by now, but just to confirm.

Code: Select all | TOGGLE FULL SIZE
// Struct containing peripheral info
typedef struct
{
  char name[16+1];

  uint16_t conn_handle;

  // Each prph need its own bleuart client service
  BLEClientUart bleuart;
} prph_info_t;


prph_info_t is defined at the top of central_bleuart_multi.ino that you had been using.

mikeysklar
 
Posts: 5844
Joined: Mon Aug 01, 2016 8:10 pm

Re: Bluefruit nRF52 dual_bleuart - Identifying data source

by twonius on Sat Oct 02, 2021 2:43 pm

that groaning sound was not a disturbance in the force.

Thanks

twonius
 
Posts: 9
Joined: Wed May 29, 2013 3:36 pm

Please be positive and constructive with your questions and comments.