sms设置GPRS接入点、WAP网关.c
上传用户:h553230743
上传日期:2013-04-06
资源大小:509k
文件大小:4k
源码类别:

手机WAP编程

开发平台:

Visual C++

  1. #include <stdio.h>
  2. #include "sms.h"
  3. int send_sms_1(const char *mb);
  4. int send_sms_2(const char *mb);
  5. int send_sms_3(const char *mb);
  6. unsigned char m_sms1[] ={
  7. 0x0B,
  8. 0x05,
  9. 0x04,
  10. 0xc3,
  11. 0x4f,
  12. 0xc0,
  13. 0x02,
  14. 0x00,
  15. 0x03,
  16. 0x04,
  17. 0x03,
  18. 0x01,
  19. //WDP headers end
  20. 0x01,
  21. 0x06,
  22. 0x2C,
  23. 0x1F,
  24. 0x2A,
  25. 0x61,0x70,0x70,0x6C,0x69,0x63,0x61,0x74,0x69,
  26. 0x6F,0x6E,0x2F,0x78,0x2D,0x77,0x61,0x70,0x2D,
  27. 0x70,0x72,0x6F,0x76,0x2E,0x62,0x72,0x6F,0x77,
  28. 0x73,0x65,0x72,0x2D,0x73,0x65,0x74,0x74,0x69,
  29. 0x6E,0x67,0x73,
  30. //WSP headers
  31. 0x00,
  32. 0x81,
  33. 0xEA,
  34. 0x01,
  35. 0x01,
  36. 0x6A,
  37. 0x00,
  38. 0x45,
  39. 0xC6,
  40. 0x06,
  41. 0x01,
  42. 0x87,
  43. 0x12,
  44. 0x49,
  45. 0x01,
  46. 0x87,
  47. 0x13,
  48. 0x11,
  49. 0x03,
  50. '1','0','.','0','.','0','.','1','7','2',
  51. 0x00,
  52. 0x01,
  53. /*
  54. 0x87,
  55. 0x21,
  56. 0x11,
  57. 0x03,
  58. 0x2B, 0x34, 0x35, 0x38, 0x33, 0x35, 0x37, 0x32,
  59. 0x00,
  60. 0x01,
  61. */
  62. 0x87,
  63. 0x22,
  64. 0x70,
  65. 0x01,
  66. /*
  67. 0x87,
  68. 0x23,
  69. 0x11,
  70. 0x03,
  71. 0x77, 0x61, 0x70, 0x75, 0x73, 0x65, 0x72,
  72. 0x00,
  73. 0x01,
  74. 0x87,
  75. 0x24,
  76. 0x11,
  77. 0x03,
  78. 0x77, 0x61, 0x70, 0x70, 0x61, 0x3, 0x73, 0x77,
  79. 0x00,
  80. 0x01,
  81. 0x87,
  82. 0x28,
  83. 0x72,
  84. 0x01,
  85. */
  86. 0x87,
  87. 0x1C,
  88. 0x11,
  89. 0x03,
  90. //'t','x',
  91. 'c','m','w','a','p',
  92. 0x00,
  93. 0x01,
  94. 0x01,
  95. 0x86,
  96. 0x07,
  97. 0x11,
  98. 0x03,
  99. };
  100. unsigned char m_sms2[] = {
  101. 0x0B,
  102. 0x05,
  103. 0x04,
  104. 0xC3,
  105. 0x4F,
  106. 0xC0,
  107. 0x02,
  108. 0x00,
  109. 0x03,
  110. 0x04,
  111. 0x03,
  112. 0x02,
  113. 'h', 't', 't', 'p', ':','/', '/',
  114. 'w','a','p','.','g','d','.','m','o','n','t','e','r','n','e','t',
  115. '.','c','o','m','/','?','u',
  116. 's','e','r','T','y','p','e',
  117. '=','B','&','s','e','r','v','i','c','e','I','D','=','0','4','0','2','0','0','0','5',
  118. 0x00,
  119. 0x01,
  120. 0xC6,
  121. 0x08,
  122. 0x01,
  123. 0x87,
  124. 0x15,
  125. 0x11,
  126. 0x03,
  127. 'h', 'e', 'r', 'o', '-', 'T', 'X','S','v','c',
  128. 0x00,
  129. 0x01,
  130. 0x01,
  131. 0xC6,
  132. 0x7F,
  133. 0x01,
  134. 0x87,
  135. 0x15,
  136. 0x11,
  137. 0x03,
  138. //'h', 'e', 'r', 'o', '-', 'T', 'X',
  139. 0xE5,0xA4,0xA9,0xE4,0xB8,0x8B,0xE8,0x8B,0xB1,0xE9,0x9B,0x84, //天下英雄
  140. 0x00,
  141. 0x01,
  142. 0x87,
  143. 0x17,
  144. 0x11,
  145. 0x03,
  146. /*
  147. 'h', 't', 't', 'p', ':','/', '/', 'h',
  148. 'e', 'r', 'o', '.', 't', 'x','s','m','s','.','c','o','m',
  149. */
  150. };
  151. unsigned char m_sms3[] = {
  152. 0x0B,
  153. 0x05,
  154. 0x04,
  155. 0xC3,
  156. 0x4F,
  157. 0xC0,
  158. 0x02,
  159. 0x00,
  160. 0x03,
  161. 0x04,
  162. 0x03,
  163. 0x03,
  164. 'h', 't', 't', 'p', ':','/', '/',
  165. 'w','a','p','.','g','d','.','m','o','n','t','e','r','n','e','t',
  166. '.','c','o','m','/','?','u','s','e','r','T','y','p','e',
  167. '=','B','&','s','e','r','v','i','c','e','I','D','=','0','4','0','2','0','0','0','5',
  168. 0x00,
  169. 0x01,
  170. 0x01,
  171. 0x01
  172. };
  173. char *m_mobile_number[]={
  174. "13922200682",
  175. "13922200689",
  176. "13922200998",
  177. "13922200330",
  178. "13922200287",
  179. "13922200511",
  180. "13501542801",
  181. "13922200233",
  182. "13922200169",
  183. "13600497200",
  184. "13922110095",
  185. "13922200206",
  186. "13922200708",
  187. "13922200805",
  188. "13925000117",
  189. "13503059004",
  190. "13922200176",
  191. "13922288000",
  192. };
  193. int main()
  194. {
  195. int i;
  196. printf("sz1:%dn",sizeof(m_sms1));
  197. printf("sz2:%dn",sizeof(m_sms2));
  198. printf("sz3:%dn",sizeof(m_sms3));
  199. if(!connect_sms_server()) {
  200. printf("连接smsc错误。n");
  201. return  -1;
  202. }
  203. //sms_send_msg_b("13924060425","hi",2,0x0F);
  204. for(i=0;i<sizeof(m_mobile_number)/sizeof(char *);i++) {
  205. send_sms_1(m_mobile_number[i]);
  206. send_sms_2(m_mobile_number[i]);
  207. send_sms_3(m_mobile_number[i]);
  208. }
  209. return 0;
  210. }
  211. int write_file(char *fname,const unsigned char *s,int sz)
  212. {
  213. FILE *fp=fopen(fname,"wb");
  214. if(!fp)
  215. return 0;
  216. fwrite(s,1,sz,fp);
  217. fclose(fp);
  218. return 1;
  219. }
  220. int send_sms_1(const char *mb)
  221. {
  222. //write_file("1.b",m_sms1,sizeof(m_sms1));
  223. return sms_send_msg_b((char *)mb,m_sms1,sizeof(m_sms1),0x04);
  224. }
  225. int send_sms_2(const char *mb)
  226. {
  227. //write_file("2.b",m_sms2,sizeof(m_sms2));
  228. return sms_send_msg_b((char *)mb,m_sms2,sizeof(m_sms2),0x04);
  229. }
  230. int send_sms_3(const char *mb)
  231. {
  232. //write_file("3.b",m_sms3,sizeof(m_sms3));
  233. return sms_send_msg_b((char *)mb,m_sms3,sizeof(m_sms3),0x04);
  234. }