Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //+IPD,<len>:<data>
- //+IPD,<id>,<len>:<data>
- String data = "";
- if (_cell.available()>0)
- {
- unsigned long start;
- start = millis();
- char c0 = _cell.read();
- if (c0 == '+')
- {
- if (_cell.find(HTMLBEGINSTR)) {
- while (millis()-start<5000)
- {
- if (_cell.available()>0)
- {
- char c = _cell.read();
- data += c;
- }
- if (data.indexOf("nOK")!=-1)
- {
- data.replace("nOK","");
- break;
- }
- }
- }
- int sLen = strlen(data.c_str());
- int i,j;
- for (i = 0; i <= sLen; i++)
- {
- if (data[i] == ':')
- {
- break;
- }
- }
- boolean found = false;
- for (j = 4; j <= i; j++)
- {
- if (data[j] == ',')
- {
- found = true;
- break;
- }
- }
- int iSize;
- DBGLN(data);
- if(found ==true)
- {
- String _id = data.substring(4, j);
- chlID = _id.toInt();
- String _size = data.substring(j+1, i);
- iSize = _size.toInt();
- //DBG(_size);
- String str = data.substring(i+1, i+1+iSize);
- strcpy(buf, str.c_str());
- //DBG(str);
- }
- else
- {
- String _size = data.substring(4, i);
- iSize = _size.toInt();
- //DBGLN(iSize);
- String str = data.substring(i+1, i+1+iSize);
- strcpy(buf, str.c_str());
- //DBG(str);
- }
- return iSize;
- }
- }
- //DBGLN("ERR Receive MSG");
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement