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

read(34000, _) ->
    {ok, []};
read(34001, _) ->
    {ok, []};
read(34002, Bin0) ->
    <<Wishtype:8, _Bin1/binary>> = Bin0, 
    {ok, [Wishtype]};
read(_Cmd, _R) -> {error, no_match}.

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

write (34001,[
    LuxuryRestTimes,
    Luxurycool,
    ExprRestTimes
] = Src_Data) ->
    Data = <<
        LuxuryRestTimes:8,
        Luxurycool:32,
        ExprRestTimes:8
    >>,
    {ok, pt:encode(34001, Data, Src_Data)};

write (34002,[
    CritRate,
    AwardNum,
    Wishtype
] = Src_Data) ->
    Data = <<
        CritRate:16,
        AwardNum:32,
        Wishtype:8
    >>,
    {ok, pt:encode(34002, Data, Src_Data)};

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


