Android Question Long mesassege send problem

Tayfur

Well-Known Member
Licensed User
Longtime User
Hello; I created a app for sms sending for all contact list.

I complate my app. So Now i find a bug.
I have recive PE_Send status Erroe= generic faliure when msessage length is long (ex. 180 char)

Why i recive error for long message?
and , each send prog cycle is very short.
Exp.: for 10 contact >> short mesagge cycle time = 10-15 second (result is good)
for 10 contact >> Long message cycle time = 1-3 second (result is error)

How can i fix it?


B4X:
Sub PE_SmsSentStatus (Success As Boolean, ErrorMessage As String, PhoneNumber As String, Intent As Intent)
'Log">>PE_SmsSentStatus> Phn :"&PhoneNumber&"- Er:"&ErrorMessage&" sc:" & Success)
If ayar Then 
    Dim labelx As Label
    labelx=ListView_log.SingleLineLayout.Label
    labelx.TextSize=14
   
    ListView_log.AddSingleLine("<<Status :"&PhoneNumber &" ("&Success&") Error:"&ErrorMessage&"-")
    End If

If Success Then
    
    SMS_Sent_Durum_guncelle(True,PhoneNumber)'>> listview  refres for  send result
    siradaki_sms_gonder ' >> this send next contcat in list 
Else
    '-----------------hata oldu sms de-----------
   
    SMS_Sent_Durum_guncelle(False,PhoneNumber) '>> listview  refres for  send result
    siradaki_sms_gonder ' >> this send next contcat in list 
  
End If

End Sub

B4X:
Sub PE_SmsDelivered (PhoneNumber As String, Intent As Intent)
'Log">>PE_SmsDelivered > Phn :"&PhoneNumber)
If ayar Then
    Dim labelx As Label
    labelx=ListView_log.SingleLineLayout.Label
    labelx.TextSize=14
   
    ListView_log.AddSingleLine("<<Delivered :"&PhoneNumber&"-")
    End If
''Log"-2------------ SMS delivered---------")   
    ekran_listeden_sil(PhoneNumber)
    Dim i As Int=0
    Dim Guncel_yap As Rbr'= Giden_Rehber.Get(i)' gelen kayıtlardan seçildi.
    Do Until Giden_Rehber.Size=i 'Or Guncel_yap.sec_telf=PhoneNumber
        Guncel_yap = Giden_Rehber.Get(i)' gelen kayıtlardan seçildi.
        If  Guncel_yap.sec_telf=PhoneNumber  Then
            Guncel_yap.iletim_durumu=4
            Giden_Rehber.RemoveAt(i)
            Giden_Rehber.Add(Guncel_yap) ' sending list refresh
            ListView_gonderi.AddTwoLinesAndBitmap2(Guncel_yap.isim,"Okundu",LoadBitmap(File.DirAssets,"ok_sms.png"),Guncel_yap.sec_telf)
            DoEvents
            ListView_gonderi.SetSelection(ListView_gonderi.Size)
            DoEvents
            Exit
        End If
        i=i+1
    Loop

End Sub

B4X:
'--------------------  SMS SEND CODE ------------------
'   I added    >> Process_Globals
'     Dim Psms As PhoneSms 
'     Dim  PE As PhoneEvents
'     Dim PhoneId As PhoneId
'------------------------------------------------
Sub SendSMS(Message As Map, id As Int)
   Dim Extra As Map
If ayar Then Log("SEND SMS :"&Message.Get("to"))
   
   Psms.Send2(Message.Get("to"),Message.Get("message"),True,True)
   If ayar Then  ListView_log.AddSingleLine(">>SEND :"&Message.Get("to"))
End Sub


This pictures my log for short message
Screenshot_2015-07-22-10-53-19_resized.png


Screenshot_2015-07-22-10-53-07_resized.png

this picture is log for generic failure with short message

Screenshot_2015-07-22-10-50-58_resized.png
Screenshot_2015-07-22-10-50-39_resized.png
 

Tayfur

