Advertisement
Guest User

Untitled

a guest
May 18th, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.18 KB | None | 0 0
  1. ========
  2. OUTPUT
  3. ========
  4. Print 1
  5. e[0]=453768097,57,0,18,0,0,0,12.05,1,0,29.38,1,3,0.000000,0.000000,0,0&e[1]=453768097,280,0,18,0,0,0,12.05,1,0,29.38,1,4,0.000000,0.000000,0,0&e[2]=453768103,260,0,25,0,0,0,12.07,1,0,29.38,1,5,0.000000,0.000000,0,0&e[3]=453768133,260,0,52,1,0,0,12.07,1,0,29.38,1,6,0.000000,0.000000,0,0&e[4]=453768163,260,0,79,1,0,0,12.05,1,0,29.44,1,7,0.000000,0.000000,0,0&e[5]=453768194,260,0,107,2,0,0,12.07,1,0,29.44,1,8,51.823174,-2.274259,8,296&e[6]=453768224,260,0,134,2,0,0,12.07,1,0,29.44,1,9,51.823135,-2.274335,7,302&e[7]=453768254,260,0,161,3,0,0,12.07,1,0,29.50,1,10,51.823219,-2.274303,7,306&e[8]=453768284,260,0,189,3,0,0,12.05,1,0,29.44,1,11,51.823204,-2.274276,8,301&e[9]=453768300,250,0,203,3,0,0,12.05,1,0,29.38,1,12,51.823185,-2.274290,7,294&e[10]=453768314,260,0,216,4,0,0,12.08,1,0,29.38,1,13,51.823196,-2.274289,7,303&e[113,3,0,0,12.05,1,0,29.38,1,12,51.823185,-2.274290,7,294&e[10]=453768314,260,0,216,4,0,0,12.08,1,0,29.38,1,13,51.8239,-.728,,33e11]=453768344,260,0,243,4,0,0,12.07,1,0,29.38,1,14,51.823254,-2.274278,8,295&e[12]=453768374,260,0,270,5,0,0,12.07,1,0,29.38,1,15,51.823185,-2.274331,6,307&e[13]=453768404,260,0,298,5,0,0,12.07,1,0,29.38,1,16,51.823303,-2.274270,7,307&e[14]=453768434,260,0,325,6,0,0,1254,-2.27428,,25e12=53634,6,020,,,,1.7,,,9.81,5518385-.7431607e[3=53680,60029,,,01.0,,,2.8,,6518233-22420730&[1]437834200,2,60012.05,1,0,29.50,1,17,51.823174,-2.274287,6,311&e[15]=453768464,260,0,352,6,0,0,12.05,1,0,29.50,1,18,51.823112,-2.274347,8,301&e[16]=453768494,260,0,379,7,0,0,12.07,1,0,29.50,1,19,51.823132,-2.274336,8,303&e[17]=453768524,260,0,407,7,0,0,12.07,1,0,29.50,1,20,51.823166,-2.274347,8,302&e[18]=453768552,210,1,433,7,0,0,12.07,1,0,29.50,1,4378,0&[1]45789,6,039,,,,1.7,,,9.01,9518312-.2436830&[7]43782,200,0,,00120,,02.5,,0,1821,-.734,,32e18=43655,10143,,,01.7,,,2.01,21,51.823132,-2.274286,7,1167&e[19]=453768554,260,2,434,8,0,0,12.03,1,0,29.50,1,22,51.823135,-2.274290,7,508&e[20]=453768555,220,0,435,8,0,0,12.07,1,0,29.50,1,23,51.823132,-2.274286,7,402&e[21]=453768555,270,0,435,8,0,0,12.07,1,0,29.50,1,24,51.823132,-2.274286,7,425&
  6.  
  7. Print 2
  8. e[0]=453768097,57,0,18,0,0,0,12.05,1,0,29.38,1,3,0.000000,0.000000,0,0&e[1]=453768097,280,0,18,0,0,0,12.05,1,0,29.38,1,4,0.000000,0.000000,0,0&e[2]=453768103,260,0,25,0,0,0,12.07,1,0,29.38,1,5,0.000000,0.000000,0,0&e[3]=453768133,260,0,52,1,0,0,12.07,1,0,29.38,1,6,0.000000,0.000000,0,0&e[4]=453768163,260,0,79,1,0,0,12.05,1,0,29.44,1,7,0.000000,0.000000,0,0&e[5]=453768194,260,0,107,2,0,0,12.07,1,0,29.44,1,8,51.823174,-2.274259,8,296&e[6]=453768224,260,0,134,2,0,0,12.07,1,0,29.44,1,9,51.823135,-2.274335,7,302&e[7]=453768254,260,0,161,3,0,0,12.07,1,0,29.50,1,10,51.823219,-2.274303,7,306&e[8]=453768284,260,0,189,3,0,0,12.05,1,0,29.44,1,11,51.823204,-2.274276,8,3,0,161,3,0,0,12.07,1,0,29.50,1,10,51.823219,-2.274303,7,306&e[8]=453768284,260,0,189,3,0,0,12.05,1,0,29.44,1,11,51.8230,-2747,,301&e[9]=453768300,250,0,203,3,0,0,12.05,1,0,29.38,1,12,51.823185,-2.274290,7,294&e[10]=453768314,260,0,216,4,0,0,12.08,1,0,29.38,1,13,51.823196,-2.274289,7,303&e[11]=453768344,260,0,243,4,0,0,12.0300,250,0,203,3,0,0,12.05,1,0,29.38,1,12,51.823185,-22490729&[0]45781420,,1,400,20,10293,,1,1.216,2.729,,03e1]=5763426024,,001.07,1,0,29.38,1,14,51.823254,-2.274278,8,295&e[12]=453768374,260,0,270,5,0,0,12.07,1,0,29.38,1,15,5293,,1,1.216,2.729,,03e1]=5763426024,,001.07,1,0,29.38,1,14,51.823254,-2.274278,8,295&e[12]=453768374,260,0,27,500127,10298,11,51.823185,-2.274331,6,307&e[13]=453768404,260,0,298,5,0,0,12.07,1,0,29.38,1,16,51.823303,-2.274270,7,307&e[14]=453768434,2674,260,0,27,500127,10298,11,51.823185,-2.274331,6,307&e[13]=453768404,260,0,298,5,0,0,12.07,1,0293,11,5.230,2.720,,07e1]=57644260,0,325,6,0,0,12.05,1,0,29.50,1,17,51.823174,-2.274287,6,311&e[15]=453768464,260,0,352,6,0,0,12.05,1,0,29.50,1,18,51.823112,-2.274347,8,301&e[16]=453768494,260,0,379,7,0,0,12.07,1,0,29.50,1,19,51.823132,-2.274336,8,303&e[17]=453768524,260,0,407,7,0,0,12.07,1,0,29.50,1,20,51.823166,-2.274347,8,302&e[18]=453768552,210,1,433,7,0,0,12.07,1,0,29.50,1,21,51.823132,-2.274286,7,1167&e[19]=453768554,260,2,434,8,0,0,12.03,1,0,29.50,1,22,51.823135,-2.274290,7,508&e[20]=453768555,220,0,435,8,0,0,12.07,1,0,29.50,1,23,51.823132,-2.274286,7,402&e[21]=453768555,270,0,435,8,0,0,12.07,1,0,29.50,1,24,51.823132,-2.274286,7,425&
  9.  
  10. Print 3
  11. e[0]=453768097,57,0,18,0,0,0,12.05,1,0,29.38,1,3,0.000000,0.000000,0,0&e[1]=453768097,280,0,18,0,0,0,12.05,1,0,29.38,1,4,0.000000,0.000000,0,0&e[2]=453768103,260,0,25,0,0,0,12.07,1,0,29.38,1,5,0.000000,0.000000,0,0&e[3]=453768133,260,0,52,1,0,0,12.07,1,0,29.38,1,6,0.000000,0.000000,0,0&e[4]=453768163,260,0,79,1,0,0,12.05,1,0,29.44,1,7,0.000000,0.000000,0,0&e[5]=453768194,2,12.07,1,0,29.38,1,6,0.000000,0.000000,0,0&e[4]=453768163,260,0,79,1,0,0,12.05,1,0,29.44,1,7,0.000000,0.000000,0,0&e[5]=453789,260,0,107,2,0,0,12.07,1,0,29.44,1,8,51.823174,-2.274259,8,296&e[6]=453768224,260,0,134,2,0,0,12.07,1,0,29.44,1,9,51.823135,-2.274335,7,302&e[7]=453768254,260,0,161,3,0,0,12.07,1,0,29.50,1,10,51.8232112.07,1,0,29.44,1,8,51.823174,-2.274259,8,296&e[6]=43622,60014,,,01.7,,,2.41,,1.215,2.735732&[]=5782426,,6130,,20710,95,11,5.2219,-2.274303,7,306&e[8]=453768284,260,0,189,3,0,0,12.05,1,0,29.44,1,11,51.823204,-2.274276,8,301&2.735732&[]=5782426,,6130,,20710,95,11,5.2219,-2.274303,7,306&e[8]=453768284,260,0,189,3,0,0,12.05,1,0,29.44,1115.8204-.746,831&e[9]=453768300,250,0,203,3,0,0,12.05,1,0,29.38,1,12,51.823185,-2.274290,7,294&e[10]=45376,0,189,3,0,0,12.05,1,0,29.44,1115.8204-.746,831&e[9]=453768300,250,0,203,3,0,0,12.05,1,0,29.38,1,12,51.823185,-2.2729,,94e10=5768314,260,0,216,4,0,0,12.08,1,0,29.38,1,13,51.823196,-2.274289,7,303&e[11]=453768344,260,0,243,4,0,0,12.07,1,0,29.38,1,14,51.823254,-2.274278,8,295&e[12]=453768374,260,0,270,5,0,0,12.07,1,0,29.38,1,15,51.823185,-2.274331,6,307&e[13]=453768404,260,0,298,5,0,0,12.07,1,0,29.38,1,16,51.823303,-2.274270,7,307&e[14]=453768434,260,0,325,6,0,0,12.05,1,0,29.50,1,17,51.823174,-2.274287,6,311&e[15]=453768464,260,0,352,6,0,0,12.05,1,0,29.50,1,18,51.823112,-2.274347,8,301&e[16]=453768494,260,0,379,7,0,0,12.07,1,0,29.50,1,19,51.823132,-2.274336,8,303&e[17]=453768524,260,0,407,7,0,0,12.07,1,0,29.50,1,20,51.823166,-2.274347,8,302&e[18]=453768552,210,1,433,7,0,0,12.07,1,0,29.50,1,21,51.823132,-2.274286,7,1167&e[19]=453768554,260,2,434,8,0,0,12.03,1,0,29.50,1,22,51.823135,-2.274290,7,508&e[20]=453768555,220,0,435,8,0,0,12.07,1,0,29.50,1,23,51.823132,-2.274286,7,402&e[21]=453768555,270,0,435,8,0,0,12.07,1,0,29.50,1,24,51.823132,-2.274286,7,425&
  12.  
  13. ===============
  14. FUNCTION
  15. ===============
  16.  
  17. // Define the event log struct
  18. typedef struct {
  19. unsigned long timestamp; // Timestamp when the event was generated
  20. int reason; // The reason why the event was added
  21. int state; // The LED state, wake, sleep etc.
  22. unsigned long rotations; // Number of rotations the wheel has done
  23. unsigned int on_time; // Number of seconds the device has been awake
  24. unsigned int half_on_time; // Number of seconds the lights have been half on
  25. unsigned int full_on_time; // Number of seconds the lights have been fully on
  26. float voltage; // The battery voltage
  27. unsigned int messages_sent; // The number of messages the device has sent
  28. unsigned int messages_failed; // The number of messages that were attempted but failed
  29. float temperature; // The temperature
  30. int moving; // Whether we're moving
  31. unsigned int event_number; // The event number
  32.  
  33. double lat; // Current latitude
  34. double lng; // Current longitude
  35. unsigned int sats; // Number of satelites involved
  36. unsigned int age; // Milliseconds since last fix
  37. } Events;
  38.  
  39. // Make an event_log object with MAX_EVENT_LOG possible entries
  40. #define MAX_EVENT_LOG 45
  41. Events event_log[MAX_EVENT_LOG];
  42. Events tmp_event_log[MAX_EVENT_LOG];
  43. int current_event = 0;
  44. int tmp_current_event = 0;
  45. char post_data[7000];
  46.  
  47. void sendEvents() {
  48. if (sending) {
  49. #ifdef SER_DEBUG
  50. mySerial.println(F("Already sending, please wait!"));
  51. #endif
  52. } else {
  53. sending = true;
  54.  
  55. // Add an event to say that we tried to send
  56. addEvent(SENDING);
  57.  
  58. // Duplicate event list
  59. memcpy(tmp_event_log, event_log, sizeof(tmp_event_log));
  60. tmp_current_event = current_event;
  61.  
  62. int bytes_to_send = 0;
  63.  
  64. // Clear the POST data array
  65. memset(post_data, 0, sizeof(post_data));
  66.  
  67. Serial.print("Start: ");
  68. Serial.println(millis());
  69. noInterrupts(); // Stop interrupts while we fill the array
  70.  
  71. for (int p = 0; p < tmp_current_event; p++) {
  72. char row[150];
  73. char *row_pos = row;
  74. memset(row, 0, sizeof(row)); // Make sure its zerod out
  75.  
  76. char int_buf[15];
  77. char long_buf[20];
  78. char float_buf[15];
  79.  
  80. // Add 'e[x]='
  81. char param_number_tmp[4];
  82. strcpy(row_pos, "e[");
  83. strcat(row_pos, itoa(p, param_number_tmp, 10));
  84. strcat(row_pos, "]=");
  85.  
  86. // Add the timestamp to the POST string
  87. memset(long_buf, 0, sizeof(long_buf)); // Reset the long buffer
  88. ltoa(tmp_event_log[p].timestamp, long_buf, 10); // Convert the long to char array
  89. strcat(row_pos, long_buf); // Add the buffer to the row char array
  90.  
  91. // Add event reason
  92. strcat(row_pos, ",");
  93. memset(int_buf, 0, sizeof(int_buf)); // Reset the int buffer
  94. itoa(tmp_event_log[p].reason, int_buf, 10);
  95. strcat(row_pos, int_buf); // Add to the row
  96.  
  97. // Add the device state
  98. strcat(row_pos, ",");
  99. memset(int_buf, 0, sizeof(int_buf)); // Reset the int buffer
  100. itoa(tmp_event_log[p].state, int_buf, 10);
  101. strcat(row_pos, int_buf); // Add to the row
  102.  
  103. // Add rotations
  104. strcat(row_pos, ",");
  105. memset(long_buf, 0, sizeof(long_buf)); // Reset the int buffer
  106. ltoa(tmp_event_log[p].rotations, long_buf, 10);
  107. strcat(row_pos, long_buf);
  108.  
  109. // Add on time
  110. strcat(row_pos, ",");
  111. memset(int_buf, 0, sizeof(int_buf)); // Reset the int buffer
  112. itoa(tmp_event_log[p].on_time, int_buf, 10);
  113. strcat(row_pos, int_buf);
  114.  
  115. // Add half on time
  116. strcat(row_pos, ",");
  117. memset(int_buf, 0, sizeof(int_buf)); // Reset the int buffer
  118. itoa(tmp_event_log[p].half_on_time, int_buf, 10);
  119. strcat(row_pos, int_buf);
  120.  
  121. // Add full on time
  122. strcat(row_pos, ",");
  123. memset(int_buf, 0, sizeof(int_buf)); // Reset the int buffer
  124. itoa(tmp_event_log[p].full_on_time, int_buf, 10);
  125. strcat(row_pos, int_buf);
  126.  
  127. // Add voltage
  128. strcat(row_pos, ",");
  129. memset(float_buf, 0, sizeof(float_buf)); // Reset the float buffer
  130. dtostrf(tmp_event_log[p].voltage, 2, 2, float_buf);
  131. strcat(row_pos, float_buf);
  132.  
  133. // Add messages sent
  134. strcat(row_pos, ",");
  135. memset(int_buf, 0, sizeof(int_buf)); // Reset the int buffer
  136. itoa(tmp_event_log[p].messages_sent, int_buf, 10);
  137. strcat(row_pos, int_buf);
  138.  
  139. // Add messages failed
  140. strcat(row_pos, ",");
  141. memset(int_buf, 0, sizeof(int_buf)); // Reset the int buffer
  142. itoa(tmp_event_log[p].messages_failed, int_buf, 10);
  143. strcat(row_pos, int_buf);
  144.  
  145. // Add temperature
  146. strcat(row_pos, ",");
  147. memset(float_buf, 0, sizeof(float_buf)); // Reset the float buffer
  148. dtostrf(tmp_event_log[p].temperature, 2, 2, float_buf);
  149. strcat(row_pos, float_buf);
  150.  
  151. // Add moving
  152. strcat(row_pos, ",");
  153. memset(int_buf, 0, sizeof(int_buf)); // Reset the int buffer
  154. itoa(tmp_event_log[p].moving, int_buf, 10);
  155. strcat(row_pos, int_buf);
  156.  
  157. // Add event number
  158. strcat(row_pos, ",");
  159. memset(int_buf, 0, sizeof(int_buf)); // Reset the int buffer
  160. itoa(tmp_event_log[p].event_number, int_buf, 10);
  161. strcat(row_pos, int_buf);
  162.  
  163. // Add latitude
  164. strcat(row_pos, ",");
  165. memset(float_buf, 0, sizeof(float_buf)); // Reset the float buffer
  166. dtostrf(tmp_event_log[p].lat, 3, 6, float_buf);
  167. strcat(row_pos, float_buf);
  168.  
  169. // Add longitude
  170. strcat(row_pos, ",");
  171. memset(float_buf, 0, sizeof(float_buf)); // Reset the float buffer
  172. dtostrf(tmp_event_log[p].lng, 3, 6, float_buf);
  173. strcat(row_pos, float_buf);
  174.  
  175. // Add the number of satellites
  176. strcat(row_pos, ",");
  177. memset(int_buf, 0, sizeof(int_buf)); // Reset the int buffer
  178. itoa(tmp_event_log[p].sats, int_buf, 10);
  179. strcat(row_pos, int_buf);
  180.  
  181. // Add the fix age
  182. strcat(row_pos, ",");
  183. memset(int_buf, 0, sizeof(int_buf));
  184. itoa(tmp_event_log[p].age, int_buf, 10);
  185. strcat(row_pos, int_buf);
  186.  
  187. // Add the row to the POST data string
  188. strcat(post_data, row);
  189. strcat(post_data, "&");
  190. }
  191.  
  192. interrupts(); // Restart interrupts now we're done with the array
  193. Serial.print("End: ");
  194. Serial.println(millis());
  195.  
  196. Serial.println(post_data);
  197. Serial.println(post_data);
  198. Serial.println(post_data);
  199.  
  200. #ifdef SER_DEBUG
  201. mySerial.print(F("POST: "));
  202. mySerial.println(post_data);
  203. mySerial.print(F(" ["));
  204. mySerial.print(strlen(post_data));
  205. mySerial.println(F("b]"));
  206. #endif
  207.  
  208. // Now we'll send the data
  209. asyncbee.sendPOST((int) strlen(post_data));
  210. }
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement