• Welcome to Forum.Deepsoftware.Com. Please login or sign up.
 
March 28, 2024, 03:46:07 pm

News:

SMF - Just Installed!


Is nrGSM support binary sms?

Started by visli, August 24, 2010, 04:25:35 am

Previous topic - Next topic

visli

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

Hello

Yes, you can try to use following code:

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

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

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

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:
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

I found the cause of the problem:
The data can not be converted correctly when type conversion on string and widestring.


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.


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".