2 // Copyright (c) 2013 Ford Motor Company
4 package com.smartdevicelink.protocol;
6 import com.smartdevicelink.protocol.enums.*;
8 public class ProtocolFrameHeaderFactory {
10 public static ProtocolFrameHeader createStartSession(SessionType serviceType, int messageID, byte version) {
11 ProtocolFrameHeader msg = new ProtocolFrameHeader();
12 msg.setVersion(version);
13 msg.setFrameType(FrameType.Control);
14 msg.setSessionType(serviceType);
15 msg.setFrameData(FrameDataControlFrameType.StartSession.value());
16 msg.setMessageID(messageID);
21 public static ProtocolFrameHeader createStartSessionACK(SessionType serviceType, byte sessionID, int messageID, byte version) {
22 ProtocolFrameHeader msg = new ProtocolFrameHeader();
23 msg.setVersion(version);
24 msg.setFrameType(FrameType.Control);
25 msg.setSessionType(serviceType);
26 msg.setSessionID(sessionID);
27 msg.setFrameData(FrameDataControlFrameType.StartSessionACK.value());
28 msg.setMessageID(messageID);
33 public static ProtocolFrameHeader createStartSessionNACK(SessionType serviceType, byte sessionID, int messageID, byte version) {
34 ProtocolFrameHeader msg = new ProtocolFrameHeader();
35 msg.setVersion(version);
36 msg.setFrameType(FrameType.Control);
37 msg.setSessionType(serviceType);
38 msg.setSessionID(sessionID);
39 msg.setFrameData(FrameDataControlFrameType.StartSessionNACK.value());
40 msg.setMessageID(messageID);
45 public static ProtocolFrameHeader createEndSession(SessionType serviceType, byte sessionID, int messageID, byte version) {
46 ProtocolFrameHeader msg = new ProtocolFrameHeader();
47 msg.setVersion(version);
48 msg.setFrameType(FrameType.Control);
49 msg.setSessionType(serviceType);
50 msg.setSessionID(sessionID);
51 msg.setFrameData(FrameDataControlFrameType.EndSession.value());
52 msg.setMessageID(messageID);
57 public static ProtocolFrameHeader createSingleSendData(SessionType serviceType, byte sessionID,
58 int dataLength, int messageID, byte version) {
59 ProtocolFrameHeader msg = new ProtocolFrameHeader();
60 msg.setVersion(version);
61 msg.setFrameType(FrameType.Single);
62 msg.setSessionType(serviceType);
63 msg.setFrameData(ProtocolFrameHeader.FrameDataSingleFrame);
64 msg.setSessionID(sessionID);
65 msg.setDataSize(dataLength);
66 msg.setMessageID(messageID);
71 public static ProtocolFrameHeader createMultiSendDataFirst(SessionType serviceType, byte sessionID,
72 int messageID, byte version) {
73 ProtocolFrameHeader msg = new ProtocolFrameHeader();
74 msg.setVersion(version);
75 msg.setFrameType(FrameType.First);
76 msg.setSessionType(serviceType);
77 msg.setFrameData(ProtocolFrameHeader.FrameDataFirstFrame);
78 msg.setSessionID(sessionID);
80 msg.setMessageID(messageID);
85 public static ProtocolFrameHeader createMultiSendDataRest(SessionType serviceType, byte sessionID,
86 int dataLength, byte frameSequenceNumber, int messageID, byte version) {
87 ProtocolFrameHeader msg = new ProtocolFrameHeader();
88 msg.setVersion(version);
89 msg.setFrameType(FrameType.Consecutive);
90 msg.setSessionType(serviceType);
91 msg.setFrameData(frameSequenceNumber/*FrameData.ConsecutiveFrame.value()*/);
92 msg.setSessionID(sessionID);
93 msg.setDataSize(dataLength);
94 msg.setMessageID(messageID);
99 public static ProtocolFrameHeader createMultiSendDataRest(SessionType serviceType, byte sessionID,
100 int dataLength, int messageID, byte version) {
101 ProtocolFrameHeader msg = new ProtocolFrameHeader();
102 msg.setVersion(version);
103 msg.setFrameType(FrameType.Consecutive);
104 msg.setSessionType(serviceType);
105 msg.setFrameData(FrameData.ConsecutiveFrame.value());
106 msg.setSessionID(sessionID);
107 msg.setDataSize(dataLength);
108 msg.setMessageID(messageID);
113 public static BinaryFrameHeader createBinaryFrameHeader(byte rpcType, int functionID, int corrID, int jsonSize) {
114 BinaryFrameHeader msg = new BinaryFrameHeader();
115 msg.setRPCType(rpcType);
116 msg.setFunctionID(functionID);
117 msg.setCorrID(corrID);
118 msg.setJsonSize(jsonSize);