Solved

Sending SMS from VB through Nokia 6310i with serial data cable

Posted on 2004-10-16
14
1,175 Views
Last Modified: 2013-12-09
Ok, i have read a questions / answers about what to type for the at commands and using MSCOMM object to talk to the nokias modem..

I can manually send an sms using hyper terminal no probs.. and XP can query the Nokia Modem and give me good results...

BUT

I drop the MSCOMM object in a form and then do the simple code as follows:

MSComm1.CommPort = 1
'MSComm1.InputLen = 0
MSComm1.Settings = "9600,N,8,1"
MSComm1.PortOpen = True
MSComm1.Output = "AT" & vbCrLf

'------------- at this point i wait for the modem to report back "OK"
'-                BUT it never does..  nothing happens at this point.
Do
    DoEvents
    Debug.Print MSComm1.CommEvent & vbCrLf      '------- ALWAYS returns 0 (zero)
loop Until InStr(buffer$, "OK" & vbCrLf)

   
'----------- This part i typed in manually in hyperterminal and it works fine...  but my prog never gets this far as above is in a loop.
     
MSComm1.Output = "AT+CMGF=1" & Chr$(13)
'MSComm1.Output = "AT+CNMI=3,3,2" & Chr(13)
MSComm1.Output = "AT+CMGS=" & "+447834871851" & Chr$(13)
MSComm1.Output = "HeartBeat from WWW1: Server Ok" & Chr$(26)
'MSComm1.PortOpen = False
Label1.Caption = MSComm1.Input

Does anyone know off the top of their head if there is something i am doing wrong?

Thanks in advance
0
Comment
Question by:Cybordax
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
14 Comments
 
LVL 2

Accepted Solution

by:
SergeiKo earned 250 total points
ID: 12340736
Hello, Cybordax.

Try to handle responses from mode as events.

From MSDN:
Event-driven communications is a very powerful method for handling serial port interactions. In many situations you want to be notified the moment an event takes place, such as when a character arrives or a change occurs in the Carrier Detect (CD) or Request To Send (RTS) lines. In such cases, use the MSComm control's OnComm event to trap and handle these communications events. The OnComm event also detects and handles communications errors. For a list of all possible events and communications errors, see the CommEvent property.

Pay attention to
MSComm1.RThreshold = 1
MSComm1.SThreshold = 1
and
Private Static Sub MSComm1_OnComm() function.


Hope the sample below will help you.

Option Explicit

Private Sub Command1_Click()
    Call Disconnect
    Call Connect
   
    Call Send("AT")
    Call Send("ati")
    Call Send("ati3")
End Sub

Function Connect()
    If MSComm1.PortOpen = False Then
        MSComm1.CommPort = 3
        MSComm1.Settings = "115200,N,8,1" ' 115200 baud, no parity, 8 data, and 1 stop bit.
        MSComm1.InputLen = 0
        MSComm1.RThreshold = 1
        MSComm1.SThreshold = 1
        MSComm1.PortOpen = True
    End If
End Function


Function Disconnect()
    If (MSComm1.PortOpen = True) Then
        MSComm1.PortOpen = False
    End If
End Function


Function Send(str As String)
    MSComm1.Output = str & vbCrLf
End Function


Private Static Sub MSComm1_OnComm()
    Select Case MSComm1.CommEvent
       ' Events
        Case comEvReceive   ' Received RThreshold # of characters
            Dim buffer As String
            buffer = MSComm1.Input
            If buffer <> "" Then
                Debug.Print ">> " & buffer
            End If
    End Select
End Sub


Regards.
0
 

Author Comment

by:Cybordax
ID: 12341733
I will give that a go and get back to you...

Got back LATE from work tonight, so i WILL let you know the following day...

Thanks for the response dude...

0
 

Author Comment

by:Cybordax
ID: 12351714
Ok, i tried what you had suggested, and still no joy, mate...

I nothing displayes in the debug window...

I can confirm the data cable is recognised by 6310i as it says data accessory connected.
i can confirm PC can see the phone and recognise it on COM1 as Hyper terminal lets me connect, send sms etc...

but VB does not like it....

I did exact coding you typed in...  and changed the send calls to send an sms etc....

i am confused!  lol

Any more help you could provide would be most greatly appreciated!

Thanks in advance
0
Optimum High-Definition Video Viewing and Control

The ATEN VM0404HA 4x4 4K HDMI Matrix Switch supports 4K resolutions of UHD (3840 x 2160) and DCI (4096 x 2160) with refresh rates of 30 Hz (4:4:4) and 60 Hz (4:2:0). It is ideal for applications where the routing of 4K digital signals is required.

 
LVL 13

Assisted Solution

by:imarshad
imarshad earned 250 total points
ID: 12355524
>>MSComm1.Output = "AT+CMGF=1" & Chr$(13)
>>'MSComm1.Output = "AT+CNMI=3,3,2" & Chr(13)
>>MSComm1.Output = "AT+CMGS=" & "+447834871851" & Chr$(13)
>>MSComm1.Output = "HeartBeat from WWW1: Server Ok" & Chr$(26)
>>'MSComm1.PortOpen = False
>>Label1.Caption = MSComm1.Input

If this is the code you are using to send the SMS then it will not do the job for you..... You must insert some delay before sending the Modem the next command.....
Here is one way i.e by using Sleep......

MSComm1.Output = "AT+CMGF=1" & Chr$(13)
sleep 500           '0.5 seconds or 500 milliseconds
MSComm1.Output = "AT+CMGS=" & "+447834871851" & Chr$(13)
sleep 500
MSComm1.Output = "HeartBeat from WWW1: Server Ok" & Chr$(26)
sleep 500
Label1.Caption = MSComm1.Input

also try to change the value to 1000 (ms) if it is not working.......and declare sleep as

Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
0
 

Author Comment

by:Cybordax
ID: 12355928
Ok, my friend, i will give that a go and get back to you.....

I have to be doing something REALLY stupid....  i did not imagine it to be this....  annoying to set up simple connection to a nokia modem....

Thanks again for your help so far...

Take care dude
0
 
LVL 2

Expert Comment

by:SergeiKo
ID: 12356558
Hello, again.

I have some thoughts:
 - try to set RThreshold = 1 and SThreshold = 1 in the setup component properties;
 - be sure you use your port number CommPort = 1 in your case;
 - in Settings you should use the same data rate as modem: 9600 or 115200 or ... . You can get modem's data rate with
   command AT+IPR? and set with command AT+IPR=115200 (to 115200 for example),
   or better choose the same data rate you choose with hyperterminal;
 - try to debug to be sure, that AT command was sent to modem.

Hope this help.

And keep patience when you are trying. If at first you don't succeed, think and try again. :-)

Regards.
0
 

Author Comment

by:Cybordax
ID: 12390499
Sorry, I have been v busy for a few days at work....

I will try what you advised, but i know i have set the same baud rate etc as hyperterminal....

I will get back to you

Thanks again
0
 
LVL 13

Expert Comment

by:imarshad
ID: 12824203
I think the suggestions by SegeiKo and imarshad can solve this problem. But the asker never got back to the Question meaning either he got it working or wasnot hoping for an answer....... If you donot want to Split then still it should be Paq'ed rather then deleted.....

Imran
0
 

Author Comment

by:Cybordax
ID: 12830982
Hello to all..

Mucho apologies for not getting back, but since the post of the question, have been too busy to continue with my little project....

I still did not get it to work.... very confusing....

The responses by SegeiKo and imarshad  were much appreciated ....  did not get much of a chance to implement and expirement with the suggestions though....

I could split the answers, but I still do not know, and wont be able to find out if their suggestions had worked...  not for a while anyway....  what is  Paq'ed  all about?
0
 
LVL 13

Expert Comment

by:imarshad
ID: 12832000
PAQ --------> Previously Asked Questions

If a question is PAQ then all the comments that have been made by the Experts are retained. But if a question is deleted then all the comments are deleted and the Question is also deleted. Since there was some useful knowledge in the posts so I wont like to let the Question be deleted.

Imran
0
 
LVL 20

Expert Comment

by:Venabili
ID: 12893609
Leaving it open for a few more days.... but do not make them too much :)

Venabili
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today sees the launch of a new case study, focusing on BYOD technologies we have been working with for some time now.  But with the advent of 802.11ac wireless technologies and the story behind our landmark developments, we would like to share this …
DECT technology has become a popular standard for wireless voice communication. DECT devices are not likely to be affected by other electronic devices and signals because they operate in a separate frequency-band.
This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.
Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question