Author Topic: Is nrGSM support binary sms?  (Read 1902 times)

visli

  • Newbie
  • *
  • Posts: 5
    • View Profile
Is nrGSM support binary sms?
« on: August 24, 2010, 07:25:35 am »
Hi,
I'm looking for a SMS component which can send binary short message(e.g. 0x43 0xE9 0xA7 0x00 0x03 0x78....).
That is, The PDU's TP-Data-Coding-Scheme:
Bit 3Bit 2Alphabet
00Default alphabet
018 bit(Binary, I need)
10UCS2 (16bit)
11Reserved

Can nrGSM support to send 8 bit short message? Thank you!

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Is nrGSM support binary sms?
« Reply #1 on: August 24, 2010, 07:47:31 am »
Hello

Yes, you can try to use following code:

Code: [Select]
var aPDU: TnrPduSms;
begin
  aPDU := TnrPduSms.Create(False);
  aPDU.Coding := pc8bit; //or pc16bit;
  aPDU.Phone := addressPhone; // destination
  aPDU.Text := myData; // here your data bytes
  aPDU.DateTime := Now;
  aPDU.Confirm := false;
  nrGsm1.SmsSend(aPDU);
  aPDU.Free;
end;

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.

visli

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Is nrGSM support binary sms?
« Reply #2 on: August 24, 2010, 12:25:20 pm »
My modem receive a binary msg, PDU data:
1.
0891683108705505F0040D91683129561621F70004018042914470230BDD400000000A000000003F
2.
0891683108705505F0040D91683129651621F700040180420241422314DD500000000D00000009010101C0A800013200DD

But TnrPduSms.AsPDU return a different value:
1.
0891683108705505F0040D91683129561621F70004018042914470230BDD400000000A000000003F
2.
0891683108705505F0040D91683129561621F700040180420241422314DD500000000D00000009010101C0A8000132003F

Roman Novgorodov

  • Engineer
  • Administrator
  • Hero Member
  • *****
  • Posts: 994
  • we will win
    • View Profile
    • Forums.nrCommLib.Com
Re: Is nrGSM support binary sms?
« Reply #3 on: August 24, 2010, 04:25:30 pm »
Hello

I'm sorry I don't understand you. What's wrong?
Does TnrPduSms.AsPDU string transmitted non correctly?

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.

visli

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Is nrGSM support binary sms?
« Reply #4 on: August 25, 2010, 12:54:35 am »
Roman, Sorry for my wrong description. I re-explain: If PDU Code is pc8bit, then the AsPDU property returns is wrong.

The result from HyperTerminal:
at+cmgr=5
+CMGR: 1,,31
0891683108705505F0040D91683129561621F70004018042914470230BDD400000000A00000000DD


OK
at+cmgr=6
+CMGR: 1,,40
0891683108705505F0040D91683129561621F700040180420241422314DD500000000D0000000901
0101C0A800013200DD

OK
at+cmgr=7
+CMGR: 1,,40
0891683108705505F0040D91683129561621F700040180420291822314DD500000000E0000000901
0101C0A800013200DD

OK

The result from GSMDemo.exe(I changed the nrGsm1SmsListItem procedure:
Code: [Select]
procedure TForm1.nrGsm1SmsListItem(Sender: TObject; aMem: String;
  idSms: Integer; aSms: TnrPduSms);
begin
  if aSms <> nil then begin
    if aSms.Report then begin
      Memo2.Lines.Add('REPORT: ' + aMem + ',' + IntToStr(idSms) + ' ======= ');
      Memo2.Lines.Add(aSms.ReportText);
    end else begin
      Memo2.Lines.Add('SMS: Code: ' + IntToStr(Ord(aSms.Coding)) + ' Mem: ' + aMem + ',' + IntToStr(idSms) + ' ======= ');
      Memo2.Lines.Add(asms.AsPDU);
    end;
  end else Memo2.Lines.Add('======= GET SMS LIST DONE!!! =============');
end;
)
SMS: Code: 2 Mem: SM,5 =======
0891683108705505F0040D91683129561621F70004018042914470230BDD400000000A000000003F
SMS: Code: 2 Mem: SM,6 =======
0891683108705505F0040D91683129561621F700040180420241422314DD500000000D00000009010101C0A8000132003F
SMS: Code: 2 Mem: SM,7 =======
0891683108705505F0040D91683129561621F700040180420291822314DD500000000E00000009010101C0A8000132003F
======= GET SMS LIST DONE!!! =============



visli

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Is nrGSM support binary sms?
« Reply #5 on: July 27, 2012, 10:14:18 am »
I found the cause of the problem:
The data can not be converted correctly when type conversion on string and widestring.

Code: [Select]
var
  b1, b2, h: string;
  w: WideString;
begin
  h := 'EEEF40000002000042EE';
  SetLength(b1, Length(h) div 2);
  HexToBin(PChar(h), PChar(b1), Length(b1));
  w := b1;
  b2 := w;  // in here, b1 <> b2

So, when i set the bin data to TnrPduSms.Text property, wrong data will get.

Code: [Select]
procedure TForm4.Button1Click(Sender: TObject);
var
  b, h: string;
  pdu: TnrPduSms;
begin
  pdu := TnrPduSms.Create(False);
  pdu.Phone := '13751020005';
  pdu.Coding := pc8bit;
  h := 'EEEF40000002000042EE';
  SetLength(b, Length(h) div 2);
  HexToBin(PChar(h), PChar(b), Length(b));

  pdu.Text := b;  // Type conversion will lost data
  Memo1.Lines.Text := pdu.AsPDU;
  pdu.Free;
end;

pdu.AsPDU return wrong user data(TP-UD) :
0011000B913157010200F50004AA0AEEEF400000020000423F

The last byte should be "EE", not "3F".