Sub EnvoiSMS() Dim x On Error Resume Next 'Form1.MSComm1.PortOpen = True 'Form1.Timer1.Enabled = False 'arret analyse buffer d'entrée GSM 'Form1.Timer4.Enabled = False 'arret lecture buffer GSM Call envoicommande("AT+WIND=63" & Chr$(13) & Chr$(10)) 'activation des évènements Modem Call attente(20) Call ReceptionGSM Call envoicommande("AT+CMEE=1" & Chr$(13) & Chr$(10)) 'activation des codes erreurs étendus Call attente(20) Call ReceptionGSM Call envoicommande("AT+CSCA=" & Operateur & Chr$(13) & Chr$(10)) 'activation des codes erreurs étendus Call attente(20) Call ReceptionGSM Call envoicommande("AT+CMGF=1" & Chr$(13) & Chr$(10)) 'SMS en mode texte Call attente(20) Call ReceptionGSM Call envoicommande("AT+CSMP=33" & Chr$(13) & Chr$(10)) 'active le Status Report Call attente(20) Call ReceptionGSM Call envoicommande("AT+CNMI=0,1,0,1,0" & Chr$(13) & Chr$(10)) 'acquit de dépot en "Notification" Call attente(20) Call ReceptionGSM Call envoicommande("AT+CMGS=+33" & Right$(NumeroSMS, 9) & Chr$(13) & Chr$(10)) 'envoi du N° de mobile destinataire Call attente(20) Call ReceptionGSM Call envoicommande(TextSMS & Chr$(&H1A)) 'envoi du message + Ctrl Z Call attente(20) Call ReceptionGSM receptionstring$ = "" 'Form1.Timer1.Enabled = True 'reprise de l'analyse buffer d'entrée GSM Form1.Timer4.Enabled = True 'reprise lecture buffer GSM 'Form1.MSComm1.PortOpen = False End Sub Sub envoicommande(ChaineCommande As String) Dim x As Integer On Error Resume Next 'Call Voyant(1) 'allumage voyant Tx receptionstring$ = "" 'RaZ de la chaine de réception For x = 1 To Len(ChaineCommande$) Form1.MSComm1.Output = Mid$(ChaineCommande$, x, 1) Next x 'affichage commande 'Call AffichageDatacom(ChaineCommande$, 0) End Sub Sub DeconnexionModem() Dim x Call envoicommande("+++") 'chaine de retour au protocole Hayes 'attente de la réponse OK Form1.MSComm1.PortOpen = False Form1.Timer4.Enabled = False End Sub Sub InitialisationGSM() Dim x On Error Resume Next 'Form15.Show DoEvents 'Form1.Timer1.Enabled = False 'arret analyse buffer d'entrée GSM Form1.Timer4.Enabled = False 'arret lecture buffer GSM 'Form1.Refresh 'suppression echo Call envoicommande("ATE0" & Chr$(13) & Chr$(10)) Call attente(10) Call ReceptionGSM 'Form1.Refresh 'lecture version logicielle ' réponse INTEGRA du type: "430a09gm.2C 1208244 110801 19:19" Call envoicommande("AT+CGMR" & Chr$(13) & Chr$(10)) receptionstring$ = "" Call attente(30) Call ReceptionGSM 'Form1.Refresh 'redirection réception messages SMS directement vers le port RS232 Call envoicommande("AT+CNMI=0,2,0,0,0" & Chr$(13) & Chr$(10)) 'acquit de dépot en "Notification" Call attente(10) Call ReceptionGSM 'Form1.Refresh receptionstring$ = "" 'Form1.Timer1.Enabled = True 'reprise de l'analyse buffer d'entrée GSM Form1.Timer4.Enabled = True 'reprise lecture buffer GSM 'Form1.Refresh End Sub Sub attente(attentemaxi) timergeneral = 0 While timergeneral < attentemaxi DoEvents Wend End Sub Sub ReceptionGSM() Dim i As Integer Dim buffer As Variant Dim lenb_buffer_total Dim savestring As String lenb_buffer_total = 0 If Form1.MSComm1.InBufferCount <> 0 Then Beep DoEvents 'Call Voyant(2) 'allumage voyant Rx buffer = Form1.MSComm1.Input lenb_buffer_total = lenb_buffer_total + LenB(buffer) For i = 1 To LenB(buffer) receptionstring$ = receptionstring$ & Chr$(buffer(i - 1)) savestring$ = savestring$ & Chr$(buffer(i - 1)) Next i 'affichage activité Call SauvegardeDatacom(receptionstring$, 1) End If End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question