-module(pt_175).
-include("common.hrl").
-export([
        read/2,
        write/2
    ]).

read(17500, _) ->
    {ok, []};
read(17501, Bin0) ->
    <<DayId:8, _Bin1/binary>> = Bin0, 
    {ok, [DayId]};
read(_Cmd, _R) -> {error, no_match}.

write (17500,[
    Errcode,
    DayState,
    LoginDays
] = Src_Data) ->
    BinList_DayState = [
        item_to_bin_0(DayState_Item) || DayState_Item <- DayState
    ], 

    DayState_Len = length(DayState), 
    Bin_DayState = list_to_binary(BinList_DayState),

    Data = <<
        Errcode:32,
        DayState_Len:16, Bin_DayState/binary,
        LoginDays:32
    >>,
    {ok, pt:encode(17500, Data, Src_Data)};

write (17501,[
    Errcode
] = Src_Data) ->
    Data = <<
        Errcode:32
    >>,
    {ok, pt:encode(17501, Data, Src_Data)};

write(_Cmd, _R) -> ?DEBUG("no_match:~p,~p~n", [_Cmd, _R]), {ok, pt:pack(0, <<>>)}.


item_to_bin_0 ({
    DayId,
    IfCanGet
}) ->
    Data = <<
        DayId:8,
        IfCanGet:8
    >>,
    Data.
