@@ -37,13 +37,15 @@ info_usage() ->
3737 " \n\n " ,
3838 " info key - Print HPR's Public Key\n "
3939 " info ips - Export all connected hotspots IPs to /tmp/hotspot_ip.json\n "
40+ " info netids - Export net ids stats as json to /tmp/net_ids.json\n "
4041 ]
4142 ].
4243
4344info_cmd () ->
4445 [
4546 [[" info" , " key" ], [], [], fun info_key /3 ],
46- [[" info" , " ips" ], [], [], fun info_ips /3 ]
47+ [[" info" , " ips" ], [], [], fun info_ips /3 ],
48+ [[" info" , " netids" ], [], [], fun info_netids /3 ]
4749 ].
4850
4951info_key ([" info" , " key" ], [], []) ->
@@ -77,6 +79,28 @@ info_ips(["info", "ips"], [], []) ->
7779info_ips (_ , _ , _ ) ->
7880 usage .
7981
82+ info_netids ([" info" , " netids" ], [], []) ->
83+ List = lists :map (
84+ fun ({NetID , Count }) ->
85+ #{
86+ net_id => NetID ,
87+ count => Count
88+ }
89+ end ,
90+ hpr_netid_stats :export ()
91+ ),
92+ Json = jsx :encode (List ),
93+ case file :open (" /tmp/net_ids.json" , [write ]) of
94+ {ok , File } ->
95+ file :write (File , Json ),
96+ file :close (File ),
97+ c_text (" Exported to /tmp/net_ids.json" );
98+ {error , Reason } ->
99+ c_text (" Failed to export ~p " , [Reason ])
100+ end ;
101+ info_netids (_ , _ , _ ) ->
102+ usage .
103+
80104% %--------------------------------------------------------------------
81105% % Helpers
82106% %--------------------------------------------------------------------
0 commit comments