diff --git a/apps/iot/src/iot_database_buffer.erl b/apps/iot/src/iot_database_buffer.erl index fc1cdff..0c5a367 100644 --- a/apps/iot/src/iot_database_buffer.erl +++ b/apps/iot/src/iot_database_buffer.erl @@ -66,7 +66,12 @@ init([]) -> {stop, Reason :: term(), Reply :: term(), NewState :: #state{}} | {stop, Reason :: term(), NewState :: #state{}}). handle_call({find_device, DeviceUUID}, _From, State = #state{devices_map = DevicesMap}) -> - {reply, maps:find(DeviceUUID, DevicesMap), State}. + case maps:take(DeviceUUID, DevicesMap) of + error -> + {reply, error, State}; + {DeviceInfo, NDevicesMap} -> + {reply, {ok, DeviceInfo}, State#state{devices_map = NDevicesMap}} + end. %% @private %% @doc Handling cast messages