Code Monkey home page Code Monkey logo

winble's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

winble's Issues

BleDevice::enumerateBleServices() inconsistent.

Derek,

I had noticed this before but I had my hands so full of other problems in my code so I just figured a way past it and didn't let it sidetrack me at the time. Now that I have my code fixed and running, I see this unusual behavior and now it is stopping me.

[Edited]
Periodically, BleDevice::enumerateBleServices() -> BleDevice::getGattServices() will error at at the line

	if (HRESULT_FROM_WIN32(ERROR_MORE_DATA) != hr)
{
	stringstream msg;
	msg << "Unable to determine the number of gatt services. Reason: ["
		<< Utility::getLastErrorString(hr) << "]";

	throw BleException(msg.str());
}

[Edited]
The hr returned error will be ERROR_NOT_FOUND 1168 (0x490) Element not found.

The stopgap measure that I have been using while working on other problems was to connect to my device with MS Bluetooth LE Explorer and then disconnect. Now, when I run my (your) program the services are found and I could proceed.

Any ideas? At the time I couldn't debug it because my Visual Studio 2017 debugger would not let me go beyond "my code". Again, I didn't stop to find out why but now I see that in the WinBleLib Project->Properties->C/C++->General->Support Just My Code Debgging was set to Yes (/JMC). I just turned that off but I had also just run MS BT LE Explorer so I currently don't have the problem happening to try and debug.

I'll let you know next time it happens and if I find anything. In the meantime, if you can think of why BT Explorer clears up the problem, let me know. Also, for the repo, it would be good for future users to have that Support Just My Code Debgging property changed to No

[Added] I notice that ERROR_NOT_FOUND is not mentioned in the doc for BluetoothGATTGetServices function. I see it is a Window System error. Can you think of what might cause this? As I said, if I start MS BT LE Explorer and connect to the BLE device and then quit and then start my program, this error goes away? Any ideas?

Can't find any Bluetooth devices

I can find a lot of Bluetooth device through SmartSensor Manager APP. But can't find any Bluetooth device with WinBleTest.exe.

Example BLE UART using WinBLE

I think this library is what I want - communicate with a BLE UART on Windows 10 from a win32 app. I can't quite figure out how notifications (of data to read) work. Do you have any examples?

BluetoothGATTGetCharacteristicValue returning E_INVALIDARG on first pass to get value data size

When trying to get the value of a Characteristic, I'm getting an E_INVALIDARG result from the call to the function BluetoothGATTGetCharacteristicValue in BleGattCharacteristic::getValue(). I believe this first call is designed to get the return value character size before calling it again to get the actual value.

This line of code in getValue() is returning the E_INVALIDARG:
HRESULT hr = BluetoothGATTGetCharacteristicValue( hBleService.get(), _pGattCharacteristic, 0, nullptr, &charValueDataSize, BLUETOOTH_GATT_FLAG_NONE);

