salut,
je suis entrain de réaliser une application pour envoi et réception des sms via une interface graphique on communicant avec la carte sim (supporté par modem GSM), j'ai trouvé ce code source qui utilisent des commandes AT pour piloter la carte sim et envoyé des sms, normalement ca doit marché, mais je ne sais pas ou est le problème exactement, si vous avez une idée sur ce sujet n'hésitez pas s'il vous plait, et merci d'avance pour vos réponse
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 Imports System Imports System.Threading Imports System.ComponentModel Imports System.IO.Ports Public Class Form1 Dim SMSEngine As New SMSCOMMS("COM4") Dim i As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click SMSEngine.Open() SMSEngine.SendSMS() End Sub End Class Public Class SMSCOMMS Private WithEvents SMSPort As SerialPort Private SMSThread As Thread Private ReadThread As Thread Shared _Continue As Boolean = False Shared _ContSMS As Boolean = False Private _Wait As Boolean = False Shared _ReadPort As Boolean = False Public Event Sending(ByVal Done As Boolean) Public Event DataReceived(ByVal Message As String) Public Sub New(ByRef COMMPORT As String) SMSPort = New SerialPort With SMSPort .PortName = COMMPORT .BaudRate = 9600 .Parity = Parity.None .DataBits = 8 .StopBits = StopBits.One .Handshake = Handshake.RequestToSend .DtrEnable = True .RtsEnable = True .NewLine = vbCrLf End With End Sub Public Function SendSMS() As Boolean If SMSPort.IsOpen = True Then SMSPort.WriteLine("AT") SMSPort.WriteLine("AT+CMGF=1" & vbCrLf) SMSPort.WriteLine("AT+CSCA=""+919822078000""" & vbCrLf) SMSPort.WriteLine("AT+CMGS= + TextBox1.text + " & vbCrLf) _ContSMS = False SMSPort.WriteLine("+ TextBox1.text +" & vbCrLf & Chr(26)) MessageBox.Show(":send") SMSPort.Close() End If End Function Public Sub Open() If Not (SMSPort.IsOpen = True) Then SMSPort.Open() End If End Sub Public Sub Close() If SMSPort.IsOpen = True Then SMSPort.Close() End If End Sub End Class
Partager