AnsweredAssumed Answered

Unable to Read BT packets

Question asked by vinoth penati on Oct 3, 2016
Latest reply on Oct 3, 2016 by igorpadykov

Hi all,

 

   I am working on marshmallow BSP[6.0.1.2.1.0] in IMX6sl evk board. While trying to bring up the bluetooth, I am unable to read the bt driver packet continuously, I am able to send the command from android and response is coming up to my driver but android bt is unable to read the response packet. I found this at eager_reader.c file's following function

static void inbound_data_waiting(void *context) {
  eager_reader_t *reader = (eager_reader_t *)context;
 
  data_buffer_t *buffer = (data_buffer_t *)reader->allocator->alloc(reader->buffer_size + sizeof(data_buffer_t));
  if (!buffer) {
    LOG_ERROR("%s couldn't aquire memory for inbound data buffer.", __func__);
    return;
  }

 

  buffer->length = 0;
  buffer->offset = 0;

 

  int bytes_read = read(reader->inbound_fd, buffer->data, reader->buffer_size);
  if (bytes_read > 0) {
    // Save the data for later
    buffer->length = bytes_read;
    fixed_queue_enqueue(reader->buffers, buffer);

 

    // Tell consumers data is available by incrementing
    // the semaphore by the number of bytes we just read
    eventfd_write(reader->bytes_available_fd, bytes_read);
  } else {
    if (bytes_read == 0)
      LOG_WARN("%s fd said bytes existed, but none were found.", __func__);
    else
      LOG_WARN("%s unable to read from file descriptor: %s", __func__, strerror(errno));

    reader->allocator->free(buffer);
    break;
  }
}

 

Then I put while(1) to read the packets continuously. Packet reading is happening on.

 

static void inbound_data_waiting(void *context) {
  eager_reader_t *reader = (eager_reader_t *)context;
  while(1){        /* -------------> created by myself */
  data_buffer_t *buffer = (data_buffer_t *)reader->allocator->alloc(reader->buffer_size + sizeof(data_buffer_t));
  if (!buffer) {
    LOG_ERROR("%s couldn't aquire memory for inbound data buffer.", __func__);
    return;
  }

 

  buffer->length = 0;
  buffer->offset = 0;

 

  int bytes_read = read(reader->inbound_fd, buffer->data, reader->buffer_size);
  if (bytes_read > 0) {
    // Save the data for later
    buffer->length = bytes_read;
    fixed_queue_enqueue(reader->buffers, buffer);

 

    // Tell consumers data is available by incrementing
    // the semaphore by the number of bytes we just read
    eventfd_write(reader->bytes_available_fd, bytes_read);
  } else {
    if (bytes_read == 0)
      LOG_WARN("%s fd said bytes existed, but none were found.", __func__);
    else
      LOG_WARN("%s unable to read from file descriptor: %s", __func__, strerror(errno));

 

    reader->allocator->free(buffer);
    break;
  }
 }            /* --------------> created by myself */
}

 

But While trying to enable the BT form GUI it is not enabled, after three iteration of same procedure, it is turned on in GUI and able to see the list available bt devices. But unable to pair with other device, while other devices trying to pair with my evb, I got assertion assert(ble_supported) while trying to pair with evb, and GUI disable is not happening on properly. I think by default Marshmallow enables the BLE on state machine.

 

Please tell me that how to switch it to BT instead of turning on BLE and avoidance of multiple iteration of GUI turn on and turn off.

 

Thanks,

Vinoth P B

Outcomes