Here are debug logs of successful connections. I have two Mega2560 and GSM Shield combos and two SIM cards from the same provider but with different contracts. The lower one is my personal SIM the other upper one is a data only SIM card.
This is what a successful connection and upload look like with the simpler code (personal details omitted):
Starting up...
Connecting to GSM network...
AT%13%
0 9>AT%13%%13%%10%OK%13%%10%
AT+CGREG?%13%
9 40>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
40 71>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
71 102>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
102 5>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
5 36>AT+CGREG?%13%%13%%10%+CGREG: 0,1%13%%10%%13%%10%OK%13%%10%
AT+IFC=1,1%13%
36 53>AT+IFC=1,1%13%%13%%10%OK%13%%10%
AT+CMGF=1%13%
53 71>%19%%17%AT+CMGF=1%13%%13%%10%OK%13%%10%
AT+CLIP=1%13%
71 87>AT+CLIP=1%13%%13%%10%OK%13%%10%
ATE0%13%
87 98>ATE0%13%%13%%10%OK%13%%10%
AT+COLP=1%13%
98 104>%13%%10%OK%13%%10%
PIN OK
AT+CGATT=1%13%
104 110>%13%%10%OK%13%%10%
AT+QIFGCNT=0%13%
110 116>%13%%10%OK%13%%10%
AT+QICSGP=1,"[MY APN]","[LOGIN]","[PASSWORD]"%13%
116 122>%13%%10%OK%13%%10%
AT+QIMUX=0%13%
122 0>%13%%10%OK%13%%10%
AT+QIMODE=1%13%
0 6>%13%%10%OK%13%%10%
AT+QINDI=1%13%
6 12>%13%%10%OK%13%%10%
AT+QIREGAPP%13%
12 18>%13%%10%OK%13%%10%
AT+QIACT%13%
18 24>%13%%10%OK%13%%10%
GPRS OK
AT+QIDNSIP=0%13%
24 30>%13%%10%OK%13%%10%
AT+QIOPEN="TCP","[SERVER IP]",[PORT]%13%
30 36>%13%%10%OK%13%%10%
30 47>%13%%10%OK%13%%10%%13%%10%CONNECT%13%%10%
Test 0/1+++AT+QICLOSE%13%
65 65>
Test 1/1
And this is what it looks like with the longer one:
Starting up...
AT%13%%10%ATE0%13%%10%Starting connections!
Connecting to GSM network...
GSM Access begin
AT%13%
44 69>AT%13%%13%%10%OK%13%%10%%13%%10%+CPIN: READY%13%%10%
AT+CGREG?%13%
69 100>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
100 3>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
3 34>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
34 65>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
65 96>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
96 127>AT+CGREG?%13%%13%%10%+CGREG: 0,1%13%%10%%13%%10%OK%13%%10%
AT+IFC=1,1%13%
127 16>AT+IFC=1,1%13%%13%%10%OK%13%%10%
AT+CMGF=1%13%
16 34>%19%%17%AT+CMGF=1%13%%13%%10%OK%13%%10%
AT+CLIP=1%13%
34 50>AT+CLIP=1%13%%13%%10%OK%13%%10%
ATE0%13%
50 75>ATE0%13%%13%%10%OK%13%%10%%13%%10%Call Ready%13%%10%
AT+COLP=1%13%
75 81>%13%%10%OK%13%%10%
...in while...
else
AT+CSQ%13%%10%while->while
AT+CGATT=1%13%
101 107>%13%%10%OK%13%%10%
AT+QIFGCNT=0%13%
107 113>%13%%10%OK%13%%10%
AT+QICSGP=1,"[APN]","[LOGIN]","[PASSWORD]"%13%
113 119>%13%%10%OK%13%%10%
AT+QIMUX=0%13%
119 125>%13%%10%OK%13%%10%
AT+QIMODE=1%13%
125 3>%13%%10%OK%13%%10%
AT+QINDI=1%13%
3 9>%13%%10%OK%13%%10%
AT+QIREGAPP%13%
9 15>%13%%10%OK%13%%10%
AT+QIACT%13%
15 21>%13%%10%OK%13%%10%
Connected to GPRS.
Connecting to server...
AT+QIDNSIP=0%13%
21 27>%13%%10%OK%13%%10%
AT+QIOPEN="TCP","[IP]",[PORT]%13%
27 33>%13%%10%OK%13%%10%
27 44>%13%%10%OK%13%%10%%13%%10%CONNECT%13%%10%
Connected
Buffer:
<Test1;Test2><13;21;440>(0/1)Sent!
Nr of tries: 1
Nr of successseseses: 1
+++AT+QICLOSE%13%
62 62>
Disconnected from server.
GSM shutdown.
This one won't even start connecting the second time. It just stays on:
Connecting to GSM network...
GSM Access begin
AT%13%
This might be because I shut the Shield down to save power, as the final design demands this. Then again, the same thing works with another Arduino Mega2560 and GSM Shield quite reliably.