Author Topic: Traceability on SMS  (Read 4738 times)

henry64

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Traceability on SMS
« on: August 21, 2010, 09:26:33 am »
Hi

Is it possible to have traceability on the sent SMS'es and Reports (delivered) notifications? It seems that none of the ID's are used?

In the log file it seems that there are some "reference" number?

[21-08-2010 10:47:21] nrGsm: DoDataSend: 61 bytes                                                                                                   
[21-08-2010 10:47:21] nrGsm: send:0031000A9154020122000008AA10005400650073007400200053004D0053\1Ah                                                   
[21-08-2010 10:47:24] nrGsm: Sms Sent Notify:  168   <-----

In my "events" log I see no seq numbering or any thing that could match the sent SMS.
21-08-2010 10:45:31 [SMS/GSM event     ] SMS Sent 4520102200 Test SMS idsms: 0
21-08-2010 10:45:36 [SMS/GSM event     ] SMS started
21-08-2010 10:45:36 [SMS/GSM event     ] SMS done
21-08-2010 10:45:38 [SMS/GSM event     ] SMS Report 4520102200 REPORT: Sms is Delivered to 4520102200 at 21-08-2010 10:45:31 idsms: 0, 0, 0

   
« Last Edit: August 21, 2010, 09:33:24 am by henry64 »

henry64

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Traceability on SMS
« Reply #1 on: August 21, 2010, 09:36:58 am »
Using the phonenumer won't work since there could be sent multiple SMS's to the same number within the period where the 1. SMS is being delivered (terminal could be off-line).

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Traceability on SMS
« Reply #2 on: August 23, 2010, 06:05:40 pm »
Hello

You can get 168  in RefID property of received report.

Roman Novgorodov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

henry64

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Traceability on SMS
« Reply #3 on: August 25, 2010, 08:33:22 pm »
Okay, so I have the ID in the "SMSsent" and "SMSreceived" event, but I need to have the ID from the  "nrGsm.SmsSend(aPDU);" to that I can keep track of which SMS's that have been delivered.
Where does that ID come from, how can I obtain that ID from the nrGsm.SmsSend(aPDU);
So the tracking would look like this

nrGsm.SmsSend(aPDU);
nrGsm.SmsSendWait;
StoreRefID(aPDU.RefID); <---- could you return the refid here?

*******
OnSMSSent event
StoreSMSWasSent(strtoint(aMem), now); <-- please consider returning the refid in asms.refid for consistency


*******
OnSMSReceived event
StoreSMSDelivered(asms.RefId, now);

That would give me traceability!!  8)

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Traceability on SMS
« Reply #4 on: August 26, 2010, 07:31:35 pm »
Hello

Thank you for your information.

But nrGsm.SmsSend() just sends command for submit SMS. It does not wait reply from device about result of sending message.
ID of sms can be available in OnSmsSent event only.

Please note that this event contains aSms: TnrPduSms argument. This means you can trace needed sms and RefID.

Roman Novgorodov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

henry64

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Traceability on SMS
« Reply #5 on: August 26, 2010, 07:44:02 pm »
So how do I know which "sms" that was sent - I dont see any link? When I receive the "smssent" I have no reference to stored event in my database, so I cannot set a flag for "sms sent" or "sms delivered".

Could it be made in the nrGsm.SmsSendWait(RefId : integer); <--- when this returns the SMS was sent, then there must be a refid somewhere, right?

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Traceability on SMS
« Reply #6 on: August 27, 2010, 04:08:20 am »
Hello

You can send SMS in PDU format.
You can see submitted SMS in aSms: TnrPduSms argument of OnSmsSent evet.
You can compare aSms.DateTime and others properties with same properties of messages from your list or database.
It's easy.

Roman Novgorodov
DeepSoftware.Com

DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

henry64

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Traceability on SMS
« Reply #7 on: August 27, 2010, 05:47:02 am »
Yes possibly, but in my opinion the valid way of having tracability is to have a unique key just like have made with refid - so my question is still; could you please implement a way of getting the refid back from smssend or nrGsm.SmsSendWait(RefId : integer);
That would solve this issue.

henry64

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Traceability on SMS
« Reply #8 on: August 30, 2010, 12:04:54 pm »
Hi Roman

Could you please have a look at this issue?

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Traceability on SMS
« Reply #9 on: August 30, 2010, 12:38:16 pm »
Hello

Yes I saw your wish about new method.

I can't promise anything now but we will try to implement something like that in the future.

Please understand that SmsSend can be called several times for send several messages before component will get notification about first one was sent.
Possible we will implement something like SmsSendAndWait() ...

Roman Novgorodov
DeepSoftware.Com
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

henry64

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Traceability on SMS
« Reply #10 on: August 30, 2010, 12:47:43 pm »
Hello

