const smpp = require("smpp");

let message_id = 0;
const session = smpp.connect(
	{
		url: "smpp://0.0.0.0:2775",
		auto_enquire_link_period: 10000,
		debug: true,
	},
	function () {
		session.bind_transceiver(
			{
				system_id: "test",
				password: "test",
			},
			function (pdu) {
				if (pdu.command_status === 0) {
					// Successfully bound
					console.log("sending shit");
					session.submit_sm(
						{
							source_addr: "smpp_test_1",
							destination_addr: "123123123123",
							short_message: "Hello!",
							data_coding: 0xc0,
						},
						function (pdu) {
							if (pdu.command_status === 0) {
								console.log(pdu.message_id);
								message_id = pdu.message_id;
							}
						}
					);
				}
			}
		);
	}
);

session.on("deliver_sm", function (pdu) {
	console.log("Got deliver_sm");
	session.send(pdu.response());
});
