-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reading of a descriptor of HID Service #3
Comments
Thanks a lot Chegewara! :) |
Hi Chegewara, Backtrace: 0x400d409a:0x3ffcdef0 0x400d1a60:0x3ffcdf50 0x400d33e9:0x3ffcdf70 0x400d3eb9:0x3ffce020 0x401053d5:0x3ffce070 0x400fe176:0x3ffce0c0 0x4008e089:0x3ffce0f0 Rebooting..._ " I've managed to interpret the codes through exception decoder: Decoding stack results Thanks a lot, |
Im guessing you are trying to read descriptor that does not exist or you didnt get service and or characteristic before reading descriptor. |
Thanks a lot that was the issue. :) |
Hello again, Sorry to keep hassling you. I am trying to read a descriptor - attached file but it seems the program does not return anything after I use get descriptor command- I have inserted a debug line [Serial.println(" - the descriptor value is: "); - [Line 214] It seems the program gets to that point, finds the charachteristic but nothing after this line get executed. Thanks a lot, |
Have to find out why it doesn't attach either C++ or text files.. sorry |
[sorry had to paste the code here as it didn't accept it as an attachment.] /**
*/ #include <Arduino.h> #include "BLEDevice.h" //#include "BLEScan.h" #include "HIDKeys.h" // The remote service we wish to connect to. static BLEUUID serviceUUID((uint16_t) 0x1812); // The characteristic of the remote service we are interested in. static BLEUUID charUUID((uint16_t) 0x2a22); static bool doConnect = false; static bool connected = false; static bool doScan = false; static BLERemoteCharacteristic* pRemoteCharacteristic; static BLEAdvertisedDevice* myDevice; static void notifyCallback( BLERemoteCharacteristic* pBLERemoteCharacteristic, uint8_t* pData, size_t length, bool isNotify) { #ifdef DEBUG
#endif
} class MyClientCallback : public BLEClientCallbacks { void onConnect(BLEClient* pclient) {
} void onDisconnect(BLEClient* pclient) {
} }; bool connectToServer() {
//pRemoteCharacteristic->registerForNotify(notifyCallback); // Serial.println(" - the descriptor value is: "); Serial.println(pRemoteDescriptor->readValue().c_str());
} /**
*/ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks { /**
*/ void onResult(BLEAdvertisedDevice advertisedDevice) {
// Test to find out if the the descriptor of the device is the same as the target descriptor } // onResult }; // MyAdvertisedDeviceCallbacks void setup() { Serial.begin(115200); Serial.println("Starting Arduino BLE Client application..."); BLEDevice::init(""); // Retrieve a Scanner and set the callback we want to use to be informed when we // have detected a new device. Specify that we want active scanning and start the // scan to run for 5 seconds. BLEScan* pBLEScan = BLEDevice::getScan(); pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); pBLEScan->setInterval(1349); pBLEScan->setWindow(449); pBLEScan->setActiveScan(true); pBLEScan->start(5, false); } // End of setup. // This is the Arduino main loop function. void loop() { // If the flag "doConnect" is true then we have scanned for and found the desired // BLE Server with which we wish to connect. Now we connect to it. Once we are // connected we set the connected flag to be true. if (doConnect == true) {
} // If we are connected to a peer BLE Server, update the characteristic each time we are reached // with the current time since boot. if (connected) {
}else if(doScan){
} delay(1000); // Delay a second between loops. } // End of loop |
The problem may be in BLE library or my code you are trying to use, because HID device can have multiple characteristics with the same UUID. What you need to do is more debugging and understand HID device you want to connect with. |
Hello again, I still cannot get any value back from the characteristics of an HID service. Could you please look into this for me? I even tried to read the HID information (0x2a4a) with no luck- I have to set the protocol mode (0x2a4e) to zero in order to tell the device that I want to use the boot host. Then I have to connect to boot keyboard input report characteristic (0x2a22) in order to set client descriptor 2902 and subscribe to notification. But seems like I cannot even read-back the protocol mode not even the HID information back form the device. I know these characteristic work as I have checked the same device with nRFConnect and they all work fine. Any help will be really appreciated. Many thanks,/**
#include <Arduino.h> // The remote service we wish to connect to. static bool doConnect = false; const uint8_t NotificationOn[]={0x2,0x0}; static BLERemoteCharacteristic* pRemoteCharacteristic_inptrt; // Call back from the boot keyboard input report notification
#ifdef DEBUG // Client is connected or not void onDisconnect(BLEClient* pclient) { // Connect to the server and create the client; Main function. // pRemoteCharachterstic_ptr->writeValue(0);
/* do {*/
delay(200);
// } while(1);*/
//set the descriptor //BLERemoteDescriptor *pRemoteDescriptor = pRemoteCharacteristic_inptrt->getDescriptor(desUUID);
}
void setup() { // Retrieve a Scanner and set the callback we want to use to be informed when we // This is the Arduino main loop function. // If the flag "doConnect" is true then we have scanned for and found the desired
} // If we are connected to a peer BLE Server, update the characteristic each time we are reached delay(1000); // Delay a second between loops. |
Thats strange it works fine with nRF connect, because some time ago android changed usage of HID and is the same as on iOS, you shouldnt be able to read HID characteristics. Only non-HID can be read now. |
Yes, it works fine nRF connect and I also can read Battery Level in Battery Service. Do you know what is the reason I cannot set/read HID characteristics/descriptors? Cheers |
Maybe issue with pairing/bonding? |
Funny enough, it founds the HID server and the characteristics, I just cannot write/read to/from the charachtersitics and descriptors. |
This is how BLE works according to specs. |
Let's say my device is protected against read and write, any clue how can I remove the protection? Thank you. |
esp32 device or other device? |
I am trying to implement a host/client in ESP32, my HID device is a barcode scanner. |
As far as i remember protection only works when you also use security, which is pairing with pass key. |
Well, interestingly the Bluetooth scanner does not require a pass key when I connect it to the operation system. However as I cannot read back the characteristics I set, I thought it might be to do with the security? |
Hi, I really hope you can help me as I am stuck in this for a couple of months now; I am not a software developer so please bear with me as I am risking my job on this. I’ve tried to replicate above procedure on the client code supplied here. |
you can test it, you can always try to read descriptor Try nRF connect without changing boot mode, and see if you receive any notifications and when, what you have to do to receive notifications etc HID protocol is not easy, and trying to work with it not being programmer is almost not possible. There is too many info, device types, each product can use its own HID semantic to proceed with HID data. |
Thanks a lot for your support, I try to read back the descriptor if I can. Btw do you recommend using BTStack from Bluekitchen? |
I dont know this library, but i know that author is much better bluetooth expert than i am. If you know C, then its worth to try. |
Hi mkardan, I wish made the same, connect a Bluetooth Scanner to ESP32, and read some data to send to ESP32. Do you have some advance about it? Regards |
Hi there,
I just wondering of there is an example of reading the descriptor of a service that I can take a look on?
Cheers,
FakeStar
The text was updated successfully, but these errors were encountered: