summaryrefslogtreecommitdiff
path: root/recipes-bsp/multitech/mts-io/mts-io.mtcap.init
blob: b4aa48997858fe4f9aabc7927606ca224d977cb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash

lora_init() {
  # reset lora chip
  mts-io-sysfs store lora-reset 0
}

eth_init() {
  # reset eth phy
  mts-io-sysfs store eth-reset 0
}

cell_init() {
  # remove /dev/modem_at[0,1] symlinks
  rm -f /dev/modem_at[0,1]

  # power down the cellular chip gracefully
  mts-io-sysfs store radio-power 0

  # power up the cellular chip
  mts-io-sysfs store radio-power 1
}

start_lora_led_updater() {
  lora-led-updater &
}

case $1 in
  start)
    echo "Loading mts-io module"
    modprobe mts_io
    lora_init
    eth_init
    cell_init &
    start_lora_led_updater
    ;;

  stop)
    echo "Unloading mts-io module"
    modprobe -r mts_io
    ;;

  *)
    echo "Usage: $0 {start|stop}"
    exit 2
    ;;
esac