I want to return FAILED or UNSENT status when credit balance is zero. But 
still it gets SENT status. How do I fix that?

On Thursday, June 21, 2012 at 7:45:44 PM UTC+5:30, Brian O Carroll wrote:
>
> Hi Thanasis,
>
> Sorry for the long delay in getting back to you. I've been very busy 
> working with other aspects of my business start-up. Just to let you know, 
> I'm going with the USB GSM dongle option for now. I may look into getting a 
> tablet with a slot for a SIM card in it to avoid needing the external USB 
> device at all.
>
> I tried a couple of Huawei modems which worked but with some awkward 
> side-effects, namely the E160G and the K3765. Side-effects were random 
> disconnections (something related to Java Comm I think) and 
> StringIndexOutOfBoundsExceptions while reading new messages.
>
> The one that works perfectly for me now all the time is the Huawei E173. 
> No special modifications required to make it work. It's good news for me 
> because Meteor (a mobile phone company in Ireland) sell a refurbished 
> (second-hand) E173 for just €9.99 - 
> http://www1.meteor.ie/mobilebroadband/payg/
>
> Regarding the read and unread messages and the problem of only wanting to 
> get unread messages, I have finally taken your recommended option and now I 
> just delete messages from the modem once they arrive and have been read by 
> SMSlib.
>
> Anyway, thanks for your help so far and for making your library available.
>
> By the way, I hope you're satisfied with the results of the Greek 
> elections last weekend. More importantly, Greece did brilliantly to get to 
> the quarter-finals of Euro 2012. Ireland did not do so well :-( Best of 
> luck against Germany tomorrow night!
>
> Cheers,
> Brian
>
> On Friday, June 8, 2012 10:00:30 PM UTC+1, T.Delenikas wrote:
>>
>> Hi Brian,
>>
>> I think that you could accomplish what you want by disabling what's 
>> called "AsyncMessageProcessor".
>> Check AModemDriver.java, method "connect()", and locate the line:
>>
>> setAsyncMessageProcessor(new AsyncMessageProcessor());
>>
>> Comment this line out.
>> Now SMSLib should retain the UNREAD status. Inbound callbacks will not work, 
>> even if you set them. You will need to call readMessages() at your own pace.
>>
>> I know this requires code changes, but try it once.
>>
>> As far as the other issue, you are correct. Targeting specific devices 
>> (pre-tested by you) could be an option. I don't know if using external 
>> modems is an option for your project - you know better, the are specific 
>> drawbacks that you've already mentioned.
>> Are all these tablet devices that much different in terms of internal 
>> modems? I though that the common O/S on them would "smooth out" the 
>> differences...
>>
>>
>>
>> On Thursday, June 7, 2012 2:19:13 PM UTC+3, Brian O Carroll wrote:
>>>
>>> Hi Thanasis, 
>>>
>>> Thanks very much for that advice. When you say, "disable 
>>> notification", do you mean just NOT calling 
>>> Service.setInboundMessageNotification? I have tried this but the 
>>> result is still the same. All new messages immediately get marked as 
>>> READ by the phone, just after they arrive, even if I don't call 
>>> readMessages in that time. Once the gateway is connected at all, the 
>>> messages automatically get marked as READ. Is there any other way to 
>>> explicitly disable notifications? 
>>> I've already come up with a simple work-around for this issue which 
>>> works pretty well - example code below (I've seen other people mention 
>>> similar solutions on this forum): 
>>> - read all READ messages at program startup and add all of these to a 
>>> vector 
>>> - every 20 seconds, read ALL messages again and ignore all those that 
>>> are already in the Vector. Any extra ones are new/unread messages. 
>>> - do whatever you want with these new messages but also add them to 
>>> the vector so they are not treated as new on the next iteration. 
>>> The only problem with the above solution is that it's pretty 
>>> inefficient (getting ALL messages regularly from the phone). Seems to 
>>> work so far though. 
>>>
>>> Most of my testing so far has been done with an old Nokia 6230 which 
>>> works very well. Another problem I'm having is that when I tried to 
>>> use the same application (readMessages) on my Samsung Galaxy S2 (GT- 
>>> I9000), readMessages only seems to be able to access messages on the 
>>> SIM card, not on the phone's internal memory. I thought this could 
>>> easily be fixed by setting an option on the phone to save messages to 
>>> SIM by default but no such option exists (not surprising on such a 
>>> modern phone because SIM card storage is so limited!). There is an 
>>> option to save a message to SIM once it has already arrived but that's 
>>> no use to me. 
>>>
>>> Anyway, I'm starting to think it might be too big of a challenge to 
>>> write an SMS feature for my 'communication aid' (http://aacireland.ie/ 
>>> Grapevine.html <http://aacireland.ie/Grapevine.html>) that will be 
>>> compatible with all potential users' 
>>> mobile phones. I think there are too many models and I will be 
>>> spending a lot of time trying to sort out bluetooth drivers and 
>>> awkward behaviours of specific phone models. For that reason, I'm 
>>> starting to think that I should use either a USB GSM modem (that I 
>>> provide to my user with the communication aid tablet PC) or an online 
>>> facility like Clickatell. 
>>>
>>> The disadvantage of the GSM modem is that it's an extra piece of 
>>> hardware to buy, along with a pay-as-you-go SIM card and credit from a 
>>> network provider. The disadvantage of an online SMS facility is that 
>>> you have to have an internet connection to use it, something which may 
>>> not always be available for mobile clients (i.e. Wifi). I think the 
>>> Clickatell route is still the better option though - if a user has a 
>>> smart phone, they can use it's mobile/3G data connection to access the 
>>> internet (or I can provide them with a unit that has 3G in the first 
>>> place!). 
>>>
>>> Any more advice on the best option for me to take Thanasis? I really 
>>> appreciate your input so far (and your great SMS Java library!!). 
>>>
>>> Thanks, 
>>> Brian 
>>>
>>> If anybody's interested, here's my code for the above example 
>>> (identifying NEW messages using a regular call to readMessages()).. 
>>> Sorry, formatting came out a bit ugly! 
>>>
>>> import java.text.DateFormat; 
>>> import java.text.SimpleDateFormat; 
>>> import java.util.Calendar; 
>>> import java.util.Vector; 
>>> import org.smslib.AGateway.Protocols; 
>>> import org.smslib.InboundMessage; 
>>> import org.smslib.InboundMessage.MessageClasses; 
>>> import org.smslib.Service; 
>>> import org.smslib.modem.SerialModemGateway; 
>>>
>>> public class ReadMessages 
>>> { 
>>>     Vector Vmsg; 
>>>
>>>         public void doIt() 
>>>         { 
>>>                 try 
>>>                 { 
>>>                         // Create the Gateway representing the serial 
>>> GSM modem. 
>>>                         SerialModemGateway gateway = new 
>>> SerialModemGateway("modem.com1", 
>>> "COM15", 9600, "", ""); 
>>>                         // Set the modem protocol to PDU (alternative is 
>>> TEXT). PDU is the 
>>> default, anyway... 
>>>                         gateway.setProtocol(Protocols.PDU); 
>>>                         // Do we want the Gateway to be used for Inbound 
>>> messages? 
>>>                         gateway.setInbound(true); 
>>>                         // Do we want the Gateway to be used for 
>>> Outbound messages? 
>>>                         gateway.setOutbound(true); 
>>>
>>>                         Service.getInstance().addGateway(gateway); 
>>>                         Service.getInstance().startService(); 
>>>                         // Printout some general information about the 
>>> modem. 
>>>                         System.out.println("Modem Information:"); 
>>>                         System.out.println("  Manufacturer: " + 
>>> gateway.getManufacturer()); 
>>>                         System.out.println("  Model: " + 
>>> gateway.getModel()); 
>>>
>>>             // Add all of the READ messages on the phone to the 
>>> Vector, Vmsg 
>>>             Vmsg = new Vector(); 
>>>             InboundMessage initmsgs[] = 
>>> Service.getInstance().readMessages(MessageClasses.READ); 
>>>             for (int i = 0; i < initmsgs.length; i++) 
>>>             { 
>>>                 Vmsg.add(getUniqueMessageString(initmsgs[i])); 
>>>                 // Display a one-line summary of each message found 
>>>                 System.out.println(" - "+initmsgs[i].getOriginator() 
>>> +" ("+initmsgs[i].getDate()+"): "+initmsgs[i].getText()); 
>>>             } 
>>>
>>>                         while(true) 
>>>             { 
>>>                 // Get ALL messages from the phone 
>>>                 InboundMessage msg[] = 
>>> Service.getInstance().readMessages(MessageClasses.ALL); 
>>>                 int countnew = 0; 
>>>
>>>                 // Check each message to see if it's already in our 
>>> Vector, Vmsg 
>>>                 for (int i = 0; i < msg.length; i++) 
>>>                 { 
>>>                     // If the message is not in our Vector, it's a NEW 
>>> message 
>>>                     if(!Vmsg.contains(getUniqueMessageString(msg[i]))) 
>>>                     { 
>>>                         // Add the new message to the Vector (so it's 
>>> not treated as new in the next iteration of this while loop) 
>>>                         Vmsg.add(getUniqueMessageString(msg[i])); 
>>>                         // Display the new message (on one line) 
>>>                         System.out.println(" - "+msg[i].getOriginator() 
>>> +" ("+msg[i].getDate()+"): "+msg[i].getText()); 
>>>                         countnew++; 
>>>                     } 
>>>                 } 
>>>                 // Display the status after this check for new 
>>> messages 
>>>                 System.out.println(getCurrentDateTimeString()+": Total 
>>> "+msg.length+" messages ("+countnew+" new).."); 
>>>
>>>                 Thread.sleep(20000); 
>>>             } 
>>>                 } 
>>>                 catch (Exception e) 
>>>                 { 
>>>                         e.printStackTrace(); 
>>>                 } 
>>>                 finally 
>>>                 { 
>>>             try 
>>>             { 
>>>                 Service.getInstance().stopService(); 
>>>             } 
>>>             catch(Exception e) 
>>>             { 
>>>                 e.printStackTrace(); 
>>>             } 
>>>                 } 
>>>         } 
>>>
>>>     public String getUniqueMessageString(InboundMessage msg) 
>>>     { 
>>>         if(msg == null) 
>>>             return null; 
>>>         return msg.getDate().toString(); 
>>>     } 
>>>
>>>     public String getCurrentDateTimeString() 
>>>     { 
>>>         DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd 
>>> HH:mm:ss"); 
>>>         Calendar cal = Calendar.getInstance(); 
>>>         return dateFormat.format(cal.getTime()); 
>>>     } 
>>>
>>>         public static void main(String args[]) 
>>>         { 
>>>                 ReadMessages app = new ReadMessages(); 
>>>         app.doIt(); 
>>>         } 
>>> } 
>>>
>>> On Jun 6, 9:46 pm, Thanasis Delenikas wrote: 
>>> > Hi, 
>>> > 
>>> > I am afraid this is not possible. 
>>> > The phone marks messages as READ by itself. 
>>> > 
>>> > You could disable the notifications (notifications are the ones which 
>>> > instruct SMSLib to read messages "behind your back", without 
>>> > you explicitly requesting the read), but you will get the same result 
>>> > (messages -> status READ) when you call readMessages() as well. 
>>> > 
>>> > Does this suit you? 
>>> > 
>>> > On Wed, Jun 6, 2012 at 1:58 PM, SMSLib Discussion Group on behalf of 
>>> Brian 
>>> > O Carroll <[email address]> wrote: 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > 
>>> > > Hi All, 
>>> > 
>>> > > I have some successful test applications working with SMSlib but 
>>> > > there's one thing that I can't get working properly. When my phone 
>>> is 
>>> > > connected and the service is started, all messages that arrive on 
>>> the 
>>> > > phone immediately get marked as 'read' on the phone (even if I don't 
>>> > > read them from SMSlib or from the phone). 
>>> > 
>>> > > Why is that? Is there some way I can stop SMSlib from doing that? 
>>> > 
>>> > > I am using a regular check of 
>>> > > Service.readMessages(MessageClasses.UNREAD) to see when new messages 
>>> > > arrive. The callback method is not suitable for me because I need to 
>>> > > leave the messages on the phone. I don't want to just delete all 
>>> > > messages from the phone when they are read. 
>>> > 
>>> > > Thanks, 
>>> > > Brian 
>>> > 
>>> > > -- 
>>> > > You received this message because you are subscribed to the Google 
>>> Groups 
>>> > > "SMSLib Discussion Group" group. 
>>> > > To post to this group, send email to [email address]. 
>>> > > To unsubscribe from this group, send email to 
>>> > > [email address]. 
>>> > > For more options, visit this group at 
>>> > >http://groups.google.com/group/smslib?hl=en.
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"SMSLib Discussion Group" group.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/smslib/36805e15-07bf-4fe6-9414-fb78800766cd%40googlegroups.com.

Reply via email to