From d795d5a4a1263563814b4f259e6cdc20568b54bc Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Fri, 16 Sep 2022 21:59:34 +0100 Subject: [PATCH] whitespace and function reordering --- sms.fnl | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/sms.fnl b/sms.fnl index bb145aa..074e8ce 100644 --- a/sms.fnl +++ b/sms.fnl @@ -54,6 +54,9 @@ (expect fd pattern fail-pattern)) nil))) +(fn command [fd s] + (tx fd (.. s "\r\n")) + (expect fd "OK" "ERROR")) (fn even? [x] @@ -66,13 +69,11 @@ (test= (phone-number->hex "85291234567") "5892214365F7") (test= (phone-number->hex "447785016005") "447758100650") -(fn mask [start end] - (let [width (+ 1 (- end start))] - (lshift (rshift 0xff (- 8 width)) start))) (fn bit-range [i start end] - (rshift (band i (mask start end)) start)) - + (let [width (+ 1 (- end start)) + mask (lshift (rshift 0xff (- 8 width)) start)] + (rshift (band i mask) start))) (fn septets->hex [body] ;; 0 body0[0-6] | body1[0] << 7 @@ -92,7 +93,7 @@ ;; nth byte is bits n..6 of nth septet, ;; and bits 0..n of(n+1)th septet - ;; for n>=7, + ;; for all n including n>=7, ;; bits n%7..6 of floor(n+ (n/7))th septet ;; and 0..(n%7) of the next one @@ -138,10 +139,6 @@ (test= (message->pdu "85291234567" "It is easy to send text messages.") "01000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E") -(fn command [fd s] - (tx fd (.. s "\r\n")) - (expect fd "OK" "ERROR")) - (fn send-message [{: fd} number body] (let [pdu (message->pdu number (unicode->gsm body)) payload (.. "00" pdu)] @@ -163,7 +160,7 @@ (bnot ISIG))) (tset termios :oflag (band termios.oflag ( bnot OPOST))) (doto fd - (tcsetattr 0 termios) + (tcsetattr 0 termios) (tcdrain) (command "AT") ; hello ?