$regfile = "m8def.dat"
$crystal = 16000000
$baud = 19200
$hwstack = 128
$swstack = 128
$framesize = 128

Declare Sub Getline(s As String)
Declare Sub Flushbuf()
Declare Sub Pwrmodule
Declare Sub Sendsms
Declare Sub Balanse


Dim F As Byte
Dim B As Byte
Dim S As String * 150
Dim Phonenumber As String * 13
Dim Otvet As String * 80


Enable Interrupts



On Urxc Getline




Config Portd.1 = Output
Config Portd.0 = Input



Gosub Pwrmodule





Phonenumber = "+38095xxxxxxx"                               '   

Gosub Balanse

End
'============================================================================
'============================================================================
 Sub Balanse

 Print "AT+CUSD=1," ; Chr(34) ; "#101#" ; Chr(34)
 Enable Urxc

  Wait 1

 Led = 1
  Wait 3
  Wait 3

  End Sub
 Return


'    
'=============================================================================
 Sub Getline(s As String):
  
  Disable Urxc
     S = ""
       Do

          B = Inkey()                                       '      ASCII
      Select Case B
          Case 0                                            '    
          Case 13                                           '  (Enter),     
          Case 10 : If S <> "" Then Exit Do                 ' ,    
          Case Else :

           S = S + Chr(b)                                   '     32   ,    
      End Select

   Loop



      Otvet = S

    Gosub Sendsms
End Sub






' 
'=============================================================================
Sub Flushbuf():
 Waitms 100
 Do
 B = Inkey()                                                '   
 Loop Until B = 0
End Sub

Return


'  
'=============================================================================
Sub Sendsms:
Print "AT+CMGS=" ; Chr(34) ; Phonenumber ; Chr(34)
Led = 0
Waitms 200
Print Otvet ; Chr(26)

Print Chr(26);
Wait 1
Print Chr(13)

    End Sub


Return


'======================================================================================
'======================================================================================
Sub Pwrmodule:

Powerkey = 1
Waitms 1000                                                 ' 1  

Powerkey = 0

Wait 21



Flushbuf


End Sub
Return




'  .      16 ,    Mega8   .



'+CUSD: 0,"NA VAShomu rahunku 12.41 grn. Taryf 'Super MTS 3D Nul-35'. Nomer diysnyi do 02.03.2016. Bezlimitnyi Internet za 1,10hrn/d!Zamovlennya *101*223#",64