Well-Known Member
Licensed User
Longtime User
@Erel I think, App must waiting all send status report. Because; appp send next sms when it recive first send status report. it dont wait other status report. I tested , 420char sms recive 7 status report. after it recived 7 delivered.

How can i control send status report for each sms parts? Or other simple way. I am open anytin...


Hello; I created a app for sms sending for all contact list.

I complate my app. So Now i find a bug.
I have recive PE_Send status Erroe= generic faliure when msessage length is long (ex. 180 char)

Why i recive error for long message?
and , each send prog cycle is very short.
Exp.: for 10 contact >> short mesagge cycle time = 10-15 second (result is good)
for 10 contact >> Long message cycle time = 1-3 second (result is error)

How can i fix it?


B4X:
Sub PE_SmsSentStatus (Success As Boolean, ErrorMessage As String, PhoneNumber As String, Intent As Intent)
'Log">>PE_SmsSentStatus> Phn :"&PhoneNumber&"- Er:"&ErrorMessage&" sc:" & Success)
If ayar Then
    Dim labelx As Label
    labelx=ListView_log.SingleLineLayout.Label
    labelx.TextSize=14
 
    ListView_log.AddSingleLine("<<Status :"&PhoneNumber &" ("&Success&") Error:"&ErrorMessage&"-")
    End If

If Success Then
  
    SMS_Sent_Durum_guncelle(True,PhoneNumber)'>> listview  refres for  send result
    siradaki_sms_gonder ' >> this send next contcat in list
Else
    '-----------------hata oldu sms de-----------
 
    SMS_Sent_Durum_guncelle(False,PhoneNumber) '>> listview  refres for  send result
    siradaki_sms_gonder ' >> this send next contcat in list

End If

End Sub

B4X:
Sub PE_SmsDelivered (PhoneNumber As String, Intent As Intent)
'Log">>PE_SmsDelivered > Phn :"&PhoneNumber)
If ayar Then
    Dim labelx As Label
    labelx=ListView_log.SingleLineLayout.Label
    labelx.TextSize=14
 
    ListView_log.AddSingleLine("<<Delivered :"&PhoneNumber&"-")
    End If
''Log"-2------------ SMS delivered---------") 
    ekran_listeden_sil(PhoneNumber)
    Dim i As Int=0
    Dim Guncel_yap As Rbr'= Giden_Rehber.Get(i)' gelen kayıtlardan seçildi.
    Do Until Giden_Rehber.Size=i 'Or Guncel_yap.sec_telf=PhoneNumber
        Guncel_yap = Giden_Rehber.Get(i)' gelen kayıtlardan seçildi.
        If  Guncel_yap.sec_telf=PhoneNumber  Then
            Guncel_yap.iletim_durumu=4
            Giden_Rehber.RemoveAt(i)
            Giden_Rehber.Add(Guncel_yap) ' sending list refresh
            ListView_gonderi.AddTwoLinesAndBitmap2(Guncel_yap.isim,"Okundu",LoadBitmap(File.DirAssets,"ok_sms.png"),Guncel_yap.sec_telf)
            DoEvents
            ListView_gonderi.SetSelection(ListView_gonderi.Size)
            DoEvents
            Exit
        End If
        i=i+1
    Loop

End Sub

B4X:
'--------------------  SMS SEND CODE ------------------
'   I added    >> Process_Globals
'     Dim Psms As PhoneSms
'     Dim  PE As PhoneEvents
'     Dim PhoneId As PhoneId
'------------------------------------------------
Sub SendSMS(Message As Map, id As Int)
   Dim Extra As Map
If ayar Then Log("SEND SMS :"&Message.Get("to"))
 
   Psms.Send2(Message.Get("to"),Message.Get("message"),True,True)
   If ayar Then  ListView_log.AddSingleLine(">>SEND :"&Message.Get("to"))
End Sub


This pictures my log for short message
View attachment 36090

View attachment 36091
this picture is log for generic failure with short message

View attachment 36092 View attachment 36093
 
Last edited:
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
For sure this is not the correct reply to your question, but I would encourage anybody to definitely abandon the SMS methos to communicate with other devices.
You will only get troubles, google for "Android SMS limit", "default SMS app with KitKat", etc.
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
our try is only 1 contact (i send to my phone). I was read sending limit for 70...50 contacts on other web sities. So I send only 1 sms.
and i recive error.

For sure this is not the correct reply to your question, but I would encourage anybody to definitely abandon the SMS methos to communicate with other devices.
You will only get troubles, google for "Android SMS limit", "default SMS app with KitKat", etc.
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
@Erel I think, App must waiting all send status report. Because; appp send next sms when it recive first send status report. it dont wait other status report. I tested , 420char sms recive 7 status report. after it recived 7 delivered.

How can i control send status report for each sms parts? Or other simple way. I am open anytin...



I reserched sms lenth

and i found it.

http://messente.com/documentation/sms-length-calculator

Multipart SMS messages
When the message length exceeds 160 characters in case of 7bit encoding (or 70 characters for UCS-2 encoding), the message is split up to multiple separate SMS and sent to the handset separately as well.

To be able to concentate the messages on the phone, special header (UDH) is set for each message, which states the order and message each part belongs to. Due to this special UDH, the length of each combined 7-bit message is shortened to 153 characters (67 chracters for UCS-2).

Regular______SMS________Multipart SMS
7-bit_______160 chars ________153 chars
Unicode______70 chars ________67 chars


Standard SMS Messages
Standard SMS messages have a maximum payload of 140 bytes (1120 bits).

Since GSM phones use a 7-bit character encoding, this allows a maximum of 160 characters per standard SMS message:

1120 bits / (7 bits/character) = 160 characters
For Unicode phones, which use a 16-bit character encoding, this allows a maximum of 70 characters per standard SMS message:

1120 bits / (16 bits/character) = 70 characters

http://spin.atomicobject.com/2011/04/20/concatenated-sms-messages-and-character-counts/

haracter Count Thresholds
The character limits for individual concatenated SMS messages results in various thresholds for which additional individual concatenated SMSmessages will be required to support sending a larger overall message:

GSM encoding:

  • 1 standard SMS message = up to 160 characters
  • 2 concatenated SMS messages = up to 306 characters
  • 3 concatenated SMS messages = up to 459 characters
  • 4 concatenated SMS messages = up to 612 characters
  • 5 concatenated SMS messages = up to 765 characters
  • etc. (153 x number of individual concatenated SMS messages)
UTF-16 encoding:

  • 1 standard SMS message = up to 70 characters
  • 2 concatenated SMS messages = up to 134 characters
  • 3 concatenated SMS messages = up to 201 characters
  • 4 concatenated SMS messages = up to 268 characters
 
Last edited:
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
hello all;

I checked my app.
I think, i found ansewrs.

Now i want to share....

I created this class module. this code calculate sms chars lentg and sms part(for multipart sms) and it check GSM alfabet or UTF8 alfabet. After automaticly calculate parts count and total char length. (this code for Turkish alfabet.you must change for your language)

if you send to serial sms (like 10 different number and long words sms (250chars)). you will read some error, and your sms dont send.
Porblem is phone lib simple code dont wait all "PE_SmsSentStatus" for multipart. App must wait all "PE_SmsSentStatus".

Your application first step:
calculate sms parts with my class.
After app must waiting all "PE_SmsSentStatus" (sms parts count).
after you can send other sms.


@Erel please update phone lib.



B4X:
'Class module
' class name :>>  sms_calculate
Sub Class_Globals
    Dim  charlist As Map
    Dim  doublecharlist As Map
    Dim  utf8charlist As Map
    Type sms_type (sms_char_length As Int, sms_sending_part As Int,GSM_alfabet As Boolean)
End Sub

