grisp / grisp_connect

GRiSP.io client application
Apache License 2.0
1 stars 0 forks source link

SEA-298 Extend protocol to update sw (with grisp_updater) #37

Closed IciaCarroBarallobre closed 1 month ago

IciaCarroBarallobre commented 2 months ago

Tasks


Get partition state local test


%% NO UPDATE
(robot@grisp-001255)4> (robot@grisp-001255)4>  {ID, Encoded} = grisp_connect_api:request(<<"get">>, <<"partition_state">>, #{}).
{<<"-134217295">>,
 <<"{\"id\":\"-134217295\",\"params\":{\"type\":\"partition_state\"},\"method\":\"get\",\"jsonrpc\":\"2.0\"}">>}

(robot@grisp-001255)5> grisp_connect_api:handle_msg(Encoded).
[{send_response,<<"{\"id\":\"-134217295\",\"result\":{\"message\":\"No update pending, running old partition\",\"state\":\"old_no_update"...>>}]```

%% Update pending

Update done
 {ID55, Encoded55} = grisp_connect_api:request(<<"get">>, <<"partition_state">>, #{}).
{<<"-134216271">>,
 <<"{\"id\":\"-134216271\",\"params\":{\"type\":\"partition_state\"},\"method\":\"get\",\"jsonrpc\":\"2.0\"}">>}
(robot@grisp-001255)7> grisp_connect_api:handle_msg(Encoded55).
[{send_response,<<"{\"id\":\"-134216271\",\"result\":{\"message\":\"Reboot required to load new partition\",\"state\":\"old\",\"action_req"...>>}]

%% Remove SD & reboot

[{send_response,<<"{\"id\":\"-134217327\",\"result\":{\"message\":\"New partition booted, validation required\",\"state\":\"new\",\"action"...>>}]
(robot@grisp-001255)3> 

%% Validate :) 

{ID552, Encoded552} = grisp_connect_api:request(<<"post">>, <<"validate">>, #{}).
(robot@grisp-001255)4> grisp_connect_api:handle_msg(Encoded552).
[{send_response,<<"{\"id\":\"-134217311\",\"result\":\"ok\",\"jsonrpc\":\"2.0\"}">>}]

%% Check state
(robot@grisp-001255)5> {ID555, Encoded555} = grisp_connect_api:request(<<"get">>, <<"partition_state">>, #{}).
{<<"-134217295">>,
 <<"{\"id\":\"-134217295\",\"params\":{\"type\":\"partition_state\"},\"method\":\"get\",\"jsonrpc\":\"2.0\"}">>}

(robot@grisp-001255)6> grisp_connect_api:handle_msg(Encoded555).
[{send_response,<<"{\"id\":\"-134217295\",\"result\":{\"message\":\"No update pending, running old partition\",\"state\":\"old_no_update"...>>}]

Improvement and other ideas

Here are some insights and suggestions I encountered while developing:

ziopio commented 1 month ago

Check https://github.com/grisp/grisp_connect/pull/40