Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. //+IPD,<len>:<data>
  2. //+IPD,<id>,<len>:<data>
  3. String data = "";
  4. if (_cell.available()>0)
  5. {
  6.  
  7. unsigned long start;
  8. start = millis();
  9. char c0 = _cell.read();
  10. if (c0 == '+')
  11. {
  12. if (_cell.find(HTMLBEGINSTR)) {
  13. while (millis()-start<5000)
  14. {
  15. if (_cell.available()>0)
  16. {
  17. char c = _cell.read();
  18. data += c;
  19. }
  20. if (data.indexOf("nOK")!=-1)
  21. {
  22. data.replace("nOK","");
  23. break;
  24. }
  25. }
  26. }
  27.  
  28. int sLen = strlen(data.c_str());
  29. int i,j;
  30. for (i = 0; i <= sLen; i++)
  31. {
  32. if (data[i] == ':')
  33. {
  34. break;
  35. }
  36.  
  37. }
  38. boolean found = false;
  39. for (j = 4; j <= i; j++)
  40. {
  41. if (data[j] == ',')
  42. {
  43. found = true;
  44. break;
  45. }
  46.  
  47. }
  48. int iSize;
  49. DBGLN(data);
  50.  
  51. if(found ==true)
  52. {
  53. String _id = data.substring(4, j);
  54. chlID = _id.toInt();
  55. String _size = data.substring(j+1, i);
  56. iSize = _size.toInt();
  57. //DBG(_size);
  58. String str = data.substring(i+1, i+1+iSize);
  59. strcpy(buf, str.c_str());
  60. //DBG(str);
  61.  
  62. }
  63. else
  64. {
  65. String _size = data.substring(4, i);
  66. iSize = _size.toInt();
  67. //DBGLN(iSize);
  68. String str = data.substring(i+1, i+1+iSize);
  69. strcpy(buf, str.c_str());
  70. //DBG(str);
  71. }
  72. return iSize;
  73. }
  74. }
  75.  
  76. //DBGLN("ERR Receive MSG");
  77. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement