Solved

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

Posted on 2004-10-16
14
1,152 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
  • 5
  • 3
  • 2
  • +1
14 Comments
 
LVL 2

Accepted Solution

by:
SergeiKo earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 13

Assisted Solution

by:imarshad
imarshad earned 250 total points
Comment Utility
>>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
Comment Utility
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
Free camera licenses with purchase of My Cloud NAS

Milestone Arcus software is compatible with thousands of industry-leading cameras for added flexibility. Upon installation on your My Cloud NAS, you will receive two (2) camera licenses already enabled in the software. And for a limited time, get additional camera licenses FREE.

 
LVL 2

Expert Comment

by:SergeiKo
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Leaving it open for a few more days.... but do not make them too much :)

Venabili
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hopefully this article will help someone who's had the same issues I had. I have a Dell Wireless 1390 WLAN Mini-Card and Windows 7, and for the past couple of days I was beyond frustrated because my wireless laptop was not able to access the Inte…
This paper addresses the security of Sennheiser DECT Contact Center and Office (CC&O) headsets. It describes the DECT security chain comprised of “Pairing”, “Per Call Authentication” and “Encryption”, which are all part of the standard DECT protocol.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now