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 Saturday, June 9, 2012 at 2:30:30 AM UTC+5:30, Thanasis 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/e9e51832-1550-49b8-af15-b194a74d0195%40googlegroups.com.
