GPS MODEM CONFIG.


/ Published in: C#
Save to your folder(s)

Configure program for CalAmp lmu-800 and skypatrol nitro gps avl , (works with every device who support AT Command)


Copy this code and paste it in your HTML
  1. /****************************************************************
  2.  * CONFIGURADOR DISPOSITIVOS AVT
  3.  * ------------------------------
  4.  *
  5.  * -MODELOS SOPORTADOS: CALAMP LMU-800 - SKYPATROL NITRO
  6.  * (Cualquier dispositivo que ocupe comandos AT)
  7.  * -CONFIGURA SEGUN APN,SERVIDOR Y MODELO
  8.  * -ENTREGA DIAGNOSTICO DE DISPOSITIVO Y DATOS GPS EN TIEMPO REAL
  9.  *
  10.  * TO DO:
  11.  * -------
  12.  * - !!!!CAMBIAR TEXTBOX MULTILINEA POR RICHTEXTBOX NAOO¡¡¡¡
  13.  * -ENVIAR COMANDOS UNICOS
  14.  * -MANEJO DE ERRORES EN SU TOTALIDAD (EVITAR CRASHING DE APLICACION)
  15.  * -CAPACIDAD DE LEER SCRIPT DE ARCHIVOS TXT
  16.  * -MODIFICAR APN (AGREGAR, QUITAR, MODIFICAR)
  17.  * -CAPACIDAD GUARDAR CONFIGURACION
  18.  * -EXTRAER INFORMACION DE FORMA LEGIBLE
  19.  * -FUNCIONALIDADES SEGUN REQUERIMIENTOS
  20.  *
  21.  * .-YEEEEEE-.
  22.  * ***************************************************************/
  23.  
  24. using System;
  25. using System.Threading;
  26. using System.Collections.Generic;
  27. using System.ComponentModel;
  28. using System.Data;
  29. using System.Drawing;
  30. using System.Linq;
  31. using System.Text;
  32. using System.IO.Ports;
  33. using System.Windows.Forms;
  34. using System.Timers;
  35.  
  36. namespace miauuu
  37. {
  38. public partial class MainForm : Form
  39. {
  40. /*INTERVALO COMANDOS AT
  41. *Un valor minimo de 600 ms puede producir problemas de comunicacion
  42. *al enviar comandos AT produciendose que los comandos
  43. *no lleguen completos al destino.
  44. *valor int intervalo = 600
  45. */
  46. int intervalo = 600;
  47.  
  48. SerialPort ComPort = new SerialPort();
  49.  
  50. public MainForm()
  51. {
  52. InitializeComponent();
  53.  
  54. //OBTENCION LISTA PUEROS COM
  55. string[] ArrayComPortsNames = null;
  56. int index = -1;
  57. string ComPortName = null;
  58.  
  59. ArrayComPortsNames = SerialPort.GetPortNames();
  60. do
  61. {
  62. index += 1;
  63. cboPorts.Items.Add(ArrayComPortsNames[index]);
  64. }
  65.  
  66. while (!((ArrayComPortsNames[index] == ComPortName)
  67. || (index == ArrayComPortsNames.GetUpperBound(0))));
  68. Array.Sort(ArrayComPortsNames);
  69.  
  70. //OBTENER PRIMER COM EN COMBOBOX
  71. if (index == ArrayComPortsNames.GetUpperBound(0))
  72. {
  73. ComPortName = ArrayComPortsNames[0];
  74. }
  75. cboPorts.Text = ArrayComPortsNames[0];
  76.  
  77. btnPortState.Enabled = true;
  78.  
  79. //LISTA APN
  80. cboApn.Items.Add("imovil.entelpcs.cl");
  81. cboApn.Items.Add("od1.korem2m.com;guest;1234");
  82. cboApn.Items.Add("data.m2mcloudconnect.com");
  83. cboApn.Text = cboApn.Items[0].ToString();
  84.  
  85. //MODELOS DE GPS SOPORTADOS
  86. cboModel.Items.Add("Calamp LMU-800");
  87. cboModel.Items.Add("Skypatrol Nitro");
  88. cboModel.Text = cboModel.Items[0].ToString();
  89.  
  90. //SERVIDORES GPS
  91. cboserver.Items.Add("StartrackLLC");
  92. cboserver.Items.Add("Gipisi");
  93. cboserver.Text = cboserver.Items[0].ToString();
  94.  
  95. //verificador de Timer en 3 (neutro)
  96. txtverifier.AppendText("3");
  97.  
  98. }
  99.  
  100. //BOTON CONECTAR PUERTO COM
  101. private void BtnPortStateClick(object sender, EventArgs e)
  102. {
  103. if (btnPortState.Text == "Conectar")
  104. {
  105. btnPortState.Text = "Desconectar";
  106. //configuracion permanente puerto COM y apertura
  107. ComPort.PortName = Convert.ToString(cboPorts.Text);
  108. ComPort.BaudRate = 115200;
  109. ComPort.DataBits = 8;
  110. ComPort.StopBits = StopBits.One;
  111. ComPort.Handshake = Handshake.None;
  112. ComPort.Parity = Parity.None;
  113. ComPort.Open();
  114. //habilitar controles de operacion y configuracion
  115. cboPorts.Enabled = false;
  116. btnatig.Enabled = true;
  117. btnatic.Enabled = true;
  118. button1.Enabled = true;
  119. cboModel.Enabled = true;
  120. cboApn.Enabled = true;
  121. cboserver.Enabled = true;
  122. chkupdate.Enabled = true;
  123. }
  124. else if (btnPortState.Text == "Desconectar")
  125. {
  126. btnPortState.Text = "Conectar";
  127. //apagar TIMER, cerrar puerto COM y deshabilitar controles de oper y conf
  128. timer1.Stop();
  129. chkupdate.Checked = false;
  130. ComPort.Close();
  131. cboPorts.Enabled = true;
  132. btnatig.Enabled = false;
  133. btnatic.Enabled = false;
  134. button1.Enabled= false;
  135. cboModel.Enabled = false;
  136. cboApn.Enabled = false;
  137. cboserver.Enabled = false;
  138. chkupdate.Enabled = false;
  139. }
  140. }
  141.  
  142. /*BOTON CONFIGURACION DE DISPOSITIVO
  143. *aca va el script integrado en el codigo del programa
  144. *se lee segun opciones elegidas.
  145. *TIMER se apaga al configurar y se activa automaticamente
  146. *al terminar configuracion CALAMP y se llena ProgressBar para indicar progreso
  147. **/
  148. private void Button1Click(object sender, EventArgs e)
  149. {
  150. progressBar1.Value = 0;
  151. button1.Text = "Configurando";
  152. //CONFIGURACION CALAMP STARTRACK - GIPISI
  153. if(cboModel.Text == "Calamp LMU-800")
  154. {
  155. chkupdate.Checked = false;
  156.  
  157. //Configuracion STARTRACK
  158. if(cboserver.Text == "StartrackLLC")
  159. {
  160. ComPort.WriteLine("ATS145=2\r");
  161. Thread.Sleep(intervalo);
  162. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  163. progressBar1.PerformStep();
  164. ComPort.WriteLine("ATS127=73\r");
  165. Thread.Sleep(intervalo);
  166. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  167. progressBar1.PerformStep();
  168. ComPort.WriteLine("ATS142=10\r");
  169. Thread.Sleep(intervalo);
  170. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  171. progressBar1.PerformStep();
  172. ComPort.WriteLine("ATS144=10 \r");
  173. Thread.Sleep(intervalo);
  174. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  175. progressBar1.PerformStep();
  176. ComPort.WriteLine("ATS156=1 \r");
  177. Thread.Sleep(intervalo);
  178. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  179. progressBar1.PerformStep();
  180. ComPort.WriteLine("ATS174=4\r");
  181. Thread.Sleep(intervalo);
  182. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  183. progressBar1.PerformStep();
  184. ComPort.WriteLine("at$app param 2319,0,206.71.179.75 \r");
  185. Thread.Sleep(intervalo);
  186. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  187. progressBar1.PerformStep();
  188. ComPort.WriteLine("at$app param 769,0,20509 \r");
  189. Thread.Sleep(intervalo);
  190. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  191. progressBar1.PerformStep();
  192. //LINEA QUE INDICA APN EN SCRIPT STARTRACK
  193. ComPort.WriteLine("AT$APP PARAM 2306,0," + cboApn.Text + "\r");
  194. Thread.Sleep(intervalo);
  195. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  196. progressBar1.PerformStep();
  197. ComPort.WriteLine("AT$APP PARAM 2314,0,web \r");
  198. Thread.Sleep(intervalo);
  199. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  200. progressBar1.PerformStep();
  201. ComPort.WriteLine("AT$APP PARAM 2315,0,web \r");
  202. Thread.Sleep(intervalo);
  203. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  204. progressBar1.PerformStep();
  205. ComPort.WriteLine("at$app param 2320,0,0 \r");
  206. Thread.Sleep(intervalo);
  207. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  208. progressBar1.PerformStep();
  209. ComPort.WriteLine("at$app param 2311,0,0 \r");
  210. Thread.Sleep(intervalo);
  211. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  212. progressBar1.PerformStep();
  213. ComPort.WriteLine("AT$APP PARAM 1035,0,139 \r");
  214. Thread.Sleep(intervalo);
  215. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  216. progressBar1.PerformStep();
  217. ComPort.WriteLine("AT$APP PARAM 257,0,2778 \r");
  218. Thread.Sleep(intervalo);
  219. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  220. progressBar1.PerformStep();
  221. ComPort.WriteLine("AT$APP PARAM 258,0,10 \r");
  222. Thread.Sleep(intervalo);
  223. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  224. progressBar1.PerformStep();
  225. ComPort.WriteLine("AT$APP PARAM 262,0,0 \r");
  226. Thread.Sleep(intervalo);
  227. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  228. progressBar1.PerformStep();
  229. ComPort.WriteLine("AT$APP PARAM 263,0,0 \r");
  230. Thread.Sleep(intervalo);
  231. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  232. progressBar1.PerformStep();
  233. ComPort.WriteLine("AT$APP PARAM 264,0,45 \r");
  234. Thread.Sleep(intervalo);
  235. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  236. progressBar1.PerformStep();
  237. ComPort.WriteLine("AT$APP PARAM 265,0,180 \r");
  238. Thread.Sleep(intervalo);
  239. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  240. progressBar1.PerformStep();
  241. ComPort.WriteLine("AT$APP PARAM 265,1,43200 \r");
  242. Thread.Sleep(intervalo);
  243. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  244. progressBar1.PerformStep();
  245. ComPort.WriteLine("AT$APP PARAM 265,14,43200 \r");
  246. Thread.Sleep(intervalo);
  247. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  248. progressBar1.PerformStep();
  249. ComPort.WriteLine("AT$APP PARAM 265,15,10 \r");
  250. Thread.Sleep(intervalo);
  251. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  252. progressBar1.PerformStep();
  253. ComPort.WriteLine("AT$APP PARAM 512,0,15,0,0,0,1,3,0,0 \r");
  254. Thread.Sleep(intervalo);
  255. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  256. progressBar1.PerformStep();
  257. ComPort.WriteLine("AT$APP PARAM 512,1,16,0,0,0,1,2,0,0 \r");
  258. Thread.Sleep(intervalo);
  259. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  260. progressBar1.PerformStep();
  261. ComPort.WriteLine("AT$APP PARAM 512,2,15,0,0,0,30,1,0,0 \r");
  262. Thread.Sleep(intervalo);
  263. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  264. progressBar1.PerformStep();
  265. ComPort.WriteLine("AT$APP PARAM 512,3,15,0,0,0,13,0,0,0 \r");
  266. Thread.Sleep(intervalo);
  267. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  268. progressBar1.PerformStep();
  269. ComPort.WriteLine("AT$APP PARAM 512,4,16,0,0,0,30,0,0,0 \r");
  270. Thread.Sleep(intervalo);
  271. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  272. progressBar1.PerformStep();
  273. ComPort.WriteLine("AT$APP PARAM 512,5,16,0,0,0,13,1,0,0 \r");
  274. Thread.Sleep(intervalo);
  275. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  276. progressBar1.PerformStep();
  277. ComPort.WriteLine("AT$APP PARAM 512,6,18,0,0,0,13,0,0,0 \r");
  278. Thread.Sleep(intervalo);
  279. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  280. progressBar1.PerformStep();
  281. ComPort.WriteLine("AT$APP PARAM 512,7,18,1,0,0,13,1,0,0 \r");
  282. Thread.Sleep(intervalo);
  283. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  284. progressBar1.PerformStep();
  285. ComPort.WriteLine("AT$APP PARAM 512,8,3,0,0,0,7,0,0,0 \r");
  286. Thread.Sleep(intervalo);
  287. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  288. progressBar1.PerformStep();
  289. ComPort.WriteLine("AT$APP PARAM 512,9,3,0,0,0,13,1,0,0 \r");
  290. Thread.Sleep(intervalo);
  291. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  292. progressBar1.PerformStep();
  293. ComPort.WriteLine("AT$APP PARAM 512,10,17,0,0,0,1,0,0,0 \r");
  294. Thread.Sleep(intervalo);
  295. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  296. progressBar1.PerformStep();
  297. ComPort.WriteLine("AT$APP PARAM 512,11,18,0,0,0,1,0,0,0 \r");
  298. Thread.Sleep(intervalo);
  299. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  300. progressBar1.PerformStep();
  301. ComPort.WriteLine("AT$APP PARAM 512,12,18,1,0,0,1,13,0,0 \r");
  302. Thread.Sleep(intervalo);
  303. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  304. progressBar1.PerformStep();
  305. ComPort.WriteLine("AT$APP PARAM 512,13,7,0,0,0,1,7,0,0 \r");
  306. Thread.Sleep(intervalo);
  307. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  308. progressBar1.PerformStep();
  309. ComPort.WriteLine("AT$APP PARAM 512,14,42,0,2,0,1,26,0,0 \r");
  310. Thread.Sleep(intervalo);
  311. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  312. progressBar1.PerformStep();
  313. ComPort.WriteLine("AT$APP PARAM 512,15,3,0,0,0,13,3,0,0 \r");
  314. Thread.Sleep(intervalo);
  315. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  316. progressBar1.PerformStep();
  317. ComPort.WriteLine("AT$APP PARAM 512,16,18,3,0,0,38,0,0,0 \r");
  318. Thread.Sleep(intervalo);
  319. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  320. ComPort.WriteLine("AT$APP PARAM 512,17,18,3,0,0,13,4,0,0 \r");
  321. progressBar1.PerformStep();
  322. Thread.Sleep(intervalo);
  323. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  324. ComPort.WriteLine("AT$APP PARAM 512,18,18,4,0,0,37,0,0,0 \r");
  325. Thread.Sleep(intervalo);
  326. progressBar1.PerformStep();
  327. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  328. ComPort.WriteLine("AT$APP PARAM 512,19,4,5,0,0,1,10,0,0 \r");
  329. Thread.Sleep(intervalo);
  330. progressBar1.PerformStep();
  331. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  332. ComPort.WriteLine("AT$APP PARAM 512,20,5,5,0,0,1,12,0,0 \r");
  333. Thread.Sleep(intervalo);
  334. progressBar1.PerformStep();
  335. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  336. ComPort.WriteLine("AT$APP PARAM 512,21,4,1,0,0,1,11,0,0 \r");
  337. Thread.Sleep(intervalo);
  338. progressBar1.PerformStep();
  339. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  340. ComPort.WriteLine("AT$APP PARAM 512,22,4,2,0,0,1,8,0,0 \r");
  341. Thread.Sleep(intervalo);
  342. progressBar1.PerformStep();
  343. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  344. ComPort.WriteLine("AT$APP PARAM 512,23,5,2,0,0,1,9,0,0 \r");
  345. Thread.Sleep(intervalo);
  346. progressBar1.PerformStep();
  347. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  348. ComPort.WriteLine("AT$APP PARAM 512,24,5,3,0,0,1,41,0,0 \r");
  349. Thread.Sleep(intervalo);
  350. progressBar1.PerformStep();
  351. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  352. ComPort.WriteLine("AT$APP PARAM 512,25,4,3,0,0,1,40,0,0 \r");
  353. Thread.Sleep(intervalo);
  354. progressBar1.PerformStep();
  355. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  356. ComPort.WriteLine("AT$APP PARAM 2313,0,60 \r");
  357. Thread.Sleep(intervalo);
  358. progressBar1.PerformStep();
  359. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  360. ComPort.WriteLine("AT$APP PARAM 771,0,20 \r");
  361. Thread.Sleep(intervalo);
  362. progressBar1.PerformStep();
  363. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  364. ComPort.WriteLine("AT$APP PARAM 771,1,40 \r");
  365. Thread.Sleep(intervalo);
  366. progressBar1.PerformStep();
  367. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  368. ComPort.WriteLine("AT$APP PARAM 771,2,60 \r");
  369. Thread.Sleep(intervalo);
  370. progressBar1.PerformStep();
  371. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  372. ComPort.WriteLine("AT$APP PARAM 771,3,90 \r");
  373. Thread.Sleep(intervalo);
  374. progressBar1.PerformStep();
  375. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  376. ComPort.WriteLine("AT$APP PARAM 771,4,120 \r");
  377. Thread.Sleep(intervalo);
  378. progressBar1.PerformStep();
  379. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  380. ComPort.WriteLine("AT$APP PARAM 771,5,150 \r");
  381. Thread.Sleep(intervalo);
  382. progressBar1.PerformStep();
  383. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  384. ComPort.WriteLine("AT$APP PARAM 270,0,5 \r");
  385. Thread.Sleep(intervalo);
  386. progressBar1.PerformStep();
  387. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  388. ComPort.WriteLine("AT$APP PARAM 271,0,3 \r");
  389. Thread.Sleep(intervalo);
  390. progressBar1.PerformStep();
  391. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  392. ComPort.WriteLine("AT$APP PARAM 272,0,3 \r");
  393. Thread.Sleep(intervalo);
  394. progressBar1.PerformStep();
  395. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  396. ComPort.WriteLine("AT$APP PARAM 270,5,5 \r");
  397. Thread.Sleep(intervalo);
  398. progressBar1.PerformStep();
  399. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  400. ComPort.WriteLine("AT$APP PARAM 271,5,3 \r");
  401. Thread.Sleep(intervalo);
  402. progressBar1.PerformStep();
  403. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  404. ComPort.WriteLine("AT$APP PARAM 272,5,3 \r");
  405. Thread.Sleep(intervalo);
  406. progressBar1.PerformStep();
  407. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  408. ComPort.WriteLine("atreset \r");
  409. Thread.Sleep(intervalo);
  410. progressBar1.PerformStep();
  411. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  412. outputbox.AppendText("\n");
  413. outputbox.AppendText("\n");
  414. outputbox.AppendText("\n---yeyeyeyeee---");
  415. received.Clear();
  416. //SE ACTUALIZA INFORMACION ATIC AUTOMATICAMENTE Y SE ENCIENDE TIMER
  417. txtverifier.Text = "0";
  418. ComPort.WriteLine("atic\r");
  419. Thread.Sleep(intervalo);
  420. received.AppendText(ComPort.ReadExisting() + "");
  421. Thread.Sleep(intervalo);
  422. chkupdate.Checked = true;
  423. }
  424. else if (cboserver.Text == "Gipisi")
  425. {
  426. //Configuracion GIPISI
  427. ComPort.WriteLine("AT$APP PARAM 2319,0,rastreo.gipisi.com \r");
  428. Thread.Sleep(intervalo);
  429. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  430. ComPort.WriteLine("AT$APP PARAM 769,0,10500 \r");
  431. Thread.Sleep(intervalo);
  432. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  433. ComPort.WriteLine("AT$APP PARAM 774,0,10500 \r");
  434. Thread.Sleep(intervalo);
  435. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  436. ComPort.WriteLine("AT$APP PARAM 2313,0,300 \r");
  437. Thread.Sleep(intervalo);
  438. /*Debido a mayor numero de lineas al configurar APN en GIPISI
  439. *se opta por SWITCH CASE uno por cada APN a utiliza*/
  440. switch (cboApn.SelectedIndex)
  441. {
  442. case 0: //ENTEL
  443. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  444. ComPort.WriteLine("AT$APP PARAM 2306,0,\"imovil.entelpcs.cl\" \r");
  445. Thread.Sleep(intervalo);
  446. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  447. ComPort.WriteLine("AT$APP PARAM 2314,0,\"\" \r");
  448. Thread.Sleep(intervalo);
  449. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  450. ComPort.WriteLine("AT$APP PARAM 2315,0,\"\" \r");
  451. Thread.Sleep(intervalo);
  452. break;
  453.  
  454. case 1: //KORE AUS
  455. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  456. ComPort.WriteLine("AT$APP PARAM 2306,0,\"od1.korem2m.com\" \r");
  457. Thread.Sleep(intervalo);
  458. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  459. ComPort.WriteLine("AT$APP PARAM 2314,0,\"guest\" \r");
  460. Thread.Sleep(intervalo);
  461. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  462. ComPort.WriteLine("AT$APP PARAM 2315,0," + "\"1234\"" + " \r");
  463. Thread.Sleep(intervalo);
  464. break;
  465. case 2: //VODAFONE
  466. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  467. ComPort.WriteLine("AT$APP PARAM 2306,0,\"data.m2mcloudconnect.com\" \r");
  468. Thread.Sleep(intervalo);
  469. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  470. ComPort.WriteLine("AT$APP PARAM 2314,0,\"\" \r");
  471. Thread.Sleep(intervalo);
  472. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  473. ComPort.WriteLine("AT$APP PARAM 2315,0,\"\" \r");
  474. Thread.Sleep(intervalo);
  475. break;
  476. }
  477. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  478. ComPort.WriteLine("ATS145=2 \r");
  479. Thread.Sleep(intervalo);
  480. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  481. ComPort.WriteLine("AT$APP PARAM 1035,0,139 \r");
  482. Thread.Sleep(intervalo);
  483. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  484. ComPort.WriteLine("AT$APP PARAM 262,0,0 \r");
  485. Thread.Sleep(intervalo);
  486. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  487. ComPort.WriteLine("AT$APP PARAM 263,0,1000 \r");
  488. Thread.Sleep(intervalo);
  489. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  490. ComPort.WriteLine("AT$APP PARAM 264,0,40 \r");
  491. Thread.Sleep(intervalo);
  492. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  493. ComPort.WriteLine("AT$APP PARAM 265,0,60 \r");
  494. Thread.Sleep(intervalo);
  495. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  496. ComPort.WriteLine("AT$APP PARAM 265,1,1200 \r");
  497. Thread.Sleep(intervalo);
  498. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  499. ComPort.WriteLine("AT$APP PARAM 265,2,300 \r");
  500. Thread.Sleep(intervalo);
  501. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  502. ComPort.WriteLine("AT$APP PARAM 265,3,0 \r");
  503. Thread.Sleep(intervalo);
  504. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  505. ComPort.WriteLine("AT$APP PARAM 265,4,10 \r");
  506. Thread.Sleep(intervalo);
  507. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  508. ComPort.WriteLine("AT$APP PARAM 265,5,60 \r");
  509. Thread.Sleep(intervalo);
  510. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  511. ComPort.WriteLine("AT$APP PARAM 265,14,43200 \r");
  512. Thread.Sleep(intervalo);
  513. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  514. ComPort.WriteLine("AT$APP PARAM 265,15,10 \r");
  515. Thread.Sleep(intervalo);
  516. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  517. ComPort.WriteLine("ATS160=50 \r");
  518. Thread.Sleep(intervalo);
  519. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  520. ComPort.WriteLine("ATS161=17 \r");
  521. Thread.Sleep(intervalo);
  522. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  523. ComPort.WriteLine("AT$APP PARAM 257,0,2777 \r");
  524. Thread.Sleep(intervalo);
  525. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  526. ComPort.WriteLine("AT$APP PARAM 258,0,2 \r");
  527. Thread.Sleep(intervalo);
  528. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  529. ComPort.WriteLine("AT$APP PARAM 259,0,5 \r");
  530. Thread.Sleep(intervalo);
  531. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  532. ComPort.WriteLine("AT$APP PARAM 260,0,5 \r");
  533. Thread.Sleep(intervalo);
  534. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  535. ComPort.WriteLine("AT$APP PARAM 1029,0,255,7 \r");
  536. Thread.Sleep(intervalo);
  537. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  538. ComPort.WriteLine("AT$APP PARAM 512,0,15,0,0,0,1,3,0,0 \r");
  539. Thread.Sleep(intervalo);
  540. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  541. ComPort.WriteLine("AT$APP PARAM 512,1,16,0,0,0,1,2,0,0 \r");
  542. Thread.Sleep(intervalo);
  543. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  544. ComPort.WriteLine("AT$APP PARAM 512,2,43,0,0,0,13,0,0,0 \r");
  545. Thread.Sleep(intervalo);
  546. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  547. ComPort.WriteLine("AT$APP PARAM 512,3,42,0,0,0,30,0,0,0 \r");
  548. Thread.Sleep(intervalo);
  549. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  550. ComPort.WriteLine("AT$APP PARAM 512,4,42,0,0,0,31,0,0,0 \r");
  551. Thread.Sleep(intervalo);
  552. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  553. ComPort.WriteLine("AT$APP PARAM 512,5,18,16,0,0,1,1,0,0 \r");
  554. Thread.Sleep(intervalo);
  555. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  556. ComPort.WriteLine("AT$APP PARAM 512,6,18,16,0,0,30,0,0,0 \r");
  557. Thread.Sleep(intervalo);
  558. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  559. ComPort.WriteLine("AT$APP PARAM 512,7,18,16,0,0,32,0,0,0 \r");
  560. Thread.Sleep(intervalo);
  561. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  562. ComPort.WriteLine("AT$APP PARAM 512,8,14,0,0,0,13,5,0,0 \r");
  563. Thread.Sleep(intervalo);
  564. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  565. ComPort.WriteLine("AT$APP PARAM 512,9,18,5,0,0,13,1,0,0 \r");
  566. Thread.Sleep(intervalo);
  567. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  568. ComPort.WriteLine("AT$APP PARAM 512,10,18,5,0,0,31,1,0,0 \r");
  569. Thread.Sleep(intervalo);
  570. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  571. ComPort.WriteLine("AT$APP PARAM 512,11,18,5,0,0,1,32,0,0 \r");
  572. Thread.Sleep(intervalo);
  573. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  574. ComPort.WriteLine("AT$APP PARAM 512,12,18,5,0,0,30,5,0,0 \r");
  575. Thread.Sleep(intervalo);
  576. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  577. ComPort.WriteLine("AT$APP PARAM 512,13,13,0,16,1,1,33,0,0 \r");
  578. Thread.Sleep(intervalo);
  579. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  580. ComPort.WriteLine("AT$APP PARAM 512,14,13,0,0,0,30,5,0,0 \r");
  581. Thread.Sleep(intervalo);
  582. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  583. ComPort.WriteLine("AT$APP PARAM 512,15,13,0,16,1,30,1,0,0 \r");
  584. Thread.Sleep(intervalo);
  585. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  586. ComPort.WriteLine("AT$APP PARAM 512,16,18,1,16,1,70,0,0,0 \r");
  587. Thread.Sleep(intervalo);
  588. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  589. ComPort.WriteLine("AT$APP PARAM 512,17,4,3,0,0,1,10,0,0 \r");
  590. Thread.Sleep(intervalo);
  591. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  592. ComPort.WriteLine("AT$APP PARAM 512,18,5,3,0,0,1,12,0,0 \r");
  593. Thread.Sleep(intervalo);
  594. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  595. ComPort.WriteLine("AT$APP PARAM 512,19,4,4,0,0,1,46,0,0 \r");
  596. Thread.Sleep(intervalo);
  597. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  598. ComPort.WriteLine("AT$APP PARAM 512,20,5,1,0,0,1,11,0,0 \r");
  599. Thread.Sleep(intervalo);
  600. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  601. ComPort.WriteLine("AT$APP PARAM 512,21,42,0,2,0,13,4,0,0 \r");
  602. Thread.Sleep(intervalo);
  603. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  604. ComPort.WriteLine("AT$APP PARAM 512,22,18,4,3,0,1,26,0,0 \r");
  605. Thread.Sleep(intervalo);
  606. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  607. ComPort.WriteLine("AT$APP PARAM 512,23,43,0,2,0,30,4,0,0 \r");
  608. Thread.Sleep(intervalo);
  609. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  610. ComPort.WriteLine("AT$APP PARAM 512,24,3,0,0,0,7,0,0,0 \r");
  611. Thread.Sleep(intervalo);
  612. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  613. ComPort.WriteLine("AT$APP PARAM 512,25,17,0,0,0,1,0,0,0 \r");
  614. Thread.Sleep(intervalo);
  615. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  616. ComPort.WriteLine("AT$APP PARAM 512,26,41,100,1,0,1,0,0,0 \r");
  617. Thread.Sleep(intervalo);
  618. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  619. ComPort.WriteLine("AT$APP PARAM 512,27,70,1,0,0,1,57,0,0 \r");
  620. Thread.Sleep(intervalo);
  621. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  622. ComPort.WriteLine("AT$APP PARAM 512,28,7,1,0,0,1,7,0,0 \r");
  623. Thread.Sleep(intervalo);
  624. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  625. ComPort.WriteLine("AT$APP PARAM 512,29,16,0,0,0,13,2,0,0 \r");
  626. Thread.Sleep(intervalo);
  627. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  628. ComPort.WriteLine("AT$APP PARAM 512,30,15,0,0,0,30,2,0,0 \r");
  629. Thread.Sleep(intervalo);
  630. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  631. ComPort.WriteLine("AT$APP PARAM 512,31,18,2,2,0,22,3,0,0 \r");
  632. Thread.Sleep(intervalo);
  633. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  634. ComPort.WriteLine("AT$APP PARAM 512,95,3,0,0,0,13,14,0,0 \r");
  635. Thread.Sleep(intervalo);
  636. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  637. ComPort.WriteLine("AT$APP PARAM 512,96,18,14,0,0,38,0,0,0 \r");
  638. Thread.Sleep(intervalo);
  639. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  640. ComPort.WriteLine("AT$APP PARAM 512,97,18,14,0,0,13,15,0,0 \r");
  641. Thread.Sleep(intervalo);
  642. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  643. ComPort.WriteLine("AT$APP PARAM 512,98,18,15,0,0,37,0,0,0 \r");
  644. Thread.Sleep(intervalo);
  645. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  646. ComPort.WriteLine("AT$APP REBOOT \r");
  647. Thread.Sleep(1200);
  648. outputbox.AppendText(ComPort.ReadExisting() + "\n");
  649. outputbox.AppendText("\n");
  650. outputbox.AppendText("\n");
  651. outputbox.AppendText("\n---yeyeyeyeee---");
  652. received.Clear();
  653. //SE ACTUALIZA INFORMACION ATIC AUTOMATICAMENTE Y SE ENCIENDE TIMER
  654. txtverifier.Text = "0";
  655. ComPort.WriteLine("atic\r");
  656. Thread.Sleep(intervalo);
  657. received.AppendText(ComPort.ReadExisting() + "");
  658. Thread.Sleep(intervalo);
  659. chkupdate.Checked = true;
  660. }
  661. }
  662. else if (cboModel.Text == "Skypatrol Nitro")
  663. //FALTA AGREGAR SCRIPT SKYPATROL NITRO (seleccion sirve para probar cosas)
  664. {
  665. outputbox.AppendText("Falta probar script skypatrol :(\n");
  666. /*switch (cboApn.SelectedIndex)
  667. {
  668. case 0:
  669. outputbox.AppendText(cboApn.Text);
  670. break;
  671.  
  672. case 1:
  673. outputbox.AppendText(cboApn.Text);
  674. break;
  675. }*/
  676. }
  677.  
  678. button1.Text = "Configurar";
  679. }
  680.  
  681. //BOTON ATIC PARA OBTENER INFORMACION DE DISPOSITIVO CALAMP LMU-800
  682. void BtnaticClick(object sender, EventArgs e)
  683. {
  684. //Verificador de TIMER se establece en "0" (indicando ATIC activo al timer)
  685. txtverifier.Text = "0";
  686. received.Clear();
  687. ComPort.WriteLine("atic\r");
  688. Thread.Sleep(intervalo);
  689. received.AppendText(ComPort.ReadExisting() + "");
  690. }
  691.  
  692. //BOTON ATIG PARA OBTENER DATOS DEL RECEPTOR GPS DISPOSITIVO CALAMP LMU-800
  693. void BtnatigClick(object sender, EventArgs e)
  694. {
  695. //Verificador de TIMER se establece en "1" (indicando ATIG activo al timer)
  696. txtverifier.Text = "1";
  697. received.Clear();
  698. ComPort.WriteLine("atig\r");
  699. Thread.Sleep(intervalo);
  700. received.AppendText(ComPort.ReadExisting() + "");
  701. }
  702.  
  703. //CONTROL TIMER PARA ACTUALIZACION EN TIEMPO REAL DATOS DISPOSITIVO GPS
  704. void Timer1Tick(object sender, EventArgs e)
  705. {
  706. /*TIMER verifica si txtverifier contiene "0" o "1" segun sea el caso
  707. *actualiza ATIG o ATIC cada 1600 milisegundos (definido x chkupdate)
  708. *TIMER se apaga al enviar configuracion y al desconectar puerto COM
  709. * 0 = atic
  710. * 1 = atig
  711. * 3 = timer sin operar*/
  712. if (txtverifier.Text == "0")
  713. {
  714. received.Clear();
  715. ComPort.WriteLine("atic\r");
  716. Thread.Sleep(intervalo);
  717. received.AppendText(ComPort.ReadExisting() + "");
  718. }
  719. else if (txtverifier.Text == "1")
  720. {
  721. received.Clear();
  722. ComPort.WriteLine("atig\r");
  723. Thread.Sleep(intervalo);
  724. received.AppendText(ComPort.ReadExisting() + "");
  725. }
  726. }
  727.  
  728. //CHECKBOX DE ACTUALIZACION EN TIEMPO REAL
  729. void ChkupdateCheckedChanged(object sender, EventArgs e)
  730. {
  731. /*Si CHKUPDATE esta marcado entonces enciende TIMER y actualiza datos
  732.  * *segun marcador TXTVERIFIER cada 1600 milisegundos
  733. *Si CHKUPDATE esta desmarcado entonces apaga TIMER.
  734. * */
  735. if (chkupdate.Checked == true)
  736. {
  737. timer1.Interval = 1600 ;
  738. timer1.Start();
  739. }
  740. if (chkupdate.Checked == false)
  741. {
  742. timer1.Stop();
  743. }
  744. }
  745.  
  746. //LIMPIAR REGISTRO OUTPUTBOX (ventana configuracion)
  747. void Button2Click(object sender, EventArgs e)
  748. {
  749. outputbox.Clear();
  750. progressBar1.Value = 0;
  751.  
  752. }
  753.  
  754. //CIERRA LA APLICACION COMO SE DEBE (detiene TIMER, cierra puerto COM)
  755. void BtnexitClick(object sender, System.EventArgs e)
  756. {
  757. timer1.Stop();
  758. cboPorts.Enabled = false;
  759. btnatig.Enabled = false;
  760. btnatic.Enabled = false;
  761. button1.Enabled = false;
  762. cboModel.Enabled = false;
  763. cboApn.Enabled = false;
  764. cboserver.Enabled = false;
  765. chkupdate.Enabled = false;
  766.  
  767. if(ComPort.IsOpen == true)
  768. {
  769. progressBar1.Value = 0;
  770. progressBar1.Maximum = 90;
  771. progressBar1.Step = 30;
  772. received.Clear();
  773. received.AppendText("...CERRANDO PUERTO COM...");
  774. Thread.Sleep(300);
  775. progressBar1.PerformStep();
  776. received.AppendText("\n");
  777. Thread.Sleep(300);
  778. progressBar1.PerformStep();
  779. received.AppendText("\n");
  780. Thread.Sleep(300);//500
  781. progressBar1.PerformStep();
  782. ComPort.Close();
  783. received.AppendText("....SALIENDO....");
  784. Thread.Sleep(300);
  785. }
  786. else
  787. {
  788. received.Clear();
  789. received.AppendText("....SALIENDO....");
  790. Thread.Sleep(300);
  791. }
  792. Close();
  793. }
  794.  
  795. }
  796. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.