nkolban / esp32-snippets

Sample ESP32 snippets and code fragments
https://leanpub.com/kolban-ESP32
Apache License 2.0
2.37k stars 710 forks source link

Cant use GPIO, BLE HID doesnt work. #1143

Open JuanJoseMoralesCalvo opened 2 years ago

JuanJoseMoralesCalvo commented 2 years ago

As simple as that, when i simulate it works good, but when i declare a pinMode and read it, the HID service doesnt work.

Thanks in advance.

JuanJoseMoralesCalvo commented 2 years ago

@chegewara I know that im just answering myself but if anyone need this i made the workaround like this:

void onConnect(BLEServer* BLEservidor){
            // Respuesta a error de post-emparejamiento ble
            if(digitalRead(17) == 1) //NOT PAIR GPIO17 SHOULD BE 0; PAIR GPIO17 SHOULD BE 1;
            {
            BLEDescriptor *hid_desc = REPORT->getDescriptorByUUID(BLEUUID((uint16_t)0x2902));
            uint8_t val[] = {0x01, 0x00};
            hid_desc->setValue(val, 2);
            }                
            device_connected = true;
}

Establishing a NO PAIR MODE (when pin17 == 0) and a PAIR MODE(when pin17==1). I dont have debug evidence but it seems in my case that when the device its NOT PAIR, the first time it connects doesnt recieve the HID Service well with the previous workaround. It will work perfectly when its already PAIR.