title: Bluetooth Low Energy with native code on Windows 10
body: <p>I have a native win32 application targeting Window 7 and on. Recently, I was required to add Bluetooth Low Energy support, but only for Windows 10.</p>
  
  <p>The BLE-GATT functionality I need is:</p>
  
  <ul>
  <li>Detect device connection/disconnection (i.e. get an event or callback when either occures)</li>
  <li>Write some characteristics on the device</li>
  <li>Get notifications (again, via an event or a callback), from the device</li>
  </ul>
  
  <p><strong>What is the best way to achieve this on Windows 10?</strong></p>
  
  <p>So far I've looked into:</p>
  
  <ul>
  <li><a href="https://msdn.microsoft.com/en-us/library/windows/hardware/mt492499(v=vs.85).aspx" rel="nofollow noreferrer">Windows Drivers Kit (WDK)</a> - the <a href="https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/bad452cb-4fc2-4a86-9b60-070b43577cc9/is-there-a-simple-example-desktop-programming-c-for-bluetooth-low-energy-devices?forum=wdk" rel="nofollow noreferrer">sample code</a> works, but I couldn't find any way to detect device connection/disconnection.</li>
  <li><a href="https://docs.microsoft.com/en-us/windows/uwp/devices-sensors/bluetooth-low-energy-overview" rel="nofollow noreferrer">Universal Windows Platform (UWP)</a> - has a slick API, but I can't find how to integrate with native win32 (possible only via COM).</li>
  </ul>