3 # Copyright (C) 2018 Weijie Gao <hackpascal@gmail.com>
5 # Helper function to extract mac addresses from mtd part for Phicomm K2T
9 .
/lib
/functions
/system.sh
10 .
/usr
/share
/libubox
/jshn.sh
13 local mtd_blk
=$
(find_mtd_part config
)
15 if [ -z "$mtd_blk" ]; then
16 echo "k2t_config_load: no mtd part named config" >&2
20 local json_size
=$
(dd if=$mtd_blk bs
=1 count
=8 2>/dev
/null
)
22 json_size
="0x$json_size"
23 json_size
=$
((json_size
))
25 if [ "$?" -ne 0 ]; then
26 echo "k2t_config_load: invalid json data size" >&2
30 if [ "$json_size" -eq 0 ]; then
31 echo "k2t_config_load: empty json data" >&2
35 local json_data
=$
(dd if=$mtd_blk bs
=1 skip
=8 count
=$json_size 2>/dev
/null
)
37 json_load
"$json_data"
43 json_set_namespace
"k2t" old_ns
45 if k2t_config_load
; then
46 json_select
"this_dev_info"
51 json_set_namespace old_ns