|
| 1 | +package com.chipkin.bacnet; |
| 2 | + |
| 3 | +import com.sun.jna.Callback; |
| 4 | +import com.sun.jna.Library; |
| 5 | +import com.sun.jna.Pointer; |
| 6 | + |
| 7 | +/** |
| 8 | + * Focused JNA mapping for the APIs this tutorial needs. |
| 9 | + * |
| 10 | + * Keeping this interface small helps beginners understand the minimum calls |
| 11 | + * required to build a BACnet client around the CAS BACnet Stack. |
| 12 | + */ |
| 13 | +public interface ICASBACnetStackLibrary extends Library { |
| 14 | + |
| 15 | + int BACnetStack_GetAPIMajorVersion(); |
| 16 | + int BACnetStack_GetAPIMinorVersion(); |
| 17 | + int BACnetStack_GetAPIPatchVersion(); |
| 18 | + int BACnetStack_GetAPIBuildVersion(); |
| 19 | + |
| 20 | + // Call often from your main loop. This drives stack processing. |
| 21 | + boolean BACnetStack_Tick(); |
| 22 | + boolean BACnetStack_AddDevice(int deviceInstance); |
| 23 | + // Enables/disables a BACnet service for the specified local device. |
| 24 | + boolean BACnetStack_SetServiceEnabled(int deviceInstance, int service, boolean enabled); |
| 25 | + |
| 26 | + int BACnetStack_DecodeAsXML(Pointer inMessageRaw, |
| 27 | + short inMessageLength, |
| 28 | + Pointer outMessageXML, |
| 29 | + int outMessageMaxLength, |
| 30 | + byte networkType); |
| 31 | + |
| 32 | + // Transport integration callbacks. |
| 33 | + // ReceiveMessage: app -> stack (incoming UDP bytes). |
| 34 | + // SendMessage: stack -> app (outgoing UDP bytes). |
| 35 | + // GetSystemTime: app -> stack (UTC seconds). |
| 36 | + void BACnetStack_RegisterCallbackReceiveMessage(ReceiveMessageCallback callback); |
| 37 | + void BACnetStack_RegisterCallbackSendMessage(SendMessageCallback callback); |
| 38 | + void BACnetStack_RegisterCallbackGetSystemTime(GetSystemTimeCallback callback); |
| 39 | + |
| 40 | + boolean BACnetStack_SendWhoIs(Pointer connectionString, |
| 41 | + byte connectionStringLength, |
| 42 | + byte networkType, |
| 43 | + boolean broadcast, |
| 44 | + short destinationNetwork, |
| 45 | + Pointer destinationAddress, |
| 46 | + byte destinationAddressLength); |
| 47 | + |
| 48 | + boolean BACnetStack_BuildReadProperty(short objectType, |
| 49 | + int objectInstance, |
| 50 | + int propertyIdentifier, |
| 51 | + boolean usePropertyArrayIndex, |
| 52 | + int propertyArrayIndex); |
| 53 | + |
| 54 | + void BACnetStack_ClearReadProperty(); |
| 55 | + |
| 56 | + boolean BACnetStack_SendReadProperty(Pointer sentInvokeId, |
| 57 | + Pointer connectionString, |
| 58 | + byte connectionStringLength, |
| 59 | + byte networkType, |
| 60 | + short destinationNetwork, |
| 61 | + Pointer destinationAddress, |
| 62 | + byte destinationAddressLength); |
| 63 | + |
| 64 | + boolean BACnetStack_SendSubscribeCOV(Pointer sentInvokeId, |
| 65 | + int subscriberProcessIdentifier, |
| 66 | + short monitoredObjectType, |
| 67 | + int monitoredObjectInstance, |
| 68 | + boolean issueConfirmedNotifications, |
| 69 | + int lifetime, |
| 70 | + Pointer connectionString, |
| 71 | + byte connectionStringLength, |
| 72 | + byte networkType, |
| 73 | + short destinationNetwork, |
| 74 | + Pointer destinationAddress, |
| 75 | + byte destinationAddressLength); |
| 76 | + |
| 77 | + // Return number of bytes copied into `message`. |
| 78 | + // Fill source connection string and network type for each received packet. |
| 79 | + interface ReceiveMessageCallback extends Callback { |
| 80 | + short callback(Pointer message, |
| 81 | + short maxMessageLength, |
| 82 | + Pointer receivedConnectionString, |
| 83 | + byte maxConnectionStringLength, |
| 84 | + Pointer receivedConnectionStringLength, |
| 85 | + Pointer networkType); |
| 86 | + } |
| 87 | + |
| 88 | + // Send the `message` bytes to `connectionString`. |
| 89 | + // Return number of bytes sent. |
| 90 | + interface SendMessageCallback extends Callback { |
| 91 | + short callback(Pointer message, |
| 92 | + short messageLength, |
| 93 | + Pointer connectionString, |
| 94 | + byte connectionStringLength, |
| 95 | + byte networkType, |
| 96 | + boolean broadcast); |
| 97 | + } |
| 98 | + |
| 99 | + interface GetSystemTimeCallback extends Callback { |
| 100 | + long callback(); |
| 101 | + } |
| 102 | +} |
0 commit comments