'http://www.urlsms.com/sms-calculator/
'http://spin.atomicobject.com/2011/04/20/concatenated-sms-messages-and-character-counts/
'http://messente.com/documentation/sms-length-calculator
'https://en.wikipedia.org/wiki/GSM_03.38
'Initializes the object. You can add parameters to this method if needed.

Public Sub Initialize
    Dim x1 As String=Chr(34) ' çit tırnak
    Dim x2 As String=Chr(39) ' tek tırnak
    charlist=(CreateMap("A":1,"B":1,"C":1,"D":1,"E":1,"F":1,"G":1,"H":1,"I":1,"J":1,"K":1,"L":1,"M":1,"N":1,"O":1,"P":1,"Q":1,"R":1,"S":1,"T":1,"U":1,"V":1,"W":1,"X":1,"Y":1,"Z":1,"Ä":1,"Ö":1,"Ñ":1,"Ü":1,"Ç":1," ":1,"a":1,"b":1,"c":1,"d":1,"e":1,"f":1,"g":1,"h":1,"i":1,"j":1,"k":1,"l":1,"m":1,"n":1,"o":1,"p":1,"q":1,"r":1,"s":1,"t":1,"u":1,"v":1,"w":1,"x":1,"y":1,"z":1,"ö":1,"ü":1,"0":1,"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"¡":1,"¿":1,":":1,";":1,"<":1,"=":1,">":1,"?":1,"!":1,x1:1,"(":1,")":1,"*":1,"+":1,",":1,"-":1,".":1,"/":1,"#":1,"¤":1,"%":1,"&":1,"'":1,"ò":1,"§":1,"Ø":1,"@":1,"£":1,"$":1,"¥":1,"è":1,"é":1,"ù":1,"ì":1,"ø":1,"Å":1,"å":1,"Δ":1,"_":1,"Φ":1,"Γ":1,"Λ":1,"Ω":1,"Π":1,"Ψ":1,"Σ":1,"Θ":1,"Ξ":1,"ä":1,"ñ":1,"à":1,"Æ":1,"æ":1,"ß":1,"É":1,x2:1))
    'doublecharlist.Clear ' Bu tablo standart 7-bit GSM alfavbesi 2 karakter sayılır
    doublecharlist= (CreateMap("|":2,"^":2,"€":2,"{":2,"}":2,"[":2,"]":2,"~":2))
    'utf8charlist.clear ' Bu tablo standart 16-bit UTF-8 alfavbesi
    utf8charlist =CreateMap("Ğ":2,"İ":2,"Ş":2,"ğ":2,"ş":2,"ç":2,"ı":2)

End Sub

' message : control string / ypur message
' Return >>> Type sms_type (sms_char_length As Int, sms_sending_part As Int,GSM_alfabet As Boolean)
Public Sub sms_check(message As String) As sms_type
    Dim x As sms_type
    Dim chr7bit As Int=0
    Dim chr16bit As Int=0
     x.GSM_alfabet=True
     Dim chars As String
     Dim chars_length As Int
    For i=0 To message.Length-1
        chars=message.SubString2(i,i+1)
        If charlist.Get(chars)<>Null Then
                chars_length=charlist.Get(chars)
                x.sms_char_length=x.sms_char_length+1 ' single char
            Else
                If doublecharlist.Get(chars)<>Null Then
                        chars_length=doublecharlist.Get(chars)
                        x.sms_char_length=x.sms_char_length+2 ' double char
                    Else
                         x.GSM_alfabet=False ' we fourn utf8 chars
                    End If
            End If
    Next

    
    If x.GSM_alfabet=False Then
        x.sms_char_length=message.Length*1
        If x.sms_char_length>70 Then
            x.sms_sending_part=Ceil(x.sms_char_length/67)
        Else
            x.sms_sending_part=1
        End If
    Else
        ' this lines for gsm alfabet
        If x.sms_char_length>160 Then
            x.sms_sending_part=Ceil(x.sms_char_length/153)
        Else
            x.sms_sending_part=1
        End If

    End If

    
    Return x
End Sub
 
Last edited:
Upvote 0
Top