public GALILEO_RETURN_CODE ConnectIOT(string targetID, int timeout, string password, Action <GALILEO_RETURN_CODE, String> onConnect = null, Action <GALILEO_RETURN_CODE, String> onDisconnect = null) { byte[] targetIDBytes = Encoding.ASCII.GetBytes(targetID); byte[] passwordBytes = Encoding.ASCII.GetBytes(password); OnConnectDelegate onConnectCB = null; OnDisconnectDelegate onDisconnectCB = null; if (onConnect != null) { onConnectCB = (status, id, length) => { byte[] result = new byte[length]; Marshal.Copy(id, result, 0, (int)length); onConnect?.Invoke(status, Encoding.ASCII.GetString(result, 0, (int)length)); }; } if (onDisconnect != null) { onDisconnectCB = (status, id, length) => { byte[] result = new byte[length]; Marshal.Copy(id, result, 0, (int)length); onDisconnect?.Invoke(status, Encoding.ASCII.GetString(result, 0, (int)length)); }; } return(GalileoFunctions.ConnectIOT(instance, targetIDBytes, targetIDBytes.Length, timeout, passwordBytes, passwordBytes.Length, onConnectCB, onDisconnectCB)); }