Yes I saw your wish about new method.

I can't promise anything now but we will try to implement something like that in the future.
Thanks for your reply.


Please understand that SmsSend can be called several times for send several messages before component will get notification about first one was sent.
Possible we will implement something like SmsSendAndWait() ...
I understand that, that's exactly why I need this  ;D I also realize that it may not be simple, but I really appreciate that you try! 


henry64

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Traceability on SMS (implemented but not working?)
« Reply #11 on: April 27, 2011, 12:25:50 pm »
Hello Roman

I have updated nrCommLib to 9.16 and I'm working on implementing the "SmsSendWaitRefID" functionality in my project, however it seems that it doesnt work very reliable. 1 out of 4 times I get the RefID back.

I'm using the gsmdemo provided with 9.16, I have attached my compiled gsmdemo.exe (zipped) and two screen dumps.

And the logfile of course.




Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Traceability on SMS
« Reply #12 on: April 27, 2011, 05:42:27 pm »
Hello

Thank you for detail information.

It is strange. It seems like I see correct ID 64 in your log file.
We will check more.

Roman Novgorodov
DeepSoftware
DeepSoftware llc - The professional components for Delphi/CBuilder/.NET. The high quality custom software development.
Forums.nrCommLib.Com - DeepSoftware Tech Support Forum.

henry64

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Traceability on SMS
« Reply #13 on: April 28, 2011, 07:35:27 am »
Hello again

I have done some more "testing" in my application and it seems that the "reply" from the modem is somehow out of sync, I have attached a log file where I have a few problems.

1. The  RefID := nrGsm.SmsSendWaitRefID(aPDU); refID returned is from the previously sent message so that when msg 87 is sent  RefID := nrGsm.SmsSendWaitRefID(aPDU); returns 86.
2. If I use nrGsm.UpdateSignalInfo; cxProgressBar1.Position := nrGsm.SignalQuality; then I get +CSQ: 14,0 as RefID  :o please see the attached screendump.
3. The Report function only works with the first message sent, following messages seems not to sent with report := true;
4. I see a timeout in the logfile - I'm not sure if it's a problem??
[2011-04-28 09:14:03] nrGsm: send:AT+CPMS="SM"\0Dh
[2011-04-28 09:14:10] nrGsm: Timeout!!! 7000 ms ""


This is my test
procedure TSetupForm.SendMessageBtnClick(Sender: TObject);
var
  aPDU : TnrPduSms;
  msg : string;
  RefID : string;

begin
  if not GSMOpen then exit;
  case WaitForSingleObject(hMutex, 5000) of
    WAIT_OBJECT_0 :
    try
      with SetupRec do
      try
        if pos(GSMCountryCode, PhoneTE.Text) = 0 then
          PhoneTE.Text := GSMCountryCode + PhoneTE.Text;

        GSMLastTestSMSPhone := PhoneTE.Text;
        GSMLastTestSMSmsg := MessageTE.Text;

        aPDU := TnrPduSms.Create(False);
        aPDU.Phone := PhoneTE.Text;
        aPDU.Coding := pc16bit;
        aPDU.Confirm := ConfirmCB.Checked;
        aPDU.AutoCutText := True;
        aPDU.DateTime := Now;
        aPDU.Text := MessageTE.Text;
        nrGsm.NewSmsMode :=  nsmSkipSave;
        msg := 'Sending SMS %s %s, %s';
        msg := format(msg,[aPDU.Phone, aPDU.Text, aPDU.AsPDU]);
    //    nrGsm.SmsSend(aPDU);
    //    nrGsm.SmsSendWait;
    //    RefID := nrGSm.SmsSendWaitRefID(aPDU.Phone, aPDU.Text, ConfirmCB.Checked);

        RefID := nrGsm.SmsSendWaitRefID(aPDU);
        Label1.Caption := RefID;
        LogEvent(lcDispatchEvents, msg);
        aPDU.Free;
      except on e:exception do
         begin
           ShowMessage(format('SendMessageBtnClick %s',[ e.message]));
         end;
      end;
    finally
      ReleaseMutex(hMutex);
    end;

    WAIT_TIMEOUT : begin
      ShowMessage('Busy, please try again!');
    end;

  end;
end;

henry64

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: Traceability on SMS
« Reply #14 on: April 28, 2011, 09:38:17 am »
I have tracked down issue 4

4. I see a timeout in the logfile - I'm not sure if it's a problem??
[2011-04-28 09:14:03] nrGsm: send:AT+CPMS="SM"\0Dh
[2011-04-28 09:14:10] nrGsm: Timeout!!! 7000 ms ""

I called   nrGsm.SmsDelete(idSms);

in the nrGsmSmsReceived event, I have specified nsmSkipSave in the send so I guess that it's trying to delete a message that is not stored in the GSM memeory?