whitespace and function reordering
This commit is contained in:
parent
5f71c2158f
commit
d795d5a4a1
17
sms.fnl
17
sms.fnl
@ -54,6 +54,9 @@
|
|||||||
(expect fd pattern fail-pattern))
|
(expect fd pattern fail-pattern))
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
|
(fn command [fd s]
|
||||||
|
(tx fd (.. s "\r\n"))
|
||||||
|
(expect fd "OK" "ERROR"))
|
||||||
|
|
||||||
|
|
||||||
(fn even? [x]
|
(fn even? [x]
|
||||||
@ -66,13 +69,11 @@
|
|||||||
(test= (phone-number->hex "85291234567") "5892214365F7")
|
(test= (phone-number->hex "85291234567") "5892214365F7")
|
||||||
(test= (phone-number->hex "447785016005") "447758100650")
|
(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]
|
(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]
|
(fn septets->hex [body]
|
||||||
;; 0 body0[0-6] | body1[0] << 7
|
;; 0 body0[0-6] | body1[0] << 7
|
||||||
@ -92,7 +93,7 @@
|
|||||||
;; nth byte is bits n..6 of nth septet,
|
;; nth byte is bits n..6 of nth septet,
|
||||||
;; and bits 0..n of(n+1)th 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
|
;; bits n%7..6 of floor(n+ (n/7))th septet
|
||||||
;; and 0..(n%7) of the next one
|
;; and 0..(n%7) of the next one
|
||||||
|
|
||||||
@ -138,10 +139,6 @@
|
|||||||
(test= (message->pdu "85291234567" "It is easy to send text messages.") "01000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E")
|
(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]
|
(fn send-message [{: fd} number body]
|
||||||
(let [pdu (message->pdu number (unicode->gsm body))
|
(let [pdu (message->pdu number (unicode->gsm body))
|
||||||
payload (.. "00" pdu)]
|
payload (.. "00" pdu)]
|
||||||
|
Loading…
Reference in New Issue
Block a user