• Support
  • Articles
  • Resources
  • Products

Become an IP socket server - Wavecom cellular modem

Moderator: boris

3 postsPage 1 of 1

celder
Newbie

Posts:
4
Joined: Fri Jan 22, 2010 11:47 am
by celder » Fri Jan 22, 2010 12:12 pm

Code: Select all

  1.  
  2.  
  3. ;;  ### Script for sending streaming Data to a TCP socket using the MTSMC-G-F4 / MTMMC-G-F4 / MTSMC-G2 /MTCBA-G-F4
  4. ;; UK o2 cellular SIM. Tested with Wipsoft 3.11 for progam function
  5. ;; untested for remote device, as fixed IP SIM function not available.
  6. ;---------------------------------------------------------------------------------------------
  7.  
  8.  
  9. ; Auto run using Com 1 - Edit as nesesary
  10. connect '/C=1'
  11. setsync 1
  12. timeout = 5
  13. ; Enable error code reporting
  14.  
  15.  
  16. ; ############################################
  17. ; Enable cellular parameters variables
  18.  
  19. apn ='"mobile.o2.co.uk"'
  20. apnun ='"mobileweb"'
  21. apnpw ='"web"'
  22. Dialnumber ='*99***1#'
  23.  
  24. ; ############################################
  25. ; Enable server device variabes
  26. ; port to use
  27. localport ='25'
  28. ; resreved index numbers for tracking connctions. Example 5 and 6
  29. index ='5,6'
  30.  
  31. ;############################################
  32. ; Sanity check the device state ( will show errors )
  33. :Begin
  34.  
  35. Pause 3
  36.  
  37. sendln 'at+cfun=1'
  38.  
  39. pause 3
  40.  
  41. sendln 'ath'
  42. waitln 'OK'
  43.  
  44.  
  45. sendln 'at+wipclose=2,1
  46. ;waitln 'OK'
  47. pause 5
  48.  
  49. sendln 'at+wipcfg=0'
  50. ; waitln 'OK'
  51. pause 3
  52.  
  53. sendln 'at+csq'
  54. waitln 'OK'
  55.  
  56. sendln 'at+creg?'
  57. waitln 'OK'
  58.  
  59. sendln 'at+wopen=0'
  60. ; waitln 'OK'
  61. pause 5
  62.  
  63. ;sendln 'at+cmee=1'
  64. ;waitln 'OK'
  65.  
  66. ; ###############################################
  67. ; Configure Device with given cellular variables
  68.  
  69. ; Open the IP stack-
  70. sendln 'at+wopen=1'
  71. ;waitln 'OK'
  72.  
  73. :RERUN
  74. sendln 'at+wipcfg=1'
  75. waitln 'ERROR' 'OK'
  76.  
  77. if result = 0 goto RERUN
  78. If result = 1 goto RERUN
  79. if result = 2 goto PROCEED
  80.  
  81. :PROCEED
  82.  
  83. ; Apply cellular parameters
  84. sendln 'at+wipbr=1,6
  85. waitln 'OK'
  86. sendln 'at+wipbr=2,6,11,'apn''
  87. waitln 'OK'
  88. SENDLN 'AT+WIPBR=2,6,0,'apnun''
  89. WAITLN 'OK'
  90. SENDLN 'AT+WIPBR=2,6,1,'apnpw'
  91. WAITLN 'OK'
  92.  
  93. ; Start the bearer  4,6,0 - GPRS with Username and password
  94.  
  95. :AGAIN
  96. pause 3
  97. sendln 'at+wipbr=4,6,0'
  98. wait 'OK' '+CME'
  99. if result = 0 goto AGAIN
  100. if result = 1 goto NEXT
  101. if result = 2 goto AGAIN
  102. :NEXT
  103.  
  104. ; #############################################################
  105. ; Open the connection
  106.  
  107. ;  Create the TCP socket - ID 1, port as defined index as defined ( Example is for 2 ports )
  108. sendln 'at+wipcreate=3,1,'localport','index'
  109. waitln 'OK'
  110.  
  111. messagebox 'recieve connection enabled' 'Recieve'
  112.  
  113. :waitconect
  114. waitln '+WIPACCEPT:1,5' '+WIPACCEPTS:1,6'
  115. if result = 0 goto waitconect
  116. if result = 1 goto index5
  117. if result = 2 goto index6
  118.  
  119.  
  120. ; Control the connection
  121. :index5
  122. messagebox 'recieve connection established index 5' 'Recieve5'
  123.  
  124. ; wait 20 seconds and then close the port
  125. pause 20
  126. sendln 'at+wipclose=2,5'
  127. waitln 'OK'
  128.  
  129. yesnobox 'restart the example' 'full_Loop_ID5'
  130. if result goto Begin
  131.  
  132. End
  133.  
  134. :index6
  135. messagebox 'recieve connection established index 6' 'Recieve6'
  136.  
  137. pause 20
  138. sendln 'at+wipclose=2,6'
  139. waitln 'OK'
  140.  
  141. yesnobox 'restart the example' 'full_Loop_ID6'
  142. if result goto Begin
  143.  
  144. End
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
boris
Moderator, LogMeTT and TTLEditor developer

Posts:
1593
Joined: Sat Jan 08, 2005 2:52 pm
by boris » Sat Jan 23, 2010 5:01 am
Celder,

Thanks for sharing your code, but 3 out of 4 your macros contain typos - missing quotes. I fixed the 1st post. Please update this one and "TCP socket to a remote destination - Cellular modem Wavecom".
Syntax highlighter that we use in these forums makes it easier to locate misplaced quotation marks; when closing quote is missing, following macro commands that should have dark blue color appear as magenta, which is the color of constant strings.
Thanks.
Best regards,
Boris
zeeshan
Newbie

Posts:
1
Joined: Mon Dec 03, 2012 8:06 am
by zeeshan » Wed Dec 19, 2012 7:19 am
Thanks for sharing...! :smile:
Display posts from previous:
Sort by:

3 postsPage 1 of 1

Users browsing this forum: No registered users