Hi,
I am trying to connect to an EFTPOS terminal using a dot net assembly, where the C# sample code is as follows:
_spi = new Spi(_posId, _eftposAddress, _spiSecrets); // It is ok to not have the secrets yet to start with.
_spi.StatusChanged += OnStatusChanged; // Called when Status changes between Unpaired, PairedConnected and PairedConnecting
_spi.SecretsChanged += OnSecretsChanged; // Called when Secrets are set or changed or voided.
_spi.PairingFlowStateChanged += OnPairingFlowStateChanged; // Called throughout to pairing process to update us with progress
_spi.TxFlowStateChanged += OnTxFlowStateChanged; // Called throughout to transaction process to update us with progress
_spi.Start();
My Windev code is as follows:
_spi is Spi dynamic //from SPIClient
_spisecrets is Secrets //from SPIClient
_posid is UNICODE string
_eftposaddress is UNICODE string
Init() //sets values for _posid, _eftposaddress & _spisecrets (if any exist which they don't currently)
_spi = new Spi(_posid,_eftposaddress,_spisecrets)
//add event handlers
_spi.add_StatusChanged(DotNetDelegate(OnStatusChanged,"EventHandler<SPIClient.SpiStatusEventArgs>"))
_spi.add_PairingFlowStateChanged(DotNetDelegate(OnPairingFlowStateChanged,"EventHandler<SPIClient.PairingFlowState>"))
_spi.add_SecretsChanged(DotNetDelegate(OnSecretsChanged,"EventHandler<SPIClient.Secrets>"))
_spi.add_TxFlowStateChanged(DotNetDelegate(OnTxFlowStateChanged,"EventHandler<SPIClient.TransactionFlowState>"))
_spi.start()
This appears to work but pressing the pairing button on the EFTPOS terminal causes my program to crash. The C# sample runs without a problem. My event procedures are all declared as eg
PROCEDURE OnStatusChanged (src, args) and currently all they are doing is a trace. spi.start() triggers the OnStatusChanged event which is traced correctly by my program. If nothing is touched on the terminal after running this the program is fine so I'm sure it has to be something to do with the event handling. That same event should be fired when the pairing button is pressed but my program is crashing before the trace on that event occurs.
I've tried just about everything I can think of including specifying argument types in the procedures, making _Secrets dynamic etc etc but without any luck. Whatever I do that compiles seems to have no impact & because the sample C# code works & the developer of it does not know Windev they can't really help me at all. Any ideas would be much appreciated.
Thanks
David