Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


mikerabat last won the day on December 19 2018

mikerabat had the most liked content!

Community Reputation

12 Good

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. mikerabat

    TBluetoothLE in Windows 10

    That is only the one half of the story. This is the base - in the next abstraction layer Emba decided to go to the different platforms - and for windows and Bluetooth LE the last file that actually implements stuff is System.Win.BluetoothWinRT.pas That is also not entierly true. The imlementation from Embarcadero lacks this ability yes - I managed though to extend the WinRT implementation such that this is possible too. See the attached file on: https://quality.embarcadero.com/browse/RSP-21711 hope that helps 😉
  2. mikerabat

    TBluetoothLE in Windows 10

    And how do you do that in win32? I wasn't able to find any BT LE classes or functions besides the WinRT stuff that is covered in Delphi. Please note that my code here patches the actual TBluetoothLE component that ships with Delphi 10.4.2! And yes I use this code in conjunction with a standard VCL app 😉
  3. mikerabat

    TBluetoothLE in Windows 10

    I ran into the same problem and managed to fix that with an external timer that calls CancelDiscovery. It works but leaves a massive memory/thread leak since every time a new discovery is started the timer variable gets overwritten and not freed leaving the pending thread and it's resources.... The problem actually is: the problem is within the Delphi implementation of the Thread that triggers the CancelDiscovery function. In Windows there is a Thread (TWinRTBluetoothLEAdapter.TDiscoverThreadTimer in System.Win.BluetoothWinRT.pas) that actually just waits for a specific amount of time and calls the given timer procedure. The problem here is that the Timer procedure cleans up the thread (calls .Free) which waits for the end of the Thread -> deadlock. To circumvent that problem I needed to adjust System.Win.BluetoothWinRT do the following: Augment the class TWinRTBluetoothLEAdapter by private const WM_BTLE_CANCELDISCOVERY = $400 + 666; // WM_USER ... private fHDL : HWND; procedure BTLETimerHandler( var msg : TMessage ); protected procedure ThrDoCancelDiscovery; .. implementation procedure TWinRTBluetoothLEAdapter.BTLETimerHandler(var msg: TMessage); begin if msg.Msg = WM_BTLE_CANCELDISCOVERY then DoCancelDiscovery; end; procedure TWinRTBluetoothLEAdapter.ThrDoCancelDiscovery; begin // just post otherwise the thread hangs! PostMessage( fHDL, WM_BTLE_CANCELDISCOVERY, 0, 0); end; constructor TWinRTBluetoothLEAdapter.Create(const AManager: TBluetoothLEManager; const ARadioInfo: TBluetoothRadioInfo); begin inherited Create(AManager); fHDL := AllocateHWnd(BTLETimerHandler); ... end; destructor TWinRTBluetoothLEAdapter.Destroy; begin DeallocateHWnd(fHDL); ... end; function TWinRTBluetoothLEAdapter.DoStartDiscovery(Timeout: Cardinal; const AFilterUUIDList: TBluetoothUUIDsList; const ABluetoothLEScanFilterList: TBluetoothLEScanFilterList): Boolean; begin ... // new code if Assigned(fTimerThread) then begin fTimerThread.Cancel; fTimerThread.Free; end; // changed from DoCancelDiscovery to ThrDoCancelDiscovery FTimerThread := TDiscoverThreadTimer.Create(Self, ThrDoCancelDiscovery, Timeout); ... end; I guess one could also use TThread.Queue instead of the "complicated" window allocation in the timer and that should do the trick too!
  4. mikerabat

    SysUtils, AnsiString

    Thank you very much much for the great insight!
  5. mikerabat

    SysUtils, AnsiString

    Sorry but can you elaborate that? I actually cannot see how I get there a string converted to a field in the record... what am I missing here?
  6. mikerabat

    SysUtils, AnsiString

    You mean I don't need AnsiCharacters to communicate with a device that only understands Single Byte characters? So... how is that? And tell me then how to use GetBytes to fill a structure like: type TPatData = packed record SurName : Array[0..31] of AnsiChar; FirstName : Array[0..31] of AnsiChar; end; var pat : TPatData; formSurName : String; begin FillChar(pat, sizeof(pat), 0); // code to be filled here.... end;
  7. mikerabat

    SysUtils, AnsiString

    haha... I'd love to but I have file and communication structures that need good old ansi strings. Or do you actually have a better idea than: str8 := UTF8String(SurName); System.AnsiStrings.StrLCopy(@patData.surname[0],PAnsiChar(str8), length(patData.surname)); to bring a normal delphi string (SurName) to a structure (patData) that contains single byte characters?
  8. mikerabat

    SysUtils, AnsiString

    Hi! I'm currently migrating our projects from Delphi2010 to Delphi 10.4. One of my biggest changes is actually using StrLCopy and other Ansistring functions that used to be in SysUtils. They are now marked as deprecated and moved to System.AnsiStrings so ... I followed the compiler hint. Now the base problem is that the compiler is confused which function to use so I always prefix the call with System.AnsiStrings.StrLCopy ... which fixed that. But that looks actually very "ugly" and I have the feeling that this is not the way to go idera ment to go. Is there a "best" or anticipated way to handle this? kind regards Mike
  9. You can check out: https://github.com/mikerabat/mrmath It provides a set of different random number generators: * Standard delphi ( linear congruential ) * Mersenne Twister * BCrypt (or actually os dependent) * If the cpu supports it: the x86 RDRAND instruction
  10. mikerabat

    FIDO2 and CBOR

    Hi there! There is the C library libFido2 around in form of a dll. I took the liberty to put arround a Delphi library that supports FIDO2 keys around that library including a little project that shows how one could do WebAuthn logins. check out: https://github.com/mikerabat/DelphiFido2 https://github.com/mikerabat/DelphiCBOR for further reading. kind regards Mike
  11. mikerabat

    LINEST function

    Hi! You could use the regression functions from here: https://github.com/mikerabat/mrmath and the regression example from here: http://www.mrsoft.org/home/downloads.html
  12. mikerabat

    Firebird Encryption options

    Cool thanks for the info!
  13. mikerabat

    Firebird Encryption options

    Thanks for the hint! I will definitely look into that 🙂
  14. mikerabat

    Firebird Encryption options

    Hi Folks! I hope anyone can give me some hints on this topic: Firebird Data encryption and encryption of the data sent. Especially the "over the line" encryption of data is going to be mandatory for our next projects since there are a few attack vectors we didn't really anticapte that this would ever be a problem: an attacker has access to an internal network (e.g. a hospital) and reads the communication from between our program and the remote database. So... data encryption ala SSL, TLS would be a great thing to have. So far the FAQ from firebird only suggest to use an SSH tunnel or similar to connect to the database but ... is this feasable or even performant? Has anyone any experience with such a problem or is there anything some Delphi components could do? kind regards Mike
  15. mikerabat

    mrMath matrix library

    Hey guys! I wanted to share my matrix library with you basically it contains tons of function for matrix manipulation (add, sub, mult, inverse) and higher order functions (SVD, CCA, PLS and tons more) The library is highly optimized (handoptimized assembler, AVX, SSE, FMA support) and can be multithreaded. Check out the repository on https://github.com/mikerabat/mrmath and check some tiny examples on: http://www.mrsoft.org/home/downloads.html hope you have fun with that ;) kind regards Mike