gsup: Attempt reconnecting if connect fails

Related: OS#5657
Change-Id: I47b6db0f0267bbd4c80fbac9d51a8647862827a0
This commit is contained in:
Pau Espin 2023-08-24 18:00:36 +02:00 committed by laforge
parent 1433617db7
commit 3ae6192d13
1 changed files with 15 additions and 12 deletions

View File

@ -65,17 +65,20 @@ init([Address, Port, Options]) ->
ipa_proto:init(),
% register the GSUP codec with the IPA core; ignore result as we might be doing this multiple times
ipa_proto:register_codec(?IPAC_PROTO_EXT_GSUP, fun gsup_protocol:encode/1, fun gsup_protocol:decode/1),
connect([Address, Port, Options]).
connect([Address, Port, Options]) ->
lager:info("Connecting to GSUP HLR on IP ~s port ~p~n", [Address, Port]),
CcmOptions = #ipa_ccm_options{
serial_number="HSS-00-00-00-00-00-00",
unit_id="0/0/0",
mac_address="00:00:00:00:00:00",
location="00:00:00:00:00:00",
unit_type="00:00:00:00:00:00",
equipment_version="00:00:00:00:00:00",
sw_version="00:00:00:00:00:00",
unit_name="HSS-00-00-00-00-00-00"
},
CcmOptions = #ipa_ccm_options{
serial_number="HSS-00-00-00-00-00-00",
unit_id="0/0/0",
mac_address="00:00:00:00:00:00",
location="00:00:00:00:00:00",
unit_type="00:00:00:00:00:00",
equipment_version="00:00:00:00:00:00",
sw_version="00:00:00:00:00:00",
unit_name="HSS-00-00-00-00-00-00"
},
case ipa_proto:connect(Address, Port, Options) of
{ok, {Socket, IpaPid}} ->
ipa_proto:set_ccm_options(Socket, CcmOptions),
@ -85,11 +88,11 @@ init([Address, Port, Options]) ->
{ok, #gsupc_state{socket=Socket, ipa_pid=IpaPid}};
{error, Reason} ->
lager:error("Connecting to GSUP HLR on IP ~s port ~p failed: ~p~n", [Address, Port, Reason]),
lager:info("Reconnecting to GSUP HLR in 5s...~n", []),
timer:sleep(5000),
{stop, Reason}
connect([Address, Port, Options])
end.
% send a given GSUP message and synchronously wait for message type ExpRes or ExpErr
handle_call({transceive_gsup, GsupMsgTx, ExpRes, ExpErr}, _From, State) ->
Socket = State#gsupc_state.socket,