Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

can you help simple the code

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
kimmi

Moderator



Joined: 24 Feb 2006
Posts: 1922
Location: Denmark

denmark.gif
PostPosted: Mon May 15, 2006 11:25 am    Post subject: can you help simple the code Reply with quote

Hey All Bascom users ..

I have made some code for siemens gsm phone for the sms to convert text to pdu format and back

the code looks like someone (like me) that dont know how to make a simple code , can it be more simple strukter so it look better and are more simple to read ....


Code:

$regfile = "m128def.dat"
$crystal = 8000000

Dim I As Byte
Dim J As Byte
Dim I1 As Byte
Dim J1 As Byte
Dim Pdu_len As Byte
Dim Smslen As Byte
Dim K As Byte
Dim K1 As Byte
Dim K2 As Byte
Dim K3 As Byte
Dim K4 As Byte
Dim Jj As Byte
Dim Txt As String * 320
Dim Pdutest As String * 320
Dim X As String * 2
Dim X1 As String * 2
Jj = 0
'convert smstxt to pdu
Do
   J = Lookup(jj , Smstxt)
   Incr Jj
Loop Until J = 0
Smslen = Jj - 1

Pdutest = ""
I = 0
J = 1
Do
   K1 = Lookup(i , Smstxt)
   K2 = Lookup(j , Smstxt)
   K = I Mod 8

   Shift K1 , Right , K
   K = 7 - K
   Shift K2 , Left , K
   K1 = K1 + K2
   Print Hex(k1);
   Pdutest = Pdutest + Hex(k1)
   Incr I
   Incr J
   If K = 1 Then
     Incr J
     Incr I
   End If
Loop Until I >= Smslen


 'convert(pdu)  to text
Print ""
 Jj = 0
 I = 0
 J = 1
 I1 = 1
 J1 = 3

 Pdu_len = Len(pdutest)
 Pdu_len = Pdu_len / 2
Do
   X = Mid(pdutest , I1 , 2)
   X1 = Mid(pdutest , J1 , 2)
   K1 = Hexval(x)
   K2 = Hexval(x1)

   K = I Mod 7
   K3 = K1

   If K = 0 Then K1 = K1 And 127
   If K = 1 Then K1 = K1 And 63
   If K = 2 Then K1 = K1 And 31
   If K = 3 Then K1 = K1 And 15
   If K = 4 Then K1 = K1 And 7
   If K = 5 Then K1 = K1 And 3
   If K = 6 Then K1 = K1 And 1

   Jj = K + 1

   Shift K1 , Left , K

   K = 7 - K
   Shift K3 , Right , K

   If K = 7 Then
    Print Chr(k1);
   Else
    K1 = K1 + K4
    Print Chr(k1);
   End If

    If K = 1 Then
   Print Chr(k3);
   K3 = 0
   End If
   K4 = K3

    I1 = I1 + 2
    J1 = J1 + 2
    Incr I
   Incr J


Loop Until I >= Pdu_len
End

Smstxt:
Data "Hey Bascom Users now I can convert smsmsg from text > pdu and from pdu > text  can you make it more simple in the code ?"

 


lokking bad right pls help me Embarassed

_________________
/ Kim
Back to top
View user's profile Visit poster's website MSN Messenger
skilcline

Bascom Member



Joined: 25 Oct 2004
Posts: 20

PostPosted: Mon May 15, 2006 3:04 pm    Post subject: Reply with quote

If it is a Siemen's mobile phone, the chances are you can send it an AT command to put it in the correct format in the first place - "AT+CMGF=1", if I remember correctly... this would mean that the phone / module will output in SMS Text format and no conversion to and from PDU will be needed.
Back to top
View user's profile
kimmi

Moderator



Joined: 24 Feb 2006
Posts: 1922
Location: Denmark

denmark.gif
PostPosted: Mon May 15, 2006 3:40 pm    Post subject: Reply with quote

Hey ..

Yes some siemens phones can but not all models

ex A65 only pdu

_________________
/ Kim
Back to top
View user's profile Visit poster's website MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum