cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Bluetooth communication through ST25DV64KC-DISCO NFC module

PoolBear
Associate III

Hey, for Bluetooth connection through the NFC tag I have given my Bluetooth mac address in the firmware code of the board, and now when I read the board through NFC-enabled mobile, it is pairing with my mobile, whose mac address is given into the firmware board, but it is not getting connected automatically. Can anyone help with this problem and give me a solution? I am also sharing a screen snippet of my firmware code.

Ndef_Bluetooth_OOB_t BleOOB = {.Type = NDEF_BLUETOOTH_BREDR,//standard bluetooth
                                    .DeviceAddress = NDEF_DEMO_BLE_ADDR_BIG_ENDIAN,//ble 
                                                       mac address is given here 
                                    .DeviceAddressType = NDEF_BLE_PUBLIC_ADDRESS_TYPE,
                                    .Role = NDEF_BLE_ROLE_CENTRAL_ONLY ,
                                    .OptionalMask = 
                     NDEF_BLUETOOTH_OPTION(BLUETOOTH_EIR_COMPLETE_LOCAL_NAME),
                                    .LocalName = NDEF_DEMO_BLE_NAME,                                
                                    };

void NDEF_DEMO_Read_Bluetooth_OOB(void)
{
  uint16_t status;
	sRecordInfo_t record;
  Ndef_Bluetooth_OOB_t bluetooth_oob;

  NDEF_DEMO_Init_Tag();

  status = getNDEFRecord(&record);
	if(status != NDEF_OK)
  {
		Menu_MsgStatus("Read OOB failure!","Cannot get the record!",MSG_STATUS_ERROR);
    return;
  }
  
  status = NDEF_ReadBluetoothOOB(&record,&bluetooth_oob);
  if(status != NDEF_OK)
  {
    Menu_MsgStatus("Read OOB failure!","OOB has not been read!",MSG_STATUS_ERROR);
	}
  else
  {
    /* 50 bytes for headers + data */////////////////////
    char *msg = (char *)malloc(50 +
                        sizeof(bluetooth_oob.DeviceAddress) +
                        strlen(bluetooth_oob.LocalName));
    if(msg == NULL)
    {
      Menu_MsgStatus("Memory error!","Cannot allocate memory",MSG_STATUS_ERROR);
      return;
    }
    
    strcpy(msg,"Type: ");
    if(bluetooth_oob.Type == NDEF_BLUETOOTH_BREDR)
    {
      strcat(msg,"BR/EDR\n\n");
    }
    else if (bluetooth_oob.Type == NDEF_BLUETOOTH_BLE)
    {
      strcat(msg,"BLE\n\n");
    }      
    strcat(msg,"DeviceAddress:\n");
    
    char device_address[18];
    sprintf(device_address, "%02X:%02X:%02X:%02X:%02X:%02X",bluetooth_oob.DeviceAddress[0],
                                                bluetooth_oob.DeviceAddress[1],
                                                bluetooth_oob.DeviceAddress[2],
                                                bluetooth_oob.DeviceAddress[3],
                                                bluetooth_oob.DeviceAddress[4],
                                                bluetooth_oob.DeviceAddress[5]);
    
    strcat(msg,device_address);
    strcat(msg,"\n\nLocal name:\n");    
    strcat(msg,bluetooth_oob.LocalName);
 		Menu_MsgStatus("OOB content",msg,MSG_STATUS_SUCCESS);

    free (msg);
  
  }  
}
1 ACCEPTED SOLUTION

Accepted Solutions
Rene Lenerve
ST Employee

Hi @PoolBear,

I think I was able to reproduce your issue with the device address buffer not set in the correct order.

Can you do a test by inverting data in the device address buffer to see if that fixes it.

Kind Regards.

View solution in original post

1 REPLY 1
Rene Lenerve
ST Employee

Hi @PoolBear,

I think I was able to reproduce your issue with the device address buffer not set in the correct order.

Can you do a test by inverting data in the device address buffer to see if that fixes it.

Kind Regards.