Hi,<div><br></div><div>I'm getting a badarg error in this code</div><div><br></div><div><div>from_binary(Data = <<Head:8, 0:1, PayloadLen:7, Trailing/bits>>, Acc) -></div><div> PayloadBytes= case PayloadLen of</div>
<div> 126 -></div><div> <<ExtPayloadLen:16, _/binary>> = Trailing,</div><div> 2 + ExtPayloadLen;</div><div> 127 -></div><div> <<ExtPayloadLen:64, _/binary>> = Trailing,</div>
<div> 8 + ExtPayloadLen;</div><div> _ -></div><div> %<<Payload:ExtPayloadLen/binary, Rest/binary>></div><div> PayloadLen</div><div> end,</div><div> FrameSize = 16 + (PayloadBytes * 8),</div>
<div> <<Frame:FrameSize, Rest/binary>> = Data,</div><div> from_binary(Rest, [decode_frame(<<Frame/binary>>) | Acc]);</div></div><div><br></div><div>The error points to the line " FrameSize = 16 + (PayloadBytes * 8)".</div>
<div><br></div><div>I've been struggling for a while but I can't figure out what's wrong. Any suggestion?</div><div><br></div><div><br></div>