OSDN Git Service

12f7ae05061fdffb24e7e04312af73a093b26e2f
[gokigen/A01d.git] / app / src / main / java / net / osdn / gokigen / a01d / camera / nikon / wrapper / command / messages / specific / NikonRegistrationMessage.java
1 package net.osdn.gokigen.a01d.camera.nikon.wrapper.command.messages.specific;
2
3 import androidx.annotation.NonNull;
4
5 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.IPtpIpCommandCallback;
6 import net.osdn.gokigen.a01d.camera.ptpip.wrapper.command.messages.PtpIpCommandBase;
7
8 import java.nio.ByteBuffer;
9 import java.util.UUID;
10
11 public class NikonRegistrationMessage extends PtpIpCommandBase
12 {
13     private final IPtpIpCommandCallback callback;
14
15     public NikonRegistrationMessage(@NonNull IPtpIpCommandCallback callback)
16     {
17         this.callback = callback;
18     }
19
20     @Override
21     public IPtpIpCommandCallback responseCallback()
22     {
23         return (callback);
24     }
25
26     @Override
27     public int getId()
28     {
29         return (SEQ_REGISTRATION);
30     }
31
32     @Override
33     public boolean receiveAgainShortLengthMessage()
34     {
35         return (false);
36     }
37
38     @Override
39     public boolean useSequenceNumber()
40     {
41         return (false);
42     }
43
44     @Override
45     public boolean isIncrementSeqNumber()
46     {
47         return (false);
48     }
49
50     @Override
51     public int receiveDelayMs()
52     {
53         return (80);
54     }
55
56     @Override
57     public byte[] commandBody()
58     {
59         int uuid = UUID.randomUUID().hashCode();
60
61         byte[] typeArray = {
62                 (byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00,
63         };
64
65         byte[] uuidArray = {
66                 (byte)0xad, (byte)0xa5, (byte)0x48, (byte)0x5d, (byte)0x87, (byte)0xb2, (byte)0x7f, (byte)0x0b,
67                 (byte)0xd3, (byte)0xd5, (byte)0xde, (byte)0xd0, (byte)0x12, (byte)0x44, (byte)0x99, (byte)0x32,
68         };
69
70         byte[] deviceNameArray = {
71                 // device_name 'GOKIGEN_a01'
72                 (byte)0x47, (byte)0x00, (byte)0x4f, (byte)0x00, (byte)0x4b, (byte)0x00, (byte)0x49, (byte)0x00,
73                 (byte)0x47, (byte)0x00, (byte)0x45, (byte)0x00, (byte)0x4e, (byte)0x00, (byte)0x5f, (byte)0x00,
74                 (byte)0x61, (byte)0x00, (byte)0x30, (byte)0x00, (byte)0x31, (byte)0x00, (byte)0x00, (byte)0x00,
75         };
76         byte[] versionArray = {
77                 //
78                 (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x00,
79         };
80
81         ByteBuffer byteBuffer = ByteBuffer.allocate(4 + 16 + 24 + 4);
82         byteBuffer.put(typeArray);
83         byteBuffer.put(uuidArray);
84         byteBuffer.put(deviceNameArray);
85         byteBuffer.put(versionArray);
86
87         return (byteBuffer.array());
88     }
89 }