if (res) {
DEBUGA_GSMOPEN("AT+CMGF? failed, continue\n", GSMOPEN_P_LOG);
}
-#ifndef WANT_GSMLIB
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=1");
if (res) {
ERRORA("Error setting SMS sending mode to TEXT on the cellphone, let's hope is TEXT by default. Continuing\n", GSMOPEN_P_LOG);
WARNINGA("AT+CSMP do not got OK from the phone, continuing\n", GSMOPEN_P_LOG);
}
}
-#else // WANT_GSMLIB
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0");
if (res) {
}
tech_pvt->sms_pdu_not_supported = 0;
tech_pvt->no_ucs2 = 1;
+#ifdef NOTDEF //GSMLIB? XXX
if (tech_pvt->no_ucs2) {
res = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"GSM\"");
if (res) {
WARNINGA("AT+CSMP do not got OK from the phone, continuing\n", GSMOPEN_P_LOG);
}
}
-#endif // WANT_GSMLIB
+#endif// NOTDEF //GSMLIB? XXX
#ifdef NOTDEF //GSMLIB? XXX
} else {
-#ifdef WANT_GSMLIB
try {
char content2[1000];
SMSMessageRef sms;
}
-#endif // WANT_GSMLIB
char pdu2[16000];
memset(pdu2, '\0', sizeof(pdu2));
int pdulenght = 0;
+ string pdu;
PUSHA_UNLOCKA(&tech_pvt->controldev_lock);
LOKKA(tech_pvt->controldev_lock);
-#ifndef WANT_GSMLIB
- err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=1");
- if (err) {
- ERRORA("AT+CMGF=1 (set message sending to TEXT (as opposed to PDU) do not got OK from the phone\n", GSMOPEN_P_LOG);
- }
-#else // WANT_GSMLIB
- err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0");
- if (err) {
- ERRORA("AT+CMGF=0 (set message sending to TEXT (as opposed to PDU) do not got OK from the phone\n", GSMOPEN_P_LOG);
- }
-#endif // WANT_GSMLIB
-
-
if (tech_pvt->no_ucs2 || tech_pvt->sms_pdu_not_supported == 0) {
-#ifdef WANT_GSMLIB
try {
- SMSMessageRef smsMessage;
+int bad_8859=0;
memset(mesg_test, '\0', sizeof(mesg_test));
sprintf(mesg_test, ":) ciao belè новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大aèéàòçù"); //let's test the beauty of utf8
//sprintf(mesg_test,":) ciao belè èéàòìù");
//text=mesg_test;
- utf8_to_iso_8859_1(tech_pvt, text, strlen(text), smscommand, sizeof(smscommand));
- smsMessage = new SMSSubmitMessage(smscommand, dest);
- string pdu = smsMessage->encode();
- strncpy(pdu2, pdu.c_str(), sizeof(pdu2) - 1);
- memset(smscommand, '\0', sizeof(smscommand));
- pdulenght = pdu.length() / 2 - 1;
- sprintf(smscommand, "AT+CMGS=%d", pdulenght);
-
-#ifdef NOTDEF
-
- ***9. How to support unicode ? You need 6 steps : 1. set datacodingschema to DCS_SIXTEEN_BIT_ALPHABET 2. set your locale correctly, for example
- , my locale, china.setlocale(LC_ALL, "chs");
-
- 3. translate MBCS(multiple byte character set) string to unicode string.wchar_t wstr[1000];
- memset(wstr, 0, 2000);
- mbstowcs(wstr, data.c_str(), data.length());
-
- 4. get unicode string length.int wcs_len = wcslen(wstr);
-
- 5. change unicode string to net order.for (int i = 0; i < wcs_len; i++)
- wstr[i] = htons(wstr[i]);
-
- 6. put unicode string into pdu.char content2[1000];
- SMSMessageRef sms;
- //MessageType messagetype;
- //Address servicecentreaddress;
- //Timestamp servicecentretimestamp;
- //Address sender_recipient_address;
-
- sms = SMSMessage::decode(tech_pvt->line_array.result[i]); // dataCodingScheme = 8 , text=ciao 123 belè новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大
+ bad_8859 = utf8_to_iso_8859_1(tech_pvt, text, strlen(text), smscommand, sizeof(smscommand));
+ if(!bad_8859){
+ err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0");
+ if (err) {
+ ERRORA("AT+CMGF=0 (set message sending to PDU (as opposed to TEXT) do not got OK from the phone\n", GSMOPEN_P_LOG);
+ }
+ SMSMessageRef smsMessage;
+ smsMessage = new SMSSubmitMessage(smscommand, dest);
+ //string pdu = smsMessage->encode();
+ pdu = smsMessage->encode();
+ strncpy(pdu2, pdu.c_str(), sizeof(pdu2) - 1);
+ memset(smscommand, '\0', sizeof(smscommand));
+ pdulenght = pdu.length() / 2 - 1;
+ sprintf(smscommand, "AT+CMGS=%d", pdulenght);
+ } else {
+ int ok;
- DEBUGA_GSMOPEN("SMS=\n%s\n", GSMOPEN_P_LOG, sms->toString().c_str());
+ UNLOCKA(tech_pvt->controldev_lock);
+ POPPA_UNLOCKA(&tech_pvt->controldev_lock);
- memset(content2, '\0', sizeof(content2));
- if (sms->dataCodingScheme().getAlphabet() == DCS_DEFAULT_ALPHABET) {
- iso_8859_1_to_utf8(tech_pvt, (char *) sms->userData().c_str(), content2, sizeof(content2));
- } else if (sms->dataCodingScheme().getAlphabet() == DCS_SIXTEEN_BIT_ALPHABET) {
- ucs2_to_utf8(tech_pvt, (char *) bufToHex((unsigned char *) sms->userData().data(), sms->userData().length()).c_str(), content2,
- sizeof(content2));
- } else {
- ERRORA("dataCodingScheme not supported=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet());
+ tech_pvt->no_ucs2 = 0;
+ tech_pvt->sms_pdu_not_supported =1;
+ ok= gsmopen_sendsms(tech_pvt, dest, text);
+ tech_pvt->no_ucs2 = 1;
+ tech_pvt->sms_pdu_not_supported =0;
+ return ok;
}
- DEBUGA_GSMOPEN("dataCodingScheme=%d\n", GSMOPEN_P_LOG, sms->dataCodingScheme().getAlphabet());
- DEBUGA_GSMOPEN("dataCodingScheme=%s\n", GSMOPEN_P_LOG, sms->dataCodingScheme().toString().c_str());
- DEBUGA_GSMOPEN("address=%s\n", GSMOPEN_P_LOG, sms->address().toString().c_str());
- DEBUGA_GSMOPEN("serviceCentreAddress=%s\n", GSMOPEN_P_LOG, sms->serviceCentreAddress().toString().c_str());
- DEBUGA_GSMOPEN("serviceCentreTimestamp=%s\n", GSMOPEN_P_LOG, sms->serviceCentreTimestamp().toString().c_str());
- DEBUGA_GSMOPEN("messageType=%d\n", GSMOPEN_P_LOG, sms->messageType());
- DEBUGA_GSMOPEN("userData= |||%s|||\n", GSMOPEN_P_LOG, content2);
-
- memset(sms_body, '\0', sizeof(sms_body));
- strncpy(sms_body, content2, sizeof(sms_body));
- DEBUGA_GSMOPEN("body=%s\n", GSMOPEN_P_LOG, sms_body);
- strncpy(tech_pvt->sms_body, sms_body, sizeof(tech_pvt->sms_body));
- strncpy(tech_pvt->sms_sender, sms->address().toString().c_str(), sizeof(tech_pvt->sms_sender));
- strncpy(tech_pvt->sms_date, sms->serviceCentreTimestamp().toString().c_str(), sizeof(tech_pvt->sms_date));
- strncpy(tech_pvt->sms_datacodingscheme, sms->dataCodingScheme().toString().c_str(), sizeof(tech_pvt->sms_datacodingscheme));
- strncpy(tech_pvt->sms_servicecentreaddress, sms->serviceCentreAddress().toString().c_str(), sizeof(tech_pvt->sms_servicecentreaddress));
- tech_pvt->sms_messagetype = sms->messageType();
- //messagetype = sms->messageType();
- //servicecentreaddress = sms->serviceCentreAddress();
- //servicecentretimestamp = sms->serviceCentreTimestamp();
- //sender_recipient_address = sms->address();
-#endif // NOTDEF
}
catch(GsmException & ge) {
ERRORA("GsmException= |||%s|||\n", GSMOPEN_P_LOG, ge.what());
}
-#else // WANT_GSMLIB
- ERRORA("tech_pvt->no_ucs2 || tech_pvt->sms_pdu_not_supported == 0 && no WANT_GSMLIB\n", GSMOPEN_P_LOG);
- return RESULT_FAILURE;
-#endif // WANT_GSMLIB
} else {
char dest2[1048];
+ err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=1");
+ if (err) {
+ ERRORA("AT+CMGF=1 (set message sending to TEXT (as opposed to PDU) do not got OK from the phone\n", GSMOPEN_P_LOG);
+ }
+
+/*
err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CSCS=\"UCS2\"");
if (err) {
ERRORA("AT+CSCS=\"UCS2\" (set TE messages to ucs2) do not got OK from the phone\n", GSMOPEN_P_LOG);
}
+*/
memset(dest2, '\0', sizeof(dest2));
utf8_to_ucs2(tech_pvt, dest, strlen(dest), dest2, sizeof(dest2));
goto uscita;
}
err = gsmopen_serial_AT_expect(tech_pvt, "> ", 0, 1); // wait 1.1s for the prompt, no crlf
-#if 1
if (err) {
DEBUGA_GSMOPEN
("Error or timeout getting prompt '> ' for sending sms directly to the remote party. BTW, seems that we cannot do that with Motorola c350, so we'll write to cellphone memory, then send from memory\n",
goto uscita;
}
}
-#endif
-#ifndef WANT_GSMLIB
- memset(mesg_test, '\0', sizeof(mesg_test));
- sprintf(mesg_test, ":) ciao belè новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大aèéàòçù"); //let's test the beauty of utf8
- //text=mesg_test;
+ if (tech_pvt->no_ucs2 || tech_pvt->sms_pdu_not_supported == 0) {
+ memset(smscommand, '\0', sizeof(smscommand));
+ sprintf(smscommand, "%s", pdu2);
+ }else{
+ memset(mesg_test, '\0', sizeof(mesg_test));
+ sprintf(mesg_test, ":) ciao belè новости לק ראת ﺎﻠﺠﻤﻋﺓ 人大aèéàòçù"); //let's test the beauty of utf8
+ //text=mesg_test;
+
+ memset(smscommand, '\0', sizeof(smscommand));
+ if (tech_pvt->no_ucs2) {
+ sprintf(smscommand, "%s", text);
+ } else {
+ utf8_to_ucs2(tech_pvt, text, strlen(text), smscommand, sizeof(smscommand));
+ }
- memset(smscommand, '\0', sizeof(smscommand));
- if (tech_pvt->no_ucs2) {
- sprintf(smscommand, "%s", text);
- } else {
- utf8_to_ucs2(tech_pvt, text, strlen(text), smscommand, sizeof(smscommand));
}
-#else // WANT_GSMLIB
-
- memset(smscommand, '\0', sizeof(smscommand));
- sprintf(smscommand, "%s", pdu2);
-#endif // WANT_GSMLIB
smscommand[strlen(smscommand)] = 0x1A;
DEBUGA_GSMOPEN("smscommand len is: %d, text is:|||%s|||\n", GSMOPEN_P_LOG, (int) strlen(smscommand), smscommand);
ERRORA("Error de-activating echo from modem\n", GSMOPEN_P_LOG);
}
}
- uscita:
+uscita:
gsmopen_sleep(1000);
if (tech_pvt->at_cmgw[0]) {
UNLOCKA(tech_pvt->controldev_lock);
POPPA_UNLOCKA(&tech_pvt->controldev_lock);
}
-#ifdef NOTDEF
- err = gsmopen_serial_write_AT_ack(tech_pvt, "AT+CMGF=0");
- if (err) {
- DEBUGA_GSMOPEN("AT+CMGF=0 (set message sending to PDU (as opposed to TEXT) do not got OK from the phone, continuing\n", GSMOPEN_P_LOG);
- }
-#endif // NOTDEF
DEBUGA_GSMOPEN("FINISH\n", GSMOPEN_P_LOG);
if (failed)