BLE disconnection during pairing MIC FAILURE error

Issue causing Device: Arduino 33 BLE sense

Hi, am just trying to make a sample project to connect to a device with few services, doesn’t matter the sketch I use, am always getting disconnected after connection but while pairing & disconnection reason is 0x3D. Not sure if it’s library issue as am using MBed_BLE_HID 1.2.0 as mentioned in the website.
Any help is much appreciated.

Update:
Security manager initialisation tested with no parameter, with bonding and MITM false etc same issue always.
Pairing result is 0x88 & disconnection reason 0x3D

Same error with Nano 33 BLE as well.

Have You Googled "Disconnect 0x3d" ?

Post the best code You have used.

Thanks!!!

Have attached the sketch here, it’s not allowing me to attache the trace of the error code (more that 1 image)

Yeah I did, couldn’t find much on google. Had to dive in the api code to figure it out, it turned out to be HCI MIC Failure error.

The DisconnectionCompleteEvent (of gap handler onDisconnectionComplete


uses the disconnection_reason_t to carry the code & it doesn’t define that code as part of its definition, finally HCI error traced it to MIC error code.
It’s defined in GapTypes.h as CONNECTION_TERMINATED_DUE_TO_MIC_FAILURE=0x3D

Your code is beyond my comfort zone so no helping details from me.
One possible cause for error can be powering. Please post a wiring, not any children Fritzing.. Pen and paper often does the job.
A tip for the future: Read the first topics telling how use this forum, how to post code.
Autoformat the code in the ide, mark and select it, click on the code tag symbol </> and paste.

I have just directly connected the board (Arduino Nano 33 BLE Sense) to PC & uploaded the code. Not much of circuit here, have pasted the code as well, just in case if useful.

#include <Nano33BleHID.h>
#include <Serial.h>

const int buttonPin = 4;          // input pin for pushbutton
int previousButtonState = HIGH;   // for checking the state of a pushButton
int counter = 0;  // button push counter

Nano33BleKeyboard keyboard("Wonderboard");


void setup() {

 keyboard.initialize();
 Serial.begin(9600);
 MbedBleHID_RunEventThread();
}


void loop()
{
  
  if(keyboard.connected())
  {
    auto *hid = keyboard.hid();
    hid->sendCharacter('A');
    //Serial.println("Sending A");
  }
}