Skip to main content

alert_notification/
alert_notification.rs

1use smpp_codec::common::{Npi, Ton};
2use smpp_codec::pdus::AlertNotification;
3use smpp_codec::tlv::Tlv;
4
5fn main() {
6    println!("=== SMPP Alert Notification Example ===");
7
8    // 1. Create Alert Notification
9    let mut alert = AlertNotification::new(
10        200, // Sequence number
11        "source_addr".to_string(),
12        "esme_addr".to_string(),
13    )
14    .with_source_addr(Ton::International, Npi::Isdn, "123".to_string())
15    .with_esme_addr(Ton::National, Npi::Telex, "456".to_string());
16
17    // 2. Add optional TLV (e.g., ms_availability_status)
18    // Tag 0x0402 is ms_availability_status
19    let tlv = Tlv::new_u8(0x0402, 1); // 1 = Available
20    alert.add_tlv(tlv);
21
22    println!("Alert Notification: {:?}", alert);
23
24    // 3. Encode
25    let mut buf = Vec::new();
26    alert.encode(&mut buf).unwrap();
27    println!("Encoded {} bytes", buf.len());
28}