I noticed that you (or someone with the same name) noted something similar on stackoverflow (https://stackoverflow.com/questions/46451135/bluetoothgattsetcharacteristicvalue-returns-e-invalidarg-or-error-invalid-functi).

Did you manage to find out why this is occurring?

Platform Toolset v142

I am using Visual Studio 2017 v141 on Windows 10. The first problem that I ran into was that the compiler complained that v142 was no available. I went to Project Properties and changed the Toolset to v141 and it compiled, When I go to run I get the error that the WinBleLib.lib is not a proper Win32 application.

From what I know v142 is from Visual Studio 2019 but in opening the project file in text mode I see
<Project DefaultTargets="Build" ToolsVersion="15.0"..... and the 15.0 would indicate VS 2017.

The question is, then, what did you create the project file with? VS 2017 or 2019? And if it was VS2017, how is it you are using the v142 Toolset?

Ed

Most setValues work but not all...

I have a situation which is driving me batty that I am hoping, when I describe it, the situation may ring a bell as to what may be causing it.

I have your WinBle select a BLE device I am working with that takes Writes in the form of "AT+CMODE=7\n" for instance to set CMODE to 7. And writing the value "AT+CMODE?\n" is the query that tells the device to reply with the current value.
The IsShotUuid is true if that has any bearing on the matter. The FFF0 is the main Service and under that, the FFF5 is the Write_To characteristic and FFF4 is the IsNotifiable to recieve the replies from the device on callback.

There are several "commands" to do things like Pause, PowerOn, PowerOff, and the Queries. There are three "commands" to set actual values. One is a clock timer, one is the Mode the device is supposed to run in, and the third is the electrical Strength that the device is supposed to output.

I can send the command to turn PowerOff and the device will turn off. I can send the query of what the clock timer is currently at and will receive the reply that is correct. I can then send the command to reset the clock to say 45 minutes and then query again and I will see 00:44:59 so that shows that everything is working as far as sending a command to set a value and getting the reply back from the device.

Here is the very odd thing. If I send the command to set the CMODE to 7, for instance, and then do a query the value is still 1. If I send the command to set the Strength to 7 and do a query the value is still 1.

I can use the same command syntax in MS Bluetooth LE Explorer or BluetoothFramework test app and the write will take place. I can see for myself by putting a query before doing any setting values. I will query the CMODE and it will say 7 which was the value set by one of the other programs. I will then set the value to 4 and do another query and it will return 7 showing that my write never had any effect.

So basically everything works except that I cannot write values for these two "commands".

I mentioned before that to get anything to write I had to change the flag in your setValue() function from BLUETOOTH_GATT_FLAG_NONE to BLUETOOTH_GATT_FLAG_WRITE_WITHOUT_RESPONSE and that worked. (for everything but these 2 commands)

I experimented with the BLUETOOTH_GATT_FLAG_WRITE_WITHOUT_RESPONSE | BLUETOOTH_GATT_FLAG_SIGNED_WRITE) flag and that did not change anything.

I then did a ReliableWrite using the ReliableWriteContext instead of the NULL that you had and that did not change anything.

Can you think of anything, anything at all, a flag somewhere or something, that would explain why I can't write these 2 values while BluetoothFramework and Bluetooth LE Explorer can?

I'm just hoping for any suggestions that I might try.

Ed

missing cpoy

here a line like
memcpy(p, pEvent->CharacteristicValue->Data, pEvent->CharacteristicValue->DataSize);
is missing, the allocated memory is uninitialized.
The received data in
callbackContext->getNotificationHandler()(*notification);
was junk.

or rather, malloc and copy should be in the
BleGattNotificationData::BleGattNotificationData(ULONG dataSize, PBYTE bytes)
constructor, since freeing is already done in the destructor

Unable to compile using VS 2022

Hi,
I'm able to partialy compile the project using VS2022 Community: subproject WinBleLib compiles fine, but WinBleTest gives me error C2280. The project fork David-Sackstein/WinBle compiles correctly. The issue seems related to the adoption of <unique_ptr>.
Do you have some suggestion or hint about ?
Thx in advance

HandleCallback not fireing.

In your WinBleTest.cpp I changed the Service and Characteristics to those for the device that I am testing.

In the main.cpp I can enumerate all of the services and all of the characteristics.
In the testSerialService I can setValue for a Tx characteristic in the service that is writeable.

However, when it gets to the part in testSerialService I never get any descriptors. I get a descriptors.size() of 2 so I go into that if (descriptors.size() > 0) block but nothing ever is reported. In fact, the HandleCallback never fires.

Do you still get the HandleCallback for your device? or did something change between VS2017 and VS2019 etc?

Edit Addition:

I started from scratch and opened and compiled in VS2017 with the v141 Toolset and SDK 10.0.18362.0. I changed the UUIDs to those for my device and ran. Again, the HandleCallback never fired.

In case this explains anything since I don't have the data for your device, my main service is FFF0 in which the FFF4 characteristic is for returns (Rx) and only has the IsNotifialbe set to true. The FFF5 is the characteristic for sending commands (Tx) and only has the IsReadable and IsWrteable set to true. If you getValue for this Tx service it will only return the last command sent via setValue.

So, because my Tx does not have an IsNotifiable, I get a txit and a rxit and get a chacteristicTx for the UUID_FFF5Tx_CHARACTERISTIC and a chacteristicRx for the UUID_FFF4Rx_CHARACTERISTIC. I send the command to turn the power on to the characteristicTx. I cannot enumerateBleDescriptors for the Tx since it is not IsNotifiable so, from that point on I use the characteristicRx since it is the receiving characteristic. Everything else remains the same as your testSerialService. I get no errors it is just that HandleCallback never fires and no descriptors are every listed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.