2 # Copyright (C) 2018 Weijie Gao <hackpascal@gmail.com>
4 # Helper function to extract mac addresses from mtd part for Phicomm K2T
8 .
/lib
/functions
/system.sh
9 .
/usr
/share
/libubox
/jshn.sh
12 local mtd_blk
=$
(find_mtd_part config
)
14 if [ -z "$mtd_blk" ]; then
15 echo "k2t_config_load: no mtd part named config" >&2
19 local json_size
=$
(dd if=$mtd_blk bs
=1 count
=8 2>/dev
/null
)
21 json_size
="0x$json_size"
22 json_size
=$
((json_size
))
24 if [ "$?" -ne 0 ]; then
25 echo "k2t_config_load: invalid json data size" >&2
29 if [ "$json_size" -eq 0 ]; then
30 echo "k2t_config_load: empty json data" >&2
34 local json_data
=$
(dd if=$mtd_blk bs
=1 skip
=8 count
=$json_size 2>/dev
/null
)
36 json_load
"$json_data"
42 json_set_namespace
"k2t" old_ns
44 if k2t_config_load
; then
45 json_select
"this_dev_info"
50 json_set_namespace old_ns