public static extern int dwg_send_ussd(ref str_t destination, int port);
public static extern int dwg_send_sms(ref str_t destination, ref str_t message, int port);
/// <summary> /// Sends a USSD request. /// </summary> /// <param name='requestCode'> /// USSD request code /// </param> /// <param name='port'> /// Gateway's port to use /// </param> /// <exception cref='Exception'> /// If the gateway is not connected, an exception will be thrown /// </exception> public static void SendUSSDMessage(string requestCode, int port) { if (!Gateway.IsGwConnected) throw new Exception("Gateway is not connected"); str_t number = new str_t(); number.s = Marshal.StringToHGlobalAnsi(requestCode); number.len = requestCode.Length; smsgw.dwg_send_ussd(ref number, port); }
static string strToString(str_t str) { return Marshal.PtrToStringAnsi(str.s, str.len); }
/// <summary> /// Sends a SMS. /// </summary> /// <returns> /// True if the message was successfully queued. /// </returns> /// <param name='destination'> /// Destination number /// </param> /// <param name='message'> /// SMS content /// </param> /// <param name='selectedPort'> /// Index of the port from which the message will be sent /// </param> public static void SendMessage(string destination, string message, int port) { if (!Gateway.IsGwConnected) throw new Exception("Gateway is not connected"); str_t number = new str_t(); number.s = Marshal.StringToHGlobalAnsi(destination); number.len = destination.Length; str_t msg = new str_t(); msg.s = Marshal.StringToHGlobalAnsi(message);; msg.len = message.Length; smsgw.dwg_send_sms(ref number, ref msg, port); }