aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pom.xml6
-rw-r--r--setup/default.xml2
-rw-r--r--src/org/traccar/BaseDataHandler.java18
-rw-r--r--src/org/traccar/BaseEventHandler.java1
-rw-r--r--src/org/traccar/BaseFrameDecoder.java37
-rw-r--r--src/org/traccar/BaseHttpProtocolDecoder.java20
-rw-r--r--src/org/traccar/BasePipelineFactory.java155
-rw-r--r--src/org/traccar/BaseProtocol.java9
-rw-r--r--src/org/traccar/BaseProtocolDecoder.java7
-rw-r--r--src/org/traccar/BaseProtocolEncoder.java32
-rw-r--r--src/org/traccar/CharacterDelimiterFrameDecoder.java20
-rw-r--r--src/org/traccar/DistanceHandler.java2
-rw-r--r--src/org/traccar/EngineHoursHandler.java2
-rw-r--r--src/org/traccar/EventLoopGroupFactory.java37
-rw-r--r--src/org/traccar/ExtendedObjectDecoder.java52
-rw-r--r--src/org/traccar/FilterHandler.java2
-rw-r--r--src/org/traccar/GeocoderHandler.java32
-rw-r--r--src/org/traccar/GeolocationHandler.java30
-rw-r--r--src/org/traccar/GlobalChannelFactory.java56
-rw-r--r--src/org/traccar/GlobalTimer.java4
-rw-r--r--src/org/traccar/HemisphereHandler.java29
-rw-r--r--src/org/traccar/MainEventHandler.java58
-rw-r--r--src/org/traccar/MotionHandler.java2
-rw-r--r--src/org/traccar/NetworkMessage.java38
-rw-r--r--src/org/traccar/PipelineBuilder.java24
-rw-r--r--src/org/traccar/Protocol.java15
-rw-r--r--src/org/traccar/RemoteAddressHandler.java18
-rw-r--r--src/org/traccar/ServerManager.java12
-rw-r--r--src/org/traccar/TrackerServer.java101
-rw-r--r--src/org/traccar/WrapperContext.java255
-rw-r--r--src/org/traccar/WrapperInboundHandler.java90
-rw-r--r--src/org/traccar/WrapperOutboundHandler.java95
-rw-r--r--src/org/traccar/api/CorsResponseFilter.java24
-rw-r--r--src/org/traccar/database/ActiveDevice.java7
-rw-r--r--src/org/traccar/database/ConnectionManager.java8
-rw-r--r--src/org/traccar/database/MediaManager.java6
-rw-r--r--src/org/traccar/events/AlertEventHandler.java2
-rw-r--r--src/org/traccar/events/CommandResultEventHandler.java2
-rw-r--r--src/org/traccar/events/DriverEventHandler.java2
-rw-r--r--src/org/traccar/events/FuelDropEventHandler.java2
-rw-r--r--src/org/traccar/events/GeofenceEventHandler.java2
-rw-r--r--src/org/traccar/events/IgnitionEventHandler.java2
-rw-r--r--src/org/traccar/events/MaintenanceEventHandler.java2
-rw-r--r--src/org/traccar/events/MotionEventHandler.java2
-rw-r--r--src/org/traccar/events/OverspeedEventHandler.java2
-rw-r--r--src/org/traccar/helper/BcdUtil.java8
-rw-r--r--src/org/traccar/helper/BitBuffer.java12
-rw-r--r--src/org/traccar/helper/BufferUtil.java46
-rw-r--r--src/org/traccar/helper/Log.java78
-rw-r--r--src/org/traccar/helper/StringFinder.java41
-rw-r--r--src/org/traccar/processing/ComputedAttributesHandler.java2
-rw-r--r--src/org/traccar/processing/CopyAttributesHandler.java2
-rw-r--r--src/org/traccar/protocol/AdmProtocol.java20
-rw-r--r--src/org/traccar/protocol/AdmProtocolDecoder.java46
-rw-r--r--src/org/traccar/protocol/AdmProtocolEncoder.java1
-rw-r--r--src/org/traccar/protocol/AisProtocol.java11
-rw-r--r--src/org/traccar/protocol/AisProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/AlematicsFrameDecoder.java18
-rw-r--r--src/org/traccar/protocol/AlematicsProtocol.java13
-rw-r--r--src/org/traccar/protocol/AlematicsProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/ApelProtocol.java18
-rw-r--r--src/org/traccar/protocol/ApelProtocolDecoder.java86
-rw-r--r--src/org/traccar/protocol/AplicomFrameDecoder.java16
-rw-r--r--src/org/traccar/protocol/AplicomProtocol.java9
-rw-r--r--src/org/traccar/protocol/AplicomProtocolDecoder.java82
-rw-r--r--src/org/traccar/protocol/AppelloProtocol.java15
-rw-r--r--src/org/traccar/protocol/AppelloProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/AquilaProtocol.java15
-rw-r--r--src/org/traccar/protocol/AquilaProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/Ardi01Protocol.java15
-rw-r--r--src/org/traccar/protocol/Ardi01ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/ArknavProtocol.java13
-rw-r--r--src/org/traccar/protocol/ArknavProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/ArknavX8Protocol.java13
-rw-r--r--src/org/traccar/protocol/ArknavX8ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/ArnaviProtocol.java15
-rw-r--r--src/org/traccar/protocol/ArnaviProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/AstraProtocol.java16
-rw-r--r--src/org/traccar/protocol/AstraProtocolDecoder.java15
-rw-r--r--src/org/traccar/protocol/At2000FrameDecoder.java33
-rw-r--r--src/org/traccar/protocol/At2000Protocol.java14
-rw-r--r--src/org/traccar/protocol/At2000ProtocolDecoder.java87
-rw-r--r--src/org/traccar/protocol/AtrackFrameDecoder.java22
-rw-r--r--src/org/traccar/protocol/AtrackProtocol.java14
-rw-r--r--src/org/traccar/protocol/AtrackProtocolDecoder.java23
-rw-r--r--src/org/traccar/protocol/AtrackProtocolEncoder.java6
-rw-r--r--src/org/traccar/protocol/AuroProtocol.java15
-rw-r--r--src/org/traccar/protocol/AuroProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/AustinNbProtocol.java11
-rw-r--r--src/org/traccar/protocol/AustinNbProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/AutoFonFrameDecoder.java16
-rw-r--r--src/org/traccar/protocol/AutoFonProtocol.java9
-rw-r--r--src/org/traccar/protocol/AutoFonProtocolDecoder.java18
-rw-r--r--src/org/traccar/protocol/AutoGradeProtocol.java13
-rw-r--r--src/org/traccar/protocol/AutoGradeProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Avl301Protocol.java11
-rw-r--r--src/org/traccar/protocol/Avl301ProtocolDecoder.java17
-rw-r--r--src/org/traccar/protocol/BceFrameDecoder.java22
-rw-r--r--src/org/traccar/protocol/BceProtocol.java14
-rw-r--r--src/org/traccar/protocol/BceProtocolDecoder.java42
-rw-r--r--src/org/traccar/protocol/BlackKiteProtocol.java14
-rw-r--r--src/org/traccar/protocol/BlackKiteProtocolDecoder.java52
-rw-r--r--src/org/traccar/protocol/BoxProtocol.java13
-rw-r--r--src/org/traccar/protocol/BoxProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/CalAmpProtocol.java9
-rw-r--r--src/org/traccar/protocol/CalAmpProtocolDecoder.java20
-rw-r--r--src/org/traccar/protocol/CarTrackProtocol.java13
-rw-r--r--src/org/traccar/protocol/CarTrackProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/CarcellProtocol.java13
-rw-r--r--src/org/traccar/protocol/CarcellProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/CarscopProtocol.java13
-rw-r--r--src/org/traccar/protocol/CarscopProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/CastelProtocol.java26
-rw-r--r--src/org/traccar/protocol/CastelProtocolDecoder.java158
-rw-r--r--src/org/traccar/protocol/CastelProtocolEncoder.java17
-rw-r--r--src/org/traccar/protocol/CautelaProtocol.java13
-rw-r--r--src/org/traccar/protocol/CautelaProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/CellocatorFrameDecoder.java30
-rw-r--r--src/org/traccar/protocol/CellocatorProtocol.java24
-rw-r--r--src/org/traccar/protocol/CellocatorProtocolDecoder.java76
-rw-r--r--src/org/traccar/protocol/CellocatorProtocolEncoder.java18
-rw-r--r--src/org/traccar/protocol/CguardProtocol.java15
-rw-r--r--src/org/traccar/protocol/CguardProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/CityeasyProtocol.java11
-rw-r--r--src/org/traccar/protocol/CityeasyProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/CityeasyProtocolEncoder.java14
-rw-r--r--src/org/traccar/protocol/ContinentalProtocol.java9
-rw-r--r--src/org/traccar/protocol/ContinentalProtocolDecoder.java6
-rw-r--r--src/org/traccar/protocol/CradlepointProtocol.java15
-rw-r--r--src/org/traccar/protocol/CradlepointProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/DishaProtocol.java15
-rw-r--r--src/org/traccar/protocol/DishaProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/DmtHttpProtocol.java17
-rw-r--r--src/org/traccar/protocol/DmtHttpProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/DmtProtocol.java18
-rw-r--r--src/org/traccar/protocol/DmtProtocolDecoder.java107
-rw-r--r--src/org/traccar/protocol/DwayProtocol.java15
-rw-r--r--src/org/traccar/protocol/DwayProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/EasyTrackProtocol.java13
-rw-r--r--src/org/traccar/protocol/EasyTrackProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/EelinkProtocol.java16
-rw-r--r--src/org/traccar/protocol/EelinkProtocolDecoder.java25
-rw-r--r--src/org/traccar/protocol/EelinkProtocolEncoder.java22
-rw-r--r--src/org/traccar/protocol/EgtsFrameDecoder.java16
-rw-r--r--src/org/traccar/protocol/EgtsProtocol.java12
-rw-r--r--src/org/traccar/protocol/EgtsProtocolDecoder.java89
-rw-r--r--src/org/traccar/protocol/EnforaProtocol.java11
-rw-r--r--src/org/traccar/protocol/EnforaProtocolDecoder.java36
-rw-r--r--src/org/traccar/protocol/EnforaProtocolEncoder.java10
-rw-r--r--src/org/traccar/protocol/EskyFrameDecoder.java18
-rw-r--r--src/org/traccar/protocol/EskyProtocol.java13
-rw-r--r--src/org/traccar/protocol/EskyProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/ExtremTracProtocol.java15
-rw-r--r--src/org/traccar/protocol/ExtremTracProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/FifotrackProtocol.java13
-rw-r--r--src/org/traccar/protocol/FifotrackProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/FlespiProtocol.java17
-rw-r--r--src/org/traccar/protocol/FlespiProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/FlexCommProtocol.java15
-rw-r--r--src/org/traccar/protocol/FlexCommProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/FlextrackProtocol.java13
-rw-r--r--src/org/traccar/protocol/FlextrackProtocolDecoder.java13
-rw-r--r--src/org/traccar/protocol/FoxProtocol.java13
-rw-r--r--src/org/traccar/protocol/FoxProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/FreedomProtocol.java15
-rw-r--r--src/org/traccar/protocol/FreedomProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/GalileoFrameDecoder.java22
-rw-r--r--src/org/traccar/protocol/GalileoProtocol.java14
-rw-r--r--src/org/traccar/protocol/GalileoProtocolDecoder.java86
-rw-r--r--src/org/traccar/protocol/GalileoProtocolEncoder.java19
-rw-r--r--src/org/traccar/protocol/GatorProtocol.java16
-rw-r--r--src/org/traccar/protocol/GatorProtocolDecoder.java13
-rw-r--r--src/org/traccar/protocol/GenxProtocol.java13
-rw-r--r--src/org/traccar/protocol/GenxProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Gl100Protocol.java18
-rw-r--r--src/org/traccar/protocol/Gl100ProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/Gl200BinaryProtocolDecoder.java22
-rw-r--r--src/org/traccar/protocol/Gl200FrameDecoder.java21
-rw-r--r--src/org/traccar/protocol/Gl200Protocol.java17
-rw-r--r--src/org/traccar/protocol/Gl200ProtocolDecoder.java9
-rw-r--r--src/org/traccar/protocol/Gl200TextProtocolDecoder.java13
-rw-r--r--src/org/traccar/protocol/GlobalSatProtocol.java13
-rw-r--r--src/org/traccar/protocol/GlobalSatProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/GnxProtocol.java13
-rw-r--r--src/org/traccar/protocol/GnxProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/GoSafeProtocol.java13
-rw-r--r--src/org/traccar/protocol/GoSafeProtocolDecoder.java5
-rw-r--r--src/org/traccar/protocol/GotopProtocol.java13
-rw-r--r--src/org/traccar/protocol/GotopProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Gps056FrameDecoder.java18
-rw-r--r--src/org/traccar/protocol/Gps056Protocol.java9
-rw-r--r--src/org/traccar/protocol/Gps056ProtocolDecoder.java37
-rw-r--r--src/org/traccar/protocol/Gps103Protocol.java18
-rw-r--r--src/org/traccar/protocol/Gps103ProtocolDecoder.java9
-rw-r--r--src/org/traccar/protocol/GpsGateProtocol.java13
-rw-r--r--src/org/traccar/protocol/GpsGateProtocolDecoder.java21
-rw-r--r--src/org/traccar/protocol/GpsMarkerProtocol.java13
-rw-r--r--src/org/traccar/protocol/GpsMarkerProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/GpsmtaProtocol.java13
-rw-r--r--src/org/traccar/protocol/GpsmtaProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/GranitFrameDecoder.java26
-rw-r--r--src/org/traccar/protocol/GranitProtocol.java16
-rw-r--r--src/org/traccar/protocol/GranitProtocolDecoder.java63
-rw-r--r--src/org/traccar/protocol/GranitProtocolEncoder.java10
-rw-r--r--src/org/traccar/protocol/Gt02Protocol.java11
-rw-r--r--src/org/traccar/protocol/Gt02ProtocolDecoder.java18
-rw-r--r--src/org/traccar/protocol/Gt06FrameDecoder.java18
-rw-r--r--src/org/traccar/protocol/Gt06Protocol.java9
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolDecoder.java63
-rw-r--r--src/org/traccar/protocol/Gt06ProtocolEncoder.java12
-rw-r--r--src/org/traccar/protocol/Gt30Protocol.java15
-rw-r--r--src/org/traccar/protocol/Gt30ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/H02FrameDecoder.java22
-rw-r--r--src/org/traccar/protocol/H02Protocol.java16
-rw-r--r--src/org/traccar/protocol/H02ProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/H02ProtocolEncoder.java2
-rw-r--r--src/org/traccar/protocol/HaicomProtocol.java13
-rw-r--r--src/org/traccar/protocol/HaicomProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/HomtecsProtocol.java13
-rw-r--r--src/org/traccar/protocol/HomtecsProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/HuaShengFrameDecoder.java20
-rw-r--r--src/org/traccar/protocol/HuaShengProtocol.java9
-rw-r--r--src/org/traccar/protocol/HuaShengProtocolDecoder.java24
-rw-r--r--src/org/traccar/protocol/HuabaoFrameDecoder.java18
-rw-r--r--src/org/traccar/protocol/HuabaoProtocol.java9
-rw-r--r--src/org/traccar/protocol/HuabaoProtocolDecoder.java35
-rw-r--r--src/org/traccar/protocol/HuabaoProtocolEncoder.java12
-rw-r--r--src/org/traccar/protocol/HunterProProtocol.java13
-rw-r--r--src/org/traccar/protocol/HunterProProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/IdplProtocol.java15
-rw-r--r--src/org/traccar/protocol/IdplProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/IntellitracFrameDecoder.java20
-rw-r--r--src/org/traccar/protocol/IntellitracProtocol.java13
-rw-r--r--src/org/traccar/protocol/IntellitracProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Ivt401Protocol.java11
-rw-r--r--src/org/traccar/protocol/Ivt401ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/JpKorjarFrameDecoder.java15
-rw-r--r--src/org/traccar/protocol/JpKorjarProtocol.java11
-rw-r--r--src/org/traccar/protocol/JpKorjarProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Jt600FrameDecoder.java18
-rw-r--r--src/org/traccar/protocol/Jt600Protocol.java11
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolDecoder.java19
-rw-r--r--src/org/traccar/protocol/Jt600ProtocolEncoder.java4
-rw-r--r--src/org/traccar/protocol/KenjiProtocol.java17
-rw-r--r--src/org/traccar/protocol/KenjiProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/KhdProtocol.java11
-rw-r--r--src/org/traccar/protocol/KhdProtocolDecoder.java19
-rw-r--r--src/org/traccar/protocol/KhdProtocolEncoder.java10
-rw-r--r--src/org/traccar/protocol/L100FrameDecoder.java16
-rw-r--r--src/org/traccar/protocol/L100Protocol.java11
-rw-r--r--src/org/traccar/protocol/L100ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/LaipacProtocol.java15
-rw-r--r--src/org/traccar/protocol/LaipacProtocolDecoder.java13
-rw-r--r--src/org/traccar/protocol/M2cProtocol.java13
-rw-r--r--src/org/traccar/protocol/M2cProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/M2mProtocol.java11
-rw-r--r--src/org/traccar/protocol/M2mProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/MaestroProtocol.java15
-rw-r--r--src/org/traccar/protocol/MaestroProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/ManPowerProtocol.java13
-rw-r--r--src/org/traccar/protocol/ManPowerProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/MegastekFrameDecoder.java22
-rw-r--r--src/org/traccar/protocol/MegastekProtocol.java13
-rw-r--r--src/org/traccar/protocol/MegastekProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/MeiligaoFrameDecoder.java18
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocol.java12
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolDecoder.java51
-rw-r--r--src/org/traccar/protocol/MeiligaoProtocolEncoder.java12
-rw-r--r--src/org/traccar/protocol/MeitrackFrameDecoder.java16
-rw-r--r--src/org/traccar/protocol/MeitrackProtocol.java25
-rw-r--r--src/org/traccar/protocol/MeitrackProtocolDecoder.java100
-rw-r--r--src/org/traccar/protocol/MiniFinderProtocol.java13
-rw-r--r--src/org/traccar/protocol/MiniFinderProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Mta6Protocol.java15
-rw-r--r--src/org/traccar/protocol/Mta6ProtocolDecoder.java51
-rw-r--r--src/org/traccar/protocol/MtxProtocol.java15
-rw-r--r--src/org/traccar/protocol/MtxProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/MxtFrameDecoder.java22
-rw-r--r--src/org/traccar/protocol/MxtProtocol.java14
-rw-r--r--src/org/traccar/protocol/MxtProtocolDecoder.java59
-rw-r--r--src/org/traccar/protocol/NavigilFrameDecoder.java24
-rw-r--r--src/org/traccar/protocol/NavigilProtocol.java14
-rw-r--r--src/org/traccar/protocol/NavigilProtocolDecoder.java158
-rw-r--r--src/org/traccar/protocol/NavisProtocol.java18
-rw-r--r--src/org/traccar/protocol/NavisProtocolDecoder.java112
-rw-r--r--src/org/traccar/protocol/NoranProtocol.java14
-rw-r--r--src/org/traccar/protocol/NoranProtocolDecoder.java58
-rw-r--r--src/org/traccar/protocol/NoranProtocolEncoder.java23
-rw-r--r--src/org/traccar/protocol/NvsFrameDecoder.java18
-rw-r--r--src/org/traccar/protocol/NvsProtocol.java9
-rw-r--r--src/org/traccar/protocol/NvsProtocolDecoder.java20
-rw-r--r--src/org/traccar/protocol/ObdDongleProtocol.java11
-rw-r--r--src/org/traccar/protocol/ObdDongleProtocolDecoder.java24
-rw-r--r--src/org/traccar/protocol/OigoProtocol.java9
-rw-r--r--src/org/traccar/protocol/OigoProtocolDecoder.java26
-rw-r--r--src/org/traccar/protocol/OkoProtocol.java11
-rw-r--r--src/org/traccar/protocol/OkoProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/OpenGtsProtocol.java13
-rw-r--r--src/org/traccar/protocol/OpenGtsProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/OrionFrameDecoder.java22
-rw-r--r--src/org/traccar/protocol/OrionProtocol.java14
-rw-r--r--src/org/traccar/protocol/OrionProtocolDecoder.java29
-rw-r--r--src/org/traccar/protocol/OsmAndProtocol.java13
-rw-r--r--src/org/traccar/protocol/OsmAndProtocolDecoder.java23
-rw-r--r--src/org/traccar/protocol/OwnTracksProtocol.java15
-rw-r--r--src/org/traccar/protocol/OwnTracksProtocolDecoder.java13
-rw-r--r--src/org/traccar/protocol/PathAwayProtocol.java15
-rw-r--r--src/org/traccar/protocol/PathAwayProtocolDecoder.java31
-rw-r--r--src/org/traccar/protocol/PiligrimProtocol.java17
-rw-r--r--src/org/traccar/protocol/PiligrimProtocolDecoder.java41
-rw-r--r--src/org/traccar/protocol/PretraceProtocol.java13
-rw-r--r--src/org/traccar/protocol/PretraceProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/PricolProtocol.java16
-rw-r--r--src/org/traccar/protocol/PricolProtocolDecoder.java16
-rw-r--r--src/org/traccar/protocol/ProgressProtocol.java18
-rw-r--r--src/org/traccar/protocol/ProgressProtocolDecoder.java78
-rw-r--r--src/org/traccar/protocol/Pt3000Protocol.java13
-rw-r--r--src/org/traccar/protocol/Pt3000ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Pt502FrameDecoder.java20
-rw-r--r--src/org/traccar/protocol/Pt502Protocol.java14
-rw-r--r--src/org/traccar/protocol/Pt502ProtocolDecoder.java19
-rw-r--r--src/org/traccar/protocol/Pt60Protocol.java11
-rw-r--r--src/org/traccar/protocol/Pt60ProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/RaveonProtocol.java15
-rw-r--r--src/org/traccar/protocol/RaveonProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/RecodaProtocol.java18
-rw-r--r--src/org/traccar/protocol/RecodaProtocolDecoder.java28
-rw-r--r--src/org/traccar/protocol/RitiProtocol.java18
-rw-r--r--src/org/traccar/protocol/RitiProtocolDecoder.java18
-rw-r--r--src/org/traccar/protocol/RoboTrackFrameDecoder.java18
-rw-r--r--src/org/traccar/protocol/RoboTrackProtocol.java12
-rw-r--r--src/org/traccar/protocol/RoboTrackProtocolDecoder.java28
-rw-r--r--src/org/traccar/protocol/RuptelaProtocol.java11
-rw-r--r--src/org/traccar/protocol/RuptelaProtocolDecoder.java25
-rw-r--r--src/org/traccar/protocol/RuptelaProtocolEncoder.java14
-rw-r--r--src/org/traccar/protocol/SabertekFrameDecoder.java14
-rw-r--r--src/org/traccar/protocol/SabertekProtocol.java9
-rw-r--r--src/org/traccar/protocol/SabertekProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/SanavProtocol.java13
-rw-r--r--src/org/traccar/protocol/SanavProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/SigfoxProtocol.java17
-rw-r--r--src/org/traccar/protocol/SigfoxProtocolDecoder.java45
-rw-r--r--src/org/traccar/protocol/SiwiProtocol.java13
-rw-r--r--src/org/traccar/protocol/SiwiProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/SkypatrolProtocol.java7
-rw-r--r--src/org/traccar/protocol/SkypatrolProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/SmokeyProtocol.java9
-rw-r--r--src/org/traccar/protocol/SmokeyProtocolDecoder.java24
-rw-r--r--src/org/traccar/protocol/SpotProtocol.java17
-rw-r--r--src/org/traccar/protocol/SpotProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/StarLinkProtocol.java15
-rw-r--r--src/org/traccar/protocol/StarLinkProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Stl060FrameDecoder.java14
-rw-r--r--src/org/traccar/protocol/Stl060Protocol.java13
-rw-r--r--src/org/traccar/protocol/Stl060ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/SuntechProtocol.java13
-rw-r--r--src/org/traccar/protocol/SuntechProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/SupermateProtocol.java14
-rw-r--r--src/org/traccar/protocol/SupermateProtocolDecoder.java10
-rw-r--r--src/org/traccar/protocol/T55Protocol.java20
-rw-r--r--src/org/traccar/protocol/T55ProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/T57FrameDecoder.java16
-rw-r--r--src/org/traccar/protocol/T57Protocol.java13
-rw-r--r--src/org/traccar/protocol/T57ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/T800xProtocol.java11
-rw-r--r--src/org/traccar/protocol/T800xProtocolDecoder.java46
-rw-r--r--src/org/traccar/protocol/T800xProtocolEncoder.java10
-rw-r--r--src/org/traccar/protocol/TaipProtocol.java18
-rw-r--r--src/org/traccar/protocol/TaipProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/TelemaxProtocol.java13
-rw-r--r--src/org/traccar/protocol/TelemaxProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/TelicFrameDecoder.java23
-rw-r--r--src/org/traccar/protocol/TelicProtocol.java18
-rw-r--r--src/org/traccar/protocol/TelicProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/TeltonikaFrameDecoder.java21
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocol.java14
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolDecoder.java50
-rw-r--r--src/org/traccar/protocol/TeltonikaProtocolEncoder.java13
-rw-r--r--src/org/traccar/protocol/ThinkRaceProtocol.java11
-rw-r--r--src/org/traccar/protocol/ThinkRaceProtocolDecoder.java17
-rw-r--r--src/org/traccar/protocol/Tk102Protocol.java11
-rw-r--r--src/org/traccar/protocol/Tk102ProtocolDecoder.java28
-rw-r--r--src/org/traccar/protocol/Tk103FrameDecoder.java16
-rw-r--r--src/org/traccar/protocol/Tk103Protocol.java18
-rw-r--r--src/org/traccar/protocol/Tk103ProtocolDecoder.java9
-rw-r--r--src/org/traccar/protocol/Tlt2hProtocol.java13
-rw-r--r--src/org/traccar/protocol/Tlt2hProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/TlvProtocol.java9
-rw-r--r--src/org/traccar/protocol/TlvProtocolDecoder.java33
-rw-r--r--src/org/traccar/protocol/TmgFrameDecoder.java45
-rw-r--r--src/org/traccar/protocol/TmgProtocol.java13
-rw-r--r--src/org/traccar/protocol/TmgProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/TopflytechProtocol.java13
-rw-r--r--src/org/traccar/protocol/TopflytechProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/TotemFrameDecoder.java21
-rw-r--r--src/org/traccar/protocol/TotemProtocol.java13
-rw-r--r--src/org/traccar/protocol/TotemProtocolDecoder.java7
-rw-r--r--src/org/traccar/protocol/Tr20Protocol.java15
-rw-r--r--src/org/traccar/protocol/Tr20ProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/Tr900Protocol.java20
-rw-r--r--src/org/traccar/protocol/Tr900ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/TrackboxProtocol.java15
-rw-r--r--src/org/traccar/protocol/TrackboxProtocolDecoder.java13
-rw-r--r--src/org/traccar/protocol/TrakMateProtocol.java13
-rw-r--r--src/org/traccar/protocol/TrakMateProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/TramigoFrameDecoder.java45
-rw-r--r--src/org/traccar/protocol/TramigoProtocol.java14
-rw-r--r--src/org/traccar/protocol/TramigoProtocolDecoder.java52
-rw-r--r--src/org/traccar/protocol/TrvProtocol.java13
-rw-r--r--src/org/traccar/protocol/TrvProtocolDecoder.java11
-rw-r--r--src/org/traccar/protocol/Tt8850Protocol.java13
-rw-r--r--src/org/traccar/protocol/Tt8850ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/TytanProtocol.java9
-rw-r--r--src/org/traccar/protocol/TytanProtocolDecoder.java23
-rw-r--r--src/org/traccar/protocol/TzoneProtocol.java12
-rw-r--r--src/org/traccar/protocol/TzoneProtocolDecoder.java18
-rw-r--r--src/org/traccar/protocol/UlbotechFrameDecoder.java23
-rw-r--r--src/org/traccar/protocol/UlbotechProtocol.java9
-rw-r--r--src/org/traccar/protocol/UlbotechProtocolDecoder.java44
-rw-r--r--src/org/traccar/protocol/UproProtocol.java11
-rw-r--r--src/org/traccar/protocol/UproProtocolDecoder.java35
-rw-r--r--src/org/traccar/protocol/V680Protocol.java18
-rw-r--r--src/org/traccar/protocol/V680ProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/VisiontekProtocol.java13
-rw-r--r--src/org/traccar/protocol/VisiontekProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/Vt200FrameDecoder.java19
-rw-r--r--src/org/traccar/protocol/Vt200Protocol.java9
-rw-r--r--src/org/traccar/protocol/Vt200ProtocolDecoder.java14
-rw-r--r--src/org/traccar/protocol/VtfmsFrameDecoder.java17
-rw-r--r--src/org/traccar/protocol/VtfmsProtocol.java17
-rw-r--r--src/org/traccar/protocol/VtfmsProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/WatchFrameDecoder.java17
-rw-r--r--src/org/traccar/protocol/WatchProtocol.java12
-rw-r--r--src/org/traccar/protocol/WatchProtocolDecoder.java27
-rw-r--r--src/org/traccar/protocol/WatchProtocolEncoder.java6
-rw-r--r--src/org/traccar/protocol/WialonProtocol.java16
-rw-r--r--src/org/traccar/protocol/WialonProtocolDecoder.java19
-rw-r--r--src/org/traccar/protocol/WondexFrameDecoder.java27
-rw-r--r--src/org/traccar/protocol/WondexProtocol.java17
-rw-r--r--src/org/traccar/protocol/WondexProtocolDecoder.java8
-rw-r--r--src/org/traccar/protocol/XexunFrameDecoder.java25
-rw-r--r--src/org/traccar/protocol/XexunProtocol.java16
-rw-r--r--src/org/traccar/protocol/XexunProtocolDecoder.java4
-rw-r--r--src/org/traccar/protocol/XirgoProtocol.java19
-rw-r--r--src/org/traccar/protocol/XirgoProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Xt013Protocol.java16
-rw-r--r--src/org/traccar/protocol/Xt013ProtocolDecoder.java2
-rw-r--r--src/org/traccar/protocol/Xt2400Protocol.java9
-rw-r--r--src/org/traccar/protocol/Xt2400ProtocolDecoder.java12
-rw-r--r--src/org/traccar/protocol/YwtProtocol.java15
-rw-r--r--src/org/traccar/protocol/YwtProtocolDecoder.java9
-rw-r--r--src/org/traccar/smpp/SmppClient.java2
-rw-r--r--test/org/traccar/FilterHandlerTest.java14
-rw-r--r--test/org/traccar/ProtocolTest.java45
-rw-r--r--test/org/traccar/helper/BcdUtilTest.java8
-rw-r--r--test/org/traccar/helper/ChecksumTest.java26
-rw-r--r--test/org/traccar/helper/StringFinderTest.java25
-rw-r--r--test/org/traccar/protocol/AdmProtocolDecoderTest.java16
-rw-r--r--test/org/traccar/protocol/At2000FrameDecoderTest.java16
-rw-r--r--test/org/traccar/protocol/At2000ProtocolDecoderTest.java22
-rw-r--r--test/org/traccar/protocol/AtrackFrameDecoderTest.java10
-rw-r--r--test/org/traccar/protocol/BceProtocolDecoderTest.java16
-rw-r--r--test/org/traccar/protocol/BlackKiteProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/CastelProtocolDecoderTest.java88
-rw-r--r--test/org/traccar/protocol/CellocatorProtocolDecoderTest.java12
-rw-r--r--test/org/traccar/protocol/DmtHttpProtocolDecoderTest.java2
-rw-r--r--test/org/traccar/protocol/DmtProtocolDecoderTest.java20
-rw-r--r--test/org/traccar/protocol/EgtsFrameDecoderTest.java4
-rw-r--r--test/org/traccar/protocol/EgtsProtocolDecoderTest.java16
-rw-r--r--test/org/traccar/protocol/FlespiProtocolDecoderTest.java2
-rw-r--r--test/org/traccar/protocol/GalileoFrameDecoderTest.java10
-rw-r--r--test/org/traccar/protocol/GalileoProtocolDecoderTest.java16
-rw-r--r--test/org/traccar/protocol/GranitFrameDecoderTest.java18
-rw-r--r--test/org/traccar/protocol/GranitProtocolDecoderTest.java22
-rw-r--r--test/org/traccar/protocol/MeitrackProtocolDecoderTest.java11
-rw-r--r--test/org/traccar/protocol/MxtProtocolDecoderTest.java22
-rw-r--r--test/org/traccar/protocol/NavigilProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/NavisProtocolDecoderTest.java14
-rw-r--r--test/org/traccar/protocol/NoranProtocolDecoderTest.java22
-rw-r--r--test/org/traccar/protocol/OrionProtocolDecoderTest.java12
-rw-r--r--test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java2
-rw-r--r--test/org/traccar/protocol/PiligrimProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/ProgressProtocolDecoderTest.java5
-rw-r--r--test/org/traccar/protocol/Pt502FrameDecoderTest.java14
-rw-r--r--test/org/traccar/protocol/RecodaProtocolDecoderTest.java8
-rw-r--r--test/org/traccar/protocol/RitiProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/protocol/RoboTrackProtocolDecoderTest.java8
-rw-r--r--test/org/traccar/protocol/SigfoxProtocolDecoderTest.java2
-rw-r--r--test/org/traccar/protocol/SpotProtocolDecoderTest.java2
-rw-r--r--test/org/traccar/protocol/TelicFrameDecoderTest.java28
-rw-r--r--test/org/traccar/protocol/Tk103FrameDecoderTest.java4
-rw-r--r--test/org/traccar/protocol/TramigoProtocolDecoderTest.java34
492 files changed, 4649 insertions, 4414 deletions
diff --git a/pom.xml b/pom.xml
index c9c1b9bd6..bf2aac74a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,8 +70,8 @@
</dependency>
<dependency>
<groupId>io.netty</groupId>
- <artifactId>netty</artifactId>
- <version>3.10.6.Final</version>
+ <artifactId>netty-all</artifactId>
+ <version>4.1.25.Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@@ -171,7 +171,7 @@
<dependency>
<groupId>com.fizzed</groupId>
<artifactId>ch-smpp</artifactId>
- <version>5.0.9</version>
+ <version>6.0.0-netty4-beta-3</version>
</dependency>
</dependencies>
diff --git a/setup/default.xml b/setup/default.xml
index 1ced20f38..f5ec4b9bf 100644
--- a/setup/default.xml
+++ b/setup/default.xml
@@ -76,7 +76,7 @@
<!-- PROTOCOL CONFIG -->
<entry key='gps103.port'>5001</entry>
- <entry key='tk103.port'>5002</entry>
+ <entry key='tk103.port'>5001</entry>
<entry key='gl100.port'>5003</entry>
<entry key='gl200.port'>5004</entry>
<entry key='t55.port'>5005</entry>
diff --git a/src/org/traccar/BaseDataHandler.java b/src/org/traccar/BaseDataHandler.java
index 0c71a6a4d..8a461cc19 100644
--- a/src/org/traccar/BaseDataHandler.java
+++ b/src/org/traccar/BaseDataHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,21 +15,19 @@
*/
package org.traccar;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
import org.traccar.model.Position;
-public abstract class BaseDataHandler extends OneToOneDecoder {
+public abstract class BaseDataHandler extends ChannelInboundHandlerAdapter {
@Override
- protected final Object decode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
-
+ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof Position) {
- return handlePosition((Position) msg);
+ ctx.fireChannelRead(handlePosition((Position) msg));
+ } else {
+ super.channelRead(ctx, msg);
}
-
- return msg;
}
protected abstract Position handlePosition(Position position);
diff --git a/src/org/traccar/BaseEventHandler.java b/src/org/traccar/BaseEventHandler.java
index b6f7e2085..50bbbefa2 100644
--- a/src/org/traccar/BaseEventHandler.java
+++ b/src/org/traccar/BaseEventHandler.java
@@ -24,7 +24,6 @@ public abstract class BaseEventHandler extends BaseDataHandler {
@Override
protected Position handlePosition(Position position) {
-
Map<Event, Position> events = analyzePosition(position);
if (events != null && Context.getNotificationManager() != null) {
Context.getNotificationManager().updateEvents(events);
diff --git a/src/org/traccar/BaseFrameDecoder.java b/src/org/traccar/BaseFrameDecoder.java
new file mode 100644
index 000000000..f90f90e4b
--- /dev/null
+++ b/src/org/traccar/BaseFrameDecoder.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+
+import java.util.List;
+
+public abstract class BaseFrameDecoder extends ByteToMessageDecoder {
+
+ @Override
+ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
+ Object decoded = decode(ctx, ctx != null ? ctx.channel() : null, in);
+ if (decoded != null) {
+ out.add(decoded);
+ }
+ }
+
+ protected abstract Object decode(ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception;
+
+}
diff --git a/src/org/traccar/BaseHttpProtocolDecoder.java b/src/org/traccar/BaseHttpProtocolDecoder.java
index 934a1b81e..57a68acac 100644
--- a/src/org/traccar/BaseHttpProtocolDecoder.java
+++ b/src/org/traccar/BaseHttpProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,12 @@
*/
package org.traccar;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
-import org.jboss.netty.handler.codec.http.HttpHeaders;
-import org.jboss.netty.handler.codec.http.HttpResponse;
-import org.jboss.netty.handler.codec.http.HttpResponseStatus;
-import org.jboss.netty.handler.codec.http.HttpVersion;
+import io.netty.channel.Channel;
+import io.netty.handler.codec.http.DefaultFullHttpResponse;
+import io.netty.handler.codec.http.HttpHeaderNames;
+import io.netty.handler.codec.http.HttpResponse;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.handler.codec.http.HttpVersion;
public abstract class BaseHttpProtocolDecoder extends BaseProtocolDecoder {
@@ -30,9 +30,9 @@ public abstract class BaseHttpProtocolDecoder extends BaseProtocolDecoder {
public void sendResponse(Channel channel, HttpResponseStatus status) {
if (channel != null) {
- HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, status);
- response.headers().add(HttpHeaders.Names.CONTENT_LENGTH, 0);
- channel.write(response);
+ HttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, status);
+ response.headers().add(HttpHeaderNames.CONTENT_LENGTH, 0);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
diff --git a/src/org/traccar/BasePipelineFactory.java b/src/org/traccar/BasePipelineFactory.java
index b0de67a15..6269fb8cc 100644
--- a/src/org/traccar/BasePipelineFactory.java
+++ b/src/org/traccar/BasePipelineFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,20 +15,20 @@
*/
package org.traccar;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.ChannelEvent;
-import org.jboss.netty.channel.ChannelHandler;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.Channels;
-import org.jboss.netty.channel.DownstreamMessageEvent;
-import org.jboss.netty.channel.MessageEvent;
-import org.jboss.netty.channel.SimpleChannelHandler;
-import org.jboss.netty.handler.logging.LoggingHandler;
-import org.jboss.netty.handler.timeout.IdleStateHandler;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelDuplexHandler;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandler;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOutboundHandler;
+import io.netty.channel.ChannelPipeline;
+import io.netty.channel.ChannelPromise;
+import io.netty.channel.socket.DatagramChannel;
+import io.netty.channel.socket.DatagramPacket;
+import io.netty.handler.timeout.IdleStateHandler;
import org.traccar.events.CommandResultEventHandler;
import org.traccar.events.DriverEventHandler;
import org.traccar.events.FuelDropEventHandler;
@@ -44,7 +44,7 @@ import org.traccar.processing.CopyAttributesHandler;
import java.net.InetSocketAddress;
-public abstract class BasePipelineFactory implements ChannelPipelineFactory {
+public abstract class BasePipelineFactory extends ChannelInitializer<Channel> {
private final TrackerServer server;
private int timeout;
@@ -70,7 +70,7 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
private MaintenanceEventHandler maintenanceEventHandler;
private DriverEventHandler driverEventHandler;
- private static final class OpenChannelHandler extends SimpleChannelHandler {
+ private static final class OpenChannelHandler extends ChannelDuplexHandler {
private final TrackerServer server;
@@ -79,41 +79,83 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
}
@Override
- public void channelOpen(ChannelHandlerContext ctx, ChannelStateEvent e) {
- server.getChannelGroup().add(e.getChannel());
+ public void channelActive(ChannelHandlerContext ctx) throws Exception {
+ super.channelActive(ctx);
+ server.getChannelGroup().add(ctx.channel());
}
+
+ @Override
+ public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+ super.channelInactive(ctx);
+ server.getChannelGroup().remove(ctx.channel());
+ }
+
}
- private static class StandardLoggingHandler extends LoggingHandler {
+ private static class NetworkMessageHandler extends ChannelDuplexHandler {
@Override
- public void log(ChannelEvent e) {
- if (e instanceof MessageEvent) {
- MessageEvent event = (MessageEvent) e;
- StringBuilder msg = new StringBuilder();
-
- msg.append("[").append(String.format("%08X", e.getChannel().getId())).append(": ");
- msg.append(((InetSocketAddress) e.getChannel().getLocalAddress()).getPort());
- if (e instanceof DownstreamMessageEvent) {
- msg.append(" > ");
- } else {
- msg.append(" < ");
- }
+ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+ if (ctx.channel() instanceof DatagramChannel) {
+ DatagramPacket packet = (DatagramPacket) msg;
+ ctx.fireChannelRead(new NetworkMessage(packet.content(), packet.sender()));
+ } else {
+ ByteBuf buffer = (ByteBuf) msg;
+ ctx.fireChannelRead(new NetworkMessage(buffer, ctx.channel().remoteAddress()));
+ }
+ }
- if (event.getRemoteAddress() != null) {
- msg.append(((InetSocketAddress) event.getRemoteAddress()).getHostString());
- } else {
- msg.append("null");
- }
- msg.append("]");
+ @Override
+ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
+ NetworkMessage message = (NetworkMessage) msg;
+ if (ctx.channel() instanceof DatagramChannel) {
+ InetSocketAddress recipient = (InetSocketAddress) message.getRemoteAddress();
+ InetSocketAddress sender = (InetSocketAddress) ctx.channel().localAddress();
+ ctx.write(new DatagramPacket((ByteBuf) message.getMessage(), recipient, sender), promise);
+ } else {
+ ctx.write(message.getMessage(), promise);
+ }
+ }
- if (event.getMessage() instanceof ChannelBuffer) {
- msg.append(" HEX: ");
- msg.append(ChannelBuffers.hexDump((ChannelBuffer) event.getMessage()));
- }
+ }
+
+ private static class StandardLoggingHandler extends ChannelDuplexHandler {
- Log.debug(msg.toString());
+ @Override
+ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+ log(ctx, false, msg);
+ super.channelRead(ctx, msg);
+ }
+
+ @Override
+ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
+ log(ctx, true, msg);
+ super.write(ctx, msg, promise);
+ }
+
+ public void log(ChannelHandlerContext ctx, boolean downstream, Object o) {
+ NetworkMessage networkMessage = (NetworkMessage) o;
+ StringBuilder message = new StringBuilder();
+
+ message.append("[").append(ctx.channel().id().asShortText()).append(": ");
+ message.append(((InetSocketAddress) ctx.channel().localAddress()).getPort());
+ if (downstream) {
+ message.append(" > ");
+ } else {
+ message.append(" < ");
}
+
+ if (networkMessage.getRemoteAddress() != null) {
+ message.append(((InetSocketAddress) networkMessage.getRemoteAddress()).getHostString());
+ } else {
+ message.append("null");
+ }
+ message.append("]");
+
+ message.append(" HEX: ");
+ message.append(ByteBufUtil.hexDump((ByteBuf) networkMessage.getMessage()));
+
+ Log.debug(message.toString());
}
}
@@ -186,20 +228,33 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
}
}
- protected abstract void addSpecificHandlers(ChannelPipeline pipeline);
+ protected abstract void addProtocolHandlers(PipelineBuilder pipeline);
@Override
- public ChannelPipeline getPipeline() {
- ChannelPipeline pipeline = Channels.pipeline();
- if (timeout > 0 && !server.isConnectionless()) {
- pipeline.addLast("idleHandler", new IdleStateHandler(GlobalTimer.getTimer(), timeout, 0, 0));
+ protected void initChannel(Channel channel) throws Exception {
+ final ChannelPipeline pipeline = channel.pipeline();
+ if (timeout > 0 && !server.isDatagram()) {
+ pipeline.addLast("idleHandler", new IdleStateHandler(timeout, 0, 0));
}
pipeline.addLast("openHandler", new OpenChannelHandler(server));
+ pipeline.addLast("messageHandler", new NetworkMessageHandler());
if (Context.isLoggerEnabled()) {
pipeline.addLast("logger", new StandardLoggingHandler());
}
- addSpecificHandlers(pipeline);
+ addProtocolHandlers(new PipelineBuilder() {
+ @Override
+ public void addLast(String name, ChannelHandler handler) {
+ if (!(handler instanceof BaseProtocolDecoder || handler instanceof BaseProtocolEncoder)) {
+ if (handler instanceof ChannelInboundHandler) {
+ handler = new WrapperInboundHandler((ChannelInboundHandler) handler);
+ } else {
+ handler = new WrapperOutboundHandler((ChannelOutboundHandler) handler);
+ }
+ }
+ pipeline.addLast(name, handler);
+ }
+ });
if (geolocationHandler != null) {
pipeline.addLast("location", geolocationHandler);
@@ -288,7 +343,6 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
}
pipeline.addLast("mainHandler", new MainEventHandler());
- return pipeline;
}
private void addDynamicHandlers(ChannelPipeline pipeline) {
@@ -303,4 +357,5 @@ public abstract class BasePipelineFactory implements ChannelPipelineFactory {
}
}
}
+
}
diff --git a/src/org/traccar/BaseProtocol.java b/src/org/traccar/BaseProtocol.java
index 07adbea5e..1729edd54 100644
--- a/src/org/traccar/BaseProtocol.java
+++ b/src/org/traccar/BaseProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,7 @@
*/
package org.traccar;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.buffer.Unpooled;
import org.traccar.database.ActiveDevice;
import org.traccar.helper.DataConverter;
import org.traccar.model.Command;
@@ -76,10 +75,10 @@ public abstract class BaseProtocol implements Protocol {
activeDevice.write(command);
} else if (command.getType().equals(Command.TYPE_CUSTOM)) {
String data = command.getString(Command.KEY_DATA);
- if (activeDevice.getChannel().getPipeline().get(StringEncoder.class) != null) {
+ if (activeDevice.getChannel().pipeline().get("stringEncoder") != null) {
activeDevice.write(data);
} else {
- activeDevice.write(ChannelBuffers.wrappedBuffer(DataConverter.parseHex(data)));
+ activeDevice.write(Unpooled.wrappedBuffer(DataConverter.parseHex(data)));
}
} else {
throw new RuntimeException("Command " + command.getType() + " is not supported in protocol " + getName());
diff --git a/src/org/traccar/BaseProtocolDecoder.java b/src/org/traccar/BaseProtocolDecoder.java
index 3ea1208ca..fe41bd857 100644
--- a/src/org/traccar/BaseProtocolDecoder.java
+++ b/src/org/traccar/BaseProtocolDecoder.java
@@ -15,9 +15,8 @@
*/
package org.traccar;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.socket.DatagramChannel;
-import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
+import io.netty.channel.Channel;
+import io.netty.channel.socket.DatagramChannel;
import org.traccar.helper.Log;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Device;
@@ -145,7 +144,7 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
}
public DeviceSession getDeviceSession(Channel channel, SocketAddress remoteAddress, String... uniqueIds) {
- if (channel != null && channel.getPipeline().get(HttpRequestDecoder.class) != null
+ if (channel != null && channel.pipeline().get("httpDecoder") != null
|| Context.getConfig().getBoolean("decoder.ignoreSessionCache")) {
long deviceId = findDeviceId(remoteAddress, uniqueIds);
if (deviceId != 0) {
diff --git a/src/org/traccar/BaseProtocolEncoder.java b/src/org/traccar/BaseProtocolEncoder.java
index 18544fd28..ed71b5551 100644
--- a/src/org/traccar/BaseProtocolEncoder.java
+++ b/src/org/traccar/BaseProtocolEncoder.java
@@ -15,14 +15,15 @@
*/
package org.traccar;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelOutboundHandlerAdapter;
+import io.netty.channel.ChannelPromise;
import org.traccar.helper.Log;
import org.traccar.model.Command;
import org.traccar.model.Device;
-public abstract class BaseProtocolEncoder extends OneToOneEncoder {
+public abstract class BaseProtocolEncoder extends ChannelOutboundHandlerAdapter {
protected String getUniqueId(long deviceId) {
return Context.getIdentityManager().getById(deviceId).getUniqueId();
@@ -41,15 +42,17 @@ public abstract class BaseProtocolEncoder extends OneToOneEncoder {
}
@Override
- protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
+ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
- if (msg instanceof Command) {
- Command command = (Command) msg;
- Object encodedCommand = encodeCommand(channel, command);
+ NetworkMessage networkMessage = (NetworkMessage) msg;
+
+ if (networkMessage.getMessage() instanceof Command) {
+
+ Command command = (Command) networkMessage.getMessage();
+ Object encodedCommand = encodeCommand(ctx.channel(), command);
- // Log command
StringBuilder s = new StringBuilder();
- s.append(String.format("[%08X] ", channel.getId()));
+ s.append("[").append(ctx.channel().id().asShortText()).append("] ");
s.append("id: ").append(getUniqueId(command.getDeviceId())).append(", ");
s.append("command type: ").append(command.getType()).append(" ");
if (encodedCommand != null) {
@@ -59,10 +62,13 @@ public abstract class BaseProtocolEncoder extends OneToOneEncoder {
}
Log.info(s.toString());
- return encodedCommand;
- }
+ ctx.write(new NetworkMessage(encodedCommand, networkMessage.getRemoteAddress()), promise);
- return msg;
+ } else {
+
+ super.write(ctx, msg, promise);
+
+ }
}
protected Object encodeCommand(Channel channel, Command command) {
diff --git a/src/org/traccar/CharacterDelimiterFrameDecoder.java b/src/org/traccar/CharacterDelimiterFrameDecoder.java
index d71974e78..5175f9b37 100644
--- a/src/org/traccar/CharacterDelimiterFrameDecoder.java
+++ b/src/org/traccar/CharacterDelimiterFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,27 +15,27 @@
*/
package org.traccar;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.handler.codec.DelimiterBasedFrameDecoder;
public class CharacterDelimiterFrameDecoder extends DelimiterBasedFrameDecoder {
- private static ChannelBuffer createDelimiter(char delimiter) {
+ private static ByteBuf createDelimiter(char delimiter) {
byte[] buf = {(byte) delimiter};
- return ChannelBuffers.wrappedBuffer(buf);
+ return Unpooled.wrappedBuffer(buf);
}
- private static ChannelBuffer createDelimiter(String delimiter) {
+ private static ByteBuf createDelimiter(String delimiter) {
byte[] buf = new byte[delimiter.length()];
for (int i = 0; i < delimiter.length(); i++) {
buf[i] = (byte) delimiter.charAt(i);
}
- return ChannelBuffers.wrappedBuffer(buf);
+ return Unpooled.wrappedBuffer(buf);
}
- private static ChannelBuffer[] convertDelimiters(String[] delimiters) {
- ChannelBuffer[] result = new ChannelBuffer[delimiters.length];
+ private static ByteBuf[] convertDelimiters(String[] delimiters) {
+ ByteBuf[] result = new ByteBuf[delimiters.length];
for (int i = 0; i < delimiters.length; i++) {
result[i] = createDelimiter(delimiters[i]);
}
diff --git a/src/org/traccar/DistanceHandler.java b/src/org/traccar/DistanceHandler.java
index 295bc3b29..657f74edf 100644
--- a/src/org/traccar/DistanceHandler.java
+++ b/src/org/traccar/DistanceHandler.java
@@ -16,12 +16,14 @@
*/
package org.traccar;
+import io.netty.channel.ChannelHandler;
import org.traccar.helper.DistanceCalculator;
import org.traccar.model.Position;
import java.math.BigDecimal;
import java.math.RoundingMode;
+@ChannelHandler.Sharable
public class DistanceHandler extends BaseDataHandler {
private final boolean filter;
diff --git a/src/org/traccar/EngineHoursHandler.java b/src/org/traccar/EngineHoursHandler.java
index 41e4dd116..c9fbc186c 100644
--- a/src/org/traccar/EngineHoursHandler.java
+++ b/src/org/traccar/EngineHoursHandler.java
@@ -16,8 +16,10 @@
*/
package org.traccar;
+import io.netty.channel.ChannelHandler;
import org.traccar.model.Position;
+@ChannelHandler.Sharable
public class EngineHoursHandler extends BaseDataHandler {
@Override
diff --git a/src/org/traccar/EventLoopGroupFactory.java b/src/org/traccar/EventLoopGroupFactory.java
new file mode 100644
index 000000000..482559253
--- /dev/null
+++ b/src/org/traccar/EventLoopGroupFactory.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar;
+
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+
+public final class EventLoopGroupFactory {
+
+ private static EventLoopGroup bossGroup = new NioEventLoopGroup();
+ private static EventLoopGroup workerGroup = new NioEventLoopGroup();
+
+ private EventLoopGroupFactory() {
+ }
+
+ public static EventLoopGroup getBossGroup() {
+ return bossGroup;
+ }
+
+ public static EventLoopGroup getWorkerGroup() {
+ return workerGroup;
+ }
+
+}
diff --git a/src/org/traccar/ExtendedObjectDecoder.java b/src/org/traccar/ExtendedObjectDecoder.java
index 75a24212f..681924e87 100644
--- a/src/org/traccar/ExtendedObjectDecoder.java
+++ b/src/org/traccar/ExtendedObjectDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +15,12 @@
*/
package org.traccar;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelEvent;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelUpstreamHandler;
-import org.jboss.netty.channel.Channels;
-import org.jboss.netty.channel.MessageEvent;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.util.ReferenceCountUtil;
import org.traccar.helper.DataConverter;
import org.traccar.model.Position;
@@ -30,14 +28,14 @@ import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
-public abstract class ExtendedObjectDecoder implements ChannelUpstreamHandler {
+public abstract class ExtendedObjectDecoder extends ChannelInboundHandlerAdapter {
private void saveOriginal(Object decodedMessage, Object originalMessage) {
if (Context.getConfig().getBoolean("database.saveOriginal") && decodedMessage instanceof Position) {
Position position = (Position) decodedMessage;
- if (originalMessage instanceof ChannelBuffer) {
- ChannelBuffer buf = (ChannelBuffer) originalMessage;
- position.set(Position.KEY_ORIGINAL, ChannelBuffers.hexDump(buf, 0, buf.writerIndex()));
+ if (originalMessage instanceof ByteBuf) {
+ ByteBuf buf = (ByteBuf) originalMessage;
+ position.set(Position.KEY_ORIGINAL, ByteBufUtil.hexDump(buf));
} else if (originalMessage instanceof String) {
position.set(Position.KEY_ORIGINAL, DataConverter.printHex(
((String) originalMessage).getBytes(StandardCharsets.US_ASCII)));
@@ -46,34 +44,28 @@ public abstract class ExtendedObjectDecoder implements ChannelUpstreamHandler {
}
@Override
- public void handleUpstream(
- ChannelHandlerContext ctx, ChannelEvent evt) throws Exception {
- if (!(evt instanceof MessageEvent)) {
- ctx.sendUpstream(evt);
- return;
- }
-
- MessageEvent e = (MessageEvent) evt;
- Object originalMessage = e.getMessage();
- Object decodedMessage = decode(e.getChannel(), e.getRemoteAddress(), originalMessage);
- onMessageEvent(e.getChannel(), e.getRemoteAddress(), originalMessage, decodedMessage);
- if (originalMessage == decodedMessage) {
- ctx.sendUpstream(evt);
- } else {
+ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+ NetworkMessage networkMessage = (NetworkMessage) msg;
+ Object originalMessage = networkMessage.getMessage();
+ try {
+ Object decodedMessage = decode(ctx.channel(), networkMessage.getRemoteAddress(), originalMessage);
+ onMessageEvent(ctx.channel(), networkMessage.getRemoteAddress(), originalMessage, decodedMessage);
if (decodedMessage == null) {
- decodedMessage = handleEmptyMessage(e.getChannel(), e.getRemoteAddress(), originalMessage);
+ decodedMessage = handleEmptyMessage(ctx.channel(), networkMessage.getRemoteAddress(), originalMessage);
}
if (decodedMessage != null) {
if (decodedMessage instanceof Collection) {
for (Object o : (Collection) decodedMessage) {
saveOriginal(o, originalMessage);
- Channels.fireMessageReceived(ctx, o, e.getRemoteAddress());
+ ctx.fireChannelRead(o);
}
} else {
saveOriginal(decodedMessage, originalMessage);
- Channels.fireMessageReceived(ctx, decodedMessage, e.getRemoteAddress());
+ ctx.fireChannelRead(decodedMessage);
}
}
+ } finally {
+ ReferenceCountUtil.release(originalMessage);
}
}
diff --git a/src/org/traccar/FilterHandler.java b/src/org/traccar/FilterHandler.java
index c6363813c..7ad68f386 100644
--- a/src/org/traccar/FilterHandler.java
+++ b/src/org/traccar/FilterHandler.java
@@ -15,10 +15,12 @@
*/
package org.traccar;
+import io.netty.channel.ChannelHandler;
import org.traccar.helper.Log;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
+@ChannelHandler.Sharable
public class FilterHandler extends BaseDataHandler {
private boolean filterInvalid;
diff --git a/src/org/traccar/GeocoderHandler.java b/src/org/traccar/GeocoderHandler.java
index 6b55e8162..0f3ba4731 100644
--- a/src/org/traccar/GeocoderHandler.java
+++ b/src/org/traccar/GeocoderHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,15 @@
*/
package org.traccar;
-import org.jboss.netty.channel.ChannelEvent;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelUpstreamHandler;
-import org.jboss.netty.channel.Channels;
-import org.jboss.netty.channel.MessageEvent;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
import org.traccar.geocoder.Geocoder;
import org.traccar.helper.Log;
import org.traccar.model.Position;
-public class GeocoderHandler implements ChannelUpstreamHandler {
+@ChannelHandler.Sharable
+public class GeocoderHandler extends ChannelInboundHandlerAdapter {
private final Geocoder geocoder;
private final boolean processInvalidPositions;
@@ -38,14 +37,7 @@ public class GeocoderHandler implements ChannelUpstreamHandler {
}
@Override
- public void handleUpstream(final ChannelHandlerContext ctx, ChannelEvent evt) throws Exception {
- if (!(evt instanceof MessageEvent)) {
- ctx.sendUpstream(evt);
- return;
- }
-
- final MessageEvent event = (MessageEvent) evt;
- Object message = event.getMessage();
+ public void channelRead(final ChannelHandlerContext ctx, Object message) throws Exception {
if (message instanceof Position) {
final Position position = (Position) message;
if (processInvalidPositions || position.getValid()) {
@@ -54,7 +46,7 @@ public class GeocoderHandler implements ChannelUpstreamHandler {
if (lastPosition != null && lastPosition.getAddress() != null
&& position.getDouble(Position.KEY_DISTANCE) <= geocoderReuseDistance) {
position.setAddress(lastPosition.getAddress());
- Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
+ ctx.fireChannelRead(position);
return;
}
}
@@ -66,20 +58,20 @@ public class GeocoderHandler implements ChannelUpstreamHandler {
@Override
public void onSuccess(String address) {
position.setAddress(address);
- Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
+ ctx.fireChannelRead(position);
}
@Override
public void onFailure(Throwable e) {
Log.warning("Geocoding failed", e);
- Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
+ ctx.fireChannelRead(position);
}
});
} else {
- Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
+ ctx.fireChannelRead(position);
}
} else {
- Channels.fireMessageReceived(ctx, message, event.getRemoteAddress());
+ ctx.fireChannelRead(message);
}
}
diff --git a/src/org/traccar/GeolocationHandler.java b/src/org/traccar/GeolocationHandler.java
index 346ad5904..0c204dc0b 100644
--- a/src/org/traccar/GeolocationHandler.java
+++ b/src/org/traccar/GeolocationHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,15 @@
*/
package org.traccar;
-import org.jboss.netty.channel.ChannelEvent;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelUpstreamHandler;
-import org.jboss.netty.channel.Channels;
-import org.jboss.netty.channel.MessageEvent;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
import org.traccar.helper.Log;
import org.traccar.geolocation.GeolocationProvider;
import org.traccar.model.Position;
-public class GeolocationHandler implements ChannelUpstreamHandler {
+@ChannelHandler.Sharable
+public class GeolocationHandler extends ChannelInboundHandlerAdapter {
private final GeolocationProvider geolocationProvider;
private final boolean processInvalidPositions;
@@ -35,14 +34,7 @@ public class GeolocationHandler implements ChannelUpstreamHandler {
}
@Override
- public void handleUpstream(final ChannelHandlerContext ctx, ChannelEvent evt) throws Exception {
- if (!(evt instanceof MessageEvent)) {
- ctx.sendUpstream(evt);
- return;
- }
-
- final MessageEvent event = (MessageEvent) evt;
- Object message = event.getMessage();
+ public void channelRead(final ChannelHandlerContext ctx, Object message) throws Exception {
if (message instanceof Position) {
final Position position = (Position) message;
if ((position.getOutdated() || processInvalidPositions && !position.getValid())
@@ -63,20 +55,20 @@ public class GeolocationHandler implements ChannelUpstreamHandler {
position.setSpeed(0);
position.setCourse(0);
position.set(Position.KEY_RSSI, 0);
- Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
+ ctx.fireChannelRead(position);
}
@Override
public void onFailure(Throwable e) {
Log.warning(e);
- Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
+ ctx.fireChannelRead(position);
}
});
} else {
- Channels.fireMessageReceived(ctx, position, event.getRemoteAddress());
+ ctx.fireChannelRead(position);
}
} else {
- Channels.fireMessageReceived(ctx, message, event.getRemoteAddress());
+ ctx.fireChannelRead(message);
}
}
diff --git a/src/org/traccar/GlobalChannelFactory.java b/src/org/traccar/GlobalChannelFactory.java
deleted file mode 100644
index c5cd1a697..000000000
--- a/src/org/traccar/GlobalChannelFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright 2012 Anton Tananaev (anton@traccar.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar;
-
-import org.jboss.netty.channel.ChannelFactory;
-import org.jboss.netty.channel.socket.DatagramChannelFactory;
-import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory;
-import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
-
-public final class GlobalChannelFactory {
-
- private static ChannelFactory channelFactory = null;
- private static DatagramChannelFactory datagramChannelFactory = null;
-
- private GlobalChannelFactory() {
- }
-
- public static void release() {
- if (channelFactory != null) {
- channelFactory.releaseExternalResources();
- }
- if (datagramChannelFactory != null) {
- datagramChannelFactory.releaseExternalResources();
- }
- channelFactory = null;
- datagramChannelFactory = null;
- }
-
- public static ChannelFactory getFactory() {
- if (channelFactory == null) {
- channelFactory = new NioServerSocketChannelFactory();
- }
- return channelFactory;
- }
-
- public static DatagramChannelFactory getDatagramFactory() {
- if (datagramChannelFactory == null) {
- datagramChannelFactory = new NioDatagramChannelFactory();
- }
- return datagramChannelFactory;
- }
-
-}
diff --git a/src/org/traccar/GlobalTimer.java b/src/org/traccar/GlobalTimer.java
index 70e6e2e45..a97321ba2 100644
--- a/src/org/traccar/GlobalTimer.java
+++ b/src/org/traccar/GlobalTimer.java
@@ -15,8 +15,8 @@
*/
package org.traccar;
-import org.jboss.netty.util.HashedWheelTimer;
-import org.jboss.netty.util.Timer;
+import io.netty.util.HashedWheelTimer;
+import io.netty.util.Timer;
public final class GlobalTimer {
diff --git a/src/org/traccar/HemisphereHandler.java b/src/org/traccar/HemisphereHandler.java
index b1e7d3fb2..d1bcd340b 100644
--- a/src/org/traccar/HemisphereHandler.java
+++ b/src/org/traccar/HemisphereHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.ChannelHandler;
import org.traccar.model.Position;
-import java.net.SocketAddress;
-
-public class HemisphereHandler extends ExtendedObjectDecoder {
+@ChannelHandler.Sharable
+public class HemisphereHandler extends BaseDataHandler {
private int latitudeFactor;
private int longitudeFactor;
@@ -45,20 +44,14 @@ public class HemisphereHandler extends ExtendedObjectDecoder {
}
@Override
- protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
-
- if (msg instanceof Position) {
- Position position = (Position) msg;
- if (latitudeFactor != 0) {
- position.setLatitude(Math.abs(position.getLatitude()) * latitudeFactor);
- }
- if (longitudeFactor != 0) {
- position.setLongitude(Math.abs(position.getLongitude()) * longitudeFactor);
- }
+ protected Position handlePosition(Position position) {
+ if (latitudeFactor != 0) {
+ position.setLatitude(Math.abs(position.getLatitude()) * latitudeFactor);
}
-
- return msg;
+ if (longitudeFactor != 0) {
+ position.setLongitude(Math.abs(position.getLongitude()) * longitudeFactor);
+ }
+ return position;
}
}
diff --git a/src/org/traccar/MainEventHandler.java b/src/org/traccar/MainEventHandler.java
index 6228f3709..49694aaff 100644
--- a/src/org/traccar/MainEventHandler.java
+++ b/src/org/traccar/MainEventHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +15,11 @@
*/
package org.traccar;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.channel.ChannelStateEvent;
-import org.jboss.netty.channel.ExceptionEvent;
-import org.jboss.netty.channel.MessageEvent;
-import org.jboss.netty.channel.socket.DatagramChannel;
-import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
-import org.jboss.netty.handler.timeout.IdleStateEvent;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+import io.netty.channel.socket.DatagramChannel;
+import io.netty.handler.timeout.IdleStateEvent;
import org.traccar.helper.Log;
import org.traccar.model.Position;
@@ -32,7 +29,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-public class MainEventHandler extends IdleStateAwareChannelHandler {
+public class MainEventHandler extends ChannelInboundHandlerAdapter {
private final Set<String> connectionlessProtocols = new HashSet<>();
@@ -44,11 +41,10 @@ public class MainEventHandler extends IdleStateAwareChannelHandler {
}
@Override
- public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) {
+ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+ if (msg instanceof Position) {
- if (e.getMessage() != null && e.getMessage() instanceof Position) {
-
- Position position = (Position) e.getMessage();
+ Position position = (Position) msg;
try {
Context.getDeviceManager().updateLatestPosition(position);
} catch (SQLException error) {
@@ -59,7 +55,7 @@ public class MainEventHandler extends IdleStateAwareChannelHandler {
// Log position
StringBuilder s = new StringBuilder();
- s.append(formatChannel(e.getChannel())).append(" ");
+ s.append(formatChannel(ctx.channel())).append(" ");
s.append("id: ").append(uniqueId);
s.append(", time: ").append(
new SimpleDateFormat(Log.DATE_FORMAT).format(position.getFixTime()));
@@ -83,36 +79,38 @@ public class MainEventHandler extends IdleStateAwareChannelHandler {
}
private static String formatChannel(Channel channel) {
- return String.format("[%08X]", channel.getId());
+ return String.format("[%s]", channel.id().asShortText());
}
@Override
- public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) {
- Log.info(formatChannel(e.getChannel()) + " connected");
+ public void channelActive(ChannelHandlerContext ctx) throws Exception {
+ Log.info(formatChannel(ctx.channel()) + " connected");
}
@Override
- public void channelDisconnected(ChannelHandlerContext ctx, ChannelStateEvent e) {
- Log.info(formatChannel(e.getChannel()) + " disconnected");
- closeChannel(e.getChannel());
+ public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+ Log.info(formatChannel(ctx.channel()) + " disconnected");
+ closeChannel(ctx.channel());
- BaseProtocolDecoder protocolDecoder = (BaseProtocolDecoder) ctx.getPipeline().get("objectDecoder");
- if (ctx.getPipeline().get("httpDecoder") == null
+ BaseProtocolDecoder protocolDecoder = (BaseProtocolDecoder) ctx.pipeline().get("objectDecoder");
+ if (ctx.pipeline().get("httpDecoder") == null
&& !connectionlessProtocols.contains(protocolDecoder.getProtocolName())) {
- Context.getConnectionManager().removeActiveDevice(e.getChannel());
+ Context.getConnectionManager().removeActiveDevice(ctx.channel());
}
}
@Override
- public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) {
- Log.warning(formatChannel(e.getChannel()) + " error", e.getCause());
- closeChannel(e.getChannel());
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+ Log.warning(formatChannel(ctx.channel()) + " error", cause);
+ closeChannel(ctx.channel());
}
@Override
- public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) {
- Log.info(formatChannel(e.getChannel()) + " timed out");
- closeChannel(e.getChannel());
+ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
+ if (evt instanceof IdleStateEvent) {
+ Log.info(formatChannel(ctx.channel()) + " timed out");
+ closeChannel(ctx.channel());
+ }
}
private void closeChannel(Channel channel) {
diff --git a/src/org/traccar/MotionHandler.java b/src/org/traccar/MotionHandler.java
index 901965dd5..ec9a5ffd7 100644
--- a/src/org/traccar/MotionHandler.java
+++ b/src/org/traccar/MotionHandler.java
@@ -16,8 +16,10 @@
*/
package org.traccar;
+import io.netty.channel.ChannelHandler;
import org.traccar.model.Position;
+@ChannelHandler.Sharable
public class MotionHandler extends BaseDataHandler {
private double speedThreshold;
diff --git a/src/org/traccar/NetworkMessage.java b/src/org/traccar/NetworkMessage.java
new file mode 100644
index 000000000..14a397e69
--- /dev/null
+++ b/src/org/traccar/NetworkMessage.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar;
+
+import java.net.SocketAddress;
+
+public class NetworkMessage {
+
+ private final SocketAddress remoteAddress;
+ private final Object message;
+
+ public NetworkMessage(Object message, SocketAddress remoteAddress) {
+ this.message = message;
+ this.remoteAddress = remoteAddress;
+ }
+
+ public SocketAddress getRemoteAddress() {
+ return remoteAddress;
+ }
+
+ public Object getMessage() {
+ return message;
+ }
+
+}
diff --git a/src/org/traccar/PipelineBuilder.java b/src/org/traccar/PipelineBuilder.java
new file mode 100644
index 000000000..20c40f159
--- /dev/null
+++ b/src/org/traccar/PipelineBuilder.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar;
+
+import io.netty.channel.ChannelHandler;
+
+public interface PipelineBuilder {
+
+ void addLast(String name, ChannelHandler handler);
+
+}
diff --git a/src/org/traccar/Protocol.java b/src/org/traccar/Protocol.java
index 87ac05298..c7aa67f9d 100644
--- a/src/org/traccar/Protocol.java
+++ b/src/org/traccar/Protocol.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.traccar;
import org.traccar.database.ActiveDevice;
diff --git a/src/org/traccar/RemoteAddressHandler.java b/src/org/traccar/RemoteAddressHandler.java
index 188bbcab9..aabc5715e 100644
--- a/src/org/traccar/RemoteAddressHandler.java
+++ b/src/org/traccar/RemoteAddressHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,26 +15,28 @@
*/
package org.traccar;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
import org.traccar.model.Position;
import java.net.InetSocketAddress;
-import java.net.SocketAddress;
-public class RemoteAddressHandler extends ExtendedObjectDecoder {
+@ChannelHandler.Sharable
+public class RemoteAddressHandler extends ChannelInboundHandlerAdapter {
@Override
- protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
+ public void channelRead(ChannelHandlerContext ctx, Object msg) {
- String hostAddress = ((InetSocketAddress) remoteAddress).getAddress().getHostAddress();
+ InetSocketAddress remoteAddress = (InetSocketAddress) ctx.channel().remoteAddress();
+ String hostAddress = remoteAddress != null ? remoteAddress.getAddress().getHostAddress() : null;
if (msg instanceof Position) {
Position position = (Position) msg;
position.set(Position.KEY_IP, hostAddress);
}
- return msg;
+ ctx.fireChannelRead(msg);
}
}
diff --git a/src/org/traccar/ServerManager.java b/src/org/traccar/ServerManager.java
index 45503b717..a8da6d57e 100644
--- a/src/org/traccar/ServerManager.java
+++ b/src/org/traccar/ServerManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
*/
package org.traccar;
-import org.jboss.netty.channel.ChannelException;
import org.traccar.helper.Log;
import java.io.File;
@@ -80,14 +79,12 @@ public class ServerManager {
return protocolList.get(name);
}
- public void start() {
+ public void start() throws Exception {
for (TrackerServer server: serverList) {
try {
server.start();
- } catch (ChannelException e) {
- if (e.getCause() instanceof BindException) {
- Log.warning("One of the protocols is disabled due to port conflict");
- }
+ } catch (BindException e) {
+ Log.warning("One of the protocols is disabled due to port conflict");
}
}
}
@@ -96,7 +93,6 @@ public class ServerManager {
for (TrackerServer server: serverList) {
server.stop();
}
- GlobalChannelFactory.release();
GlobalTimer.release();
}
diff --git a/src/org/traccar/TrackerServer.java b/src/org/traccar/TrackerServer.java
index 7e0a6f0c6..3a1e1c4e8 100644
--- a/src/org/traccar/TrackerServer.java
+++ b/src/org/traccar/TrackerServer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,55 +15,58 @@
*/
package org.traccar;
-import org.jboss.netty.bootstrap.Bootstrap;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.buffer.HeapChannelBufferFactory;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.group.ChannelGroup;
-import org.jboss.netty.channel.group.ChannelGroupFuture;
-import org.jboss.netty.channel.group.DefaultChannelGroup;
+import io.netty.bootstrap.AbstractBootstrap;
+import io.netty.bootstrap.Bootstrap;
+import io.netty.bootstrap.ServerBootstrap;
+import io.netty.channel.Channel;
+import io.netty.channel.group.ChannelGroup;
+import io.netty.channel.group.DefaultChannelGroup;
+import io.netty.channel.socket.nio.NioDatagramChannel;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.util.concurrent.GlobalEventExecutor;
import java.net.InetSocketAddress;
-import java.nio.ByteOrder;
public abstract class TrackerServer {
- private final Bootstrap bootstrap;
- private final String protocol;
+ private final boolean datagram;
+ private final AbstractBootstrap bootstrap;
- public boolean isConnectionless() {
- return bootstrap instanceof ConnectionlessBootstrap;
+ public boolean isDatagram() {
+ return datagram;
}
- public String getProtocol() {
- return protocol;
- }
-
- public TrackerServer(Bootstrap bootstrap, String protocol) {
- this.bootstrap = bootstrap;
- this.protocol = protocol;
-
- if (bootstrap instanceof ServerBootstrap) {
- bootstrap.setFactory(GlobalChannelFactory.getFactory());
- } else if (bootstrap instanceof ConnectionlessBootstrap) {
- bootstrap.setFactory(GlobalChannelFactory.getDatagramFactory());
- }
+ public TrackerServer(boolean datagram, String protocol) {
+ this.datagram = datagram;
address = Context.getConfig().getString(protocol + ".address");
port = Context.getConfig().getInteger(protocol + ".port");
- bootstrap.setPipelineFactory(new BasePipelineFactory(this, protocol) {
+ BasePipelineFactory pipelineFactory = new BasePipelineFactory(this, protocol) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- TrackerServer.this.addSpecificHandlers(pipeline);
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
+ TrackerServer.this.addProtocolHandlers(pipeline);
}
- });
+ };
+
+ if (datagram) {
+
+ this.bootstrap = new Bootstrap()
+ .group(EventLoopGroupFactory.getWorkerGroup())
+ .channel(NioDatagramChannel.class)
+ .handler(pipelineFactory);
+
+ } else {
+
+ this.bootstrap = new ServerBootstrap()
+ .group(EventLoopGroupFactory.getBossGroup(), EventLoopGroupFactory.getWorkerGroup())
+ .channel(NioServerSocketChannel.class)
+ .childHandler(pipelineFactory);
+
+ }
}
- protected abstract void addSpecificHandlers(ChannelPipeline pipeline);
+ protected abstract void addProtocolHandlers(PipelineBuilder pipeline);
private int port;
@@ -85,26 +88,13 @@ public abstract class TrackerServer {
this.address = address;
}
- public void setEndianness(ByteOrder byteOrder) {
- bootstrap.setOption("bufferFactory", new HeapChannelBufferFactory(byteOrder));
- bootstrap.setOption("child.bufferFactory", new HeapChannelBufferFactory(byteOrder));
- }
-
- private final ChannelGroup allChannels = new DefaultChannelGroup();
+ private final ChannelGroup channelGroup = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
public ChannelGroup getChannelGroup() {
- return allChannels;
- }
-
- public void setPipelineFactory(ChannelPipelineFactory pipelineFactory) {
- bootstrap.setPipelineFactory(pipelineFactory);
+ return channelGroup;
}
- public ChannelPipelineFactory getPipelineFactory() {
- return bootstrap.getPipelineFactory();
- }
-
- public void start() {
+ public void start() throws Exception {
InetSocketAddress endpoint;
if (address == null) {
endpoint = new InetSocketAddress(port);
@@ -112,21 +102,14 @@ public abstract class TrackerServer {
endpoint = new InetSocketAddress(address, port);
}
- Channel channel = null;
- if (bootstrap instanceof ServerBootstrap) {
- channel = ((ServerBootstrap) bootstrap).bind(endpoint);
- } else if (bootstrap instanceof ConnectionlessBootstrap) {
- channel = ((ConnectionlessBootstrap) bootstrap).bind(endpoint);
- }
-
+ Channel channel = bootstrap.bind(endpoint).sync().channel();
if (channel != null) {
getChannelGroup().add(channel);
}
}
public void stop() {
- ChannelGroupFuture future = getChannelGroup().close();
- future.awaitUninterruptibly();
+ channelGroup.close().awaitUninterruptibly();
}
}
diff --git a/src/org/traccar/WrapperContext.java b/src/org/traccar/WrapperContext.java
new file mode 100644
index 000000000..372d3c60d
--- /dev/null
+++ b/src/org/traccar/WrapperContext.java
@@ -0,0 +1,255 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar;
+
+import io.netty.buffer.ByteBufAllocator;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelPipeline;
+import io.netty.channel.ChannelProgressivePromise;
+import io.netty.channel.ChannelPromise;
+import io.netty.util.Attribute;
+import io.netty.util.AttributeKey;
+import io.netty.util.concurrent.EventExecutor;
+
+import java.net.SocketAddress;
+
+public class WrapperContext implements ChannelHandlerContext {
+
+ private ChannelHandlerContext context;
+ private SocketAddress remoteAddress;
+
+ public WrapperContext(ChannelHandlerContext context, SocketAddress remoteAddress) {
+ this.context = context;
+ this.remoteAddress = remoteAddress;
+ }
+
+ @Override
+ public Channel channel() {
+ return context.channel();
+ }
+
+ @Override
+ public EventExecutor executor() {
+ return context.executor();
+ }
+
+ @Override
+ public String name() {
+ return context.name();
+ }
+
+ @Override
+ public ChannelHandler handler() {
+ return context.handler();
+ }
+
+ @Override
+ public boolean isRemoved() {
+ return context.isRemoved();
+ }
+
+ @Override
+ public ChannelHandlerContext fireChannelRegistered() {
+ return context.fireChannelRegistered();
+ }
+
+ @Override
+ public ChannelHandlerContext fireChannelUnregistered() {
+ return context.fireChannelUnregistered();
+ }
+
+ @Override
+ public ChannelHandlerContext fireChannelActive() {
+ return context.fireChannelActive();
+ }
+
+ @Override
+ public ChannelHandlerContext fireChannelInactive() {
+ return context.fireChannelInactive();
+ }
+
+ @Override
+ public ChannelHandlerContext fireExceptionCaught(Throwable cause) {
+ return context.fireExceptionCaught(cause);
+ }
+
+ @Override
+ public ChannelHandlerContext fireUserEventTriggered(Object evt) {
+ return context.fireUserEventTriggered(evt);
+ }
+
+ @Override
+ public ChannelHandlerContext fireChannelRead(Object msg) {
+ if (!(msg instanceof NetworkMessage)) {
+ msg = new NetworkMessage(msg, remoteAddress);
+ }
+ return context.fireChannelRead(msg);
+ }
+
+ @Override
+ public ChannelHandlerContext fireChannelReadComplete() {
+ return context.fireChannelReadComplete();
+ }
+
+ @Override
+ public ChannelHandlerContext fireChannelWritabilityChanged() {
+ return context.fireChannelWritabilityChanged();
+ }
+
+ @Override
+ public ChannelFuture bind(SocketAddress localAddress) {
+ return context.bind(localAddress);
+ }
+
+ @Override
+ public ChannelFuture connect(SocketAddress remoteAddress) {
+ return context.connect(remoteAddress);
+ }
+
+ @Override
+ public ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress) {
+ return context.connect(remoteAddress, localAddress);
+ }
+
+ @Override
+ public ChannelFuture disconnect() {
+ return context.disconnect();
+ }
+
+ @Override
+ public ChannelFuture close() {
+ return context.close();
+ }
+
+ @Override
+ public ChannelFuture deregister() {
+ return context.deregister();
+ }
+
+ @Override
+ public ChannelFuture bind(SocketAddress localAddress, ChannelPromise promise) {
+ return context.bind(localAddress, promise);
+ }
+
+ @Override
+ public ChannelFuture connect(SocketAddress remoteAddress, ChannelPromise promise) {
+ return context.connect(remoteAddress, promise);
+ }
+
+ @Override
+ public ChannelFuture connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) {
+ return context.connect(remoteAddress, localAddress, promise);
+ }
+
+ @Override
+ public ChannelFuture disconnect(ChannelPromise promise) {
+ return context.disconnect(promise);
+ }
+
+ @Override
+ public ChannelFuture close(ChannelPromise promise) {
+ return context.close(promise);
+ }
+
+ @Override
+ public ChannelFuture deregister(ChannelPromise promise) {
+ return context.deregister(promise);
+ }
+
+ @Override
+ public ChannelHandlerContext read() {
+ return context.read();
+ }
+
+ @Override
+ public ChannelFuture write(Object msg) {
+ return context.write(msg);
+ }
+
+ @Override
+ public ChannelFuture write(Object msg, ChannelPromise promise) {
+ if (!(msg instanceof NetworkMessage)) {
+ msg = new NetworkMessage(msg, remoteAddress);
+ }
+ return context.write(msg, promise);
+ }
+
+ @Override
+ public ChannelHandlerContext flush() {
+ return context.flush();
+ }
+
+ @Override
+ public ChannelFuture writeAndFlush(Object msg, ChannelPromise promise) {
+ return context.writeAndFlush(msg, promise);
+ }
+
+ @Override
+ public ChannelFuture writeAndFlush(Object msg) {
+ return context.writeAndFlush(msg);
+ }
+
+ @Override
+ public ChannelPromise newPromise() {
+ return context.newPromise();
+ }
+
+ @Override
+ public ChannelProgressivePromise newProgressivePromise() {
+ return context.newProgressivePromise();
+ }
+
+ @Override
+ public ChannelFuture newSucceededFuture() {
+ return context.newSucceededFuture();
+ }
+
+ @Override
+ public ChannelFuture newFailedFuture(Throwable cause) {
+ return context.newFailedFuture(cause);
+ }
+
+ @Override
+ public ChannelPromise voidPromise() {
+ return context.voidPromise();
+ }
+
+ @Override
+ public ChannelPipeline pipeline() {
+ return context.pipeline();
+ }
+
+ @Override
+ public ByteBufAllocator alloc() {
+ return context.alloc();
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public <T> Attribute<T> attr(AttributeKey<T> key) {
+ return context.attr(key);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public <T> boolean hasAttr(AttributeKey<T> key) {
+ return context.hasAttr(key);
+ }
+
+}
diff --git a/src/org/traccar/WrapperInboundHandler.java b/src/org/traccar/WrapperInboundHandler.java
new file mode 100644
index 000000000..f81f97108
--- /dev/null
+++ b/src/org/traccar/WrapperInboundHandler.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandler;
+
+public class WrapperInboundHandler implements ChannelInboundHandler {
+
+ private ChannelInboundHandler handler;
+
+ public WrapperInboundHandler(ChannelInboundHandler handler) {
+ this.handler = handler;
+ }
+
+ @Override
+ public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
+ handler.channelRegistered(ctx);
+ }
+
+ @Override
+ public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
+ handler.channelUnregistered(ctx);
+ }
+
+ @Override
+ public void channelActive(ChannelHandlerContext ctx) throws Exception {
+ handler.channelActive(ctx);
+ }
+
+ @Override
+ public void channelInactive(ChannelHandlerContext ctx) throws Exception {
+ handler.channelInactive(ctx);
+ }
+
+ @Override
+ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+ if (msg instanceof NetworkMessage) {
+ NetworkMessage nm = (NetworkMessage) msg;
+ handler.channelRead(new WrapperContext(ctx, nm.getRemoteAddress()), nm.getMessage());
+ } else {
+ handler.channelRead(ctx, msg);
+ }
+ }
+
+ @Override
+ public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+ handler.channelReadComplete(ctx);
+ }
+
+ @Override
+ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
+ handler.userEventTriggered(ctx, evt);
+ }
+
+ @Override
+ public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception {
+ handler.channelWritabilityChanged(ctx);
+ }
+
+ @Override
+ public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
+ handler.handlerAdded(ctx);
+ }
+
+ @Override
+ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
+ handler.handlerRemoved(ctx);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+ handler.exceptionCaught(ctx, cause);
+ }
+
+}
diff --git a/src/org/traccar/WrapperOutboundHandler.java b/src/org/traccar/WrapperOutboundHandler.java
new file mode 100644
index 000000000..99afd9774
--- /dev/null
+++ b/src/org/traccar/WrapperOutboundHandler.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelOutboundHandler;
+import io.netty.channel.ChannelPromise;
+
+import java.net.SocketAddress;
+
+public class WrapperOutboundHandler implements ChannelOutboundHandler {
+
+ private ChannelOutboundHandler handler;
+
+ public WrapperOutboundHandler(ChannelOutboundHandler handler) {
+ this.handler = handler;
+ }
+
+ @Override
+ public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception {
+ handler.bind(ctx, localAddress, promise);
+ }
+
+ @Override
+ public void connect(
+ ChannelHandlerContext ctx, SocketAddress remoteAddress,
+ SocketAddress localAddress, ChannelPromise promise) throws Exception {
+ handler.connect(ctx, remoteAddress, localAddress, promise);
+ }
+
+ @Override
+ public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
+ handler.disconnect(ctx, promise);
+ }
+
+ @Override
+ public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
+ handler.close(ctx, promise);
+ }
+
+ @Override
+ public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
+ handler.deregister(ctx, promise);
+ }
+
+ @Override
+ public void read(ChannelHandlerContext ctx) throws Exception {
+ handler.read(ctx);
+ }
+
+ @Override
+ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
+ if (msg instanceof NetworkMessage) {
+ NetworkMessage nm = (NetworkMessage) msg;
+ handler.write(new WrapperContext(ctx, nm.getRemoteAddress()), nm.getMessage(), promise);
+ } else {
+ handler.write(ctx, msg, promise);
+ }
+ }
+
+ @Override
+ public void flush(ChannelHandlerContext ctx) throws Exception {
+ handler.flush(ctx);
+ }
+
+ @Override
+ public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
+ handler.handlerAdded(ctx);
+ }
+
+ @Override
+ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
+ handler.handlerRemoved(ctx);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
+ handler.exceptionCaught(ctx, cause);
+ }
+
+}
diff --git a/src/org/traccar/api/CorsResponseFilter.java b/src/org/traccar/api/CorsResponseFilter.java
index 70ea7e3e1..227f80609 100644
--- a/src/org/traccar/api/CorsResponseFilter.java
+++ b/src/org/traccar/api/CorsResponseFilter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.api;
-import org.jboss.netty.handler.codec.http.HttpHeaders;
+import io.netty.handler.codec.http.HttpHeaderNames;
import org.traccar.Context;
import javax.ws.rs.container.ContainerRequestContext;
@@ -31,26 +31,26 @@ public class CorsResponseFilter implements ContainerResponseFilter {
@Override
public void filter(ContainerRequestContext request, ContainerResponseContext response) throws IOException {
- if (!response.getHeaders().containsKey(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_HEADERS)) {
- response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_HEADERS, HEADERS_ALL);
+ if (!response.getHeaders().containsKey(HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS.toString())) {
+ response.getHeaders().add(HttpHeaderNames.ACCESS_CONTROL_ALLOW_HEADERS.toString(), HEADERS_ALL);
}
- if (!response.getHeaders().containsKey(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_CREDENTIALS)) {
- response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_CREDENTIALS, true);
+ if (!response.getHeaders().containsKey(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS.toString())) {
+ response.getHeaders().add(HttpHeaderNames.ACCESS_CONTROL_ALLOW_CREDENTIALS.toString(), true);
}
- if (!response.getHeaders().containsKey(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_METHODS)) {
- response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_METHODS, METHODS_ALL);
+ if (!response.getHeaders().containsKey(HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS.toString())) {
+ response.getHeaders().add(HttpHeaderNames.ACCESS_CONTROL_ALLOW_METHODS.toString(), METHODS_ALL);
}
- if (!response.getHeaders().containsKey(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN)) {
- String origin = request.getHeaderString(HttpHeaders.Names.ORIGIN);
+ if (!response.getHeaders().containsKey(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString())) {
+ String origin = request.getHeaderString(HttpHeaderNames.ORIGIN.toString());
String allowed = Context.getConfig().getString("web.origin");
if (origin == null) {
- response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN, ORIGIN_ALL);
+ response.getHeaders().add(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString(), ORIGIN_ALL);
} else if (allowed == null || allowed.equals(ORIGIN_ALL) || allowed.contains(origin)) {
- response.getHeaders().add(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN, origin);
+ response.getHeaders().add(HttpHeaderNames.ACCESS_CONTROL_ALLOW_ORIGIN.toString(), origin);
}
}
}
diff --git a/src/org/traccar/database/ActiveDevice.java b/src/org/traccar/database/ActiveDevice.java
index f491111e1..207fc454b 100644
--- a/src/org/traccar/database/ActiveDevice.java
+++ b/src/org/traccar/database/ActiveDevice.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,8 @@
*/
package org.traccar.database;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
+import org.traccar.NetworkMessage;
import org.traccar.Protocol;
import org.traccar.model.Command;
@@ -48,7 +49,7 @@ public class ActiveDevice {
}
public void write(Object message) {
- getChannel().write(message, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(message, remoteAddress));
}
}
diff --git a/src/org/traccar/database/ConnectionManager.java b/src/org/traccar/database/ConnectionManager.java
index e5a7a272f..657c0e6e8 100644
--- a/src/org/traccar/database/ConnectionManager.java
+++ b/src/org/traccar/database/ConnectionManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,9 @@
*/
package org.traccar.database;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.util.Timeout;
-import org.jboss.netty.util.TimerTask;
+import io.netty.channel.Channel;
+import io.netty.util.Timeout;
+import io.netty.util.TimerTask;
import org.traccar.Context;
import org.traccar.GlobalTimer;
import org.traccar.Protocol;
diff --git a/src/org/traccar/database/MediaManager.java b/src/org/traccar/database/MediaManager.java
index 482442735..0bb6afac7 100644
--- a/src/org/traccar/database/MediaManager.java
+++ b/src/org/traccar/database/MediaManager.java
@@ -15,7 +15,7 @@
*/
package org.traccar.database;
-import org.jboss.netty.buffer.ChannelBuffer;
+import io.netty.buffer.ByteBuf;
import org.traccar.helper.Log;
import java.io.File;
@@ -46,13 +46,13 @@ public class MediaManager {
return filePath.toFile();
}
- public String writeFile(String uniqueId, ChannelBuffer buf, String extension) {
+ public String writeFile(String uniqueId, ByteBuf buf, String extension) {
if (path != null) {
int size = buf.readableBytes();
String name = new SimpleDateFormat("yyyyMMddhhmmss").format(new Date()) + "." + extension;
try (FileOutputStream output = new FileOutputStream(createFile(uniqueId, name));
FileChannel fileChannel = output.getChannel()) {
- ByteBuffer byteBuffer = buf.toByteBuffer();
+ ByteBuffer byteBuffer = buf.nioBuffer();
int written = 0;
while (written < size) {
written += fileChannel.write(byteBuffer);
diff --git a/src/org/traccar/events/AlertEventHandler.java b/src/org/traccar/events/AlertEventHandler.java
index 7db371c70..b14869e72 100644
--- a/src/org/traccar/events/AlertEventHandler.java
+++ b/src/org/traccar/events/AlertEventHandler.java
@@ -18,11 +18,13 @@ package org.traccar.events;
import java.util.Collections;
import java.util.Map;
+import io.netty.channel.ChannelHandler;
import org.traccar.BaseEventHandler;
import org.traccar.Context;
import org.traccar.model.Event;
import org.traccar.model.Position;
+@ChannelHandler.Sharable
public class AlertEventHandler extends BaseEventHandler {
private final boolean ignoreDuplicateAlerts;
diff --git a/src/org/traccar/events/CommandResultEventHandler.java b/src/org/traccar/events/CommandResultEventHandler.java
index 775aa903f..89ec44190 100644
--- a/src/org/traccar/events/CommandResultEventHandler.java
+++ b/src/org/traccar/events/CommandResultEventHandler.java
@@ -18,10 +18,12 @@ package org.traccar.events;
import java.util.Collections;
import java.util.Map;
+import io.netty.channel.ChannelHandler;
import org.traccar.BaseEventHandler;
import org.traccar.model.Event;
import org.traccar.model.Position;
+@ChannelHandler.Sharable
public class CommandResultEventHandler extends BaseEventHandler {
@Override
diff --git a/src/org/traccar/events/DriverEventHandler.java b/src/org/traccar/events/DriverEventHandler.java
index 39b8eb9c0..c8efd0576 100644
--- a/src/org/traccar/events/DriverEventHandler.java
+++ b/src/org/traccar/events/DriverEventHandler.java
@@ -19,11 +19,13 @@ package org.traccar.events;
import java.util.Collections;
import java.util.Map;
+import io.netty.channel.ChannelHandler;
import org.traccar.BaseEventHandler;
import org.traccar.Context;
import org.traccar.model.Event;
import org.traccar.model.Position;
+@ChannelHandler.Sharable
public class DriverEventHandler extends BaseEventHandler {
@Override
diff --git a/src/org/traccar/events/FuelDropEventHandler.java b/src/org/traccar/events/FuelDropEventHandler.java
index 2ee3e1a58..31b17d500 100644
--- a/src/org/traccar/events/FuelDropEventHandler.java
+++ b/src/org/traccar/events/FuelDropEventHandler.java
@@ -15,6 +15,7 @@
*/
package org.traccar.events;
+import io.netty.channel.ChannelHandler;
import org.traccar.BaseEventHandler;
import org.traccar.Context;
import org.traccar.model.Device;
@@ -24,6 +25,7 @@ import org.traccar.model.Position;
import java.util.Collections;
import java.util.Map;
+@ChannelHandler.Sharable
public class FuelDropEventHandler extends BaseEventHandler {
public static final String ATTRIBUTE_FUEL_DROP_THRESHOLD = "fuelDropThreshold";
diff --git a/src/org/traccar/events/GeofenceEventHandler.java b/src/org/traccar/events/GeofenceEventHandler.java
index 31d82a81e..ea379dbdb 100644
--- a/src/org/traccar/events/GeofenceEventHandler.java
+++ b/src/org/traccar/events/GeofenceEventHandler.java
@@ -20,6 +20,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import io.netty.channel.ChannelHandler;
import org.traccar.BaseEventHandler;
import org.traccar.Context;
import org.traccar.database.GeofenceManager;
@@ -28,6 +29,7 @@ import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Position;
+@ChannelHandler.Sharable
public class GeofenceEventHandler extends BaseEventHandler {
private GeofenceManager geofenceManager;
diff --git a/src/org/traccar/events/IgnitionEventHandler.java b/src/org/traccar/events/IgnitionEventHandler.java
index cc53b216c..a17f15318 100644
--- a/src/org/traccar/events/IgnitionEventHandler.java
+++ b/src/org/traccar/events/IgnitionEventHandler.java
@@ -19,12 +19,14 @@ package org.traccar.events;
import java.util.Collections;
import java.util.Map;
+import io.netty.channel.ChannelHandler;
import org.traccar.BaseEventHandler;
import org.traccar.Context;
import org.traccar.model.Device;
import org.traccar.model.Event;
import org.traccar.model.Position;
+@ChannelHandler.Sharable
public class IgnitionEventHandler extends BaseEventHandler {
@Override
diff --git a/src/org/traccar/events/MaintenanceEventHandler.java b/src/org/traccar/events/MaintenanceEventHandler.java
index 4a6122826..5bebb1baf 100644
--- a/src/org/traccar/events/MaintenanceEventHandler.java
+++ b/src/org/traccar/events/MaintenanceEventHandler.java
@@ -19,12 +19,14 @@ package org.traccar.events;
import java.util.HashMap;
import java.util.Map;
+import io.netty.channel.ChannelHandler;
import org.traccar.BaseEventHandler;
import org.traccar.Context;
import org.traccar.model.Event;
import org.traccar.model.Maintenance;
import org.traccar.model.Position;
+@ChannelHandler.Sharable
public class MaintenanceEventHandler extends BaseEventHandler {
@Override
diff --git a/src/org/traccar/events/MotionEventHandler.java b/src/org/traccar/events/MotionEventHandler.java
index 0c1c4848f..4047b83a4 100644
--- a/src/org/traccar/events/MotionEventHandler.java
+++ b/src/org/traccar/events/MotionEventHandler.java
@@ -19,6 +19,7 @@ package org.traccar.events;
import java.util.Collections;
import java.util.Map;
+import io.netty.channel.ChannelHandler;
import org.traccar.BaseEventHandler;
import org.traccar.Context;
import org.traccar.model.Device;
@@ -28,6 +29,7 @@ import org.traccar.model.Position;
import org.traccar.reports.ReportUtils;
import org.traccar.reports.model.TripsConfig;
+@ChannelHandler.Sharable
public class MotionEventHandler extends BaseEventHandler {
private TripsConfig tripsConfig;
diff --git a/src/org/traccar/events/OverspeedEventHandler.java b/src/org/traccar/events/OverspeedEventHandler.java
index 4ebe43fda..aed79a2f5 100644
--- a/src/org/traccar/events/OverspeedEventHandler.java
+++ b/src/org/traccar/events/OverspeedEventHandler.java
@@ -19,6 +19,7 @@ package org.traccar.events;
import java.util.Collections;
import java.util.Map;
+import io.netty.channel.ChannelHandler;
import org.traccar.BaseEventHandler;
import org.traccar.Context;
import org.traccar.model.Device;
@@ -27,6 +28,7 @@ import org.traccar.model.Event;
import org.traccar.model.Geofence;
import org.traccar.model.Position;
+@ChannelHandler.Sharable
public class OverspeedEventHandler extends BaseEventHandler {
public static final String ATTRIBUTE_SPEED_LIMIT = "speedLimit";
diff --git a/src/org/traccar/helper/BcdUtil.java b/src/org/traccar/helper/BcdUtil.java
index 495f94104..c87529e32 100644
--- a/src/org/traccar/helper/BcdUtil.java
+++ b/src/org/traccar/helper/BcdUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +15,14 @@
*/
package org.traccar.helper;
-import org.jboss.netty.buffer.ChannelBuffer;
+import io.netty.buffer.ByteBuf;
public final class BcdUtil {
private BcdUtil() {
}
- public static int readInteger(ChannelBuffer buf, int digits) {
+ public static int readInteger(ByteBuf buf, int digits) {
int result = 0;
for (int i = 0; i < digits / 2; i++) {
@@ -42,7 +42,7 @@ public final class BcdUtil {
return result;
}
- public static double readCoordinate(ChannelBuffer buf) {
+ public static double readCoordinate(ByteBuf buf) {
int b1 = buf.readUnsignedByte();
int b2 = buf.readUnsignedByte();
int b3 = buf.readUnsignedByte();
diff --git a/src/org/traccar/helper/BitBuffer.java b/src/org/traccar/helper/BitBuffer.java
index ac307efdf..f30a4557b 100644
--- a/src/org/traccar/helper/BitBuffer.java
+++ b/src/org/traccar/helper/BitBuffer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,12 @@
*/
package org.traccar.helper;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
public class BitBuffer {
- private final ChannelBuffer buffer;
+ private final ByteBuf buffer;
private int writeByte;
private int writeCount;
@@ -29,10 +29,10 @@ public class BitBuffer {
private int readCount;
public BitBuffer() {
- buffer = ChannelBuffers.dynamicBuffer();
+ buffer = Unpooled.buffer();
}
- public BitBuffer(ChannelBuffer buffer) {
+ public BitBuffer(ByteBuf buffer) {
this.buffer = buffer;
}
diff --git a/src/org/traccar/helper/BufferUtil.java b/src/org/traccar/helper/BufferUtil.java
new file mode 100644
index 000000000..5606dba8a
--- /dev/null
+++ b/src/org/traccar/helper/BufferUtil.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.traccar.helper;
+
+import java.nio.charset.StandardCharsets;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+
+public final class BufferUtil {
+
+ private BufferUtil() {
+ }
+
+ public static int indexOf(String needle, ByteBuf haystack) {
+ ByteBuf needleBuffer = Unpooled.wrappedBuffer(needle.getBytes(StandardCharsets.US_ASCII));
+ try {
+ return ByteBufUtil.indexOf(needleBuffer, haystack);
+ } finally {
+ needleBuffer.release();
+ }
+ }
+
+ public static int indexOf(String needle, ByteBuf haystack, int startIndex, int endIndex) {
+ haystack = Unpooled.wrappedBuffer(haystack);
+ haystack.readerIndex(startIndex);
+ haystack.writerIndex(endIndex);
+ return indexOf(needle, haystack);
+ }
+
+}
diff --git a/src/org/traccar/helper/Log.java b/src/org/traccar/helper/Log.java
index d74246a64..a22e4bde2 100644
--- a/src/org/traccar/helper/Log.java
+++ b/src/org/traccar/helper/Log.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,9 +23,6 @@ import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.varia.NullAppender;
-import org.jboss.netty.logging.AbstractInternalLogger;
-import org.jboss.netty.logging.InternalLogger;
-import org.jboss.netty.logging.InternalLoggerFactory;
import org.traccar.Config;
import java.io.IOException;
@@ -67,14 +64,6 @@ public final class Log {
logger.addAppender(appender);
logger.setLevel(Level.toLevel(config.getString("logger.level"), Level.ALL));
- // Workaround for "Bug 745866 - (EDG-45) Possible netty logging config problem"
- InternalLoggerFactory.setDefaultFactory(new InternalLoggerFactory() {
- @Override
- public InternalLogger newInstance(String string) {
- return new NettyInternalLogger();
- }
- });
-
Log.logSystemInfo();
Log.info("Version: " + getAppVersion());
}
@@ -200,69 +189,4 @@ public final class Log {
return s.toString();
}
- /**
- * Netty logger implementation
- */
- private static class NettyInternalLogger extends AbstractInternalLogger {
-
- @Override
- public boolean isDebugEnabled() {
- return false;
- }
-
- @Override
- public boolean isInfoEnabled() {
- return false;
- }
-
- @Override
- public boolean isWarnEnabled() {
- return true;
- }
-
- @Override
- public boolean isErrorEnabled() {
- return true;
- }
-
- @Override
- public void debug(String string) {
- debug(string, null);
- }
-
- @Override
- public void debug(String string, Throwable thrwbl) {
- }
-
- @Override
- public void info(String string) {
- info(string, null);
- }
-
- @Override
- public void info(String string, Throwable thrwbl) {
- }
-
- @Override
- public void warn(String string) {
- warn(string, null);
- }
-
- @Override
- public void warn(String string, Throwable thrwbl) {
- getLogger().warn("netty warning: " + string);
- }
-
- @Override
- public void error(String string) {
- error(string, null);
- }
-
- @Override
- public void error(String string, Throwable thrwbl) {
- getLogger().error("netty error: " + string);
- }
-
- }
-
}
diff --git a/src/org/traccar/helper/StringFinder.java b/src/org/traccar/helper/StringFinder.java
deleted file mode 100644
index 2fa0aa9a4..000000000
--- a/src/org/traccar/helper/StringFinder.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.traccar.helper;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBufferIndexFinder;
-
-import java.nio.charset.StandardCharsets;
-
-public class StringFinder implements ChannelBufferIndexFinder {
-
- private String string;
-
- public StringFinder(String string) {
- this.string = string;
- }
-
- @Override
- public boolean find(ChannelBuffer buffer, int guessedIndex) {
-
- if (buffer.writerIndex() - guessedIndex < string.length()) {
- return false;
- }
-
- return string.equals(buffer.toString(guessedIndex, string.length(), StandardCharsets.US_ASCII));
- }
-
-}
diff --git a/src/org/traccar/processing/ComputedAttributesHandler.java b/src/org/traccar/processing/ComputedAttributesHandler.java
index b37db05bf..a4edcc460 100644
--- a/src/org/traccar/processing/ComputedAttributesHandler.java
+++ b/src/org/traccar/processing/ComputedAttributesHandler.java
@@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import io.netty.channel.ChannelHandler;
import org.apache.commons.jexl2.JexlEngine;
import org.apache.commons.jexl2.JexlException;
import org.apache.commons.jexl2.MapContext;
@@ -35,6 +36,7 @@ import org.traccar.model.Attribute;
import org.traccar.model.Device;
import org.traccar.model.Position;
+@ChannelHandler.Sharable
public class ComputedAttributesHandler extends BaseDataHandler {
private JexlEngine engine;
diff --git a/src/org/traccar/processing/CopyAttributesHandler.java b/src/org/traccar/processing/CopyAttributesHandler.java
index 9fbcfa73f..bdd73b141 100644
--- a/src/org/traccar/processing/CopyAttributesHandler.java
+++ b/src/org/traccar/processing/CopyAttributesHandler.java
@@ -16,10 +16,12 @@
*/
package org.traccar.processing;
+import io.netty.channel.ChannelHandler;
import org.traccar.BaseDataHandler;
import org.traccar.Context;
import org.traccar.model.Position;
+@ChannelHandler.Sharable
public class CopyAttributesHandler extends BaseDataHandler {
private Position getLastPosition(long deviceId) {
diff --git a/src/org/traccar/protocol/AdmProtocol.java b/src/org/traccar/protocol/AdmProtocol.java
index 4d2cbe7b3..994661af2 100644
--- a/src/org/traccar/protocol/AdmProtocol.java
+++ b/src/org/traccar/protocol/AdmProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -37,17 +36,16 @@ public class AdmProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 1, -3, 0));
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
+ pipeline.addLast("frameDecoder",
+ new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 1024, 2, 1, -3, 0, true));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new AdmProtocolEncoder());
pipeline.addLast("objectDecoder", new AdmProtocolDecoder(AdmProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/AdmProtocolDecoder.java b/src/org/traccar/protocol/AdmProtocolDecoder.java
index 4ae16017a..4c41d29cd 100644
--- a/src/org/traccar/protocol/AdmProtocolDecoder.java
+++ b/src/org/traccar/protocol/AdmProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
@@ -38,7 +38,7 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_PHOTO = 0x0A;
public static final int MSG_ADM5 = 0x01;
- private Position decodeData(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf, int type) {
+ private Position decodeData(Channel channel, SocketAddress remoteAddress, ByteBuf buf, int type) {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
if (deviceSession == null) {
@@ -50,25 +50,25 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte());
- position.set(Position.KEY_INDEX, buf.readUnsignedShort());
+ position.set(Position.KEY_INDEX, buf.readUnsignedShortLE());
- int status = buf.readUnsignedShort();
+ int status = buf.readUnsignedShortLE();
position.set(Position.KEY_STATUS, status);
position.setValid(!BitUtil.check(status, 5));
- position.setLatitude(buf.readFloat());
- position.setLongitude(buf.readFloat());
- position.setCourse(buf.readUnsignedShort() * 0.1);
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort() * 0.1));
+ position.setLatitude(buf.readFloatLE());
+ position.setLongitude(buf.readFloatLE());
+ position.setCourse(buf.readUnsignedShortLE() * 0.1);
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShortLE() * 0.1));
position.set(Position.KEY_ACCELERATION, buf.readUnsignedByte() * 0.1);
- position.setAltitude(buf.readUnsignedShort());
+ position.setAltitude(buf.readUnsignedShortLE());
position.set(Position.KEY_HDOP, buf.readUnsignedByte() * 0.1);
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte() & 0x0f);
- position.setTime(new Date(buf.readUnsignedInt() * 1000));
+ position.setTime(new Date(buf.readUnsignedIntLE() * 1000));
- position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.001);
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001);
+ position.set(Position.KEY_POWER, buf.readUnsignedShortLE() * 0.001);
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.001);
if (BitUtil.check(type, 2)) {
buf.readUnsignedByte(); // vib
@@ -84,19 +84,19 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(type, 3)) {
for (int i = 1; i <= 6; i++) {
- position.set(Position.PREFIX_ADC + i, buf.readUnsignedShort() * 0.001);
+ position.set(Position.PREFIX_ADC + i, buf.readUnsignedShortLE() * 0.001);
}
}
if (BitUtil.check(type, 4)) {
for (int i = 1; i <= 2; i++) {
- position.set(Position.PREFIX_COUNT + i, buf.readUnsignedInt());
+ position.set(Position.PREFIX_COUNT + i, buf.readUnsignedIntLE());
}
}
if (BitUtil.check(type, 5)) {
for (int i = 1; i <= 3; i++) {
- buf.readUnsignedShort(); // fuel level
+ buf.readUnsignedShortLE(); // fuel level
}
for (int i = 1; i <= 3; i++) {
position.set(Position.PREFIX_TEMP + i, buf.readUnsignedByte());
@@ -108,7 +108,7 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
}
if (BitUtil.check(type, 7)) {
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
}
return position;
@@ -117,7 +117,7 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- private Position parseCommandResponse(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private Position parseCommandResponse(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
if (deviceSession == null) {
return null;
@@ -132,22 +132,22 @@ public class AdmProtocolDecoder extends BaseProtocolDecoder {
if (responseTextLength < 0) {
responseTextLength = CMD_RESPONSE_SIZE - 3;
}
- position.set(Position.KEY_RESULT, buf.readBytes(responseTextLength).toString(StandardCharsets.UTF_8));
+ position.set(Position.KEY_RESULT, buf.readSlice(responseTextLength).toString(StandardCharsets.UTF_8));
return position;
}
@Override
protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
- buf.readUnsignedShort(); // device id
+ buf.readUnsignedShortLE(); // device id
int size = buf.readUnsignedByte();
if (size != CMD_RESPONSE_SIZE) {
int type = buf.readUnsignedByte();
if (type == MSG_IMEI) {
- getDeviceSession(channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.UTF_8));
+ getDeviceSession(channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.UTF_8));
} else {
return decodeData(channel, remoteAddress, buf, type);
}
diff --git a/src/org/traccar/protocol/AdmProtocolEncoder.java b/src/org/traccar/protocol/AdmProtocolEncoder.java
index 8cbd8618d..bcbf8a2f1 100644
--- a/src/org/traccar/protocol/AdmProtocolEncoder.java
+++ b/src/org/traccar/protocol/AdmProtocolEncoder.java
@@ -39,4 +39,5 @@ public class AdmProtocolEncoder extends StringProtocolEncoder {
return null;
}
+
}
diff --git a/src/org/traccar/protocol/AisProtocol.java b/src/org/traccar/protocol/AisProtocol.java
index 4b2e1719e..ff81db45c 100644
--- a/src/org/traccar/protocol/AisProtocol.java
+++ b/src/org/traccar/protocol/AisProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -31,9 +30,9 @@ public class AisProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new AisProtocolDecoder(AisProtocol.this));
}
diff --git a/src/org/traccar/protocol/AisProtocolDecoder.java b/src/org/traccar/protocol/AisProtocolDecoder.java
index 842260e98..7954ef5f9 100644
--- a/src/org/traccar/protocol/AisProtocolDecoder.java
+++ b/src/org/traccar/protocol/AisProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitBuffer;
diff --git a/src/org/traccar/protocol/AlematicsFrameDecoder.java b/src/org/traccar/protocol/AlematicsFrameDecoder.java
index b8b3e3403..be7666657 100644
--- a/src/org/traccar/protocol/AlematicsFrameDecoder.java
+++ b/src/org/traccar/protocol/AlematicsFrameDecoder.java
@@ -15,10 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import org.traccar.NetworkMessage;
public class AlematicsFrameDecoder extends LineBasedFrameDecoder {
@@ -31,20 +31,20 @@ public class AlematicsFrameDecoder extends LineBasedFrameDecoder {
// example of heartbeat: FA F8 00 07 00 03 15 AD 4E 78 3A D2
@Override
- protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ protected Object decode(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
if (buf.readableBytes() < MESSAGE_MINIMUM_LENGTH) {
return null;
}
if (buf.getUnsignedShort(buf.readerIndex()) == 0xFAF8) {
- ChannelBuffer heartbeat = buf.readBytes(12);
- if (channel != null) {
- channel.write(heartbeat);
+ ByteBuf heartbeat = buf.readRetainedSlice(12);
+ if (ctx != null && ctx.channel() != null) {
+ ctx.channel().writeAndFlush(new NetworkMessage(heartbeat, ctx.channel().remoteAddress()));
}
}
- return super.decode(ctx, channel, buf);
+ return super.decode(ctx, buf);
}
}
diff --git a/src/org/traccar/protocol/AlematicsProtocol.java b/src/org/traccar/protocol/AlematicsProtocol.java
index 241ce8bf9..a8bb124f9 100644
--- a/src/org/traccar/protocol/AlematicsProtocol.java
+++ b/src/org/traccar/protocol/AlematicsProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class AlematicsProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new AlematicsFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/AlematicsProtocolDecoder.java b/src/org/traccar/protocol/AlematicsProtocolDecoder.java
index b83081cc1..794588f5f 100644
--- a/src/org/traccar/protocol/AlematicsProtocolDecoder.java
+++ b/src/org/traccar/protocol/AlematicsProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
diff --git a/src/org/traccar/protocol/ApelProtocol.java b/src/org/traccar/protocol/ApelProtocol.java
index 690b5ed99..6b18c2fb8 100644
--- a/src/org/traccar/protocol/ApelProtocol.java
+++ b/src/org/traccar/protocol/ApelProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.nio.ByteOrder;
@@ -32,15 +31,14 @@ public class ApelProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, 4, 0));
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
+ pipeline.addLast("frameDecoder",
+ new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 1024, 2, 2, 4, 0, true));
pipeline.addLast("objectDecoder", new ApelProtocolDecoder(ApelProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/ApelProtocolDecoder.java b/src/org/traccar/protocol/ApelProtocolDecoder.java
index a107f7d6f..affbdedaf 100644
--- a/src/org/traccar/protocol/ApelProtocolDecoder.java
+++ b/src/org/traccar/protocol/ApelProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,17 +15,17 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Checksum;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.LinkedList;
@@ -66,24 +66,24 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder {
public static final short MSG_GPRS_COMMAND = 180;
private void sendSimpleMessage(Channel channel, short type) {
- ChannelBuffer request = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 8);
- request.writeShort(type);
- request.writeShort(0);
- request.writeInt(Checksum.crc32(request.toByteBuffer(0, 4)));
- channel.write(request);
+ ByteBuf request = Unpooled.buffer(8);
+ request.writeShortLE(type);
+ request.writeShortLE(0);
+ request.writeIntLE(Checksum.crc32(request.nioBuffer(0, 4)));
+ channel.writeAndFlush(new NetworkMessage(request, channel.remoteAddress()));
}
private void requestArchive(Channel channel) {
if (lastIndex == 0) {
lastIndex = newIndex;
} else if (newIndex > lastIndex) {
- ChannelBuffer request = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 14);
- request.writeShort(MSG_REQUEST_LOG_RECORDS);
- request.writeShort(6);
- request.writeInt((int) lastIndex);
- request.writeShort(512);
- request.writeInt(Checksum.crc32(request.toByteBuffer(0, 10)));
- channel.write(request);
+ ByteBuf request = Unpooled.buffer(14);
+ request.writeShortLE(MSG_REQUEST_LOG_RECORDS);
+ request.writeShortLE(6);
+ request.writeIntLE((int) lastIndex);
+ request.writeShortLE(512);
+ request.writeIntLE(Checksum.crc32(request.nioBuffer(0, 10)));
+ channel.writeAndFlush(new NetworkMessage(request, channel.remoteAddress()));
}
}
@@ -91,11 +91,11 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
- int type = buf.readUnsignedShort();
+ ByteBuf buf = (ByteBuf) msg;
+ int type = buf.readUnsignedShortLE();
boolean alarm = (type & 0x8000) != 0;
type = type & 0x7FFF;
- buf.readUnsignedShort(); // length
+ buf.readUnsignedShortLE(); // length
if (alarm) {
sendSimpleMessage(channel, MSG_ACK_ALARM);
@@ -107,15 +107,15 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_TRACKER_ID_EXT) {
- buf.readUnsignedInt(); // id
- int length = buf.readUnsignedShort();
+ buf.readUnsignedIntLE(); // id
+ int length = buf.readUnsignedShortLE();
buf.skipBytes(length);
- length = buf.readUnsignedShort();
- getDeviceSession(channel, remoteAddress, buf.readBytes(length).toString(StandardCharsets.US_ASCII));
+ length = buf.readUnsignedShortLE();
+ getDeviceSession(channel, remoteAddress, buf.readSlice(length).toString(StandardCharsets.US_ASCII));
} else if (type == MSG_LAST_LOG_INDEX) {
- long index = buf.readUnsignedInt();
+ long index = buf.readUnsignedIntLE();
if (index > 0) {
newIndex = index;
requestArchive(channel);
@@ -132,7 +132,7 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder {
int recordCount = 1;
if (type == MSG_LOG_RECORDS) {
- recordCount = buf.readUnsignedShort();
+ recordCount = buf.readUnsignedShortLE();
}
for (int j = 0; j < recordCount; j++) {
@@ -142,20 +142,20 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder {
int subtype = type;
if (type == MSG_LOG_RECORDS) {
position.set(Position.KEY_ARCHIVE, true);
- lastIndex = buf.readUnsignedInt() + 1;
+ lastIndex = buf.readUnsignedIntLE() + 1;
position.set(Position.KEY_INDEX, lastIndex);
- subtype = buf.readUnsignedShort();
+ subtype = buf.readUnsignedShortLE();
if (subtype != MSG_CURRENT_GPS_DATA && subtype != MSG_STATE_FULL_INFO_T104) {
- buf.skipBytes(buf.readUnsignedShort());
+ buf.skipBytes(buf.readUnsignedShortLE());
continue;
}
- buf.readUnsignedShort(); // length
+ buf.readUnsignedShortLE(); // length
}
- position.setTime(new Date(buf.readUnsignedInt() * 1000));
- position.setLatitude(buf.readInt() * 180.0 / 0x7FFFFFFF);
- position.setLongitude(buf.readInt() * 180.0 / 0x7FFFFFFF);
+ position.setTime(new Date(buf.readUnsignedIntLE() * 1000));
+ position.setLatitude(buf.readIntLE() * 180.0 / 0x7FFFFFFF);
+ position.setLongitude(buf.readIntLE() * 180.0 / 0x7FFFFFFF);
if (subtype == MSG_STATE_FULL_INFO_T104) {
int speed = buf.readUnsignedByte();
@@ -163,36 +163,36 @@ public class ApelProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromKph(speed));
position.set(Position.KEY_HDOP, buf.readByte());
} else {
- int speed = buf.readShort();
+ int speed = buf.readShortLE();
position.setValid(speed != -1);
position.setSpeed(UnitsConverter.knotsFromKph(speed * 0.01));
}
- position.setCourse(buf.readShort() * 0.01);
- position.setAltitude(buf.readShort());
+ position.setCourse(buf.readShortLE() * 0.01);
+ position.setAltitude(buf.readShortLE());
if (subtype == MSG_STATE_FULL_INFO_T104) {
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
position.set(Position.KEY_RSSI, buf.readUnsignedByte());
- position.set(Position.KEY_EVENT, buf.readUnsignedShort());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ position.set(Position.KEY_EVENT, buf.readUnsignedShortLE());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
position.set(Position.KEY_INPUT, buf.readUnsignedByte());
position.set(Position.KEY_OUTPUT, buf.readUnsignedByte());
for (int i = 1; i <= 8; i++) {
- position.set(Position.PREFIX_ADC + i, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + i, buf.readUnsignedShortLE());
}
- position.set(Position.PREFIX_COUNT + 1, buf.readUnsignedInt());
- position.set(Position.PREFIX_COUNT + 2, buf.readUnsignedInt());
- position.set(Position.PREFIX_COUNT + 3, buf.readUnsignedInt());
+ position.set(Position.PREFIX_COUNT + 1, buf.readUnsignedIntLE());
+ position.set(Position.PREFIX_COUNT + 2, buf.readUnsignedIntLE());
+ position.set(Position.PREFIX_COUNT + 3, buf.readUnsignedIntLE());
}
positions.add(position);
}
- buf.readUnsignedInt(); // crc
+ buf.readUnsignedIntLE(); // crc
if (type == MSG_LOG_RECORDS) {
requestArchive(channel);
diff --git a/src/org/traccar/protocol/AplicomFrameDecoder.java b/src/org/traccar/protocol/AplicomFrameDecoder.java
index 24d55f1cf..6e81e8202 100644
--- a/src/org/traccar/protocol/AplicomFrameDecoder.java
+++ b/src/org/traccar/protocol/AplicomFrameDecoder.java
@@ -15,19 +15,19 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class AplicomFrameDecoder extends FrameDecoder {
+public class AplicomFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
// Skip Alive message
- while (buf.readable() && Character.isDigit(buf.getByte(buf.readerIndex()))) {
+ while (buf.isReadable() && Character.isDigit(buf.getByte(buf.readerIndex()))) {
buf.readByte();
}
@@ -53,7 +53,7 @@ public class AplicomFrameDecoder extends FrameDecoder {
// Return buffer
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
return null;
diff --git a/src/org/traccar/protocol/AplicomProtocol.java b/src/org/traccar/protocol/AplicomProtocol.java
index 80f6f528f..6b9074163 100644
--- a/src/org/traccar/protocol/AplicomProtocol.java
+++ b/src/org/traccar/protocol/AplicomProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class AplicomProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new AplicomFrameDecoder());
pipeline.addLast("objectDecoder", new AplicomProtocolDecoder(AplicomProtocol.this));
}
diff --git a/src/org/traccar/protocol/AplicomProtocolDecoder.java b/src/org/traccar/protocol/AplicomProtocolDecoder.java
index e649b52a6..54b15700a 100644
--- a/src/org/traccar/protocol/AplicomProtocolDecoder.java
+++ b/src/org/traccar/protocol/AplicomProtocolDecoder.java
@@ -15,9 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
@@ -82,7 +82,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
private static final int EVENT_DATA = 119;
- private void decodeEventData(Position position, ChannelBuffer buf, int event) {
+ private void decodeEventData(Position position, ByteBuf buf, int event) {
switch (event) {
case 2:
case 40:
@@ -117,7 +117,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeCanData(ChannelBuffer buf, Position position) {
+ private void decodeCanData(ByteBuf buf, Position position) {
buf.readUnsignedMedium(); // packet identifier
position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte());
@@ -128,63 +128,63 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(8);
- ArrayList<ChannelBuffer> values = new ArrayList<>(count);
+ ArrayList<ByteBuf> values = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
- values.add(buf.readBytes(8));
+ values.add(buf.readSlice(8));
}
for (int i = 0; i < count; i++) {
- ChannelBuffer value = values.get(i);
+ ByteBuf value = values.get(i);
switch (buf.readInt()) {
case 0x20D:
- position.set(Position.KEY_RPM, ChannelBuffers.swapShort(value.readShort()));
- position.set("dieselTemperature", ChannelBuffers.swapShort(value.readShort()) * 0.1);
- position.set("batteryVoltage", ChannelBuffers.swapShort(value.readShort()) * 0.01);
- position.set("supplyAirTempDep1", ChannelBuffers.swapShort(value.readShort()) * 0.1);
+ position.set(Position.KEY_RPM, value.readShortLE());
+ position.set("dieselTemperature", value.readShortLE() * 0.1);
+ position.set("batteryVoltage", value.readShortLE() * 0.01);
+ position.set("supplyAirTempDep1", value.readShortLE() * 0.1);
break;
case 0x30D:
- position.set("activeAlarm", ChannelBuffers.hexDump(value));
+ position.set("activeAlarm", ByteBufUtil.hexDump(value));
break;
case 0x40C:
- position.set("airTempDep1", ChannelBuffers.swapShort(value.readShort()) * 0.1);
- position.set("airTempDep2", ChannelBuffers.swapShort(value.readShort()) * 0.1);
+ position.set("airTempDep1", value.readShortLE() * 0.1);
+ position.set("airTempDep2", value.readShortLE() * 0.1);
break;
case 0x40D:
- position.set("coldUnitState", ChannelBuffers.hexDump(value));
+ position.set("coldUnitState", ByteBufUtil.hexDump(value));
break;
case 0x50C:
- position.set("defrostTempDep1", ChannelBuffers.swapShort(value.readShort()) * 0.1);
- position.set("defrostTempDep2", ChannelBuffers.swapShort(value.readShort()) * 0.1);
+ position.set("defrostTempDep1", value.readShortLE() * 0.1);
+ position.set("defrostTempDep2", value.readShortLE() * 0.1);
break;
case 0x50D:
- position.set("condenserPressure", ChannelBuffers.swapShort(value.readShort()) * 0.1);
- position.set("suctionPressure", ChannelBuffers.swapShort(value.readShort()) * 0.1);
+ position.set("condenserPressure", value.readShortLE() * 0.1);
+ position.set("suctionPressure", value.readShortLE() * 0.1);
break;
case 0x58C:
value.readByte();
value.readShort(); // index
switch (value.readByte()) {
case 0x01:
- position.set("setpointZone1", ChannelBuffers.swapInt(value.readInt()) * 0.1);
+ position.set("setpointZone1", value.readIntLE() * 0.1);
break;
case 0x02:
- position.set("setpointZone2", ChannelBuffers.swapInt(value.readInt()) * 0.1);
+ position.set("setpointZone2", value.readIntLE() * 0.1);
break;
case 0x05:
- position.set("unitType", ChannelBuffers.swapInt(value.readInt()));
+ position.set("unitType", value.readIntLE());
break;
case 0x13:
- position.set("dieselHours", ChannelBuffers.swapInt(value.readInt()) / 60 / 60);
+ position.set("dieselHours", value.readIntLE() / 60 / 60);
break;
case 0x14:
- position.set("electricHours", ChannelBuffers.swapInt(value.readInt()) / 60 / 60);
+ position.set("electricHours", value.readIntLE() / 60 / 60);
break;
case 0x17:
- position.set("serviceIndicator", ChannelBuffers.swapInt(value.readInt()));
+ position.set("serviceIndicator", value.readIntLE());
break;
case 0x18:
- position.set("softwareVersion", ChannelBuffers.swapInt(value.readInt()) * 0.01);
+ position.set("softwareVersion", value.readIntLE() * 0.01);
break;
default:
break;
@@ -197,7 +197,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeD(Position position, ChannelBuffer buf, int selector, int event) {
+ private void decodeD(Position position, ByteBuf buf, int selector, int event) {
if ((selector & 0x0008) != 0) {
position.setValid((buf.readUnsignedByte() & 0x40) != 0);
@@ -292,12 +292,12 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
if (Context.getConfig().getBoolean(getProtocolName() + ".can")
- && buf.readable() && (selector & 0x1000) != 0 && event == EVENT_DATA) {
+ && buf.isReadable() && (selector & 0x1000) != 0 && event == EVENT_DATA) {
decodeCanData(buf, position);
}
}
- private void decodeE(Position position, ChannelBuffer buf, int selector) {
+ private void decodeE(Position position, ByteBuf buf, int selector) {
if ((selector & 0x0008) != 0) {
position.set("tachographEvent", buf.readUnsignedShort());
@@ -349,13 +349,13 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
if ((selector & 0x0800) != 0) {
- position.set(Position.KEY_VIN, buf.readBytes(18).toString(StandardCharsets.US_ASCII).trim());
+ position.set(Position.KEY_VIN, buf.readSlice(18).toString(StandardCharsets.US_ASCII).trim());
}
if ((selector & 0x2000) != 0) {
buf.readUnsignedByte(); // card 1 type
buf.readUnsignedByte(); // card 1 country code
- String card = buf.readBytes(20).toString(StandardCharsets.US_ASCII).trim();
+ String card = buf.readSlice(20).toString(StandardCharsets.US_ASCII).trim();
if (!card.isEmpty()) {
position.set("card1", card);
}
@@ -364,7 +364,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
if ((selector & 0x4000) != 0) {
buf.readUnsignedByte(); // card 2 type
buf.readUnsignedByte(); // card 2 country code
- String card = buf.readBytes(20).toString(StandardCharsets.US_ASCII).trim();
+ String card = buf.readSlice(20).toString(StandardCharsets.US_ASCII).trim();
if (!card.isEmpty()) {
position.set("card2", card);
}
@@ -373,13 +373,13 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
if ((selector & 0x10000) != 0) {
int count = buf.readUnsignedByte();
for (int i = 1; i <= count; i++) {
- position.set("driver" + i, buf.readBytes(22).toString(StandardCharsets.US_ASCII).trim());
+ position.set("driver" + i, buf.readSlice(22).toString(StandardCharsets.US_ASCII).trim());
position.set("driverTime" + i, buf.readUnsignedInt());
}
}
}
- private void decodeH(Position position, ChannelBuffer buf, int selector) {
+ private void decodeH(Position position, ByteBuf buf, int selector) {
if ((selector & 0x0004) != 0) {
getLastLocation(position, new Date(buf.readUnsignedInt() * 1000));
@@ -457,7 +457,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeEB(Position position, ChannelBuffer buf) {
+ private void decodeEB(Position position, ByteBuf buf) {
if (buf.readByte() != (byte) 'E' || buf.readByte() != (byte) 'B') {
return;
@@ -477,7 +477,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
switch (type) {
case 0x01:
- position.set("brakeFlags", ChannelBuffers.hexDump(buf.readBytes(length)));
+ position.set("brakeFlags", ByteBufUtil.hexDump(buf.readSlice(length)));
break;
case 0x02:
position.set("wheelSpeed", buf.readUnsignedShort() / 256.0);
@@ -507,10 +507,10 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
position.set("vdcActiveCounter", buf.readUnsignedShort());
break;
case 0x0B:
- position.set("brakeMinMaxData", ChannelBuffers.hexDump(buf.readBytes(length)));
+ position.set("brakeMinMaxData", ByteBufUtil.hexDump(buf.readSlice(length)));
break;
case 0x0C:
- position.set("missingPgn", ChannelBuffers.hexDump(buf.readBytes(length)));
+ position.set("missingPgn", ByteBufUtil.hexDump(buf.readSlice(length)));
break;
case 0x0D:
buf.readUnsignedByte();
@@ -526,7 +526,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeF(Position position, ChannelBuffer buf, int selector) {
+ private void decodeF(Position position, ByteBuf buf, int selector) {
getLastLocation(position, null);
@@ -636,7 +636,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
char protocol = (char) buf.readByte();
int version = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/AppelloProtocol.java b/src/org/traccar/protocol/AppelloProtocol.java
index 8581850a1..33c7bbeed 100644
--- a/src/org/traccar/protocol/AppelloProtocol.java
+++ b/src/org/traccar/protocol/AppelloProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class AppelloProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/AppelloProtocolDecoder.java b/src/org/traccar/protocol/AppelloProtocolDecoder.java
index bf95b4068..ea0a2e243 100644
--- a/src/org/traccar/protocol/AppelloProtocolDecoder.java
+++ b/src/org/traccar/protocol/AppelloProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/AquilaProtocol.java b/src/org/traccar/protocol/AquilaProtocol.java
index c1de71cd3..b8c8e45d9 100644
--- a/src/org/traccar/protocol/AquilaProtocol.java
+++ b/src/org/traccar/protocol/AquilaProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class AquilaProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/AquilaProtocolDecoder.java b/src/org/traccar/protocol/AquilaProtocolDecoder.java
index 3821e13ca..8e4343ac4 100644
--- a/src/org/traccar/protocol/AquilaProtocolDecoder.java
+++ b/src/org/traccar/protocol/AquilaProtocolDecoder.java
@@ -15,10 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
@@ -302,7 +303,8 @@ public class AquilaProtocolDecoder extends BaseProtocolDecoder {
if (channel != null) {
String password = Context.getIdentityManager().lookupAttributeString(
position.getDeviceId(), getProtocolName() + ".password", "aquila123", true);
- channel.write("#set$" + id + "@" + password + "#EMR_MODE:0*");
+ channel.writeAndFlush(new NetworkMessage(
+ "#set$" + id + "@" + password + "#EMR_MODE:0*", remoteAddress));
}
}
diff --git a/src/org/traccar/protocol/Ardi01Protocol.java b/src/org/traccar/protocol/Ardi01Protocol.java
index 446592bd0..5242df08c 100644
--- a/src/org/traccar/protocol/Ardi01Protocol.java
+++ b/src/org/traccar/protocol/Ardi01Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class Ardi01Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/Ardi01ProtocolDecoder.java b/src/org/traccar/protocol/Ardi01ProtocolDecoder.java
index dea9e3483..7e25159b1 100644
--- a/src/org/traccar/protocol/Ardi01ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Ardi01ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/ArknavProtocol.java b/src/org/traccar/protocol/ArknavProtocol.java
index c22e5f443..3497ab8bb 100644
--- a/src/org/traccar/protocol/ArknavProtocol.java
+++ b/src/org/traccar/protocol/ArknavProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class ArknavProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r'));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/ArknavProtocolDecoder.java b/src/org/traccar/protocol/ArknavProtocolDecoder.java
index aeea4a734..c1a297e97 100644
--- a/src/org/traccar/protocol/ArknavProtocolDecoder.java
+++ b/src/org/traccar/protocol/ArknavProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/ArknavX8Protocol.java b/src/org/traccar/protocol/ArknavX8Protocol.java
index e759b5294..f5ad81660 100644
--- a/src/org/traccar/protocol/ArknavX8Protocol.java
+++ b/src/org/traccar/protocol/ArknavX8Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class ArknavX8Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java
index 47cc267fe..60d7fe0db 100644
--- a/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java
+++ b/src/org/traccar/protocol/ArknavX8ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/ArnaviProtocol.java b/src/org/traccar/protocol/ArnaviProtocol.java
index 956f2329a..88203fdbe 100644
--- a/src/org/traccar/protocol/ArnaviProtocol.java
+++ b/src/org/traccar/protocol/ArnaviProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class ArnaviProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/ArnaviProtocolDecoder.java b/src/org/traccar/protocol/ArnaviProtocolDecoder.java
index ec96343fe..7649dddf6 100644
--- a/src/org/traccar/protocol/ArnaviProtocolDecoder.java
+++ b/src/org/traccar/protocol/ArnaviProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/AstraProtocol.java b/src/org/traccar/protocol/AstraProtocol.java
index 87c562a9d..301afa532 100644
--- a/src/org/traccar/protocol/AstraProtocol.java
+++ b/src/org/traccar/protocol/AstraProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,16 +30,16 @@ public class AstraProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 1, 2, -3, 0));
pipeline.addLast("objectDecoder", new AstraProtocolDecoder(AstraProtocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectDecoder", new AstraProtocolDecoder(AstraProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/AstraProtocolDecoder.java b/src/org/traccar/protocol/AstraProtocolDecoder.java
index 7f247251d..c386c7757 100644
--- a/src/org/traccar/protocol/AstraProtocolDecoder.java
+++ b/src/org/traccar/protocol/AstraProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Log;
@@ -44,10 +45,10 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (channel != null) {
- channel.write(ChannelBuffers.wrappedBuffer(new byte[] {0x06}), remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(Unpooled.wrappedBuffer(new byte[] {0x06}), remoteAddress));
}
buf.readUnsignedByte(); // protocol
@@ -104,7 +105,7 @@ public class AstraProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // geofence events
if (BitUtil.check(status, 8)) {
- position.set(Position.KEY_DRIVER_UNIQUE_ID, buf.readBytes(7).toString(StandardCharsets.US_ASCII));
+ position.set(Position.KEY_DRIVER_UNIQUE_ID, buf.readSlice(7).toString(StandardCharsets.US_ASCII));
position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium() * 1000);
position.set(Position.KEY_HOURS, UnitsConverter.msFromHours(buf.readUnsignedShort()));
}
diff --git a/src/org/traccar/protocol/At2000FrameDecoder.java b/src/org/traccar/protocol/At2000FrameDecoder.java
index af257d0fb..5fa82a5f7 100644
--- a/src/org/traccar/protocol/At2000FrameDecoder.java
+++ b/src/org/traccar/protocol/At2000FrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,38 +15,37 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
+import org.traccar.NetworkMessage;
-import java.nio.ByteOrder;
-
-public class At2000FrameDecoder extends FrameDecoder {
+public class At2000FrameDecoder extends BaseFrameDecoder {
private static final int BLOCK_LENGTH = 16;
private static final int ACK_LENGTH = 496;
private boolean firstPacket = true;
- private ChannelBuffer currentBuffer;
+ private ByteBuf currentBuffer;
private int acknowledgedBytes;
private void sendResponse(Channel channel) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 2 * BLOCK_LENGTH);
+ ByteBuf response = Unpooled.buffer(2 * BLOCK_LENGTH);
response.writeByte(At2000ProtocolDecoder.MSG_ACKNOWLEDGEMENT);
- response.writeMedium(ChannelBuffers.swapMedium(1));
+ response.writeMedium(1);
response.writeByte(0x00); // success
response.writerIndex(2 * BLOCK_LENGTH);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 5) {
return null;
@@ -55,9 +54,9 @@ public class At2000FrameDecoder extends FrameDecoder {
int length;
if (firstPacket) {
firstPacket = false;
- length = buf.getUnsignedMedium(buf.readerIndex() + 2);
+ length = buf.getUnsignedMediumLE(buf.readerIndex() + 2);
} else {
- length = buf.getUnsignedMedium(buf.readerIndex() + 1);
+ length = buf.getUnsignedMediumLE(buf.readerIndex() + 1);
}
length += BLOCK_LENGTH;
@@ -73,7 +72,7 @@ public class At2000FrameDecoder extends FrameDecoder {
}
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
return null;
diff --git a/src/org/traccar/protocol/At2000Protocol.java b/src/org/traccar/protocol/At2000Protocol.java
index 35aa0b469..1aca8bb13 100644
--- a/src/org/traccar/protocol/At2000Protocol.java
+++ b/src/org/traccar/protocol/At2000Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
-import java.nio.ByteOrder;
import java.util.List;
public class At2000Protocol extends BaseProtocol {
@@ -31,15 +29,13 @@ public class At2000Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new At2000FrameDecoder());
pipeline.addLast("objectDecoder", new At2000ProtocolDecoder(At2000Protocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/At2000ProtocolDecoder.java b/src/org/traccar/protocol/At2000ProtocolDecoder.java
index e0f2b4278..4457854e3 100644
--- a/src/org/traccar/protocol/At2000ProtocolDecoder.java
+++ b/src/org/traccar/protocol/At2000ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DataConverter;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -28,7 +29,6 @@ import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.LinkedList;
@@ -52,11 +52,11 @@ public class At2000ProtocolDecoder extends BaseProtocolDecoder {
private static void sendRequest(Channel channel) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, BLOCK_LENGTH);
+ ByteBuf response = Unpooled.buffer(BLOCK_LENGTH);
response.writeByte(MSG_TRACK_REQUEST);
- response.writeMedium(ChannelBuffers.swapMedium(0));
+ response.writeMedium(0);
response.writerIndex(BLOCK_LENGTH);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
@@ -64,19 +64,19 @@ public class At2000ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (buf.getUnsignedByte(buf.readerIndex()) == 0x01) {
buf.readUnsignedByte(); // codec id
}
int type = buf.readUnsignedByte();
- buf.readUnsignedMedium(); // length
+ buf.readUnsignedMediumLE(); // length
buf.skipBytes(BLOCK_LENGTH - 1 - 3);
if (type == MSG_DEVICE_ID) {
- String imei = buf.readBytes(15).toString(StandardCharsets.US_ASCII);
+ String imei = buf.readSlice(15).toString(StandardCharsets.US_ASCII);
if (getDeviceSession(channel, remoteAddress, imei) != null) {
byte[] iv = new byte[BLOCK_LENGTH];
@@ -106,51 +106,54 @@ public class At2000ProtocolDecoder extends BaseProtocolDecoder {
return null; // empty message
}
- byte[] data = new byte[buf.capacity() - BLOCK_LENGTH];
- buf.readBytes(data);
- buf = ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, cipher.update(data));
-
List<Position> positions = new LinkedList<>();
- while (buf.readableBytes() >= 63) {
+ byte[] data = new byte[buf.capacity() - BLOCK_LENGTH];
+ buf.readBytes(data);
+ buf = Unpooled.wrappedBuffer(cipher.update(data));
+ try {
+ while (buf.readableBytes() >= 63) {
- Position position = new Position(getProtocolName());
- position.setDeviceId(deviceSession.getDeviceId());
+ Position position = new Position(getProtocolName());
+ position.setDeviceId(deviceSession.getDeviceId());
- buf.readUnsignedShort(); // index
- buf.readUnsignedShort(); // reserved
+ buf.readUnsignedShortLE(); // index
+ buf.readUnsignedShortLE(); // reserved
- position.setValid(true);
+ position.setValid(true);
- position.setTime(new Date(buf.readLong() * 1000));
+ position.setTime(new Date(buf.readLongLE() * 1000));
- position.setLatitude(buf.readFloat());
- position.setLongitude(buf.readFloat());
- position.setAltitude(buf.readFloat());
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readFloat()));
- position.setCourse(buf.readFloat());
+ position.setLatitude(buf.readFloatLE());
+ position.setLongitude(buf.readFloatLE());
+ position.setAltitude(buf.readFloatLE());
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readFloatLE()));
+ position.setCourse(buf.readFloatLE());
- buf.readUnsignedInt(); // geozone event
- buf.readUnsignedInt(); // io events
- buf.readUnsignedInt(); // geozone value
- buf.readUnsignedInt(); // io values
- buf.readUnsignedShort(); // operator
+ buf.readUnsignedIntLE(); // geozone event
+ buf.readUnsignedIntLE(); // io events
+ buf.readUnsignedIntLE(); // geozone value
+ buf.readUnsignedIntLE(); // io values
+ buf.readUnsignedShortLE(); // operator
- position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
- position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShortLE());
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShortLE());
- position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.001);
+ position.set(Position.KEY_POWER, buf.readUnsignedShortLE() * 0.001);
- buf.readUnsignedShort(); // cid
- position.set(Position.KEY_RSSI, buf.readUnsignedByte());
- buf.readUnsignedByte(); // current profile
+ buf.readUnsignedShortLE(); // cid
+ position.set(Position.KEY_RSSI, buf.readUnsignedByte());
+ buf.readUnsignedByte(); // current profile
- position.set(Position.KEY_BATTERY, buf.readUnsignedByte());
- position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedByte());
- position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
+ position.set(Position.KEY_BATTERY, buf.readUnsignedByte());
+ position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedByte());
+ position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
- positions.add(position);
+ positions.add(position);
+ }
+ } finally {
+ buf.release();
}
return positions;
diff --git a/src/org/traccar/protocol/AtrackFrameDecoder.java b/src/org/traccar/protocol/AtrackFrameDecoder.java
index 224679bde..3d33d9862 100644
--- a/src/org/traccar/protocol/AtrackFrameDecoder.java
+++ b/src/org/traccar/protocol/AtrackFrameDecoder.java
@@ -15,26 +15,26 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.traccar.helper.StringFinder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
+import org.traccar.helper.BufferUtil;
-public class AtrackFrameDecoder extends FrameDecoder {
+public class AtrackFrameDecoder extends BaseFrameDecoder {
private static final int KEEPALIVE_LENGTH = 12;
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() >= 2) {
if (buf.getUnsignedShort(buf.readerIndex()) == 0xfe02) {
if (buf.readableBytes() >= KEEPALIVE_LENGTH) {
- return buf.readBytes(KEEPALIVE_LENGTH);
+ return buf.readRetainedSlice(KEEPALIVE_LENGTH);
}
} else if (buf.getUnsignedShort(buf.readerIndex()) == 0x4050 && buf.getByte(buf.readerIndex() + 2) != ',') {
@@ -42,15 +42,15 @@ public class AtrackFrameDecoder extends FrameDecoder {
if (buf.readableBytes() > 6) {
int length = buf.getUnsignedShort(buf.readerIndex() + 4) + 4 + 2;
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
}
} else {
- int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("\r\n"));
+ int endIndex = BufferUtil.indexOf("\r\n", buf);
if (endIndex > 0) {
- return buf.readBytes(endIndex - buf.readerIndex() + 2);
+ return buf.readRetainedSlice(endIndex - buf.readerIndex() + 2);
}
}
diff --git a/src/org/traccar/protocol/AtrackProtocol.java b/src/org/traccar/protocol/AtrackProtocol.java
index 5104e5587..74840a1f5 100644
--- a/src/org/traccar/protocol/AtrackProtocol.java
+++ b/src/org/traccar/protocol/AtrackProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -34,17 +32,17 @@ public class AtrackProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new AtrackFrameDecoder());
pipeline.addLast("objectEncoder", new AtrackProtocolEncoder());
pipeline.addLast("objectDecoder", new AtrackProtocolDecoder(AtrackProtocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectEncoder", new AtrackProtocolEncoder());
pipeline.addLast("objectDecoder", new AtrackProtocolDecoder(AtrackProtocol.this));
}
diff --git a/src/org/traccar/protocol/AtrackProtocolDecoder.java b/src/org/traccar/protocol/AtrackProtocolDecoder.java
index ac208c0f2..ebccfec94 100644
--- a/src/org/traccar/protocol/AtrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/AtrackProtocolDecoder.java
@@ -15,12 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -80,25 +81,25 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
private static void sendResponse(Channel channel, SocketAddress remoteAddress, long rawId, int index) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(12);
+ ByteBuf response = Unpooled.buffer(12);
response.writeShort(0xfe02);
response.writeLong(rawId);
response.writeShort(index);
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
- private static String readString(ChannelBuffer buf) {
+ private static String readString(ByteBuf buf) {
String result = null;
int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0);
if (index > buf.readerIndex()) {
- result = buf.readBytes(index - buf.readerIndex()).toString(StandardCharsets.US_ASCII);
+ result = buf.readSlice(index - buf.readerIndex()).toString(StandardCharsets.US_ASCII);
}
buf.readByte();
return result;
}
- private void readCustomData(Position position, ChannelBuffer buf, String form) {
+ private void readCustomData(Position position, ByteBuf buf, String form) {
CellTower cellTower = new CellTower();
String[] keys = form.substring(1).split("%");
for (String key : keys) {
@@ -321,7 +322,7 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private List<Position> decodeBinary(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private List<Position> decodeBinary(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
buf.skipBytes(2); // prefix
buf.readUnsignedShort(); // checksum
@@ -414,11 +415,11 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (buf.getUnsignedShort(buf.readerIndex()) == 0xfe02) {
if (channel != null) {
- channel.write(buf, remoteAddress); // keep-alive message
+ channel.writeAndFlush(new NetworkMessage(buf, remoteAddress)); // keep-alive message
}
return null;
} else if (buf.getByte(buf.readerIndex()) == '$') {
diff --git a/src/org/traccar/protocol/AtrackProtocolEncoder.java b/src/org/traccar/protocol/AtrackProtocolEncoder.java
index 77f16527f..1aa580435 100644
--- a/src/org/traccar/protocol/AtrackProtocolEncoder.java
+++ b/src/org/traccar/protocol/AtrackProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Log;
import org.traccar.model.Command;
@@ -29,7 +29,7 @@ public class AtrackProtocolEncoder extends BaseProtocolEncoder {
switch (command.getType()) {
case Command.TYPE_CUSTOM:
- return ChannelBuffers.copiedBuffer(
+ return Unpooled.copiedBuffer(
command.getString(Command.KEY_DATA) + "\r\n", StandardCharsets.US_ASCII);
default:
Log.warning(new UnsupportedOperationException(command.getType()));
diff --git a/src/org/traccar/protocol/AuroProtocol.java b/src/org/traccar/protocol/AuroProtocol.java
index e1b23478f..99affeba1 100644
--- a/src/org/traccar/protocol/AuroProtocol.java
+++ b/src/org/traccar/protocol/AuroProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class AuroProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/AuroProtocolDecoder.java b/src/org/traccar/protocol/AuroProtocolDecoder.java
index 3cb3a440c..e84b65bf3 100644
--- a/src/org/traccar/protocol/AuroProtocolDecoder.java
+++ b/src/org/traccar/protocol/AuroProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/AustinNbProtocol.java b/src/org/traccar/protocol/AustinNbProtocol.java
index 7f6739495..1ffb6e4ad 100644
--- a/src/org/traccar/protocol/AustinNbProtocol.java
+++ b/src/org/traccar/protocol/AustinNbProtocol.java
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class AustinNbProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new AustinNbProtocolDecoder(AustinNbProtocol.this));
diff --git a/src/org/traccar/protocol/AustinNbProtocolDecoder.java b/src/org/traccar/protocol/AustinNbProtocolDecoder.java
index c8f4baf78..5e2ee6178 100644
--- a/src/org/traccar/protocol/AustinNbProtocolDecoder.java
+++ b/src/org/traccar/protocol/AustinNbProtocolDecoder.java
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/AutoFonFrameDecoder.java b/src/org/traccar/protocol/AutoFonFrameDecoder.java
index 2fa1b4072..69f28133f 100644
--- a/src/org/traccar/protocol/AutoFonFrameDecoder.java
+++ b/src/org/traccar/protocol/AutoFonFrameDecoder.java
@@ -16,18 +16,16 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class AutoFonFrameDecoder extends FrameDecoder {
+public class AutoFonFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
// Check minimum length
if (buf.readableBytes() < 12) {
@@ -58,7 +56,7 @@ public class AutoFonFrameDecoder extends FrameDecoder {
// Check length and return buffer
if (length != 0 && buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
return null;
diff --git a/src/org/traccar/protocol/AutoFonProtocol.java b/src/org/traccar/protocol/AutoFonProtocol.java
index 927bda120..993f8610c 100644
--- a/src/org/traccar/protocol/AutoFonProtocol.java
+++ b/src/org/traccar/protocol/AutoFonProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class AutoFonProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new AutoFonFrameDecoder());
pipeline.addLast("objectDecoder", new AutoFonProtocolDecoder(AutoFonProtocol.this));
}
diff --git a/src/org/traccar/protocol/AutoFonProtocolDecoder.java b/src/org/traccar/protocol/AutoFonProtocolDecoder.java
index e243b93ea..c5a3692f2 100644
--- a/src/org/traccar/protocol/AutoFonProtocolDecoder.java
+++ b/src/org/traccar/protocol/AutoFonProtocolDecoder.java
@@ -16,11 +16,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.model.CellTower;
@@ -60,7 +62,7 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder {
}
}
- private Position decodePosition(DeviceSession deviceSession, ChannelBuffer buf, boolean history) {
+ private Position decodePosition(DeviceSession deviceSession, ByteBuf buf, boolean history) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -118,7 +120,7 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
int type = buf.readUnsignedByte();
@@ -129,14 +131,14 @@ public class AutoFonProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // software version
}
- String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1);
+ String imei = ByteBufUtil.hexDump(buf.readSlice(8)).substring(1);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession != null && channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeBytes("resp_crc=".getBytes(StandardCharsets.US_ASCII));
response.writeByte(buf.getByte(buf.writerIndex() - 1));
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
return null;
diff --git a/src/org/traccar/protocol/AutoGradeProtocol.java b/src/org/traccar/protocol/AutoGradeProtocol.java
index 41bb8d9ad..ba51c2bfc 100644
--- a/src/org/traccar/protocol/AutoGradeProtocol.java
+++ b/src/org/traccar/protocol/AutoGradeProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class AutoGradeProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ')'));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/AutoGradeProtocolDecoder.java b/src/org/traccar/protocol/AutoGradeProtocolDecoder.java
index b98c68cbd..9b9ef7d46 100644
--- a/src/org/traccar/protocol/AutoGradeProtocolDecoder.java
+++ b/src/org/traccar/protocol/AutoGradeProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
diff --git a/src/org/traccar/protocol/Avl301Protocol.java b/src/org/traccar/protocol/Avl301Protocol.java
index 4a217bad6..98a9b8edc 100644
--- a/src/org/traccar/protocol/Avl301Protocol.java
+++ b/src/org/traccar/protocol/Avl301Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -31,9 +30,9 @@ public class Avl301Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 1, -3, 0));
pipeline.addLast("objectDecoder", new Avl301ProtocolDecoder(Avl301Protocol.this));
}
diff --git a/src/org/traccar/protocol/Avl301ProtocolDecoder.java b/src/org/traccar/protocol/Avl301ProtocolDecoder.java
index 056395d35..a3697117b 100644
--- a/src/org/traccar/protocol/Avl301ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Avl301ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.model.CellTower;
import org.traccar.model.Network;
@@ -33,7 +34,7 @@ public class Avl301ProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private String readImei(ChannelBuffer buf) {
+ private String readImei(ByteBuf buf) {
int b = buf.readUnsignedByte();
StringBuilder imei = new StringBuilder();
imei.append(b & 0x0F);
@@ -51,12 +52,12 @@ public class Avl301ProtocolDecoder extends BaseProtocolDecoder {
private void sendResponse(Channel channel, int type) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(5);
+ ByteBuf response = Unpooled.buffer(5);
response.writeByte('$');
response.writeByte(type);
response.writeByte('#');
response.writeByte('\r'); response.writeByte('\n');
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
@@ -64,7 +65,7 @@ public class Avl301ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(1); // header
int type = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/BceFrameDecoder.java b/src/org/traccar/protocol/BceFrameDecoder.java
index 4fac79f85..381a97696 100644
--- a/src/org/traccar/protocol/BceFrameDecoder.java
+++ b/src/org/traccar/protocol/BceFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,18 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class BceFrameDecoder extends FrameDecoder {
+public class BceFrameDecoder extends BaseFrameDecoder {
private static final int HANDSHAKE_LENGTH = 7; // "#BCE#\r\n"
private boolean header = true;
- private static byte checksum(ChannelBuffer buf, int end) {
+ private static byte checksum(ByteBuf buf, int end) {
byte result = 0;
for (int i = 0; i < end; i++) {
result += buf.getByte(buf.readerIndex() + i);
@@ -36,9 +36,7 @@ public class BceFrameDecoder extends FrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (header && buf.readableBytes() >= HANDSHAKE_LENGTH) {
buf.skipBytes(HANDSHAKE_LENGTH);
@@ -48,10 +46,10 @@ public class BceFrameDecoder extends FrameDecoder {
int end = 8; // IMEI
while (buf.readableBytes() >= end + 2 + 1 + 1 + 1) {
- end += buf.getUnsignedShort(buf.readerIndex() + end) + 2;
+ end += buf.getUnsignedShortLE(buf.readerIndex() + end) + 2;
if (buf.readableBytes() > end && checksum(buf, end) == buf.getByte(buf.readerIndex() + end)) {
- return buf.readBytes(end + 1);
+ return buf.readRetainedSlice(end + 1);
}
}
diff --git a/src/org/traccar/protocol/BceProtocol.java b/src/org/traccar/protocol/BceProtocol.java
index 5374fd0e1..880a4df70 100644
--- a/src/org/traccar/protocol/BceProtocol.java
+++ b/src/org/traccar/protocol/BceProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
-import java.nio.ByteOrder;
import java.util.List;
public class BceProtocol extends BaseProtocol {
@@ -31,15 +29,13 @@ public class BceProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new BceFrameDecoder());
pipeline.addLast("objectDecoder", new BceProtocolDecoder(BceProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/BceProtocolDecoder.java b/src/org/traccar/protocol/BceProtocolDecoder.java
index f48757a4f..301be7847 100644
--- a/src/org/traccar/protocol/BceProtocolDecoder.java
+++ b/src/org/traccar/protocol/BceProtocolDecoder.java
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.CellTower;
@@ -27,7 +28,6 @@ import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
@@ -50,9 +50,9 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
- String imei = String.format("%015d", buf.readLong());
+ String imei = String.format("%015d", buf.readLongLE());
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession == null) {
return null;
@@ -62,7 +62,7 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
while (buf.readableBytes() > 1) {
- int dataEnd = buf.readUnsignedShort() + buf.readerIndex();
+ int dataEnd = buf.readUnsignedShortLE() + buf.readerIndex();
int type = buf.readUnsignedByte();
int confirmKey = buf.readUnsignedByte() & 0x7F;
@@ -73,7 +73,7 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
int structEnd = buf.readUnsignedByte() + buf.readerIndex();
- long time = buf.readUnsignedInt();
+ long time = buf.readUnsignedIntLE();
if ((time & 0x0f) == DATA_TYPE) {
time = time >> 4 << 1;
@@ -84,7 +84,7 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
int mask;
List<Integer> masks = new LinkedList<>();
do {
- mask = buf.readUnsignedShort();
+ mask = buf.readUnsignedShortLE();
masks.add(mask);
} while (BitUtil.check(mask, 15));
@@ -92,8 +92,8 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(mask, 0)) {
position.setValid(true);
- position.setLongitude(buf.readFloat());
- position.setLatitude(buf.readFloat());
+ position.setLongitude(buf.readFloatLE());
+ position.setLatitude(buf.readFloatLE());
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
int status = buf.readUnsignedByte();
@@ -101,18 +101,18 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_HDOP, BitUtil.from(status, 4));
position.setCourse(buf.readUnsignedByte() * 2);
- position.setAltitude(buf.readUnsignedShort());
+ position.setAltitude(buf.readUnsignedShortLE());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
}
if (BitUtil.check(mask, 1)) {
- position.set(Position.KEY_INPUT, buf.readUnsignedShort());
+ position.set(Position.KEY_INPUT, buf.readUnsignedShortLE());
}
for (int i = 1; i <= 8; i++) {
if (BitUtil.check(mask, i + 1)) {
- position.set(Position.PREFIX_ADC + i, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + i, buf.readUnsignedShortLE());
}
}
@@ -131,8 +131,8 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
if (BitUtil.check(mask, 14)) {
position.setNetwork(new Network(CellTower.from(
- buf.readUnsignedShort(), buf.readUnsignedByte(),
- buf.readUnsignedShort(), buf.readUnsignedShort(),
+ buf.readUnsignedShortLE(), buf.readUnsignedByte(),
+ buf.readUnsignedShortLE(), buf.readUnsignedShortLE(),
buf.readUnsignedByte())));
buf.readUnsignedByte();
}
@@ -147,9 +147,9 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
// Send response
if (type == MSG_ASYNC_STACK && channel != null) {
- ChannelBuffer response = ChannelBuffers.buffer(ByteOrder.LITTLE_ENDIAN, 8 + 2 + 2 + 1);
- response.writeLong(Long.parseLong(imei));
- response.writeShort(2);
+ ByteBuf response = Unpooled.buffer(8 + 2 + 2 + 1);
+ response.writeLongLE(Long.parseLong(imei));
+ response.writeShortLE(2);
response.writeByte(MSG_STACK_COFIRM);
response.writeByte(confirmKey);
@@ -159,7 +159,7 @@ public class BceProtocolDecoder extends BaseProtocolDecoder {
}
response.writeByte(checksum);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
diff --git a/src/org/traccar/protocol/BlackKiteProtocol.java b/src/org/traccar/protocol/BlackKiteProtocol.java
index db32f5328..423562907 100644
--- a/src/org/traccar/protocol/BlackKiteProtocol.java
+++ b/src/org/traccar/protocol/BlackKiteProtocol.java
@@ -1,6 +1,6 @@
/*
* Copyright 2015 Vijay Kumar (vijaykumar@zilogic.com)
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +16,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
-import java.nio.ByteOrder;
import java.util.List;
public class BlackKiteProtocol extends BaseProtocol {
@@ -32,15 +30,13 @@ public class BlackKiteProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new GalileoFrameDecoder());
pipeline.addLast("objectDecoder", new BlackKiteProtocolDecoder(BlackKiteProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java
index 7fc39fc7c..aebf970d0 100644
--- a/src/org/traccar/protocol/BlackKiteProtocolDecoder.java
+++ b/src/org/traccar/protocol/BlackKiteProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
* Copyright 2015 Vijay Kumar (vijaykumar@zilogic.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,16 +16,16 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashSet;
@@ -56,11 +56,11 @@ public class BlackKiteProtocolDecoder extends BaseProtocolDecoder {
private static final int TAG_XT3 = 0x62;
private void sendReply(Channel channel, int checksum) {
- ChannelBuffer reply = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 3);
- reply.writeByte(0x02);
- reply.writeShort((short) checksum);
if (channel != null) {
- channel.write(reply);
+ ByteBuf reply = Unpooled.buffer(3);
+ reply.writeByte(0x02);
+ reply.writeShortLE((short) checksum);
+ channel.writeAndFlush(new NetworkMessage(reply, channel.remoteAddress()));
}
}
@@ -68,10 +68,10 @@ public class BlackKiteProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.readUnsignedByte(); // header
- int length = (buf.readUnsignedShort() & 0x7fff) + 3;
+ int length = (buf.readUnsignedShortLE() & 0x7fff) + 3;
List<Position> positions = new LinkedList<>();
Set<Integer> tags = new HashSet<>();
@@ -95,31 +95,31 @@ public class BlackKiteProtocolDecoder extends BaseProtocolDecoder {
switch (tag) {
case TAG_IMEI:
- getDeviceSession(channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII));
+ getDeviceSession(channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.US_ASCII));
break;
case TAG_DATE:
- position.setTime(new Date(buf.readUnsignedInt() * 1000));
+ position.setTime(new Date(buf.readUnsignedIntLE() * 1000));
break;
case TAG_COORDINATES:
hasLocation = true;
position.setValid((buf.readUnsignedByte() & 0xf0) == 0x00);
- position.setLatitude(buf.readInt() / 1000000.0);
- position.setLongitude(buf.readInt() / 1000000.0);
+ position.setLatitude(buf.readIntLE() / 1000000.0);
+ position.setLongitude(buf.readIntLE() / 1000000.0);
break;
case TAG_SPEED_COURSE:
- position.setSpeed(buf.readUnsignedShort() * 0.0539957);
- position.setCourse(buf.readUnsignedShort() * 0.1);
+ position.setSpeed(buf.readUnsignedShortLE() * 0.0539957);
+ position.setCourse(buf.readUnsignedShortLE() * 0.1);
break;
case TAG_ALTITUDE:
- position.setAltitude(buf.readShort());
+ position.setAltitude(buf.readShortLE());
break;
case TAG_STATUS:
- int status = buf.readUnsignedShort();
+ int status = buf.readUnsignedShortLE();
position.set(Position.KEY_IGNITION, BitUtil.check(status, 9));
if (BitUtil.check(status, 15)) {
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
@@ -128,33 +128,33 @@ public class BlackKiteProtocolDecoder extends BaseProtocolDecoder {
break;
case TAG_DIGITAL_INPUTS:
- int input = buf.readUnsignedShort();
+ int input = buf.readUnsignedShortLE();
for (int i = 0; i < 16; i++) {
position.set(Position.PREFIX_IO + (i + 1), BitUtil.check(input, i));
}
break;
case TAG_DIGITAL_OUTPUTS:
- int output = buf.readUnsignedShort();
+ int output = buf.readUnsignedShortLE();
for (int i = 0; i < 16; i++) {
position.set(Position.PREFIX_IO + (i + 17), BitUtil.check(output, i));
}
break;
case TAG_INPUT_VOLTAGE1:
- position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort() / 1000.0);
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShortLE() / 1000.0);
break;
case TAG_INPUT_VOLTAGE2:
- position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort() / 1000.0);
+ position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShortLE() / 1000.0);
break;
case TAG_INPUT_VOLTAGE3:
- position.set(Position.PREFIX_ADC + 3, buf.readUnsignedShort() / 1000.0);
+ position.set(Position.PREFIX_ADC + 3, buf.readUnsignedShortLE() / 1000.0);
break;
case TAG_INPUT_VOLTAGE4:
- position.set(Position.PREFIX_ADC + 4, buf.readUnsignedShort() / 1000.0);
+ position.set(Position.PREFIX_ADC + 4, buf.readUnsignedShortLE() / 1000.0);
break;
case TAG_XT1:
@@ -178,7 +178,7 @@ public class BlackKiteProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- sendReply(channel, buf.readUnsignedShort());
+ sendReply(channel, buf.readUnsignedShortLE());
for (Position p : positions) {
p.setDeviceId(deviceSession.getDeviceId());
diff --git a/src/org/traccar/protocol/BoxProtocol.java b/src/org/traccar/protocol/BoxProtocol.java
index 36e7790f0..6e76ee635 100644
--- a/src/org/traccar/protocol/BoxProtocol.java
+++ b/src/org/traccar/protocol/BoxProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class BoxProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/BoxProtocolDecoder.java b/src/org/traccar/protocol/BoxProtocolDecoder.java
index 63238bcef..231fd9b36 100644
--- a/src/org/traccar/protocol/BoxProtocolDecoder.java
+++ b/src/org/traccar/protocol/BoxProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
@@ -62,7 +63,7 @@ public class BoxProtocolDecoder extends BaseProtocolDecoder {
} else if (sentence.startsWith("E,")) {
if (channel != null) {
- channel.write("A," + sentence.substring(2) + "\r");
+ channel.writeAndFlush(new NetworkMessage("A," + sentence.substring(2) + "\r", remoteAddress));
}
} else if (sentence.startsWith("L,")) {
diff --git a/src/org/traccar/protocol/CalAmpProtocol.java b/src/org/traccar/protocol/CalAmpProtocol.java
index a3577f10c..29cb2974f 100644
--- a/src/org/traccar/protocol/CalAmpProtocol.java
+++ b/src/org/traccar/protocol/CalAmpProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class CalAmpProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectDecoder", new CalAmpProtocolDecoder(CalAmpProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/CalAmpProtocolDecoder.java b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
index f717d3c5d..d495e7400 100644
--- a/src/org/traccar/protocol/CalAmpProtocolDecoder.java
+++ b/src/org/traccar/protocol/CalAmpProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -52,7 +54,7 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
private void sendResponse(Channel channel, SocketAddress remoteAddress, int type, int index, int result) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(10);
+ ByteBuf response = Unpooled.buffer(10);
response.writeByte(SERVICE_RESPONSE);
response.writeByte(MSG_ACK);
response.writeShort(index);
@@ -60,11 +62,11 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
response.writeByte(result);
response.writeByte(0);
response.writeMedium(0);
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
- private Position decodePosition(DeviceSession deviceSession, int type, ChannelBuffer buf) {
+ private Position decodePosition(DeviceSession deviceSession, int type, ByteBuf buf) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -143,14 +145,14 @@ public class CalAmpProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (BitUtil.check(buf.getByte(buf.readerIndex()), 7)) {
int content = buf.readUnsignedByte();
if (BitUtil.check(content, 0)) {
- String id = ChannelBuffers.hexDump(buf.readBytes(buf.readUnsignedByte()));
+ String id = ByteBufUtil.hexDump(buf.readSlice(buf.readUnsignedByte()));
getDeviceSession(channel, remoteAddress, id);
}
diff --git a/src/org/traccar/protocol/CarTrackProtocol.java b/src/org/traccar/protocol/CarTrackProtocol.java
index d235c92be..2ac6598a4 100644
--- a/src/org/traccar/protocol/CarTrackProtocol.java
+++ b/src/org/traccar/protocol/CarTrackProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class CarTrackProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "##"));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/CarTrackProtocolDecoder.java b/src/org/traccar/protocol/CarTrackProtocolDecoder.java
index 94215379d..87c4ae345 100644
--- a/src/org/traccar/protocol/CarTrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/CarTrackProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
* Copyright 2014 Rohit
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,7 +16,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/CarcellProtocol.java b/src/org/traccar/protocol/CarcellProtocol.java
index c9fedad65..40ecfbbe7 100644
--- a/src/org/traccar/protocol/CarcellProtocol.java
+++ b/src/org/traccar/protocol/CarcellProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,12 +17,11 @@ package org.traccar.protocol;
import java.util.List;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -37,9 +36,9 @@ public class CarcellProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/CarcellProtocolDecoder.java b/src/org/traccar/protocol/CarcellProtocolDecoder.java
index 52b777b81..a4da7982e 100644
--- a/src/org/traccar/protocol/CarcellProtocolDecoder.java
+++ b/src/org/traccar/protocol/CarcellProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ package org.traccar.protocol;
import java.net.SocketAddress;
import java.util.regex.Pattern;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/CarscopProtocol.java b/src/org/traccar/protocol/CarscopProtocol.java
index 01a754027..c52b025bc 100644
--- a/src/org/traccar/protocol/CarscopProtocol.java
+++ b/src/org/traccar/protocol/CarscopProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class CarscopProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '^'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/CarscopProtocolDecoder.java b/src/org/traccar/protocol/CarscopProtocolDecoder.java
index 7f9dcc3b7..d8634b512 100644
--- a/src/org/traccar/protocol/CarscopProtocolDecoder.java
+++ b/src/org/traccar/protocol/CarscopProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/CastelProtocol.java b/src/org/traccar/protocol/CastelProtocol.java
index d5ba5cd55..fcf461fde 100644
--- a/src/org/traccar/protocol/CastelProtocol.java
+++ b/src/org/traccar/protocol/CastelProtocol.java
@@ -15,11 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -37,26 +35,22 @@ public class CastelProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 0));
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
+ pipeline.addLast("frameDecoder",
+ new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 1024, 2, 2, -4, 0, true));
pipeline.addLast("objectEncoder", new CastelProtocolEncoder());
pipeline.addLast("objectDecoder", new CastelProtocolDecoder(CastelProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
-
- server = new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ });
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectEncoder", new CastelProtocolEncoder());
pipeline.addLast("objectDecoder", new CastelProtocolDecoder(CastelProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/CastelProtocolDecoder.java b/src/org/traccar/protocol/CastelProtocolDecoder.java
index 2ac79f9cf..344ca2df4 100644
--- a/src/org/traccar/protocol/CastelProtocolDecoder.java
+++ b/src/org/traccar/protocol/CastelProtocolDecoder.java
@@ -15,11 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.ObdDecoder;
@@ -29,7 +31,6 @@ import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.LinkedList;
@@ -100,7 +101,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
public static final short MSG_CC_PETROL_CONTROL = 0x4583;
public static final short MSG_CC_HEARTBEAT_RESPONSE = (short) 0x8206;
- private Position readPosition(DeviceSession deviceSession, ChannelBuffer buf) {
+ private Position readPosition(DeviceSession deviceSession, ByteBuf buf) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -110,10 +111,10 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
.setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte());
position.setTime(dateBuilder.getDate());
- double lat = buf.readUnsignedInt() / 3600000.0;
- double lon = buf.readUnsignedInt() / 3600000.0;
- position.setSpeed(UnitsConverter.knotsFromCps(buf.readUnsignedShort()));
- position.setCourse(buf.readUnsignedShort() * 0.1);
+ double lat = buf.readUnsignedIntLE() / 3600000.0;
+ double lon = buf.readUnsignedIntLE() / 3600000.0;
+ position.setSpeed(UnitsConverter.knotsFromCps(buf.readUnsignedShortLE()));
+ position.setCourse(buf.readUnsignedShortLE() * 0.1);
int flags = buf.readUnsignedByte();
if ((flags & 0x02) == 0) {
@@ -140,13 +141,13 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private void decodeObd(Position position, ChannelBuffer buf, boolean groups) {
+ private void decodeObd(Position position, ByteBuf buf, boolean groups) {
int count = buf.readUnsignedByte();
int[] pids = new int[count];
for (int i = 0; i < count; i++) {
- pids[i] = buf.readUnsignedShort() & 0xff;
+ pids[i] = buf.readUnsignedShortLE() & 0xff;
}
if (groups) {
@@ -161,10 +162,10 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
value = buf.readUnsignedByte();
break;
case 2:
- value = buf.readUnsignedShort();
+ value = buf.readUnsignedShortLE();
break;
case 4:
- value = buf.readInt();
+ value = buf.readIntLE();
break;
default:
value = 0;
@@ -174,21 +175,21 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeStat(Position position, ChannelBuffer buf) {
+ private void decodeStat(Position position, ByteBuf buf) {
- buf.readUnsignedInt(); // ACC ON time
- buf.readUnsignedInt(); // UTC time
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
- position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt());
- position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedInt());
- buf.readUnsignedShort(); // current fuel consumption
- position.set(Position.KEY_STATUS, buf.readUnsignedInt());
+ buf.readUnsignedIntLE(); // ACC ON time
+ buf.readUnsignedIntLE(); // UTC time
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
+ position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedIntLE());
+ position.set(Position.KEY_FUEL_CONSUMPTION, buf.readUnsignedIntLE());
+ buf.readUnsignedShortLE(); // current fuel consumption
+ position.set(Position.KEY_STATUS, buf.readUnsignedIntLE());
buf.skipBytes(8);
}
private void sendResponse(
Channel channel, SocketAddress remoteAddress,
- int version, ChannelBuffer id, short type, ChannelBuffer content) {
+ int version, ByteBuf id, short type, ByteBuf content) {
if (channel != null) {
int length = 2 + 2 + 1 + id.readableBytes() + 2 + 2 + 2;
@@ -196,41 +197,42 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
length += content.readableBytes();
}
- ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, length);
+ ByteBuf response = Unpooled.buffer(length);
response.writeByte('@'); response.writeByte('@');
- response.writeShort(length);
+ response.writeShortLE(length);
response.writeByte(version);
response.writeBytes(id);
- response.writeShort(ChannelBuffers.swapShort(type));
+ response.writeShort(type);
if (content != null) {
response.writeBytes(content);
+ content.release();
}
- response.writeShort(
- Checksum.crc16(Checksum.CRC16_X25, response.toByteBuffer(0, response.writerIndex())));
+ response.writeShortLE(
+ Checksum.crc16(Checksum.CRC16_X25, response.nioBuffer(0, response.writerIndex())));
response.writeByte(0x0D); response.writeByte(0x0A);
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
private void sendResponse(
- Channel channel, SocketAddress remoteAddress, ChannelBuffer id, short type) {
+ Channel channel, SocketAddress remoteAddress, ByteBuf id, short type) {
if (channel != null) {
int length = 2 + 2 + id.readableBytes() + 2 + 4 + 8 + 2 + 2;
- ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, length);
+ ByteBuf response = Unpooled.buffer(length);
response.writeByte('@'); response.writeByte('@');
- response.writeShort(length);
+ response.writeShortLE(length);
response.writeBytes(id);
- response.writeShort(ChannelBuffers.swapShort(type));
- response.writeInt(0);
+ response.writeShort(type);
+ response.writeIntLE(0);
for (int i = 0; i < 8; i++) {
response.writeByte(0xff);
}
- response.writeShort(
- Checksum.crc16(Checksum.CRC16_X25, response.toByteBuffer(0, response.writerIndex())));
+ response.writeShortLE(
+ Checksum.crc16(Checksum.CRC16_X25, response.nioBuffer(0, response.writerIndex())));
response.writeByte(0x0D); response.writeByte(0x0A);
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
@@ -284,8 +286,8 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
}
private Object decodeSc(
- Channel channel, SocketAddress remoteAddress, ChannelBuffer buf,
- int version, ChannelBuffer id, short type, DeviceSession deviceSession) {
+ Channel channel, SocketAddress remoteAddress, ByteBuf buf,
+ int version, ByteBuf id, short type, DeviceSession deviceSession) {
if (type == MSG_SC_HEARTBEAT) {
@@ -295,28 +297,28 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
|| type == MSG_SC_ALARM || type == MSG_SC_CURRENT_LOCATION || type == MSG_SC_FUEL) {
if (type == MSG_SC_LOGIN) {
- ChannelBuffer response = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 10);
- response.writeInt(0xFFFFFFFF);
- response.writeShort(0);
- response.writeInt((int) (System.currentTimeMillis() / 1000));
+ ByteBuf response = Unpooled.buffer(10);
+ response.writeIntLE(0xFFFFFFFF);
+ response.writeShortLE(0);
+ response.writeIntLE((int) (System.currentTimeMillis() / 1000));
sendResponse(channel, remoteAddress, version, id, MSG_SC_LOGIN_RESPONSE, response);
}
if (type == MSG_SC_GPS) {
buf.readUnsignedByte(); // historical
} else if (type == MSG_SC_ALARM) {
- buf.readUnsignedInt(); // alarm
+ buf.readUnsignedIntLE(); // alarm
} else if (type == MSG_SC_CURRENT_LOCATION) {
- buf.readUnsignedShort();
+ buf.readUnsignedShortLE();
}
- buf.readUnsignedInt(); // ACC ON time
- buf.readUnsignedInt(); // UTC time
- long odometer = buf.readUnsignedInt();
- long tripOdometer = buf.readUnsignedInt();
- long fuelConsumption = buf.readUnsignedInt();
- buf.readUnsignedShort(); // current fuel consumption
- long status = buf.readUnsignedInt();
+ buf.readUnsignedIntLE(); // ACC ON time
+ buf.readUnsignedIntLE(); // UTC time
+ long odometer = buf.readUnsignedIntLE();
+ long tripOdometer = buf.readUnsignedIntLE();
+ long fuelConsumption = buf.readUnsignedIntLE();
+ buf.readUnsignedShortLE(); // current fuel consumption
+ long status = buf.readUnsignedIntLE();
buf.skipBytes(8);
int count = buf.readUnsignedByte();
@@ -340,13 +342,13 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
for (Position position : positions) {
decodeAlarm(position, alarm);
}
- buf.readUnsignedShort(); // description
- buf.readUnsignedShort(); // threshold
+ buf.readUnsignedShortLE(); // description
+ buf.readUnsignedShortLE(); // threshold
}
}
} else if (type == MSG_SC_FUEL) {
for (Position position : positions) {
- position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShortLE());
}
}
@@ -356,7 +358,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_SC_GPS_SLEEP) {
- buf.readUnsignedInt(); // device time
+ buf.readUnsignedIntLE(); // device time
return readPosition(deviceSession, buf);
@@ -370,7 +372,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
decodeStat(position, buf);
- buf.readUnsignedShort(); // sample rate
+ buf.readUnsignedShortLE(); // sample rate
decodeObd(position, buf, true);
return position;
@@ -382,7 +384,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
decodeStat(position, buf);
buf.readUnsignedByte(); // flag
- position.add(ObdDecoder.decodeCodes(ChannelBuffers.hexDump(buf.readBytes(buf.readUnsignedByte()))));
+ position.add(ObdDecoder.decodeCodes(ByteBufUtil.hexDump(buf.readSlice(buf.readUnsignedByte()))));
return position;
@@ -404,7 +406,7 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
decodeStat(position, buf);
position.setNetwork(new Network(
- CellTower.fromLacCid(buf.readUnsignedShort(), buf.readUnsignedShort())));
+ CellTower.fromLacCid(buf.readUnsignedShortLE(), buf.readUnsignedShortLE())));
return position;
@@ -412,20 +414,20 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
Position position = createPosition(deviceSession);
- buf.readUnsignedShort(); // index
+ buf.readUnsignedShortLE(); // index
buf.readUnsignedByte(); // response count
buf.readUnsignedByte(); // response index
int failureCount = buf.readUnsignedByte();
for (int i = 0; i < failureCount; i++) {
- buf.readUnsignedShort(); // tag
+ buf.readUnsignedShortLE(); // tag
}
int successCount = buf.readUnsignedByte();
for (int i = 0; i < successCount; i++) {
- buf.readUnsignedShort(); // tag
+ buf.readUnsignedShortLE(); // tag
position.set(Position.KEY_RESULT,
- buf.readBytes(buf.readUnsignedShort()).toString(StandardCharsets.US_ASCII));
+ buf.readSlice(buf.readUnsignedShortLE()).toString(StandardCharsets.US_ASCII));
}
return position;
@@ -436,8 +438,8 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
}
private Object decodeCc(
- Channel channel, SocketAddress remoteAddress, ChannelBuffer buf,
- int version, ChannelBuffer id, short type, DeviceSession deviceSession) {
+ Channel channel, SocketAddress remoteAddress, ByteBuf buf,
+ int version, ByteBuf id, short type, DeviceSession deviceSession) {
if (type == MSG_CC_HEARTBEAT) {
@@ -451,16 +453,16 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
for (int i = 0; i < count; i++) {
Position position = readPosition(deviceSession, buf);
- position.set(Position.KEY_STATUS, buf.readUnsignedInt());
+ position.set(Position.KEY_STATUS, buf.readUnsignedIntLE());
position.set(Position.KEY_BATTERY, buf.readUnsignedByte());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
buf.readUnsignedByte(); // geo-fencing id
buf.readUnsignedByte(); // geo-fencing flags
buf.readUnsignedByte(); // additional flags
position.setNetwork(new Network(
- CellTower.fromLacCid(buf.readUnsignedShort(), buf.readUnsignedShort())));
+ CellTower.fromLacCid(buf.readUnsignedShortLE(), buf.readUnsignedShortLE())));
positions.add(position);
}
@@ -473,9 +475,9 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
Position position = readPosition(deviceSession, buf);
- position.set(Position.KEY_STATUS, buf.readUnsignedInt());
+ position.set(Position.KEY_STATUS, buf.readUnsignedIntLE());
position.set(Position.KEY_BATTERY, buf.readUnsignedByte());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
buf.readUnsignedByte(); // geo-fencing id
buf.readUnsignedByte(); // geo-fencing flags
@@ -493,8 +495,8 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
}
private Object decodeMpip(
- Channel channel, SocketAddress remoteAddress, ChannelBuffer buf,
- int version, ChannelBuffer id, short type, DeviceSession deviceSession) {
+ Channel channel, SocketAddress remoteAddress, ByteBuf buf,
+ int version, ByteBuf id, short type, DeviceSession deviceSession) {
if (type == 0x4001) {
@@ -506,8 +508,8 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
sendResponse(channel, remoteAddress, id, (short) 0x1001);
- buf.readUnsignedInt(); // index
- buf.readUnsignedInt(); // unix time
+ buf.readUnsignedIntLE(); // index
+ buf.readUnsignedIntLE(); // unix time
buf.readUnsignedByte();
return readPosition(deviceSession, buf);
@@ -537,18 +539,18 @@ public class CastelProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
- int header = buf.readUnsignedShort();
- buf.readUnsignedShort(); // length
+ int header = buf.readUnsignedShortLE();
+ buf.readUnsignedShortLE(); // length
int version = -1;
if (header == 0x4040) {
version = buf.readUnsignedByte();
}
- ChannelBuffer id = buf.readBytes(20);
- short type = ChannelBuffers.swapShort(buf.readShort());
+ ByteBuf id = buf.readSlice(20);
+ short type = buf.readShort();
DeviceSession deviceSession = getDeviceSession(
channel, remoteAddress, id.toString(StandardCharsets.US_ASCII).trim());
diff --git a/src/org/traccar/protocol/CastelProtocolEncoder.java b/src/org/traccar/protocol/CastelProtocolEncoder.java
index 806dac19e..dde8ac11f 100644
--- a/src/org/traccar/protocol/CastelProtocolEncoder.java
+++ b/src/org/traccar/protocol/CastelProtocolEncoder.java
@@ -15,37 +15,36 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.Context;
import org.traccar.helper.Checksum;
import org.traccar.helper.Log;
import org.traccar.model.Command;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
public class CastelProtocolEncoder extends BaseProtocolEncoder {
- private ChannelBuffer encodeContent(long deviceId, short type, ChannelBuffer content) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ private ByteBuf encodeContent(long deviceId, short type, ByteBuf content) {
+ ByteBuf buf = Unpooled.buffer(0);
String uniqueId = Context.getIdentityManager().getById(deviceId).getUniqueId();
buf.writeByte('@');
buf.writeByte('@');
- buf.writeShort(2 + 2 + 1 + 20 + 2 + content.readableBytes() + 2 + 2); // length
+ buf.writeShortLE(2 + 2 + 1 + 20 + 2 + content.readableBytes() + 2 + 2); // length
buf.writeByte(1); // protocol version
buf.writeBytes(uniqueId.getBytes(StandardCharsets.US_ASCII));
buf.writeZero(20 - uniqueId.length());
- buf.writeShort(ChannelBuffers.swapShort(type));
+ buf.writeShort(type);
buf.writeBytes(content);
- buf.writeShort(Checksum.crc16(Checksum.CRC16_X25, buf.toByteBuffer()));
+ buf.writeShortLE(Checksum.crc16(Checksum.CRC16_X25, buf.nioBuffer()));
buf.writeByte('\r');
buf.writeByte('\n');
@@ -55,7 +54,7 @@ public class CastelProtocolEncoder extends BaseProtocolEncoder {
@Override
protected Object encodeCommand(Command command) {
- ChannelBuffer content = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf content = Unpooled.buffer(0);
switch (command.getType()) {
case Command.TYPE_ENGINE_STOP:
content.writeByte(1);
diff --git a/src/org/traccar/protocol/CautelaProtocol.java b/src/org/traccar/protocol/CautelaProtocol.java
index 89ab7a1d0..dc5c82193 100644
--- a/src/org/traccar/protocol/CautelaProtocol.java
+++ b/src/org/traccar/protocol/CautelaProtocol.java
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class CautelaProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/CautelaProtocolDecoder.java b/src/org/traccar/protocol/CautelaProtocolDecoder.java
index 7c48ff690..ce231591e 100644
--- a/src/org/traccar/protocol/CautelaProtocolDecoder.java
+++ b/src/org/traccar/protocol/CautelaProtocolDecoder.java
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/CellocatorFrameDecoder.java b/src/org/traccar/protocol/CellocatorFrameDecoder.java
index b4708f5db..986dc75ec 100644
--- a/src/org/traccar/protocol/CellocatorFrameDecoder.java
+++ b/src/org/traccar/protocol/CellocatorFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,29 +15,24 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
import org.traccar.helper.Log;
-public class CellocatorFrameDecoder extends FrameDecoder {
+public class CellocatorFrameDecoder extends BaseFrameDecoder {
private static final int MESSAGE_MINIMUM_LENGTH = 15;
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
- // Check minimum length
- int available = buf.readableBytes();
- if (available < MESSAGE_MINIMUM_LENGTH) {
+ if (buf.readableBytes() < MESSAGE_MINIMUM_LENGTH) {
return null;
}
- // Size depending on message type
int length = 0;
int type = buf.getUnsignedByte(4);
switch (type) {
@@ -51,8 +46,8 @@ public class CellocatorFrameDecoder extends FrameDecoder {
length = 70;
break;
case CellocatorProtocolDecoder.MSG_CLIENT_SERIAL:
- if (available >= 19) {
- length = 19 + buf.getUnsignedShort(16);
+ if (buf.readableBytes() >= 19) {
+ length = 19 + buf.getUnsignedShortLE(16);
}
break;
case CellocatorProtocolDecoder.MSG_CLIENT_MODULAR:
@@ -63,9 +58,8 @@ public class CellocatorFrameDecoder extends FrameDecoder {
break;
}
- // Read packet
- if (length > 0 && available >= length) {
- return buf.readBytes(length);
+ if (length > 0 && buf.readableBytes() >= length) {
+ return buf.readRetainedSlice(length);
}
return null;
diff --git a/src/org/traccar/protocol/CellocatorProtocol.java b/src/org/traccar/protocol/CellocatorProtocol.java
index 4a20bc977..bf186e67f 100644
--- a/src/org/traccar/protocol/CellocatorProtocol.java
+++ b/src/org/traccar/protocol/CellocatorProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
-import java.nio.ByteOrder;
import java.util.List;
public class CellocatorProtocol extends BaseProtocol {
@@ -35,26 +32,21 @@ public class CellocatorProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CellocatorFrameDecoder());
pipeline.addLast("objectEncoder", new CellocatorProtocolEncoder());
pipeline.addLast("objectDecoder", new CellocatorProtocolDecoder(CellocatorProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
-
- server = new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ });
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectEncoder", new CellocatorProtocolEncoder());
pipeline.addLast("objectDecoder", new CellocatorProtocolDecoder(CellocatorProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/CellocatorProtocolDecoder.java b/src/org/traccar/protocol/CellocatorProtocolDecoder.java
index 67db9aa7d..30319eaee 100644
--- a/src/org/traccar/protocol/CellocatorProtocolDecoder.java
+++ b/src/org/traccar/protocol/CellocatorProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,17 +15,17 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
@@ -44,27 +44,27 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
private byte commandCount;
private void sendReply(Channel channel, SocketAddress remoteAddress, long deviceId, byte packetNumber) {
- ChannelBuffer reply = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 28);
- reply.writeByte('M');
- reply.writeByte('C');
- reply.writeByte('G');
- reply.writeByte('P');
- reply.writeByte(MSG_SERVER_ACKNOWLEDGE);
- reply.writeInt((int) deviceId);
- reply.writeByte(commandCount++);
- reply.writeInt(0); // authentication code
- reply.writeByte(0);
- reply.writeByte(packetNumber);
- reply.writeZero(11);
-
- byte checksum = 0;
- for (int i = 4; i < 27; i++) {
- checksum += reply.getByte(i);
- }
- reply.writeByte(checksum);
-
if (channel != null) {
- channel.write(reply, remoteAddress);
+ ByteBuf reply = Unpooled.buffer(28);
+ reply.writeByte('M');
+ reply.writeByte('C');
+ reply.writeByte('G');
+ reply.writeByte('P');
+ reply.writeByte(MSG_SERVER_ACKNOWLEDGE);
+ reply.writeIntLE((int) deviceId);
+ reply.writeByte(commandCount++);
+ reply.writeIntLE(0); // authentication code
+ reply.writeByte(0);
+ reply.writeByte(packetNumber);
+ reply.writeZero(11);
+
+ byte checksum = 0;
+ for (int i = 4; i < 27; i++) {
+ checksum += reply.getByte(i);
+ }
+ reply.writeByte(checksum);
+
+ channel.writeAndFlush(new NetworkMessage(reply, remoteAddress));
}
}
@@ -85,14 +85,14 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(4); // system code
int type = buf.readUnsignedByte();
- long deviceUniqueId = buf.readUnsignedInt();
+ long deviceUniqueId = buf.readUnsignedIntLE();
if (type != MSG_CLIENT_SERIAL) {
- buf.readUnsignedShort(); // communication control
+ buf.readUnsignedShortLE(); // communication control
}
byte packetNumber = buf.readByte();
@@ -121,17 +121,17 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ALARM, decodeAlarm(buf.readUnsignedByte()));
position.set("mode", buf.readUnsignedByte());
- position.set(Position.PREFIX_IO + 1, buf.readUnsignedInt());
+ position.set(Position.PREFIX_IO + 1, buf.readUnsignedIntLE());
operator <<= 8;
operator += buf.readUnsignedByte();
position.set(Position.KEY_OPERATOR, operator);
- position.set(Position.PREFIX_ADC + 1, buf.readUnsignedInt());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium());
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedIntLE());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedMediumLE());
buf.skipBytes(6); // multi-purpose data
- position.set(Position.KEY_GPS, buf.readUnsignedShort());
+ position.set(Position.KEY_GPS, buf.readUnsignedShortLE());
position.set("locationStatus", buf.readUnsignedByte());
position.set("mode1", buf.readUnsignedByte());
position.set("mode2", buf.readUnsignedByte());
@@ -139,15 +139,15 @@ public class CellocatorProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
position.setValid(true);
- position.setLongitude(buf.readInt() / Math.PI * 180 / 100000000);
- position.setLatitude(buf.readInt() / Math.PI * 180 / 100000000.0);
- position.setAltitude(buf.readInt() * 0.01);
- position.setSpeed(UnitsConverter.knotsFromMps(buf.readInt() * 0.01));
- position.setCourse(buf.readUnsignedShort() / Math.PI * 180.0 / 1000.0);
+ position.setLongitude(buf.readIntLE() / Math.PI * 180 / 100000000);
+ position.setLatitude(buf.readIntLE() / Math.PI * 180 / 100000000.0);
+ position.setAltitude(buf.readIntLE() * 0.01);
+ position.setSpeed(UnitsConverter.knotsFromMps(buf.readIntLE() * 0.01));
+ position.setCourse(buf.readUnsignedShortLE() / Math.PI * 180.0 / 1000.0);
DateBuilder dateBuilder = new DateBuilder()
.setTimeReverse(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
- .setDateReverse(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedShort());
+ .setDateReverse(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedShortLE());
position.setTime(dateBuilder.getDate());
return position;
diff --git a/src/org/traccar/protocol/CellocatorProtocolEncoder.java b/src/org/traccar/protocol/CellocatorProtocolEncoder.java
index bb143d349..4eef42128 100644
--- a/src/org/traccar/protocol/CellocatorProtocolEncoder.java
+++ b/src/org/traccar/protocol/CellocatorProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,34 +15,32 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Log;
import org.traccar.model.Command;
-import java.nio.ByteOrder;
-
public class CellocatorProtocolEncoder extends BaseProtocolEncoder {
- private ChannelBuffer encodeContent(long deviceId, int command, int data1, int data2) {
+ private ByteBuf encodeContent(long deviceId, int command, int data1, int data2) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf buf = Unpooled.buffer(0);
buf.writeByte('M');
buf.writeByte('C');
buf.writeByte('G');
buf.writeByte('P');
buf.writeByte(0);
- buf.writeInt(Integer.parseInt(getUniqueId(deviceId)));
+ buf.writeIntLE(Integer.parseInt(getUniqueId(deviceId)));
buf.writeByte(0); // command numerator
- buf.writeInt(0); // authentication code
+ buf.writeIntLE(0); // authentication code
buf.writeByte(command);
buf.writeByte(command);
buf.writeByte(data1);
buf.writeByte(data1);
buf.writeByte(data2);
buf.writeByte(data2);
- buf.writeInt(0); // command specific data
+ buf.writeIntLE(0); // command specific data
byte checksum = 0;
for (int i = 4; i < buf.writerIndex(); i++) {
diff --git a/src/org/traccar/protocol/CguardProtocol.java b/src/org/traccar/protocol/CguardProtocol.java
index 460bd331f..5d2ffb6fd 100644
--- a/src/org/traccar/protocol/CguardProtocol.java
+++ b/src/org/traccar/protocol/CguardProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class CguardProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/CguardProtocolDecoder.java b/src/org/traccar/protocol/CguardProtocolDecoder.java
index 2e20537c8..806f500ab 100644
--- a/src/org/traccar/protocol/CguardProtocolDecoder.java
+++ b/src/org/traccar/protocol/CguardProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/CityeasyProtocol.java b/src/org/traccar/protocol/CityeasyProtocol.java
index 7e5ca0ba0..82b33e0f4 100644
--- a/src/org/traccar/protocol/CityeasyProtocol.java
+++ b/src/org/traccar/protocol/CityeasyProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -37,9 +36,9 @@ public class CityeasyProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 0));
pipeline.addLast("objectEncoder", new CityeasyProtocolEncoder());
pipeline.addLast("objectDecoder", new CityeasyProtocolDecoder(CityeasyProtocol.this));
diff --git a/src/org/traccar/protocol/CityeasyProtocolDecoder.java b/src/org/traccar/protocol/CityeasyProtocolDecoder.java
index 7a1d8119d..a66b9adb3 100644
--- a/src/org/traccar/protocol/CityeasyProtocolDecoder.java
+++ b/src/org/traccar/protocol/CityeasyProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Checksum;
@@ -69,12 +69,12 @@ public class CityeasyProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
buf.readUnsignedShort(); // length
- String imei = ChannelBuffers.hexDump(buf.readBytes(7));
+ String imei = ByteBufUtil.hexDump(buf.readSlice(7));
DeviceSession deviceSession = getDeviceSession(
channel, remoteAddress, imei, imei + Checksum.luhn(Long.parseLong(imei)));
if (deviceSession == null) {
diff --git a/src/org/traccar/protocol/CityeasyProtocolEncoder.java b/src/org/traccar/protocol/CityeasyProtocolEncoder.java
index 387926e03..e143563f0 100644
--- a/src/org/traccar/protocol/CityeasyProtocolEncoder.java
+++ b/src/org/traccar/protocol/CityeasyProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,8 +17,8 @@ package org.traccar.protocol;
import java.util.TimeZone;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Checksum;
import org.traccar.helper.Log;
@@ -26,9 +26,9 @@ import org.traccar.model.Command;
public class CityeasyProtocolEncoder extends BaseProtocolEncoder {
- private ChannelBuffer encodeContent(int type, ChannelBuffer content) {
+ private ByteBuf encodeContent(int type, ByteBuf content) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ ByteBuf buf = Unpooled.buffer();
buf.writeByte('S');
buf.writeByte('S');
@@ -36,7 +36,7 @@ public class CityeasyProtocolEncoder extends BaseProtocolEncoder {
buf.writeShort(type);
buf.writeBytes(content);
buf.writeInt(0x0B);
- buf.writeShort(Checksum.crc16(Checksum.CRC16_KERMIT, buf.toByteBuffer()));
+ buf.writeShort(Checksum.crc16(Checksum.CRC16_KERMIT, buf.nioBuffer()));
buf.writeByte('\r');
buf.writeByte('\n');
@@ -46,7 +46,7 @@ public class CityeasyProtocolEncoder extends BaseProtocolEncoder {
@Override
protected Object encodeCommand(Command command) {
- ChannelBuffer content = ChannelBuffers.dynamicBuffer();
+ ByteBuf content = Unpooled.buffer();
switch (command.getType()) {
case Command.TYPE_POSITION_SINGLE:
diff --git a/src/org/traccar/protocol/ContinentalProtocol.java b/src/org/traccar/protocol/ContinentalProtocol.java
index 5f43a51f7..540128120 100644
--- a/src/org/traccar/protocol/ContinentalProtocol.java
+++ b/src/org/traccar/protocol/ContinentalProtocol.java
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -31,9 +30,9 @@ public class ContinentalProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, -4, 0));
pipeline.addLast("objectDecoder", new ContinentalProtocolDecoder(ContinentalProtocol.this));
}
diff --git a/src/org/traccar/protocol/ContinentalProtocolDecoder.java b/src/org/traccar/protocol/ContinentalProtocolDecoder.java
index 5ea1d3246..20134fc1f 100644
--- a/src/org/traccar/protocol/ContinentalProtocolDecoder.java
+++ b/src/org/traccar/protocol/ContinentalProtocolDecoder.java
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
@@ -41,7 +41,7 @@ public class ContinentalProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
buf.readUnsignedShort(); // length
diff --git a/src/org/traccar/protocol/CradlepointProtocol.java b/src/org/traccar/protocol/CradlepointProtocol.java
index 6ed54aa17..51de43bd9 100644
--- a/src/org/traccar/protocol/CradlepointProtocol.java
+++ b/src/org/traccar/protocol/CradlepointProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class CradlepointProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/CradlepointProtocolDecoder.java b/src/org/traccar/protocol/CradlepointProtocolDecoder.java
index 48bd67021..222f73ec3 100644
--- a/src/org/traccar/protocol/CradlepointProtocolDecoder.java
+++ b/src/org/traccar/protocol/CradlepointProtocolDecoder.java
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/DishaProtocol.java b/src/org/traccar/protocol/DishaProtocol.java
index 53ba36004..1e746f270 100644
--- a/src/org/traccar/protocol/DishaProtocol.java
+++ b/src/org/traccar/protocol/DishaProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class DishaProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/DishaProtocolDecoder.java b/src/org/traccar/protocol/DishaProtocolDecoder.java
index a4e567b34..994bf6828 100644
--- a/src/org/traccar/protocol/DishaProtocolDecoder.java
+++ b/src/org/traccar/protocol/DishaProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/DmtHttpProtocol.java b/src/org/traccar/protocol/DmtHttpProtocol.java
index 2378441ba..ee369dca0 100644
--- a/src/org/traccar/protocol/DmtHttpProtocol.java
+++ b/src/org/traccar/protocol/DmtHttpProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
-import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
-import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpRequestDecoder;
+import io.netty.handler.codec.http.HttpResponseEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,12 +32,12 @@ public class DmtHttpProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
- pipeline.addLast("httpAggregator", new HttpChunkAggregator(65535));
+ pipeline.addLast("httpAggregator", new HttpObjectAggregator(65535));
pipeline.addLast("objectDecoder", new DmtHttpProtocolDecoder(DmtHttpProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/DmtHttpProtocolDecoder.java b/src/org/traccar/protocol/DmtHttpProtocolDecoder.java
index 200a20759..bfe7d26a7 100644
--- a/src/org/traccar/protocol/DmtHttpProtocolDecoder.java
+++ b/src/org/traccar/protocol/DmtHttpProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.handler.codec.http.HttpRequest;
-import org.jboss.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.channel.Channel;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.HttpResponseStatus;
import org.traccar.BaseHttpProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
@@ -46,9 +46,9 @@ public class DmtHttpProtocolDecoder extends BaseHttpProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- HttpRequest request = (HttpRequest) msg;
+ FullHttpRequest request = (FullHttpRequest) msg;
JsonObject root = Json.createReader(
- new StringReader(request.getContent().toString(StandardCharsets.US_ASCII))).readObject();
+ new StringReader(request.content().toString(StandardCharsets.US_ASCII))).readObject();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
diff --git a/src/org/traccar/protocol/DmtProtocol.java b/src/org/traccar/protocol/DmtProtocol.java
index 18bb1524a..3df261443 100644
--- a/src/org/traccar/protocol/DmtProtocol.java
+++ b/src/org/traccar/protocol/DmtProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.nio.ByteOrder;
@@ -32,15 +31,14 @@ public class DmtProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2));
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
+ pipeline.addLast("frameDecoder",
+ new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 1024, 3, 2, 0, 0, true));
pipeline.addLast("objectDecoder", new DmtProtocolDecoder(DmtProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/DmtProtocolDecoder.java b/src/org/traccar/protocol/DmtProtocolDecoder.java
index 30a6ae13a..613b8cddd 100644
--- a/src/org/traccar/protocol/DmtProtocolDecoder.java
+++ b/src/org/traccar/protocol/DmtProtocolDecoder.java
@@ -15,18 +15,18 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.LinkedList;
@@ -50,20 +50,21 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_CANNED_REQUEST_2 = 0x22;
public static final int MSG_CANNED_RESPONSE_2 = 0x23;
- private void sendResponse(Channel channel, int type, ChannelBuffer content) {
+ private void sendResponse(Channel channel, int type, ByteBuf content) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf response = Unpooled.buffer();
response.writeByte(0x02); response.writeByte(0x55); // header
response.writeByte(type);
- response.writeShort(content != null ? content.readableBytes() : 0);
+ response.writeShortLE(content != null ? content.readableBytes() : 0);
if (content != null) {
response.writeBytes(content);
+ content.release();
}
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
- private List<Position> decodeFixed64(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private List<Position> decodeFixed64(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
if (deviceSession == null) {
@@ -78,9 +79,9 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
buf.readByte(); // type
- position.set(Position.KEY_INDEX, buf.readUnsignedInt());
+ position.set(Position.KEY_INDEX, buf.readUnsignedIntLE());
- long time = buf.readUnsignedInt();
+ long time = buf.readUnsignedIntLE();
position.setTime(new DateBuilder()
.setYear((int) (2000 + (time & 0x3F)))
.setMonth((int) (time >> 6) & 0xF)
@@ -90,39 +91,39 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
.setSecond((int) (time >> 26) & 0x3F)
.getDate());
- position.setLongitude(buf.readInt() * 0.0000001);
- position.setLatitude(buf.readInt() * 0.0000001);
- position.setSpeed(UnitsConverter.knotsFromCps(buf.readUnsignedShort()));
+ position.setLongitude(buf.readIntLE() * 0.0000001);
+ position.setLatitude(buf.readIntLE() * 0.0000001);
+ position.setSpeed(UnitsConverter.knotsFromCps(buf.readUnsignedShortLE()));
position.setCourse(buf.readUnsignedByte() * 2);
- position.setAltitude(buf.readShort());
+ position.setAltitude(buf.readShortLE());
- buf.readUnsignedShort(); // position accuracy
+ buf.readUnsignedShortLE(); // position accuracy
buf.readUnsignedByte(); // speed accuracy
position.set(Position.KEY_EVENT, buf.readUnsignedByte());
position.setValid(BitUtil.check(buf.readByte(), 0));
- position.set(Position.KEY_INPUT, buf.readUnsignedInt());
- position.set(Position.KEY_OUTPUT, buf.readUnsignedShort());
+ position.set(Position.KEY_INPUT, buf.readUnsignedIntLE());
+ position.set(Position.KEY_OUTPUT, buf.readUnsignedShortLE());
for (int i = 1; i <= 5; i++) {
- position.set(Position.PREFIX_ADC + i, buf.readShort());
+ position.set(Position.PREFIX_ADC + i, buf.readShortLE());
}
position.set(Position.KEY_DEVICE_TEMP, buf.readByte());
- buf.readShort(); // accelerometer x
- buf.readShort(); // accelerometer y
- buf.readShort(); // accelerometer z
+ buf.readShortLE(); // accelerometer x
+ buf.readShortLE(); // accelerometer y
+ buf.readShortLE(); // accelerometer z
buf.skipBytes(8); // device id
- position.set(Position.KEY_PDOP, buf.readUnsignedShort() * 0.01);
+ position.set(Position.KEY_PDOP, buf.readUnsignedShortLE() * 0.01);
buf.skipBytes(2); // reserved
- buf.readUnsignedShort(); // checksum
+ buf.readUnsignedShortLE(); // checksum
positions.add(position);
}
@@ -130,7 +131,7 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
return positions;
}
- private List<Position> decodeStandard(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private List<Position> decodeStandard(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
if (deviceSession == null) {
@@ -139,15 +140,15 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
List<Position> positions = new LinkedList<>();
- while (buf.readable()) {
- int recordEnd = buf.readerIndex() + buf.readUnsignedShort();
+ while (buf.isReadable()) {
+ int recordEnd = buf.readerIndex() + buf.readUnsignedShortLE();
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.set(Position.KEY_INDEX, buf.readUnsignedInt());
+ position.set(Position.KEY_INDEX, buf.readUnsignedIntLE());
- position.setDeviceTime(new Date(1356998400000L + buf.readUnsignedInt() * 1000)); // since 1 Jan 2013
+ position.setDeviceTime(new Date(1356998400000L + buf.readUnsignedIntLE() * 1000)); // since 1 Jan 2013
position.set(Position.KEY_EVENT, buf.readUnsignedByte());
@@ -155,15 +156,15 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
int fieldId = buf.readUnsignedByte();
int fieldLength = buf.readUnsignedByte();
- int fieldEnd = buf.readerIndex() + (fieldLength == 255 ? buf.readUnsignedShort() : fieldLength);
+ int fieldEnd = buf.readerIndex() + (fieldLength == 255 ? buf.readUnsignedShortLE() : fieldLength);
if (fieldId == 0) {
- position.setFixTime(new Date(1356998400000L + buf.readUnsignedInt() * 1000));
- position.setLatitude(buf.readInt() * 0.0000001);
- position.setLongitude(buf.readInt() * 0.0000001);
- position.setAltitude(buf.readShort());
- position.setSpeed(UnitsConverter.knotsFromCps(buf.readUnsignedShort()));
+ position.setFixTime(new Date(1356998400000L + buf.readUnsignedIntLE() * 1000));
+ position.setLatitude(buf.readIntLE() * 0.0000001);
+ position.setLongitude(buf.readIntLE() * 0.0000001);
+ position.setAltitude(buf.readShortLE());
+ position.setSpeed(UnitsConverter.knotsFromCps(buf.readUnsignedShortLE()));
buf.readUnsignedByte(); // speed accuracy
@@ -176,9 +177,9 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
} else if (fieldId == 2) {
- int input = buf.readInt();
- int output = buf.readUnsignedShort();
- int status = buf.readUnsignedShort();
+ int input = buf.readIntLE();
+ int output = buf.readUnsignedShortLE();
+ int status = buf.readUnsignedShortLE();
position.set(Position.KEY_IGNITION, BitUtil.check(input, 0));
@@ -191,19 +192,19 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
while (buf.readerIndex() < fieldEnd) {
switch (buf.readUnsignedByte()) {
case 1:
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001);
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.001);
break;
case 2:
- position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01);
+ position.set(Position.KEY_POWER, buf.readUnsignedShortLE() * 0.01);
break;
case 3:
- position.set(Position.KEY_DEVICE_TEMP, buf.readShort() * 0.01);
+ position.set(Position.KEY_DEVICE_TEMP, buf.readShortLE() * 0.01);
break;
case 4:
- position.set(Position.KEY_RSSI, buf.readUnsignedShort());
+ position.set(Position.KEY_RSSI, buf.readUnsignedShortLE());
break;
case 5:
- position.set("solarPower", buf.readUnsignedShort() * 0.001);
+ position.set("solarPower", buf.readUnsignedShortLE() * 0.001);
break;
default:
break;
@@ -230,40 +231,40 @@ public class DmtProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
int type = buf.readUnsignedByte();
- int length = buf.readUnsignedShort();
+ int length = buf.readUnsignedShortLE();
if (type == MSG_HELLO) {
- buf.readUnsignedInt(); // device serial number
+ buf.readUnsignedIntLE(); // device serial number
DeviceSession deviceSession = getDeviceSession(
- channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII));
+ channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.US_ASCII));
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf response = Unpooled.buffer();
if (length == 51) {
response.writeByte(0); // reserved
- response.writeInt(0); // reserved
+ response.writeIntLE(0); // reserved
} else {
- response.writeInt((int) ((System.currentTimeMillis() - 1356998400000L) / 1000));
- response.writeInt(deviceSession != null ? 0 : 1); // flags
+ response.writeIntLE((int) ((System.currentTimeMillis() - 1356998400000L) / 1000));
+ response.writeIntLE(deviceSession != null ? 0 : 1); // flags
}
sendResponse(channel, MSG_HELLO_RESPONSE, response);
} else if (type == MSG_COMMIT) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf response = Unpooled.buffer(0);
response.writeByte(1); // flags (success)
sendResponse(channel, MSG_COMMIT_RESPONSE, response);
} else if (type == MSG_CANNED_REQUEST_1) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf response = Unpooled.buffer(0);
response.writeBytes(new byte[12]);
sendResponse(channel, MSG_CANNED_RESPONSE_1, response);
diff --git a/src/org/traccar/protocol/DwayProtocol.java b/src/org/traccar/protocol/DwayProtocol.java
index 151d3fe01..d9af5bd02 100644
--- a/src/org/traccar/protocol/DwayProtocol.java
+++ b/src/org/traccar/protocol/DwayProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class DwayProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/DwayProtocolDecoder.java b/src/org/traccar/protocol/DwayProtocolDecoder.java
index 8ddd62b83..f2e1ad710 100644
--- a/src/org/traccar/protocol/DwayProtocolDecoder.java
+++ b/src/org/traccar/protocol/DwayProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
@@ -61,7 +62,7 @@ public class DwayProtocolDecoder extends BaseProtocolDecoder {
String sentence = (String) msg;
if (sentence.equals("AA55,HB")) {
if (channel != null) {
- channel.write("55AA,HB,OK\r\n");
+ channel.writeAndFlush(new NetworkMessage("55AA,HB,OK\r\n", remoteAddress));
}
return null;
}
diff --git a/src/org/traccar/protocol/EasyTrackProtocol.java b/src/org/traccar/protocol/EasyTrackProtocol.java
index eeed07129..5e1bb48be 100644
--- a/src/org/traccar/protocol/EasyTrackProtocol.java
+++ b/src/org/traccar/protocol/EasyTrackProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class EasyTrackProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "#", "\r\n"));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java
index efc69eca8..243b5f55d 100644
--- a/src/org/traccar/protocol/EasyTrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/EasyTrackProtocolDecoder.java
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
diff --git a/src/org/traccar/protocol/EelinkProtocol.java b/src/org/traccar/protocol/EelinkProtocol.java
index 3d0a006de..0ad23fc14 100644
--- a/src/org/traccar/protocol/EelinkProtocol.java
+++ b/src/org/traccar/protocol/EelinkProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -39,17 +37,17 @@ public class EelinkProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2));
pipeline.addLast("objectEncoder", new EelinkProtocolEncoder(false));
pipeline.addLast("objectDecoder", new EelinkProtocolDecoder(EelinkProtocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectEncoder", new EelinkProtocolEncoder(true));
pipeline.addLast("objectDecoder", new EelinkProtocolDecoder(EelinkProtocol.this));
}
diff --git a/src/org/traccar/protocol/EelinkProtocolDecoder.java b/src/org/traccar/protocol/EelinkProtocolDecoder.java
index 0fda6fb74..67e7f5127 100644
--- a/src/org/traccar/protocol/EelinkProtocolDecoder.java
+++ b/src/org/traccar/protocol/EelinkProtocolDecoder.java
@@ -15,12 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.socket.DatagramChannel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.Channel;
+import io.netty.channel.socket.DatagramChannel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -62,8 +63,8 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
private void sendResponse(Channel channel, SocketAddress remoteAddress, String uniqueId, int type, int index) {
if (channel != null) {
- channel.write(EelinkProtocolEncoder.encodeContent(
- channel instanceof DatagramChannel, uniqueId, type, index, null), remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(EelinkProtocolEncoder.encodeContent(
+ channel instanceof DatagramChannel, uniqueId, type, index, null), remoteAddress));
}
}
@@ -113,7 +114,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_STATUS, status);
}
- private Position decodeOld(DeviceSession deviceSession, ChannelBuffer buf, int type, int index) {
+ private Position decodeOld(DeviceSession deviceSession, ByteBuf buf, int type, int index) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -170,7 +171,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private Position decodeNew(DeviceSession deviceSession, ChannelBuffer buf, int type, int index) {
+ private Position decodeNew(DeviceSession deviceSession, ByteBuf buf, int type, int index) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -294,7 +295,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
.number("(dd):(dd):(dd)") // time
.compile();
- private Position decodeResult(DeviceSession deviceSession, ChannelBuffer buf, int index) {
+ private Position decodeResult(DeviceSession deviceSession, ByteBuf buf, int index) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -331,14 +332,14 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
String uniqueId = null;
DeviceSession deviceSession;
if (buf.getByte(0) == 'E' && buf.getByte(1) == 'L') {
buf.skipBytes(2 + 2 + 2); // udp header
- uniqueId = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1);
+ uniqueId = ByteBufUtil.hexDump(buf.readSlice(8)).substring(1);
deviceSession = getDeviceSession(channel, remoteAddress, uniqueId);
} else {
deviceSession = getDeviceSession(channel, remoteAddress);
@@ -356,7 +357,7 @@ public class EelinkProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_LOGIN) {
if (deviceSession == null) {
- getDeviceSession(channel, remoteAddress, ChannelBuffers.hexDump(buf.readBytes(8)).substring(1));
+ getDeviceSession(channel, remoteAddress, ByteBufUtil.hexDump(buf.readSlice(8)).substring(1));
}
} else {
diff --git a/src/org/traccar/protocol/EelinkProtocolEncoder.java b/src/org/traccar/protocol/EelinkProtocolEncoder.java
index 4d2d86e68..64236ca4a 100644
--- a/src/org/traccar/protocol/EelinkProtocolEncoder.java
+++ b/src/org/traccar/protocol/EelinkProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.DataConverter;
import org.traccar.helper.Log;
@@ -41,13 +41,13 @@ public class EelinkProtocolEncoder extends BaseProtocolEncoder {
return sum;
}
- public static ChannelBuffer encodeContent(
- boolean connectionless, String uniqueId, int type, int index, ChannelBuffer content) {
+ public static ByteBuf encodeContent(
+ boolean connectionless, String uniqueId, int type, int index, ByteBuf content) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ ByteBuf buf = Unpooled.buffer();
if (connectionless) {
- buf.writeBytes(ChannelBuffers.wrappedBuffer(DataConverter.parseHex('0' + uniqueId)));
+ buf.writeBytes(DataConverter.parseHex('0' + uniqueId));
}
buf.writeByte(0x67);
@@ -60,13 +60,13 @@ public class EelinkProtocolEncoder extends BaseProtocolEncoder {
buf.writeBytes(content);
}
- ChannelBuffer result = ChannelBuffers.dynamicBuffer();
+ ByteBuf result = Unpooled.buffer();
if (connectionless) {
result.writeByte('E');
result.writeByte('L');
result.writeShort(2 + buf.readableBytes()); // length
- result.writeShort(checksum(buf.toByteBuffer()));
+ result.writeShort(checksum(buf.nioBuffer()));
}
result.writeBytes(buf);
@@ -74,9 +74,9 @@ public class EelinkProtocolEncoder extends BaseProtocolEncoder {
return result;
}
- private ChannelBuffer encodeContent(long deviceId, String content) {
+ private ByteBuf encodeContent(long deviceId, String content) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ ByteBuf buf = Unpooled.buffer();
buf.writeByte(0x01); // command
buf.writeInt(0); // server id
diff --git a/src/org/traccar/protocol/EgtsFrameDecoder.java b/src/org/traccar/protocol/EgtsFrameDecoder.java
index 71ffc1811..84f1f11a7 100644
--- a/src/org/traccar/protocol/EgtsFrameDecoder.java
+++ b/src/org/traccar/protocol/EgtsFrameDecoder.java
@@ -15,28 +15,28 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class EgtsFrameDecoder extends FrameDecoder {
+public class EgtsFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 10) {
return null;
}
int headerLength = buf.getUnsignedByte(buf.readerIndex() + 3);
- int frameLength = buf.getUnsignedShort(buf.readerIndex() + 5);
+ int frameLength = buf.getUnsignedShortLE(buf.readerIndex() + 5);
int length = headerLength + frameLength + (frameLength > 0 ? 2 : 0);
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
return null;
diff --git a/src/org/traccar/protocol/EgtsProtocol.java b/src/org/traccar/protocol/EgtsProtocol.java
index 13ec6c9a7..2bc2ec10d 100644
--- a/src/org/traccar/protocol/EgtsProtocol.java
+++ b/src/org/traccar/protocol/EgtsProtocol.java
@@ -15,12 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
-import java.nio.ByteOrder;
import java.util.List;
public class EgtsProtocol extends BaseProtocol {
@@ -31,15 +29,13 @@ public class EgtsProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new EgtsFrameDecoder());
pipeline.addLast("objectDecoder", new EgtsProtocolDecoder(EgtsProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/EgtsProtocolDecoder.java b/src/org/traccar/protocol/EgtsProtocolDecoder.java
index 6ac7af440..45e191d1e 100644
--- a/src/org/traccar/protocol/EgtsProtocolDecoder.java
+++ b/src/org/traccar/protocol/EgtsProtocolDecoder.java
@@ -15,18 +15,18 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.LinkedList;
@@ -72,41 +72,44 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
private int packetId;
private void sendResponse(
- Channel channel, int packetType, int index, int serviceType, int type, ChannelBuffer content) {
+ Channel channel, int packetType, int index, int serviceType, int type, ByteBuf content) {
if (channel != null) {
- ChannelBuffer data = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf data = Unpooled.buffer();
data.writeByte(type);
- data.writeShort(content.readableBytes());
+ data.writeShortLE(content.readableBytes());
data.writeBytes(content);
+ content.release();
- ChannelBuffer record = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf record = Unpooled.buffer();
if (packetType == PT_RESPONSE) {
- record.writeShort(index);
+ record.writeShortLE(index);
record.writeByte(0); // success
}
- record.writeShort(data.readableBytes());
- record.writeShort(0);
+ record.writeShortLE(data.readableBytes());
+ record.writeShortLE(0);
record.writeByte(0); // flags (possibly 1 << 6)
record.writeByte(serviceType);
record.writeByte(serviceType);
record.writeBytes(data);
- int recordChecksum = Checksum.crc16(Checksum.CRC16_CCITT_FALSE, record.toByteBuffer());
+ data.release();
+ int recordChecksum = Checksum.crc16(Checksum.CRC16_CCITT_FALSE, record.nioBuffer());
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf response = Unpooled.buffer();
response.writeByte(1); // protocol version
response.writeByte(0); // security key id
response.writeByte(0); // flags
response.writeByte(5 + 2 + 2 + 2); // header length
response.writeByte(0); // encoding
- response.writeShort(record.readableBytes());
- response.writeShort(packetId++);
+ response.writeShortLE(record.readableBytes());
+ response.writeShortLE(packetId++);
response.writeByte(packetType);
- response.writeByte(Checksum.crc8(Checksum.CRC8_EGTS, response.toByteBuffer()));
+ response.writeByte(Checksum.crc8(Checksum.CRC8_EGTS, response.nioBuffer()));
response.writeBytes(record);
- response.writeShort(recordChecksum);
+ record.release();
+ response.writeShortLE(recordChecksum);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
@@ -115,7 +118,7 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
int index = buf.getUnsignedShort(buf.readerIndex() + 5 + 2);
buf.skipBytes(buf.getUnsignedByte(buf.readerIndex() + 3));
@@ -124,19 +127,19 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
while (buf.readableBytes() > 2) {
- int length = buf.readUnsignedShort();
- int recordIndex = buf.readUnsignedShort();
+ int length = buf.readUnsignedShortLE();
+ int recordIndex = buf.readUnsignedShortLE();
int recordFlags = buf.readUnsignedByte();
if (BitUtil.check(recordFlags, 0)) {
- buf.readUnsignedInt(); // object id
+ buf.readUnsignedIntLE(); // object id
}
if (BitUtil.check(recordFlags, 1)) {
- buf.readUnsignedInt(); // event id
+ buf.readUnsignedIntLE(); // event id
}
if (BitUtil.check(recordFlags, 2)) {
- buf.readUnsignedInt(); // time
+ buf.readUnsignedIntLE(); // time
}
int serviceType = buf.readUnsignedByte();
@@ -150,30 +153,30 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
position.setDeviceId(deviceSession.getDeviceId());
}
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
- response.writeShort(recordIndex);
+ ByteBuf response = Unpooled.buffer();
+ response.writeShortLE(recordIndex);
response.writeByte(0); // success
sendResponse(channel, PT_RESPONSE, index, serviceType, MSG_RECORD_RESPONSE, response);
while (buf.readerIndex() < recordEnd) {
int type = buf.readUnsignedByte();
- int end = buf.readUnsignedShort() + buf.readerIndex();
+ int end = buf.readUnsignedShortLE() + buf.readerIndex();
if (type == MSG_TERM_IDENTITY) {
- buf.readUnsignedInt(); // object id
+ buf.readUnsignedIntLE(); // object id
int flags = buf.readUnsignedByte();
if (BitUtil.check(flags, 0)) {
- buf.readUnsignedShort(); // home dispatcher identifier
+ buf.readUnsignedShortLE(); // home dispatcher identifier
}
if (BitUtil.check(flags, 1)) {
getDeviceSession(
- channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII).trim());
+ channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.US_ASCII).trim());
}
if (BitUtil.check(flags, 2)) {
getDeviceSession(
- channel, remoteAddress, buf.readBytes(16).toString(StandardCharsets.US_ASCII).trim());
+ channel, remoteAddress, buf.readSlice(16).toString(StandardCharsets.US_ASCII).trim());
}
if (BitUtil.check(flags, 3)) {
buf.skipBytes(3); // language identifier
@@ -182,22 +185,22 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(3); // network identifier
}
if (BitUtil.check(flags, 6)) {
- buf.readUnsignedShort(); // buffer size
+ buf.readUnsignedShortLE(); // buffer size
}
if (BitUtil.check(flags, 7)) {
getDeviceSession(
- channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII).trim());
+ channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.US_ASCII).trim());
}
- response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ response = Unpooled.buffer();
response.writeByte(0); // success
sendResponse(channel, PT_APPDATA, 0, serviceType, MSG_RESULT_CODE, response);
} else if (type == MSG_POS_DATA) {
- position.setTime(new Date((buf.readUnsignedInt() + 1262304000) * 1000)); // since 2010-01-01
- position.setLatitude(buf.readUnsignedInt() * 90.0 / 0xFFFFFFFFL);
- position.setLongitude(buf.readUnsignedInt() * 180.0 / 0xFFFFFFFFL);
+ position.setTime(new Date((buf.readUnsignedIntLE() + 1262304000) * 1000)); // since 2010-01-01
+ position.setLatitude(buf.readUnsignedIntLE() * 90.0 / 0xFFFFFFFFL);
+ position.setLongitude(buf.readUnsignedIntLE() * 180.0 / 0xFFFFFFFFL);
int flags = buf.readUnsignedByte();
position.setValid(BitUtil.check(flags, 0));
@@ -208,16 +211,16 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
position.setLongitude(-position.getLongitude());
}
- int speed = buf.readUnsignedShort();
+ int speed = buf.readUnsignedShortLE();
position.setSpeed(UnitsConverter.knotsFromKph(BitUtil.to(speed, 14) * 0.1));
position.setCourse(buf.readUnsignedByte() + (BitUtil.check(speed, 15) ? 0x100 : 0));
- position.set(Position.KEY_ODOMETER, buf.readUnsignedMedium() * 100);
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedMediumLE() * 100);
position.set(Position.KEY_INPUT, buf.readUnsignedByte());
position.set(Position.KEY_EVENT, buf.readUnsignedByte());
if (BitUtil.check(flags, 7)) {
- position.setAltitude(buf.readMedium());
+ position.setAltitude(buf.readMediumLE());
}
} else if (type == MSG_EXT_POS_DATA) {
@@ -225,13 +228,13 @@ public class EgtsProtocolDecoder extends BaseProtocolDecoder {
int flags = buf.readUnsignedByte();
if (BitUtil.check(flags, 0)) {
- position.set(Position.KEY_VDOP, buf.readUnsignedShort());
+ position.set(Position.KEY_VDOP, buf.readUnsignedShortLE());
}
if (BitUtil.check(flags, 1)) {
- position.set(Position.KEY_HDOP, buf.readUnsignedShort());
+ position.set(Position.KEY_HDOP, buf.readUnsignedShortLE());
}
if (BitUtil.check(flags, 2)) {
- position.set(Position.KEY_PDOP, buf.readUnsignedShort());
+ position.set(Position.KEY_PDOP, buf.readUnsignedShortLE());
}
if (BitUtil.check(flags, 3)) {
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
diff --git a/src/org/traccar/protocol/EnforaProtocol.java b/src/org/traccar/protocol/EnforaProtocol.java
index 79cc47c0b..ebdb4a31b 100644
--- a/src/org/traccar/protocol/EnforaProtocol.java
+++ b/src/org/traccar/protocol/EnforaProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -36,9 +35,9 @@ public class EnforaProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 0, 2, -2, 2));
pipeline.addLast("objectEncoder", new EnforaProtocolEncoder());
pipeline.addLast("objectDecoder", new EnforaProtocolDecoder(EnforaProtocol.this));
diff --git a/src/org/traccar/protocol/EnforaProtocolDecoder.java b/src/org/traccar/protocol/EnforaProtocolDecoder.java
index c5500c3b3..d78be685f 100644
--- a/src/org/traccar/protocol/EnforaProtocolDecoder.java
+++ b/src/org/traccar/protocol/EnforaProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,15 +15,14 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBufferIndexFinder;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.helper.BufferUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
-import org.traccar.helper.StringFinder;
import org.traccar.model.Position;
import java.net.SocketAddress;
@@ -56,23 +55,22 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
// Find IMEI number
- int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new ChannelBufferIndexFinder() {
- @Override
- public boolean find(ChannelBuffer buffer, int guessedIndex) {
- if (buffer.writerIndex() - guessedIndex >= IMEI_LENGTH) {
- for (int i = 0; i < IMEI_LENGTH; i++) {
- if (!Character.isDigit((char) buffer.getByte(guessedIndex + i))) {
- return false;
- }
- }
- return true;
+ int index = -1;
+ for (int i = buf.readerIndex(); i < buf.writerIndex() - IMEI_LENGTH; i++) {
+ index = i;
+ for (int j = i; j < i + IMEI_LENGTH; j++) {
+ if (!Character.isDigit((char) buf.getByte(j))) {
+ index = -1;
+ break;
}
- return false;
}
- });
+ if (index > 0) {
+ break;
+ }
+ }
if (index == -1) {
return null;
}
@@ -84,7 +82,7 @@ public class EnforaProtocolDecoder extends BaseProtocolDecoder {
}
// Find NMEA sentence
- int start = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("GPRMC"));
+ int start = BufferUtil.indexOf("GPRMC", buf);
if (start == -1) {
return null;
}
diff --git a/src/org/traccar/protocol/EnforaProtocolEncoder.java b/src/org/traccar/protocol/EnforaProtocolEncoder.java
index 3dca1b9b3..a8fe53691 100644
--- a/src/org/traccar/protocol/EnforaProtocolEncoder.java
+++ b/src/org/traccar/protocol/EnforaProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
* Copyright 2017 Jose Castellanos
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,8 +16,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.StringProtocolEncoder;
import org.traccar.helper.Log;
import org.traccar.model.Command;
@@ -26,9 +26,9 @@ import java.nio.charset.StandardCharsets;
public class EnforaProtocolEncoder extends StringProtocolEncoder {
- private ChannelBuffer encodeContent(String content) {
+ private ByteBuf encodeContent(String content) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ ByteBuf buf = Unpooled.buffer();
buf.writeShort(content.length() + 6);
buf.writeShort(0); // index
diff --git a/src/org/traccar/protocol/EskyFrameDecoder.java b/src/org/traccar/protocol/EskyFrameDecoder.java
index 3175698fd..da24c1273 100644
--- a/src/org/traccar/protocol/EskyFrameDecoder.java
+++ b/src/org/traccar/protocol/EskyFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,24 +15,24 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class EskyFrameDecoder extends FrameDecoder {
+public class EskyFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
buf.readerIndex(buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 'E'));
int endIndex = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 'E');
if (endIndex > 0) {
- return buf.readBytes(endIndex - buf.readerIndex());
+ return buf.readRetainedSlice(endIndex - buf.readerIndex());
} else {
- return buf.readBytes(buf.readableBytes()); // assume full frame
+ return buf.readRetainedSlice(buf.readableBytes()); // assume full frame
}
}
diff --git a/src/org/traccar/protocol/EskyProtocol.java b/src/org/traccar/protocol/EskyProtocol.java
index 4c1d11f7d..65dd607a3 100644
--- a/src/org/traccar/protocol/EskyProtocol.java
+++ b/src/org/traccar/protocol/EskyProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class EskyProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new EskyFrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/EskyProtocolDecoder.java b/src/org/traccar/protocol/EskyProtocolDecoder.java
index bf790541b..712632ac3 100644
--- a/src/org/traccar/protocol/EskyProtocolDecoder.java
+++ b/src/org/traccar/protocol/EskyProtocolDecoder.java
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/ExtremTracProtocol.java b/src/org/traccar/protocol/ExtremTracProtocol.java
index d9b178e23..e0c2876ca 100644
--- a/src/org/traccar/protocol/ExtremTracProtocol.java
+++ b/src/org/traccar/protocol/ExtremTracProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class ExtremTracProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/ExtremTracProtocolDecoder.java b/src/org/traccar/protocol/ExtremTracProtocolDecoder.java
index 553720f1e..c214b4f5d 100644
--- a/src/org/traccar/protocol/ExtremTracProtocolDecoder.java
+++ b/src/org/traccar/protocol/ExtremTracProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/FifotrackProtocol.java b/src/org/traccar/protocol/FifotrackProtocol.java
index f4ca450c0..6d42fc8fe 100644
--- a/src/org/traccar/protocol/FifotrackProtocol.java
+++ b/src/org/traccar/protocol/FifotrackProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class FifotrackProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new FifotrackProtocolDecoder(FifotrackProtocol.this));
diff --git a/src/org/traccar/protocol/FifotrackProtocolDecoder.java b/src/org/traccar/protocol/FifotrackProtocolDecoder.java
index cb7a23315..b27368e3a 100644
--- a/src/org/traccar/protocol/FifotrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/FifotrackProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/FlespiProtocol.java b/src/org/traccar/protocol/FlespiProtocol.java
index d22bd7ae0..4ac5d2ccd 100644
--- a/src/org/traccar/protocol/FlespiProtocol.java
+++ b/src/org/traccar/protocol/FlespiProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
-import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
-import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpRequestDecoder;
+import io.netty.handler.codec.http.HttpResponseEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,12 +32,12 @@ public class FlespiProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
- pipeline.addLast("httpAggregator", new HttpChunkAggregator(Integer.MAX_VALUE));
+ pipeline.addLast("httpAggregator", new HttpObjectAggregator(Integer.MAX_VALUE));
pipeline.addLast("objectDecoder", new FlespiProtocolDecoder(FlespiProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/FlespiProtocolDecoder.java b/src/org/traccar/protocol/FlespiProtocolDecoder.java
index 526e10fa2..da5ba13e9 100644
--- a/src/org/traccar/protocol/FlespiProtocolDecoder.java
+++ b/src/org/traccar/protocol/FlespiProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.handler.codec.http.HttpRequest;
-import org.jboss.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.channel.Channel;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.HttpResponseStatus;
import org.traccar.BaseHttpProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.model.Position;
@@ -46,8 +46,8 @@ public class FlespiProtocolDecoder extends BaseHttpProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- HttpRequest request = (HttpRequest) msg;
- JsonArray result = Json.createReader(new StringReader(request.getContent().toString(StandardCharsets.UTF_8)))
+ FullHttpRequest request = (FullHttpRequest) msg;
+ JsonArray result = Json.createReader(new StringReader(request.content().toString(StandardCharsets.UTF_8)))
.readArray();
List<Position> positions = new LinkedList<>();
for (int i = 0; i < result.size(); i++) {
diff --git a/src/org/traccar/protocol/FlexCommProtocol.java b/src/org/traccar/protocol/FlexCommProtocol.java
index 5dba4421a..69bd99c79 100644
--- a/src/org/traccar/protocol/FlexCommProtocol.java
+++ b/src/org/traccar/protocol/FlexCommProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.FixedLengthFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.FixedLengthFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class FlexCommProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new FixedLengthFrameDecoder(2 + 2 + 101 + 5));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/FlexCommProtocolDecoder.java b/src/org/traccar/protocol/FlexCommProtocolDecoder.java
index 8bd4dcee0..3a1e23d20 100644
--- a/src/org/traccar/protocol/FlexCommProtocolDecoder.java
+++ b/src/org/traccar/protocol/FlexCommProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
@@ -117,7 +118,7 @@ public class FlexCommProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_POWER, parser.nextInt() * 0.1);
if (channel != null) {
- channel.write("{01}");
+ channel.writeAndFlush(new NetworkMessage("{01}", remoteAddress));
}
return position;
diff --git a/src/org/traccar/protocol/FlextrackProtocol.java b/src/org/traccar/protocol/FlextrackProtocol.java
index 77e316d82..a94df710a 100644
--- a/src/org/traccar/protocol/FlextrackProtocol.java
+++ b/src/org/traccar/protocol/FlextrackProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class FlextrackProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\r"));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/FlextrackProtocolDecoder.java b/src/org/traccar/protocol/FlextrackProtocolDecoder.java
index 8f7525147..a6970ba86 100644
--- a/src/org/traccar/protocol/FlextrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/FlextrackProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
@@ -65,9 +66,9 @@ public class FlextrackProtocolDecoder extends BaseProtocolDecoder {
.number("(d+)") // odometer
.compile();
- private void sendAcknowledgement(Channel channel, String index) {
+ private void sendAcknowledgement(Channel channel, SocketAddress remoteAddress, String index) {
if (channel != null) {
- channel.write(index + ",ACK\r");
+ channel.writeAndFlush(new NetworkMessage(index + ",ACK\r", remoteAddress));
}
}
@@ -84,7 +85,7 @@ public class FlextrackProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- sendAcknowledgement(channel, parser.next());
+ sendAcknowledgement(channel, remoteAddress, parser.next());
String id = parser.next();
String iccid = parser.next();
@@ -106,7 +107,7 @@ public class FlextrackProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- sendAcknowledgement(channel, parser.next());
+ sendAcknowledgement(channel, remoteAddress, parser.next());
position.setTime(parser.nextDateTime());
diff --git a/src/org/traccar/protocol/FoxProtocol.java b/src/org/traccar/protocol/FoxProtocol.java
index 501bff4c4..6f312dc8e 100644
--- a/src/org/traccar/protocol/FoxProtocol.java
+++ b/src/org/traccar/protocol/FoxProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class FoxProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "</fox>"));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/FoxProtocolDecoder.java b/src/org/traccar/protocol/FoxProtocolDecoder.java
index 16f8fce27..7ce57109d 100644
--- a/src/org/traccar/protocol/FoxProtocolDecoder.java
+++ b/src/org/traccar/protocol/FoxProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/FreedomProtocol.java b/src/org/traccar/protocol/FreedomProtocol.java
index 5b4bf22ff..7ea09d25a 100644
--- a/src/org/traccar/protocol/FreedomProtocol.java
+++ b/src/org/traccar/protocol/FreedomProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class FreedomProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/FreedomProtocolDecoder.java b/src/org/traccar/protocol/FreedomProtocolDecoder.java
index 28456c617..95348ba11 100644
--- a/src/org/traccar/protocol/FreedomProtocolDecoder.java
+++ b/src/org/traccar/protocol/FreedomProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/GalileoFrameDecoder.java b/src/org/traccar/protocol/GalileoFrameDecoder.java
index 6d02ce744..c23d26c83 100644
--- a/src/org/traccar/protocol/GalileoFrameDecoder.java
+++ b/src/org/traccar/protocol/GalileoFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,30 +15,26 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class GalileoFrameDecoder extends FrameDecoder {
+public class GalileoFrameDecoder extends BaseFrameDecoder {
private static final int MESSAGE_MINIMUM_LENGTH = 5;
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
- // Check minimum length
if (buf.readableBytes() < MESSAGE_MINIMUM_LENGTH) {
return null;
}
- // Read packet
- int length = buf.getUnsignedShort(buf.readerIndex() + 1) & 0x7fff;
+ int length = buf.getUnsignedShortLE(buf.readerIndex() + 1) & 0x7fff;
if (buf.readableBytes() >= (length + MESSAGE_MINIMUM_LENGTH)) {
- return buf.readBytes(length + MESSAGE_MINIMUM_LENGTH);
+ return buf.readRetainedSlice(length + MESSAGE_MINIMUM_LENGTH);
}
return null;
diff --git a/src/org/traccar/protocol/GalileoProtocol.java b/src/org/traccar/protocol/GalileoProtocol.java
index f76de04a0..93178ea52 100644
--- a/src/org/traccar/protocol/GalileoProtocol.java
+++ b/src/org/traccar/protocol/GalileoProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
-import java.nio.ByteOrder;
import java.util.List;
public class GalileoProtocol extends BaseProtocol {
@@ -35,16 +33,14 @@ public class GalileoProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new GalileoFrameDecoder());
pipeline.addLast("objectEncoder", new GalileoProtocolEncoder());
pipeline.addLast("objectDecoder", new GalileoProtocolDecoder(GalileoProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/GalileoProtocolDecoder.java b/src/org/traccar/protocol/GalileoProtocolDecoder.java
index d8a1651bb..7e17ebd93 100644
--- a/src/org/traccar/protocol/GalileoProtocolDecoder.java
+++ b/src/org/traccar/protocol/GalileoProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,17 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashMap;
@@ -92,15 +93,15 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
}
private void sendReply(Channel channel, int checksum) {
- ChannelBuffer reply = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 3);
- reply.writeByte(0x02);
- reply.writeShort((short) checksum);
if (channel != null) {
- channel.write(reply);
+ ByteBuf reply = Unpooled.buffer(3);
+ reply.writeByte(0x02);
+ reply.writeShortLE((short) checksum);
+ channel.writeAndFlush(new NetworkMessage(reply, channel.remoteAddress()));
}
}
- private void decodeTag(Position position, ChannelBuffer buf, int tag) {
+ private void decodeTag(Position position, ByteBuf buf, int tag) {
switch (tag) {
case 0x01:
position.set(Position.KEY_VERSION_HW, buf.readUnsignedByte());
@@ -109,41 +110,41 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_VERSION_FW, buf.readUnsignedByte());
break;
case 0x04:
- position.set("deviceId", buf.readUnsignedShort());
+ position.set("deviceId", buf.readUnsignedShortLE());
break;
case 0x10:
- position.set(Position.KEY_INDEX, buf.readUnsignedShort());
+ position.set(Position.KEY_INDEX, buf.readUnsignedShortLE());
break;
case 0x20:
- position.setTime(new Date(buf.readUnsignedInt() * 1000));
+ position.setTime(new Date(buf.readUnsignedIntLE() * 1000));
break;
case 0x33:
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort() * 0.1));
- position.setCourse(buf.readUnsignedShort() * 0.1);
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShortLE() * 0.1));
+ position.setCourse(buf.readUnsignedShortLE() * 0.1);
break;
case 0x34:
- position.setAltitude(buf.readShort());
+ position.setAltitude(buf.readShortLE());
break;
case 0x40:
- position.set(Position.KEY_STATUS, buf.readUnsignedShort());
+ position.set(Position.KEY_STATUS, buf.readUnsignedShortLE());
break;
case 0x41:
- position.set(Position.KEY_POWER, buf.readUnsignedShort());
+ position.set(Position.KEY_POWER, buf.readUnsignedShortLE());
break;
case 0x42:
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort());
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE());
break;
case 0x43:
position.set(Position.KEY_DEVICE_TEMP, buf.readByte());
break;
case 0x44:
- position.set(Position.KEY_ACCELERATION, buf.readUnsignedInt());
+ position.set(Position.KEY_ACCELERATION, buf.readUnsignedIntLE());
break;
case 0x45:
- position.set(Position.KEY_OUTPUT, buf.readUnsignedShort());
+ position.set(Position.KEY_OUTPUT, buf.readUnsignedShortLE());
break;
case 0x46:
- position.set(Position.KEY_INPUT, buf.readUnsignedShort());
+ position.set(Position.KEY_INPUT, buf.readUnsignedShortLE());
break;
case 0x50:
case 0x51:
@@ -153,27 +154,27 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
case 0x55:
case 0x56:
case 0x57:
- position.set(Position.PREFIX_ADC + (tag - 0x50), buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + (tag - 0x50), buf.readUnsignedShortLE());
break;
case 0x58:
- position.set("rs2320", buf.readUnsignedShort());
+ position.set("rs2320", buf.readUnsignedShortLE());
break;
case 0x59:
- position.set("rs2321", buf.readUnsignedShort());
+ position.set("rs2321", buf.readUnsignedShortLE());
break;
case 0xc0:
- position.set("fuelTotal", buf.readUnsignedInt() * 0.5);
+ position.set("fuelTotal", buf.readUnsignedIntLE() * 0.5);
break;
case 0xc1:
position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedByte() * 0.4);
position.set(Position.PREFIX_TEMP + 1, buf.readUnsignedByte() - 40);
- position.set(Position.KEY_RPM, buf.readUnsignedShort() * 0.125);
+ position.set(Position.KEY_RPM, buf.readUnsignedShortLE() * 0.125);
break;
case 0xc2:
- position.set("canB0", buf.readUnsignedInt());
+ position.set("canB0", buf.readUnsignedIntLE());
break;
case 0xc3:
- position.set("canB1", buf.readUnsignedInt());
+ position.set("canB1", buf.readUnsignedIntLE());
break;
case 0xc4:
case 0xc5:
@@ -197,24 +198,24 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
case 0xd8:
case 0xd9:
case 0xda:
- position.set("can16Bit" + (tag - 0xd6), buf.readUnsignedShort());
+ position.set("can16Bit" + (tag - 0xd6), buf.readUnsignedShortLE());
break;
case 0xdb:
case 0xdc:
case 0xdd:
case 0xde:
case 0xdf:
- position.set("can32Bit" + (tag - 0xdb), buf.readUnsignedInt());
+ position.set("can32Bit" + (tag - 0xdb), buf.readUnsignedIntLE());
break;
case 0xd4:
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
break;
case 0xe0:
- position.set(Position.KEY_INDEX, buf.readUnsignedInt());
+ position.set(Position.KEY_INDEX, buf.readUnsignedIntLE());
break;
case 0xe1:
position.set(Position.KEY_RESULT,
- buf.readBytes(buf.readUnsignedByte()).toString(StandardCharsets.US_ASCII));
+ buf.readSlice(buf.readUnsignedByte()).toString(StandardCharsets.US_ASCII));
break;
case 0xe2:
case 0xe3:
@@ -224,10 +225,11 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
case 0xe7:
case 0xe8:
case 0xe9:
- position.set("userData" + (tag - 0xe2), buf.readUnsignedInt());
+ position.set("userData" + (tag - 0xe2), buf.readUnsignedIntLE());
break;
case 0xea:
- position.set("userDataArray", ChannelBuffers.hexDump(buf.readBytes(buf.readUnsignedByte())));
+ position.set("userDataArray", ByteBufUtil.hexDump(buf.readSlice(buf.readUnsignedByte())));
+ position.set("userDataArray", ByteBufUtil.hexDump(buf.readSlice(buf.readUnsignedByte())));
break;
default:
buf.skipBytes(getTagLength(tag));
@@ -239,10 +241,10 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.readUnsignedByte(); // header
- int length = (buf.readUnsignedShort() & 0x7fff) + 3;
+ int length = (buf.readUnsignedShortLE() & 0x7fff) + 3;
List<Position> positions = new LinkedList<>();
Set<Integer> tags = new HashSet<>();
@@ -266,12 +268,12 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
if (tag == 0x03) {
deviceSession = getDeviceSession(
- channel, remoteAddress, buf.readBytes(15).toString(StandardCharsets.US_ASCII));
+ channel, remoteAddress, buf.readSlice(15).toString(StandardCharsets.US_ASCII));
} else if (tag == 0x30) {
hasLocation = true;
position.setValid((buf.readUnsignedByte() & 0xf0) == 0x00);
- position.setLatitude(buf.readInt() / 1000000.0);
- position.setLongitude(buf.readInt() / 1000000.0);
+ position.setLatitude(buf.readIntLE() / 1000000.0);
+ position.setLongitude(buf.readIntLE() / 1000000.0);
} else {
decodeTag(position, buf, tag);
}
@@ -293,7 +295,7 @@ public class GalileoProtocolDecoder extends BaseProtocolDecoder {
positions.add(position);
}
- sendReply(channel, buf.readUnsignedShort());
+ sendReply(channel, buf.readUnsignedShortLE());
for (Position p : positions) {
p.setDeviceId(deviceSession.getDeviceId());
diff --git a/src/org/traccar/protocol/GalileoProtocolEncoder.java b/src/org/traccar/protocol/GalileoProtocolEncoder.java
index cb6028abb..12463dc7d 100644
--- a/src/org/traccar/protocol/GalileoProtocolEncoder.java
+++ b/src/org/traccar/protocol/GalileoProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,39 +15,38 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Checksum;
import org.traccar.helper.Log;
import org.traccar.model.Command;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
public class GalileoProtocolEncoder extends BaseProtocolEncoder {
- private ChannelBuffer encodeText(String uniqueId, String text) {
+ private ByteBuf encodeText(String uniqueId, String text) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 256);
+ ByteBuf buf = Unpooled.buffer(256);
buf.writeByte(0x01);
- buf.writeShort(uniqueId.length() + text.length() + 11); // TODO
+ buf.writeShortLE(uniqueId.length() + text.length() + 11);
buf.writeByte(0x03); // imei tag
buf.writeBytes(uniqueId.getBytes(StandardCharsets.US_ASCII));
buf.writeByte(0x04); // device id tag
- buf.writeShort(0); // not needed if imei provided
+ buf.writeShortLE(0); // not needed if imei provided
buf.writeByte(0xE0); // index tag
- buf.writeInt(0); // index
+ buf.writeIntLE(0); // index
buf.writeByte(0xE1); // command text tag
buf.writeByte(text.length());
buf.writeBytes(text.getBytes(StandardCharsets.US_ASCII));
- buf.writeShort(Checksum.crc16(Checksum.CRC16_MODBUS, buf.toByteBuffer(0, buf.writerIndex())));
+ buf.writeShortLE(Checksum.crc16(Checksum.CRC16_MODBUS, buf.nioBuffer(0, buf.writerIndex())));
return buf;
}
diff --git a/src/org/traccar/protocol/GatorProtocol.java b/src/org/traccar/protocol/GatorProtocol.java
index 7fa4854d3..531f1238c 100644
--- a/src/org/traccar/protocol/GatorProtocol.java
+++ b/src/org/traccar/protocol/GatorProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,16 +30,16 @@ public class GatorProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2));
pipeline.addLast("objectDecoder", new GatorProtocolDecoder(GatorProtocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectDecoder", new GatorProtocolDecoder(GatorProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/GatorProtocolDecoder.java b/src/org/traccar/protocol/GatorProtocolDecoder.java
index b38214457..f77723691 100644
--- a/src/org/traccar/protocol/GatorProtocolDecoder.java
+++ b/src/org/traccar/protocol/GatorProtocolDecoder.java
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BcdUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
@@ -58,7 +59,7 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder {
private void sendResponse(Channel channel, SocketAddress remoteAddress, byte calibration) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeByte(0x24); response.writeByte(0x24); // header
response.writeByte(MSG_HEARTBEAT); // size
response.writeShort(5);
@@ -67,7 +68,7 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder {
response.writeByte(0); // slave order
response.writeByte(1); // calibration
response.writeByte(0x0D);
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
@@ -75,7 +76,7 @@ public class GatorProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
int type = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/GenxProtocol.java b/src/org/traccar/protocol/GenxProtocol.java
index 2b5b1a43d..2c3c4f7a0 100644
--- a/src/org/traccar/protocol/GenxProtocol.java
+++ b/src/org/traccar/protocol/GenxProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class GenxProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new GenxProtocolDecoder(GenxProtocol.this));
diff --git a/src/org/traccar/protocol/GenxProtocolDecoder.java b/src/org/traccar/protocol/GenxProtocolDecoder.java
index d4a348ce1..399a42109 100644
--- a/src/org/traccar/protocol/GenxProtocolDecoder.java
+++ b/src/org/traccar/protocol/GenxProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
diff --git a/src/org/traccar/protocol/Gl100Protocol.java b/src/org/traccar/protocol/Gl100Protocol.java
index 0fd18d44f..90beab23a 100644
--- a/src/org/traccar/protocol/Gl100Protocol.java
+++ b/src/org/traccar/protocol/Gl100Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -34,18 +32,18 @@ public class Gl100Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\0'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(Gl100Protocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new Gl100ProtocolDecoder(Gl100Protocol.this));
diff --git a/src/org/traccar/protocol/Gl100ProtocolDecoder.java b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
index 405090695..a1654d062 100644
--- a/src/org/traccar/protocol/Gl100ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl100ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.model.Position;
@@ -64,7 +65,7 @@ public class Gl100ProtocolDecoder extends BaseProtocolDecoder {
String response = "+RESP:GTHBD,GPRS ACTIVE,";
response += sentence.substring(9, sentence.lastIndexOf(','));
response += '\0';
- channel.write(response); // heartbeat response
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress)); // heartbeat response
}
Parser parser = new Parser(PATTERN, sentence);
diff --git a/src/org/traccar/protocol/Gl200BinaryProtocolDecoder.java b/src/org/traccar/protocol/Gl200BinaryProtocolDecoder.java
index ba3baaa75..62caaf13d 100644
--- a/src/org/traccar/protocol/Gl200BinaryProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200BinaryProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitBuffer;
@@ -39,7 +39,7 @@ public class Gl200BinaryProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private Date decodeTime(ChannelBuffer buf) {
+ private Date decodeTime(ByteBuf buf) {
DateBuilder dateBuilder = new DateBuilder()
.setDate(buf.readUnsignedShort(), buf.readUnsignedByte(), buf.readUnsignedByte())
.setTime(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte());
@@ -50,7 +50,7 @@ public class Gl200BinaryProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_RSP_GEO = 8;
public static final int MSG_RSP_COMPRESSED = 100;
- private List<Position> decodeLocation(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private List<Position> decodeLocation(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
List<Position> positions = new LinkedList<>();
@@ -113,7 +113,7 @@ public class Gl200BinaryProtocolDecoder extends BaseProtocolDecoder {
switch (BitUtil.from(buf.getUnsignedByte(buf.readerIndex()), 8 - 2)) {
case 1:
- bits = new BitBuffer(buf.readBytes(3));
+ bits = new BitBuffer(buf.readSlice(3));
bits.readUnsigned(2); // point attribute
bits.readUnsigned(1); // fix type
speed = bits.readUnsigned(12);
@@ -125,7 +125,7 @@ public class Gl200BinaryProtocolDecoder extends BaseProtocolDecoder {
}
break;
case 2:
- bits = new BitBuffer(buf.readBytes(5));
+ bits = new BitBuffer(buf.readSlice(5));
bits.readUnsigned(2); // point attribute
bits.readUnsigned(1); // fix type
speed += bits.readSigned(7);
@@ -202,7 +202,7 @@ public class Gl200BinaryProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_EVT_CRA = 23;
public static final int MSG_EVT_UPC = 34;
- private Position decodeEvent(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private Position decodeEvent(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
Position position = new Position(getProtocolName());
@@ -308,7 +308,7 @@ public class Gl200BinaryProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_INF_TMZ = 9;
public static final int MSG_INF_GIR = 10;
- private Position decodeInformation(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private Position decodeInformation(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
Position position = new Position(getProtocolName());
@@ -385,9 +385,9 @@ public class Gl200BinaryProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
- switch (buf.readBytes(4).toString(StandardCharsets.US_ASCII)) {
+ switch (buf.readSlice(4).toString(StandardCharsets.US_ASCII)) {
case "+RSP":
return decodeLocation(channel, remoteAddress, buf);
case "+INF":
diff --git a/src/org/traccar/protocol/Gl200FrameDecoder.java b/src/org/traccar/protocol/Gl200FrameDecoder.java
index 960c3779a..c192cc28d 100644
--- a/src/org/traccar/protocol/Gl200FrameDecoder.java
+++ b/src/org/traccar/protocol/Gl200FrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,24 +15,25 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import org.traccar.BaseFrameDecoder;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-public class Gl200FrameDecoder extends FrameDecoder {
+public class Gl200FrameDecoder extends BaseFrameDecoder {
private static final int MINIMUM_LENGTH = 11;
private static final Set<String> BINARY_HEADERS = new HashSet<>(
Arrays.asList("+RSP", "+BSP", "+EVT", "+BVT", "+INF", "+BNF", "+HBD", "+CRD", "+BRD"));
- public static boolean isBinary(ChannelBuffer buf) {
+ public static boolean isBinary(ByteBuf buf) {
String header = buf.toString(buf.readerIndex(), 4, StandardCharsets.US_ASCII);
if (header.equals("+ACK")) {
return buf.getByte(buf.readerIndex() + header.length()) != (byte) ':';
@@ -43,7 +44,7 @@ public class Gl200FrameDecoder extends FrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < MINIMUM_LENGTH) {
return null;
@@ -73,7 +74,7 @@ public class Gl200FrameDecoder extends FrameDecoder {
}
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
} else {
@@ -83,7 +84,7 @@ public class Gl200FrameDecoder extends FrameDecoder {
endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0);
}
if (endIndex > 0) {
- ChannelBuffer frame = buf.readBytes(endIndex - buf.readerIndex());
+ ByteBuf frame = buf.readRetainedSlice(endIndex - buf.readerIndex());
buf.readByte(); // delimiter
return frame;
}
diff --git a/src/org/traccar/protocol/Gl200Protocol.java b/src/org/traccar/protocol/Gl200Protocol.java
index 799d7fe36..15ed00d06 100644
--- a/src/org/traccar/protocol/Gl200Protocol.java
+++ b/src/org/traccar/protocol/Gl200Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
+import io.netty.handler.codec.string.StringEncoder;
+
import java.util.List;
public class Gl200Protocol extends BaseProtocol {
@@ -39,18 +38,18 @@ public class Gl200Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new Gl200FrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new Gl200ProtocolEncoder());
pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(Gl200Protocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new Gl200ProtocolEncoder());
pipeline.addLast("objectDecoder", new Gl200ProtocolDecoder(Gl200Protocol.this));
diff --git a/src/org/traccar/protocol/Gl200ProtocolDecoder.java b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
index 0de7bb926..8abaa1e37 100644
--- a/src/org/traccar/protocol/Gl200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+
import java.net.SocketAddress;
public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
@@ -36,7 +37,7 @@ public class Gl200ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (Gl200FrameDecoder.isBinary(buf)) {
return binaryProtocolDecoder.decode(channel, remoteAddress, msg);
diff --git a/src/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/org/traccar/protocol/Gl200TextProtocolDecoder.java
index 1c7fe4688..e6187a002 100644
--- a/src/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -29,6 +28,9 @@ import org.traccar.model.Network;
import org.traccar.model.Position;
import org.traccar.model.WifiAccessPoint;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+
import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
@@ -368,7 +370,8 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
if (type.equals("HBD")) {
if (channel != null) {
parser.skip(6);
- channel.write("+SACK:GTHBD," + protocolVersion + "," + parser.next() + "$", remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(
+ "+SACK:GTHBD," + protocolVersion + "," + parser.next() + "$", remoteAddress));
}
} else {
Position position = new Position(getProtocolName());
@@ -980,7 +983,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
decodeDeviceTime(position, parser);
if (Context.getConfig().getBoolean(getProtocolName() + ".ack") && channel != null) {
- channel.write("+SACK:" + parser.next() + "$", remoteAddress);
+ channel.writeAndFlush(new NetworkMessage("+SACK:" + parser.next() + "$", remoteAddress));
}
return position;
@@ -1060,7 +1063,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- String sentence = ((ChannelBuffer) msg).toString(StandardCharsets.US_ASCII);
+ String sentence = ((ByteBuf) msg).toString(StandardCharsets.US_ASCII);
int typeIndex = sentence.indexOf(":GT");
if (typeIndex < 0) {
diff --git a/src/org/traccar/protocol/GlobalSatProtocol.java b/src/org/traccar/protocol/GlobalSatProtocol.java
index f3d07fc96..dddf07d55 100644
--- a/src/org/traccar/protocol/GlobalSatProtocol.java
+++ b/src/org/traccar/protocol/GlobalSatProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class GlobalSatProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '!'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
index 4361e0c2f..4b67c1eff 100644
--- a/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
+++ b/src/org/traccar/protocol/GlobalSatProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -51,7 +52,7 @@ public class GlobalSatProtocolDecoder extends BaseProtocolDecoder {
private Position decodeOriginal(Channel channel, SocketAddress remoteAddress, String sentence) {
if (channel != null) {
- channel.write("ACK\r");
+ channel.writeAndFlush(new NetworkMessage("ACK\r", remoteAddress));
}
String format;
diff --git a/src/org/traccar/protocol/GnxProtocol.java b/src/org/traccar/protocol/GnxProtocol.java
index 84af24000..985f200eb 100644
--- a/src/org/traccar/protocol/GnxProtocol.java
+++ b/src/org/traccar/protocol/GnxProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class GnxProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\n\r"));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/GnxProtocolDecoder.java b/src/org/traccar/protocol/GnxProtocolDecoder.java
index b3a636d14..36bcba2dc 100644
--- a/src/org/traccar/protocol/GnxProtocolDecoder.java
+++ b/src/org/traccar/protocol/GnxProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/GoSafeProtocol.java b/src/org/traccar/protocol/GoSafeProtocol.java
index bfd473df9..e4c6cc66f 100644
--- a/src/org/traccar/protocol/GoSafeProtocol.java
+++ b/src/org/traccar/protocol/GoSafeProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class GoSafeProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/GoSafeProtocolDecoder.java b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
index ae00ad71a..f3900a61b 100644
--- a/src/org/traccar/protocol/GoSafeProtocolDecoder.java
+++ b/src/org/traccar/protocol/GoSafeProtocolDecoder.java
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
@@ -205,7 +206,7 @@ public class GoSafeProtocolDecoder extends BaseProtocolDecoder {
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
if (channel != null) {
- channel.write("1234");
+ channel.writeAndFlush(new NetworkMessage("1234", remoteAddress));
}
String sentence = (String) msg;
diff --git a/src/org/traccar/protocol/GotopProtocol.java b/src/org/traccar/protocol/GotopProtocol.java
index 5d522adf5..272c38cd0 100644
--- a/src/org/traccar/protocol/GotopProtocol.java
+++ b/src/org/traccar/protocol/GotopProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class GotopProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/GotopProtocolDecoder.java b/src/org/traccar/protocol/GotopProtocolDecoder.java
index 29e8d87dd..728c2a8d6 100644
--- a/src/org/traccar/protocol/GotopProtocolDecoder.java
+++ b/src/org/traccar/protocol/GotopProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/Gps056FrameDecoder.java b/src/org/traccar/protocol/Gps056FrameDecoder.java
index 4ce83dc0a..0d84bf231 100644
--- a/src/org/traccar/protocol/Gps056FrameDecoder.java
+++ b/src/org/traccar/protocol/Gps056FrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,26 +15,26 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
import java.nio.charset.StandardCharsets;
-public class Gps056FrameDecoder extends FrameDecoder {
+public class Gps056FrameDecoder extends BaseFrameDecoder {
private static final int MESSAGE_HEADER = 4;
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() >= MESSAGE_HEADER) {
int length = Integer.parseInt(buf.toString(2, 2, StandardCharsets.US_ASCII)) + 5;
if (buf.readableBytes() >= length) {
- ChannelBuffer frame = buf.readBytes(length);
- while (buf.readable() && buf.getUnsignedByte(buf.readerIndex()) != '$') {
+ ByteBuf frame = buf.readRetainedSlice(length);
+ while (buf.isReadable() && buf.getUnsignedByte(buf.readerIndex()) != '$') {
buf.readByte();
}
return frame;
diff --git a/src/org/traccar/protocol/Gps056Protocol.java b/src/org/traccar/protocol/Gps056Protocol.java
index 33c190ad2..f5122830d 100644
--- a/src/org/traccar/protocol/Gps056Protocol.java
+++ b/src/org/traccar/protocol/Gps056Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class Gps056Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new Gps056FrameDecoder());
pipeline.addLast("objectDecoder", new Gps056ProtocolDecoder(Gps056Protocol.this));
}
diff --git a/src/org/traccar/protocol/Gps056ProtocolDecoder.java b/src/org/traccar/protocol/Gps056ProtocolDecoder.java
index ccb389250..13027142f 100644
--- a/src/org/traccar/protocol/Gps056ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps056ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -33,20 +34,20 @@ public class Gps056ProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private static void sendResponse(Channel channel, String type, String imei, ChannelBuffer content) {
+ private static void sendResponse(Channel channel, String type, String imei, ByteBuf content) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
String header = "*" + type + imei;
response.writeBytes(header.getBytes(StandardCharsets.US_ASCII));
if (content != null) {
response.writeBytes(content);
}
response.writeByte('#');
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
- private static double decodeCoordinate(ChannelBuffer buf) {
+ private static double decodeCoordinate(ByteBuf buf) {
double degrees = buf.getUnsignedShort(buf.readerIndex()) / 100;
double minutes = buf.readUnsignedShort() % 100 + buf.readUnsignedShort() * 0.0001;
degrees += minutes / 60;
@@ -57,12 +58,12 @@ public class Gps056ProtocolDecoder extends BaseProtocolDecoder {
return degrees;
}
- private static void decodeStatus(ChannelBuffer buf, Position position) {
+ private static void decodeStatus(ByteBuf buf, Position position) {
position.set(Position.KEY_INPUT, buf.readUnsignedByte());
position.set(Position.KEY_OUTPUT, buf.readUnsignedByte());
- position.set(Position.PREFIX_ADC + 1, ChannelBuffers.swapShort(buf.readShort()) * 5.06); // mV
+ position.set(Position.PREFIX_ADC + 1, buf.readShortLE() * 5.06); // mV
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
position.set(Position.KEY_RSSI, buf.readUnsignedByte());
@@ -73,13 +74,13 @@ public class Gps056ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
buf.skipBytes(2); // length
- String type = buf.readBytes(7).toString(StandardCharsets.US_ASCII);
- String imei = buf.readBytes(15).toString(StandardCharsets.US_ASCII);
+ String type = buf.readSlice(7).toString(StandardCharsets.US_ASCII);
+ String imei = buf.readSlice(15).toString(StandardCharsets.US_ASCII);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession == null) {
@@ -88,8 +89,12 @@ public class Gps056ProtocolDecoder extends BaseProtocolDecoder {
if (type.startsWith("LOGN")) {
- sendResponse(channel, "LGSA" + type.substring(4), imei,
- ChannelBuffers.copiedBuffer("1", StandardCharsets.US_ASCII));
+ ByteBuf content = Unpooled.copiedBuffer("1", StandardCharsets.US_ASCII);
+ try {
+ sendResponse(channel, "LGSA" + type.substring(4), imei, content);
+ } finally {
+ content.release();
+ }
} else if (type.startsWith("GPSL")) {
@@ -109,7 +114,7 @@ public class Gps056ProtocolDecoder extends BaseProtocolDecoder {
decodeStatus(buf, position);
- sendResponse(channel, "GPSA" + type.substring(4), imei, buf.readBytes(2));
+ sendResponse(channel, "GPSA" + type.substring(4), imei, buf.readSlice(2));
return position;
diff --git a/src/org/traccar/protocol/Gps103Protocol.java b/src/org/traccar/protocol/Gps103Protocol.java
index a5bd32261..068f362c9 100644
--- a/src/org/traccar/protocol/Gps103Protocol.java
+++ b/src/org/traccar/protocol/Gps103Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -45,9 +43,9 @@ public class Gps103Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(2048, "\r\n", "\n", ";"));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
@@ -55,9 +53,9 @@ public class Gps103Protocol extends BaseProtocol {
pipeline.addLast("objectDecoder", new Gps103ProtocolDecoder(Gps103Protocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectEncoder", new Gps103ProtocolEncoder());
diff --git a/src/org/traccar/protocol/Gps103ProtocolDecoder.java b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
index 9a27dd9d2..2b797d05a 100644
--- a/src/org/traccar/protocol/Gps103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gps103ProtocolDecoder.java
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -160,7 +161,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ALARM, decodeAlarm(alarm));
if (alarm.equals("help me")) {
if (channel != null) {
- channel.write("**,imei:" + imei + ",E;", remoteAddress);
+ channel.writeAndFlush(new NetworkMessage("**,imei:" + imei + ",E;", remoteAddress));
}
} else if (alarm.equals("acc on")) {
position.set(Position.KEY_IGNITION, true);
@@ -276,7 +277,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
if (sentence.contains("##")) {
if (channel != null) {
- channel.write("LOAD", remoteAddress);
+ channel.writeAndFlush(new NetworkMessage("LOAD", remoteAddress));
Matcher matcher = Pattern.compile("##,imei:(\\d+),A").matcher(sentence);
if (matcher.matches()) {
getDeviceSession(channel, remoteAddress, matcher.group(1));
@@ -287,7 +288,7 @@ public class Gps103ProtocolDecoder extends BaseProtocolDecoder {
if (!sentence.isEmpty() && Character.isDigit(sentence.charAt(0))) {
if (channel != null) {
- channel.write("ON", remoteAddress);
+ channel.writeAndFlush(new NetworkMessage("ON", remoteAddress));
}
int start = sentence.indexOf("imei:");
if (start >= 0) {
diff --git a/src/org/traccar/protocol/GpsGateProtocol.java b/src/org/traccar/protocol/GpsGateProtocol.java
index c7dc2c4f3..4685e40b7 100644
--- a/src/org/traccar/protocol/GpsGateProtocol.java
+++ b/src/org/traccar/protocol/GpsGateProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class GpsGateProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\0", "\n", "\r\n"));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/GpsGateProtocolDecoder.java b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
index 5c7096276..6eff3eb76 100644
--- a/src/org/traccar/protocol/GpsGateProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsGateProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
@@ -65,9 +66,9 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
.any()
.compile();
- private void send(Channel channel, String message) {
+ private void send(Channel channel, SocketAddress remoteAddress, String message) {
if (channel != null) {
- channel.write(message + Checksum.nmea(message) + "\r\n");
+ channel.writeAndFlush(new NetworkMessage(message + Checksum.nmea(message) + "\r\n", remoteAddress));
}
}
@@ -79,7 +80,6 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
if (sentence.startsWith("$FRLIN,")) {
- // Login
int beginIndex = sentence.indexOf(',', 7);
if (beginIndex != -1) {
beginIndex += 1;
@@ -89,22 +89,21 @@ public class GpsGateProtocolDecoder extends BaseProtocolDecoder {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession != null) {
if (channel != null) {
- send(channel, "$FRSES," + channel.getId());
+ send(channel, remoteAddress, "$FRSES," + channel.id().asShortText());
}
} else {
- send(channel, "$FRERR,AuthError,Unknown device");
+ send(channel, remoteAddress, "$FRERR,AuthError,Unknown device");
}
} else {
- send(channel, "$FRERR,AuthError,Parse error");
+ send(channel, remoteAddress, "$FRERR,AuthError,Parse error");
}
} else {
- send(channel, "$FRERR,AuthError,Parse error");
+ send(channel, remoteAddress, "$FRERR,AuthError,Parse error");
}
} else if (sentence.startsWith("$FRVER,")) {
- // Version check
- send(channel, "$FRVER,1,0,GpsGate Server 1.0");
+ send(channel, remoteAddress, "$FRVER,1,0,GpsGate Server 1.0");
} else if (sentence.startsWith("$GPRMC,")) {
diff --git a/src/org/traccar/protocol/GpsMarkerProtocol.java b/src/org/traccar/protocol/GpsMarkerProtocol.java
index 5c64d16b2..0655d2c88 100644
--- a/src/org/traccar/protocol/GpsMarkerProtocol.java
+++ b/src/org/traccar/protocol/GpsMarkerProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class GpsMarkerProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\r"));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java b/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java
index ca5bdcbed..a6e39e353 100644
--- a/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsMarkerProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/GpsmtaProtocol.java b/src/org/traccar/protocol/GpsmtaProtocol.java
index 2d1181bec..b2720cb8a 100644
--- a/src/org/traccar/protocol/GpsmtaProtocol.java
+++ b/src/org/traccar/protocol/GpsmtaProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class GpsmtaProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new GpsmtaProtocolDecoder(GpsmtaProtocol.this));
diff --git a/src/org/traccar/protocol/GpsmtaProtocolDecoder.java b/src/org/traccar/protocol/GpsmtaProtocolDecoder.java
index c71162078..1d80178cb 100644
--- a/src/org/traccar/protocol/GpsmtaProtocolDecoder.java
+++ b/src/org/traccar/protocol/GpsmtaProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.model.Position;
@@ -81,7 +82,7 @@ public class GpsmtaProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_CHARGE, parser.nextInt(0) == 1);
if (channel != null) {
- channel.write(time, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(time, remoteAddress));
}
return position;
diff --git a/src/org/traccar/protocol/GranitFrameDecoder.java b/src/org/traccar/protocol/GranitFrameDecoder.java
index 7e8f4a3f5..bb7f4be44 100644
--- a/src/org/traccar/protocol/GranitFrameDecoder.java
+++ b/src/org/traccar/protocol/GranitFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,29 +15,29 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.traccar.helper.StringFinder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
+import org.traccar.helper.BufferUtil;
-public class GranitFrameDecoder extends FrameDecoder {
+public class GranitFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
- int indexEnd = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("\r\n"));
+ int indexEnd = BufferUtil.indexOf("\r\n", buf);
if (indexEnd != -1) {
- int indexTilde = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("~"));
+ int indexTilde = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '~');
if (indexTilde != -1 && indexTilde < indexEnd) {
- int length = buf.getUnsignedShort(indexTilde + 1);
- indexEnd = buf.indexOf(indexTilde + 2 + length, buf.writerIndex(), new StringFinder("\r\n"));
+ int length = buf.getUnsignedShortLE(indexTilde + 1);
+ indexEnd = BufferUtil.indexOf("\r\n", buf, indexTilde + 2 + length, buf.writerIndex());
if (indexEnd == -1) {
return null;
}
}
- ChannelBuffer frame = buf.readBytes(indexEnd - buf.readerIndex());
+ ByteBuf frame = buf.readRetainedSlice(indexEnd - buf.readerIndex());
buf.skipBytes(2);
return frame;
}
diff --git a/src/org/traccar/protocol/GranitProtocol.java b/src/org/traccar/protocol/GranitProtocol.java
index 32e8e00b0..5855d34ee 100644
--- a/src/org/traccar/protocol/GranitProtocol.java
+++ b/src/org/traccar/protocol/GranitProtocol.java
@@ -1,6 +1,6 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
- * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,13 +16,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
-import java.nio.ByteOrder;
import java.util.List;
public class GranitProtocol extends BaseProtocol {
@@ -41,16 +39,14 @@ public class GranitProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new GranitFrameDecoder());
pipeline.addLast("objectEncoder", new GranitProtocolEncoder());
pipeline.addLast("objectDecoder", new GranitProtocolDecoder(GranitProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/GranitProtocolDecoder.java b/src/org/traccar/protocol/GranitProtocolDecoder.java
index 50d879bb4..d4aa7e6e8 100644
--- a/src/org/traccar/protocol/GranitProtocolDecoder.java
+++ b/src/org/traccar/protocol/GranitProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,19 +15,18 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
-import org.traccar.helper.StringFinder;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
@@ -50,35 +49,35 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
adc4Ratio = Context.getConfig().getDouble("granit.adc4Ratio", 1);
}
- public static void appendChecksum(ChannelBuffer buffer, int length) {
+ public static void appendChecksum(ByteBuf buffer, int length) {
buffer.writeByte('*');
- int checksum = Checksum.xor(buffer.toByteBuffer(0, length)) & 0xFF;
+ int checksum = Checksum.xor(buffer.nioBuffer(0, length)) & 0xFF;
String checksumString = String.format("%02X", checksum);
buffer.writeBytes(checksumString.getBytes(StandardCharsets.US_ASCII));
buffer.writeByte('\r'); buffer.writeByte('\n');
}
private static void sendResponseCurrent(Channel channel, int deviceId, long time) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf response = Unpooled.buffer();
response.writeBytes("BB+UGRC~".getBytes(StandardCharsets.US_ASCII));
- response.writeShort(6); // length
+ response.writeShortLE(6); // length
response.writeInt((int) time);
- response.writeShort(deviceId);
+ response.writeShortLE(deviceId);
appendChecksum(response, 16);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
private static void sendResponseArchive(Channel channel, int deviceId, int packNum) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf response = Unpooled.buffer();
response.writeBytes("BB+ARCF~".getBytes(StandardCharsets.US_ASCII));
- response.writeShort(4); // length
- response.writeShort(packNum);
- response.writeShort(deviceId);
+ response.writeShortLE(4); // length
+ response.writeShortLE(packNum);
+ response.writeShortLE(deviceId);
appendChecksum(response, 14);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
- private void decodeStructure(ChannelBuffer buf, Position position) {
+ private void decodeStructure(ByteBuf buf, Position position) {
short flags = buf.readUnsignedByte();
position.setValid(BitUtil.check(flags, 7));
if (BitUtil.check(flags, 1)) {
@@ -93,8 +92,8 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
int lonDegrees = buf.readUnsignedByte();
int latDegrees = buf.readUnsignedByte();
- int lonMinutes = buf.readUnsignedShort();
- int latMinutes = buf.readUnsignedShort();
+ int lonMinutes = buf.readUnsignedShortLE();
+ int latMinutes = buf.readUnsignedShortLE();
double latitude = latDegrees + latMinutes / 60000.0;
double longitude = lonDegrees + lonMinutes / 60000.0;
@@ -119,7 +118,7 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
}
position.setCourse(course);
- position.set(Position.KEY_DISTANCE, buf.readShort());
+ position.set(Position.KEY_DISTANCE, buf.readShortLE());
int analogIn1 = buf.readUnsignedByte();
int analogIn2 = buf.readUnsignedByte();
@@ -150,9 +149,9 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
- int indexTilde = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("~"));
+ int indexTilde = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '~');
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
@@ -171,17 +170,17 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
if (buf.readableBytes() < HEADER_LENGTH) {
return null;
}
- String header = buf.readBytes(HEADER_LENGTH).toString(StandardCharsets.US_ASCII);
+ String header = buf.readSlice(HEADER_LENGTH).toString(StandardCharsets.US_ASCII);
if (header.equals("+RRCB~")) {
- buf.skipBytes(2); //binary length 26
- int deviceId = buf.readUnsignedShort();
+ buf.skipBytes(2); // binary length 26
+ int deviceId = buf.readUnsignedShortLE();
deviceSession = getDeviceSession(channel, remoteAddress, String.valueOf(deviceId));
if (deviceSession == null) {
return null;
}
- long unixTime = buf.readUnsignedInt();
+ long unixTime = buf.readUnsignedIntLE();
if (channel != null) {
sendResponseCurrent(channel, deviceId, unixTime);
}
@@ -195,8 +194,8 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
} else if (header.equals("+DDAT~")) {
- buf.skipBytes(2); //binary length
- int deviceId = buf.readUnsignedShort();
+ buf.skipBytes(2); // binary length
+ int deviceId = buf.readUnsignedShortLE();
deviceSession = getDeviceSession(channel, remoteAddress, String.valueOf(deviceId));
if (deviceSession == null) {
return null;
@@ -206,15 +205,15 @@ public class GranitProtocolDecoder extends BaseProtocolDecoder {
return null;
}
byte nblocks = buf.readByte();
- int packNum = buf.readUnsignedShort();
+ int packNum = buf.readUnsignedShortLE();
if (channel != null) {
sendResponseArchive(channel, deviceId, packNum);
}
List<Position> positions = new ArrayList<>();
while (nblocks > 0) {
nblocks--;
- long unixTime = buf.readUnsignedInt();
- int timeIncrement = buf.getUnsignedShort(buf.readerIndex() + 120);
+ long unixTime = buf.readUnsignedIntLE();
+ int timeIncrement = buf.getUnsignedShortLE(buf.readerIndex() + 120);
for (int i = 0; i < 6; i++) {
if (buf.getUnsignedByte(buf.readerIndex()) != 0xFE) {
Position position = new Position(getProtocolName());
diff --git a/src/org/traccar/protocol/GranitProtocolEncoder.java b/src/org/traccar/protocol/GranitProtocolEncoder.java
index dbfd30ff1..bde267ee6 100644
--- a/src/org/traccar/protocol/GranitProtocolEncoder.java
+++ b/src/org/traccar/protocol/GranitProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
- package org.traccar.protocol;
+package org.traccar.protocol;
import java.nio.charset.StandardCharsets;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Log;
import org.traccar.model.Command;
@@ -44,7 +44,7 @@ public class GranitProtocolEncoder extends BaseProtocolEncoder {
return null;
}
if (!commandString.isEmpty()) {
- ChannelBuffer commandBuf = ChannelBuffers.dynamicBuffer();
+ ByteBuf commandBuf = Unpooled.buffer();
commandBuf.writeBytes(commandString.getBytes(StandardCharsets.US_ASCII));
GranitProtocolDecoder.appendChecksum(commandBuf, commandString.length());
return commandBuf;
diff --git a/src/org/traccar/protocol/Gt02Protocol.java b/src/org/traccar/protocol/Gt02Protocol.java
index e484b66cd..f44cb3979 100644
--- a/src/org/traccar/protocol/Gt02Protocol.java
+++ b/src/org/traccar/protocol/Gt02Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -31,9 +30,9 @@ public class Gt02Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 1, 2, 0));
pipeline.addLast("objectDecoder", new Gt02ProtocolDecoder(Gt02Protocol.this));
}
diff --git a/src/org/traccar/protocol/Gt02ProtocolDecoder.java b/src/org/traccar/protocol/Gt02ProtocolDecoder.java
index a4f1a4161..ab4c7022e 100644
--- a/src/org/traccar/protocol/Gt02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt02ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
@@ -42,7 +44,7 @@ public class Gt02ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
buf.readByte(); // size
@@ -53,7 +55,7 @@ public class Gt02ProtocolDecoder extends BaseProtocolDecoder {
int power = buf.readUnsignedByte();
int gsm = buf.readUnsignedByte();
- String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1);
+ String imei = ByteBufUtil.hexDump(buf.readSlice(8)).substring(1);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession == null) {
return null;
@@ -73,7 +75,7 @@ public class Gt02ProtocolDecoder extends BaseProtocolDecoder {
if (channel != null) {
byte[] response = {0x54, 0x68, 0x1A, 0x0D, 0x0A};
- channel.write(ChannelBuffers.wrappedBuffer(response));
+ channel.writeAndFlush(new NetworkMessage(Unpooled.wrappedBuffer(response), remoteAddress));
}
} else if (type == MSG_DATA) {
@@ -108,7 +110,7 @@ public class Gt02ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
position.set(Position.KEY_RESULT,
- buf.readBytes(buf.readUnsignedByte()).toString(StandardCharsets.US_ASCII));
+ buf.readSlice(buf.readUnsignedByte()).toString(StandardCharsets.US_ASCII));
} else {
diff --git a/src/org/traccar/protocol/Gt06FrameDecoder.java b/src/org/traccar/protocol/Gt06FrameDecoder.java
index c8b5e56ae..cc934be42 100644
--- a/src/org/traccar/protocol/Gt06FrameDecoder.java
+++ b/src/org/traccar/protocol/Gt06FrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,16 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class Gt06FrameDecoder extends FrameDecoder {
+public class Gt06FrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 5) {
return null;
@@ -39,14 +39,14 @@ public class Gt06FrameDecoder extends FrameDecoder {
}
if (buf.readableBytes() >= length && buf.getUnsignedShort(buf.readerIndex() + length - 2) == 0x0d0a) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
int endIndex = buf.readerIndex() - 1;
do {
endIndex = buf.indexOf(endIndex + 1, buf.writerIndex(), (byte) 0x0d);
if (endIndex > 0 && buf.writerIndex() > endIndex + 1 && buf.getByte(endIndex + 1) == 0x0a) {
- return buf.readBytes(endIndex + 2 - buf.readerIndex());
+ return buf.readRetainedSlice(endIndex + 2 - buf.readerIndex());
}
} while (endIndex > 0);
diff --git a/src/org/traccar/protocol/Gt06Protocol.java b/src/org/traccar/protocol/Gt06Protocol.java
index f45ac95ee..e00a585ca 100644
--- a/src/org/traccar/protocol/Gt06Protocol.java
+++ b/src/org/traccar/protocol/Gt06Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -35,9 +34,9 @@ public class Gt06Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new Gt06FrameDecoder());
pipeline.addLast("objectEncoder", new Gt06ProtocolEncoder());
pipeline.addLast("objectDecoder", new Gt06ProtocolDecoder(Gt06Protocol.this));
diff --git a/src/org/traccar/protocol/Gt06ProtocolDecoder.java b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
index 3e5ebc8c5..fa4ed417d 100644
--- a/src/org/traccar/protocol/Gt06ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolDecoder.java
@@ -15,12 +15,14 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BcdUtil;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
@@ -44,7 +46,7 @@ import java.util.regex.Pattern;
public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
- private final Map<Integer, ChannelBuffer> photos = new HashMap<>();
+ private final Map<Integer, ByteBuf> photos = new HashMap<>();
public Gt06ProtocolDecoder(Gt06Protocol protocol) {
super(protocol);
@@ -162,9 +164,9 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void sendResponse(Channel channel, boolean extended, int type, int index, ChannelBuffer content) {
+ private void sendResponse(Channel channel, boolean extended, int type, int index, ByteBuf content) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
int length = 5 + (content != null ? content.readableBytes() : 0);
if (extended) {
response.writeShort(0x7979);
@@ -176,25 +178,26 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
response.writeByte(type);
if (content != null) {
response.writeBytes(content);
+ content.release();
}
response.writeShort(index);
response.writeShort(Checksum.crc16(Checksum.CRC16_X25,
- response.toByteBuffer(2, response.writerIndex() - 2)));
+ response.nioBuffer(2, response.writerIndex() - 2)));
response.writeByte('\r'); response.writeByte('\n'); // ending
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
private void sendPhotoRequest(Channel channel, int pictureId) {
- ChannelBuffer photo = photos.get(pictureId);
- ChannelBuffer content = ChannelBuffers.dynamicBuffer();
+ ByteBuf photo = photos.get(pictureId);
+ ByteBuf content = Unpooled.buffer();
content.writeInt(pictureId);
content.writeInt(photo.writerIndex());
content.writeShort(Math.min(photo.writableBytes(), 1024));
sendResponse(channel, false, MSG_X1_PHOTO_DATA, 0, content);
}
- private boolean decodeGps(Position position, ChannelBuffer buf, boolean hasLength, TimeZone timezone) {
+ private boolean decodeGps(Position position, ByteBuf buf, boolean hasLength, TimeZone timezone) {
DateBuilder dateBuilder = new DateBuilder(timezone)
.setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
@@ -232,7 +235,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return true;
}
- private boolean decodeLbs(Position position, ChannelBuffer buf, boolean hasLength) {
+ private boolean decodeLbs(Position position, ByteBuf buf, boolean hasLength) {
int length = 0;
if (hasLength) {
@@ -255,7 +258,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return true;
}
- private boolean decodeStatus(Position position, ChannelBuffer buf) {
+ private boolean decodeStatus(Position position, ByteBuf buf) {
int status = buf.readUnsignedByte();
@@ -367,7 +370,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private Object decodeBasic(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception {
+ private Object decodeBasic(Channel channel, SocketAddress remoteAddress, ByteBuf buf) throws Exception {
int length = buf.readUnsignedByte();
int dataLength = length - 5;
@@ -386,7 +389,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_LOGIN) {
- String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1);
+ String imei = ByteBufUtil.hexDump(buf.readSlice(8)).substring(1);
buf.readUnsignedShort(); // type
deviceSession = getDeviceSession(channel, remoteAddress, imei);
@@ -435,7 +438,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_ADDRESS_REQUEST) {
String response = "NA&&NA&&0##";
- ChannelBuffer content = ChannelBuffers.dynamicBuffer();
+ ByteBuf content = Unpooled.buffer();
content.writeByte(response.length());
content.writeInt(0);
content.writeBytes(response.getBytes(StandardCharsets.US_ASCII));
@@ -444,7 +447,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_TIME_REQUEST) {
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- ChannelBuffer content = ChannelBuffers.dynamicBuffer();
+ ByteBuf content = Unpooled.buffer();
content.writeByte(calendar.get(Calendar.YEAR) - 2000);
content.writeByte(calendar.get(Calendar.MONTH) + 1);
content.writeByte(calendar.get(Calendar.DAY_OF_MONTH));
@@ -482,7 +485,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // photo source
buf.readUnsignedByte(); // picture format
- ChannelBuffer photo = ChannelBuffers.buffer(buf.readInt());
+ ByteBuf photo = Unpooled.buffer(buf.readInt());
int pictureId = buf.readInt();
photos.put(pictureId, photo);
sendPhotoRequest(channel, pictureId);
@@ -500,7 +503,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- private Object decodeWifi(ChannelBuffer buf, DeviceSession deviceSession) throws Exception {
+ private Object decodeWifi(ByteBuf buf, DeviceSession deviceSession) throws Exception {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -537,7 +540,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private Object decodeBasicOther(Channel channel, ChannelBuffer buf,
+ private Object decodeBasicOther(Channel channel, ByteBuf buf,
DeviceSession deviceSession, int type, int dataLength) throws Exception {
Position position = new Position(getProtocolName());
@@ -571,7 +574,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
if (type != MSG_LBS_MULTIPLE && type != MSG_LBS_2) {
int wifiCount = buf.readUnsignedByte();
for (int i = 0; i < wifiCount; i++) {
- String mac = ChannelBuffers.hexDump(buf.readBytes(6)).replaceAll("(..)", "$1:");
+ String mac = ByteBufUtil.hexDump(buf.readSlice(6)).replaceAll("(..)", "$1:");
network.addWifiAccessPoint(WifiAccessPoint.from(
mac.substring(0, mac.length() - 1), buf.readUnsignedByte()));
}
@@ -588,7 +591,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
if (commandLength > 0) {
buf.readUnsignedByte(); // server flag (reserved)
position.set(Position.KEY_RESULT,
- buf.readBytes(commandLength - 1).toString(StandardCharsets.US_ASCII));
+ buf.readSlice(commandLength - 1).toString(StandardCharsets.US_ASCII));
}
} else if (isSupported(type)) {
@@ -619,7 +622,9 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
} else {
- buf.skipBytes(dataLength);
+ if (dataLength > 0) {
+ buf.skipBytes(dataLength);
+ }
if (type != MSG_COMMAND_0 && type != MSG_COMMAND_1 && type != MSG_COMMAND_2) {
sendResponse(channel, false, type, buf.getShort(buf.writerIndex() - 6), null);
}
@@ -640,7 +645,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private Object decodeExtended(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception {
+ private Object decodeExtended(Channel channel, SocketAddress remoteAddress, ByteBuf buf) throws Exception {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress);
if (deviceSession == null) {
@@ -662,9 +667,9 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedInt(); // server flag
String data;
if (buf.readUnsignedByte() == 1) {
- data = buf.readBytes(buf.readableBytes() - 6).toString(StandardCharsets.US_ASCII);
+ data = buf.readSlice(buf.readableBytes() - 6).toString(StandardCharsets.US_ASCII);
} else {
- data = buf.readBytes(buf.readableBytes() - 6).toString(StandardCharsets.UTF_16BE);
+ data = buf.readSlice(buf.readableBytes() - 6).toString(StandardCharsets.UTF_16BE);
}
if (decodeLocationString(position, data) == null) {
@@ -704,7 +709,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
int pictureId = buf.readInt();
- ChannelBuffer photo = photos.get(pictureId);
+ ByteBuf photo = photos.get(pictureId);
buf.readUnsignedInt(); // offset
buf.readBytes(photo, buf.readUnsignedShort());
@@ -715,7 +720,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
Device device = Context.getDeviceManager().getById(deviceSession.getDeviceId());
position.set(
Position.KEY_IMAGE, Context.getMediaManager().writeFile(device.getUniqueId(), photo, "jpg"));
- photos.remove(pictureId);
+ photos.remove(pictureId).release();
}
} else if (type == MSG_AZ735_GPS || type == MSG_AZ735_ALARM) {
@@ -772,7 +777,7 @@ public class Gt06ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
int header = buf.readShort();
diff --git a/src/org/traccar/protocol/Gt06ProtocolEncoder.java b/src/org/traccar/protocol/Gt06ProtocolEncoder.java
index daf045f4f..46b4fa5a4 100644
--- a/src/org/traccar/protocol/Gt06ProtocolEncoder.java
+++ b/src/org/traccar/protocol/Gt06ProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.Context;
import org.traccar.helper.Checksum;
@@ -27,11 +27,11 @@ import java.nio.charset.StandardCharsets;
public class Gt06ProtocolEncoder extends BaseProtocolEncoder {
- private ChannelBuffer encodeContent(long deviceId, String content) {
+ private ByteBuf encodeContent(long deviceId, String content) {
boolean language = Context.getIdentityManager().lookupAttributeBoolean(deviceId, "gt06.language", false, true);
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ ByteBuf buf = Unpooled.buffer();
buf.writeByte(0x78);
buf.writeByte(0x78);
@@ -50,7 +50,7 @@ public class Gt06ProtocolEncoder extends BaseProtocolEncoder {
buf.writeShort(0); // message index
- buf.writeShort(Checksum.crc16(Checksum.CRC16_X25, buf.toByteBuffer(2, buf.writerIndex() - 2)));
+ buf.writeShort(Checksum.crc16(Checksum.CRC16_X25, buf.nioBuffer(2, buf.writerIndex() - 2)));
buf.writeByte('\r');
buf.writeByte('\n');
diff --git a/src/org/traccar/protocol/Gt30Protocol.java b/src/org/traccar/protocol/Gt30Protocol.java
index 186002a35..43bb5a70b 100644
--- a/src/org/traccar/protocol/Gt30Protocol.java
+++ b/src/org/traccar/protocol/Gt30Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class Gt30Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/Gt30ProtocolDecoder.java b/src/org/traccar/protocol/Gt30ProtocolDecoder.java
index 27081a108..ac1557994 100644
--- a/src/org/traccar/protocol/Gt30ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Gt30ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/H02FrameDecoder.java b/src/org/traccar/protocol/H02FrameDecoder.java
index 391fccc87..583ad599f 100644
--- a/src/org/traccar/protocol/H02FrameDecoder.java
+++ b/src/org/traccar/protocol/H02FrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class H02FrameDecoder extends FrameDecoder {
+public class H02FrameDecoder extends BaseFrameDecoder {
private static final int MESSAGE_SHORT = 32;
private static final int MESSAGE_LONG = 45;
@@ -33,7 +33,7 @@ public class H02FrameDecoder extends FrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
char marker = (char) buf.getByte(buf.readerIndex());
@@ -50,8 +50,8 @@ public class H02FrameDecoder extends FrameDecoder {
// Return text message
int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '#');
if (index != -1) {
- ChannelBuffer result = buf.readBytes(index + 1 - buf.readerIndex());
- while (buf.readable()
+ ByteBuf result = buf.readRetainedSlice(index + 1 - buf.readerIndex());
+ while (buf.isReadable()
&& (buf.getByte(buf.readerIndex()) == '\r' || buf.getByte(buf.readerIndex()) == '\n')) {
buf.readByte(); // skip new line
}
@@ -71,7 +71,7 @@ public class H02FrameDecoder extends FrameDecoder {
}
if (buf.readableBytes() >= messageLength) {
- return buf.readBytes(messageLength);
+ return buf.readRetainedSlice(messageLength);
}
break;
@@ -79,7 +79,7 @@ public class H02FrameDecoder extends FrameDecoder {
case 'X':
if (buf.readableBytes() >= MESSAGE_SHORT) {
- return buf.readBytes(MESSAGE_SHORT);
+ return buf.readRetainedSlice(MESSAGE_SHORT);
}
break;
diff --git a/src/org/traccar/protocol/H02Protocol.java b/src/org/traccar/protocol/H02Protocol.java
index 66965e9db..29ac89f78 100644
--- a/src/org/traccar/protocol/H02Protocol.java
+++ b/src/org/traccar/protocol/H02Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.Context;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -41,9 +39,9 @@ public class H02Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
int messageLength = Context.getConfig().getInteger(getName() + ".messageLength");
pipeline.addLast("frameDecoder", new H02FrameDecoder(messageLength));
pipeline.addLast("stringEncoder", new StringEncoder());
@@ -51,9 +49,9 @@ public class H02Protocol extends BaseProtocol {
pipeline.addLast("objectDecoder", new H02ProtocolDecoder(H02Protocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new H02ProtocolEncoder());
pipeline.addLast("objectDecoder", new H02ProtocolDecoder(H02Protocol.this));
diff --git a/src/org/traccar/protocol/H02ProtocolDecoder.java b/src/org/traccar/protocol/H02ProtocolDecoder.java
index 54671bdbf..2abde7d6f 100644
--- a/src/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/org/traccar/protocol/H02ProtocolDecoder.java
@@ -15,9 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BcdUtil;
@@ -40,7 +40,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private static double readCoordinate(ChannelBuffer buf, boolean lon) {
+ private static double readCoordinate(ByteBuf buf, boolean lon) {
int degrees = BcdUtil.readInteger(buf, 2);
if (lon) {
@@ -99,14 +99,14 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
}
}
- private Position decodeBinary(ChannelBuffer buf, Channel channel, SocketAddress remoteAddress) {
+ private Position decodeBinary(ByteBuf buf, Channel channel, SocketAddress remoteAddress) {
Position position = new Position(getProtocolName());
buf.readByte(); // marker
DeviceSession deviceSession = getDeviceSession(
- channel, remoteAddress, ChannelBuffers.hexDump(buf.readBytes(5)));
+ channel, remoteAddress, ByteBufUtil.hexDump(buf.readSlice(5)));
if (deviceSession == null) {
return null;
}
@@ -451,7 +451,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
String marker = buf.toString(0, 1, StandardCharsets.US_ASCII);
switch (marker) {
diff --git a/src/org/traccar/protocol/H02ProtocolEncoder.java b/src/org/traccar/protocol/H02ProtocolEncoder.java
index 7b5ff13bb..fb418dbab 100644
--- a/src/org/traccar/protocol/H02ProtocolEncoder.java
+++ b/src/org/traccar/protocol/H02ProtocolEncoder.java
@@ -1,6 +1,6 @@
/*
* Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com)
- * 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/src/org/traccar/protocol/HaicomProtocol.java b/src/org/traccar/protocol/HaicomProtocol.java
index 4380dd2cc..45bf9f890 100644
--- a/src/org/traccar/protocol/HaicomProtocol.java
+++ b/src/org/traccar/protocol/HaicomProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class HaicomProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '*'));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/HaicomProtocolDecoder.java b/src/org/traccar/protocol/HaicomProtocolDecoder.java
index 94ec93cfb..b828b5a16 100644
--- a/src/org/traccar/protocol/HaicomProtocolDecoder.java
+++ b/src/org/traccar/protocol/HaicomProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
diff --git a/src/org/traccar/protocol/HomtecsProtocol.java b/src/org/traccar/protocol/HomtecsProtocol.java
index a9ea19c51..e57cb96be 100644
--- a/src/org/traccar/protocol/HomtecsProtocol.java
+++ b/src/org/traccar/protocol/HomtecsProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class HomtecsProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new HomtecsProtocolDecoder(HomtecsProtocol.this));
diff --git a/src/org/traccar/protocol/HomtecsProtocolDecoder.java b/src/org/traccar/protocol/HomtecsProtocolDecoder.java
index f4ae54d1f..80294795e 100644
--- a/src/org/traccar/protocol/HomtecsProtocolDecoder.java
+++ b/src/org/traccar/protocol/HomtecsProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/HuaShengFrameDecoder.java b/src/org/traccar/protocol/HuaShengFrameDecoder.java
index 4c29b7915..bd52aa9e7 100644
--- a/src/org/traccar/protocol/HuaShengFrameDecoder.java
+++ b/src/org/traccar/protocol/HuaShengFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,19 +15,17 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class HuaShengFrameDecoder extends FrameDecoder {
+public class HuaShengFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 2) {
return null;
@@ -35,7 +33,7 @@ public class HuaShengFrameDecoder extends FrameDecoder {
int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0xC0);
if (index != -1) {
- ChannelBuffer result = ChannelBuffers.buffer(index + 1 - buf.readerIndex());
+ ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex());
while (buf.readerIndex() <= index) {
int b = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/HuaShengProtocol.java b/src/org/traccar/protocol/HuaShengProtocol.java
index e0fddae20..b1f187e14 100644
--- a/src/org/traccar/protocol/HuaShengProtocol.java
+++ b/src/org/traccar/protocol/HuaShengProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class HuaShengProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new HuaShengFrameDecoder());
pipeline.addLast("objectDecoder", new HuaShengProtocolDecoder(HuaShengProtocol.this));
}
diff --git a/src/org/traccar/protocol/HuaShengProtocolDecoder.java b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
index 88f23b28c..ae57ef296 100644
--- a/src/org/traccar/protocol/HuaShengProtocolDecoder.java
+++ b/src/org/traccar/protocol/HuaShengProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
@@ -41,9 +42,9 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_HSO_REQ = 0x0002;
public static final int MSG_HSO_RSP = 0x0003;
- private void sendResponse(Channel channel, int type, int index, ChannelBuffer content) {
+ private void sendResponse(Channel channel, int type, int index, ByteBuf content) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeByte(0xC0);
response.writeShort(0x0100);
response.writeShort(12 + (content != null ? content.readableBytes() : 0));
@@ -52,9 +53,10 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
response.writeInt(index);
if (content != null) {
response.writeBytes(content);
+ content.release();
}
response.writeByte(0xC0);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
@@ -62,7 +64,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(1); // start marker
buf.readUnsignedByte(); // flag
@@ -80,10 +82,10 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
int subtype = buf.readUnsignedShort();
int length = buf.readUnsignedShort() - 4;
if (subtype == 0x0003) {
- String imei = buf.readBytes(length).toString(StandardCharsets.US_ASCII);
+ String imei = buf.readSlice(length).toString(StandardCharsets.US_ASCII);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession != null && channel != null) {
- ChannelBuffer content = ChannelBuffers.dynamicBuffer();
+ ByteBuf content = Unpooled.buffer();
content.writeByte(0); // success
sendResponse(channel, MSG_LOGIN_RSP, index, content);
}
@@ -114,7 +116,7 @@ public class HuaShengProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_IGNITION, BitUtil.check(status, 14));
position.set(Position.KEY_EVENT, buf.readUnsignedShort());
- String time = buf.readBytes(12).toString(StandardCharsets.US_ASCII);
+ String time = buf.readSlice(12).toString(StandardCharsets.US_ASCII);
DateBuilder dateBuilder = new DateBuilder()
.setYear(Integer.parseInt(time.substring(0, 2)))
diff --git a/src/org/traccar/protocol/HuabaoFrameDecoder.java b/src/org/traccar/protocol/HuabaoFrameDecoder.java
index 8e9c9fe72..b520f6be9 100644
--- a/src/org/traccar/protocol/HuabaoFrameDecoder.java
+++ b/src/org/traccar/protocol/HuabaoFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,17 +15,17 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class HuabaoFrameDecoder extends FrameDecoder {
+public class HuabaoFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 2) {
return null;
@@ -33,7 +33,7 @@ public class HuabaoFrameDecoder extends FrameDecoder {
int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0x7e);
if (index != -1) {
- ChannelBuffer result = ChannelBuffers.buffer(index + 1 - buf.readerIndex());
+ ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex());
while (buf.readerIndex() <= index) {
int b = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/HuabaoProtocol.java b/src/org/traccar/protocol/HuabaoProtocol.java
index c74cb58c7..113aa4b62 100644
--- a/src/org/traccar/protocol/HuabaoProtocol.java
+++ b/src/org/traccar/protocol/HuabaoProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -34,9 +33,9 @@ public class HuabaoProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new HuabaoFrameDecoder());
pipeline.addLast("objectEncoder", new HuabaoProtocolEncoder());
pipeline.addLast("objectDecoder", new HuabaoProtocolDecoder(HuabaoProtocol.this));
diff --git a/src/org/traccar/protocol/HuabaoProtocolDecoder.java b/src/org/traccar/protocol/HuabaoProtocolDecoder.java
index 8643f39af..afb29e3c3 100644
--- a/src/org/traccar/protocol/HuabaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/HuabaoProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BcdUtil;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
@@ -46,27 +48,29 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
public static final int RESULT_SUCCESS = 0;
- public static ChannelBuffer formatMessage(int type, ChannelBuffer id, ChannelBuffer data) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ public static ByteBuf formatMessage(int type, ByteBuf id, ByteBuf data) {
+ ByteBuf buf = Unpooled.buffer();
buf.writeByte(0x7e);
buf.writeShort(type);
buf.writeShort(data.readableBytes());
buf.writeBytes(id);
buf.writeShort(1); // index
buf.writeBytes(data);
- buf.writeByte(Checksum.xor(buf.toByteBuffer(1, buf.readableBytes() - 1)));
+ data.release();
+ buf.writeByte(Checksum.xor(buf.nioBuffer(1, buf.readableBytes() - 1)));
buf.writeByte(0x7e);
return buf;
}
private void sendGeneralResponse(
- Channel channel, SocketAddress remoteAddress, ChannelBuffer id, int type, int index) {
+ Channel channel, SocketAddress remoteAddress, ByteBuf id, int type, int index) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeShort(index);
response.writeShort(type);
response.writeByte(RESULT_SUCCESS);
- channel.write(formatMessage(MSG_GENERAL_RESPONSE, id, response), remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(
+ formatMessage(MSG_GENERAL_RESPONSE, id, response), remoteAddress));
}
}
@@ -100,15 +104,15 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.readUnsignedByte(); // start marker
int type = buf.readUnsignedShort();
buf.readUnsignedShort(); // body length
- ChannelBuffer id = buf.readBytes(6); // phone number
+ ByteBuf id = buf.readSlice(6); // phone number
int index = buf.readUnsignedShort();
- DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, ChannelBuffers.hexDump(id));
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, ByteBufUtil.hexDump(id));
if (deviceSession == null) {
return null;
}
@@ -116,11 +120,12 @@ public class HuabaoProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_TERMINAL_REGISTER) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeShort(index);
response.writeByte(RESULT_SUCCESS);
response.writeBytes("authentication".getBytes(StandardCharsets.US_ASCII));
- channel.write(formatMessage(MSG_TERMINAL_REGISTER_RESPONSE, id, response), remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(
+ formatMessage(MSG_TERMINAL_REGISTER_RESPONSE, id, response), remoteAddress));
}
} else if (type == MSG_TERMINAL_AUTH) {
diff --git a/src/org/traccar/protocol/HuabaoProtocolEncoder.java b/src/org/traccar/protocol/HuabaoProtocolEncoder.java
index d1889bf5e..a622fdb9a 100644
--- a/src/org/traccar/protocol/HuabaoProtocolEncoder.java
+++ b/src/org/traccar/protocol/HuabaoProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.DataConverter;
import org.traccar.helper.Log;
@@ -30,10 +30,10 @@ public class HuabaoProtocolEncoder extends BaseProtocolEncoder {
@Override
protected Object encodeCommand(Command command) {
- ChannelBuffer id = ChannelBuffers.wrappedBuffer(
- DataConverter.parseHex(getUniqueId(command.getDeviceId())));
+ ByteBuf id = Unpooled.wrappedBuffer(
+ DataConverter.parseHex(getUniqueId(command.getDeviceId()))); // TODO ref count
- ChannelBuffer data = ChannelBuffers.dynamicBuffer();
+ ByteBuf data = Unpooled.buffer();
byte[] time = DataConverter.parseHex(new SimpleDateFormat("yyMMddHHmmss").format(new Date()));
switch (command.getType()) {
diff --git a/src/org/traccar/protocol/HunterProProtocol.java b/src/org/traccar/protocol/HunterProProtocol.java
index 17352a0f3..8b81e8f22 100644
--- a/src/org/traccar/protocol/HunterProProtocol.java
+++ b/src/org/traccar/protocol/HunterProProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class HunterProProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "\r"));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/HunterProProtocolDecoder.java b/src/org/traccar/protocol/HunterProProtocolDecoder.java
index fa470c065..c166d151d 100644
--- a/src/org/traccar/protocol/HunterProProtocolDecoder.java
+++ b/src/org/traccar/protocol/HunterProProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/IdplProtocol.java b/src/org/traccar/protocol/IdplProtocol.java
index f90d3fe7f..2275aaeb2 100644
--- a/src/org/traccar/protocol/IdplProtocol.java
+++ b/src/org/traccar/protocol/IdplProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,12 +17,11 @@ package org.traccar.protocol;
import java.util.List;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
public class IdplProtocol extends BaseProtocol {
@@ -33,9 +32,9 @@ public class IdplProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/IdplProtocolDecoder.java b/src/org/traccar/protocol/IdplProtocolDecoder.java
index 9990e0da5..cf3c03d7f 100644
--- a/src/org/traccar/protocol/IdplProtocolDecoder.java
+++ b/src/org/traccar/protocol/IdplProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ package org.traccar.protocol;
import java.net.SocketAddress;
import java.util.regex.Pattern;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.Protocol;
diff --git a/src/org/traccar/protocol/IntellitracFrameDecoder.java b/src/org/traccar/protocol/IntellitracFrameDecoder.java
index 49f8b4a5d..8322e65ba 100644
--- a/src/org/traccar/protocol/IntellitracFrameDecoder.java
+++ b/src/org/traccar/protocol/IntellitracFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import org.traccar.NetworkMessage;
public class IntellitracFrameDecoder extends LineBasedFrameDecoder {
@@ -31,7 +31,7 @@ public class IntellitracFrameDecoder extends LineBasedFrameDecoder {
// example of sync header: 0xFA 0xF8 0x1B 0x01 0x81 0x60 0x33 0x3C
@Override
- protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ protected Object decode(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
// Check minimum length
if (buf.readableBytes() < MESSAGE_MINIMUM_LENGTH) {
@@ -40,13 +40,13 @@ public class IntellitracFrameDecoder extends LineBasedFrameDecoder {
// Check for sync packet
if (buf.getUnsignedShort(buf.readerIndex()) == 0xFAF8) {
- ChannelBuffer syncMessage = buf.readBytes(8);
- if (channel != null) {
- channel.write(syncMessage);
+ ByteBuf syncMessage = buf.readRetainedSlice(8);
+ if (ctx != null && ctx.channel() != null) {
+ ctx.channel().writeAndFlush(new NetworkMessage(syncMessage, ctx.channel().remoteAddress()));
}
}
- return super.decode(ctx, channel, buf);
+ return super.decode(ctx, buf);
}
}
diff --git a/src/org/traccar/protocol/IntellitracProtocol.java b/src/org/traccar/protocol/IntellitracProtocol.java
index 2d9421636..fc954625a 100644
--- a/src/org/traccar/protocol/IntellitracProtocol.java
+++ b/src/org/traccar/protocol/IntellitracProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class IntellitracProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new IntellitracFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/IntellitracProtocolDecoder.java b/src/org/traccar/protocol/IntellitracProtocolDecoder.java
index 5b66fa7ec..58898f8fd 100644
--- a/src/org/traccar/protocol/IntellitracProtocolDecoder.java
+++ b/src/org/traccar/protocol/IntellitracProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/Ivt401Protocol.java b/src/org/traccar/protocol/Ivt401Protocol.java
index b58601ba1..dce0f2b79 100644
--- a/src/org/traccar/protocol/Ivt401Protocol.java
+++ b/src/org/traccar/protocol/Ivt401Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringDecoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class Ivt401Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';'));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new Ivt401ProtocolDecoder(Ivt401Protocol.this));
diff --git a/src/org/traccar/protocol/Ivt401ProtocolDecoder.java b/src/org/traccar/protocol/Ivt401ProtocolDecoder.java
index d2f1d3d69..38dacb02b 100644
--- a/src/org/traccar/protocol/Ivt401ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Ivt401ProtocolDecoder.java
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/JpKorjarFrameDecoder.java b/src/org/traccar/protocol/JpKorjarFrameDecoder.java
index 33a1b3f36..0eb65c8ef 100644
--- a/src/org/traccar/protocol/JpKorjarFrameDecoder.java
+++ b/src/org/traccar/protocol/JpKorjarFrameDecoder.java
@@ -1,5 +1,6 @@
/*
* Copyright 2016 Nyash (nyashh@gmail.com)
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +16,16 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class JpKorjarFrameDecoder extends FrameDecoder {
+public class JpKorjarFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 80) {
return null;
@@ -40,7 +41,7 @@ public class JpKorjarFrameDecoder extends FrameDecoder {
return null;
}
- return buf.readBytes(endIndex + 1);
+ return buf.readRetainedSlice(endIndex + 1);
}
}
diff --git a/src/org/traccar/protocol/JpKorjarProtocol.java b/src/org/traccar/protocol/JpKorjarProtocol.java
index c54994708..020575a7d 100644
--- a/src/org/traccar/protocol/JpKorjarProtocol.java
+++ b/src/org/traccar/protocol/JpKorjarProtocol.java
@@ -1,5 +1,6 @@
/*
* Copyright 2016 Nyash (nyashh@gmail.com)
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +16,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -31,10 +31,9 @@ public class JpKorjarProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), this.getName()) {
+ serverList.add(new TrackerServer(false, this.getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
-
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new JpKorjarFrameDecoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new JpKorjarProtocolDecoder(JpKorjarProtocol.this));
diff --git a/src/org/traccar/protocol/JpKorjarProtocolDecoder.java b/src/org/traccar/protocol/JpKorjarProtocolDecoder.java
index 8766115ce..860e3ea23 100644
--- a/src/org/traccar/protocol/JpKorjarProtocolDecoder.java
+++ b/src/org/traccar/protocol/JpKorjarProtocolDecoder.java
@@ -1,6 +1,6 @@
/*
* Copyright 2016 Nyash (nyashh@gmail.com)
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/Jt600FrameDecoder.java b/src/org/traccar/protocol/Jt600FrameDecoder.java
index 261f46fe8..b5d060ecc 100644
--- a/src/org/traccar/protocol/Jt600FrameDecoder.java
+++ b/src/org/traccar/protocol/Jt600FrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,18 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
import java.text.ParseException;
-public class Jt600FrameDecoder extends FrameDecoder {
+public class Jt600FrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 10) {
return null;
@@ -38,12 +38,12 @@ public class Jt600FrameDecoder extends FrameDecoder {
boolean longFormat = buf.getUnsignedByte(buf.readerIndex() + 1) == 0x75;
int length = buf.getUnsignedShort(buf.readerIndex() + (longFormat ? 8 : 7)) + 10;
if (length <= buf.readableBytes()) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
} else if (type == '(') {
int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ')');
if (endIndex != -1) {
- return buf.readBytes(endIndex + 1);
+ return buf.readRetainedSlice(endIndex + 1);
}
} else {
throw new ParseException(null, 0); // unknown message
diff --git a/src/org/traccar/protocol/Jt600Protocol.java b/src/org/traccar/protocol/Jt600Protocol.java
index 8c71ca4f6..17fd4cb6b 100644
--- a/src/org/traccar/protocol/Jt600Protocol.java
+++ b/src/org/traccar/protocol/Jt600Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -37,9 +36,9 @@ public class Jt600Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new Jt600FrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new Jt600ProtocolEncoder());
diff --git a/src/org/traccar/protocol/Jt600ProtocolDecoder.java b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
index 5a53f362a..87996a0c3 100644
--- a/src/org/traccar/protocol/Jt600ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolDecoder.java
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BcdUtil;
import org.traccar.helper.BitBuffer;
import org.traccar.helper.BitUtil;
@@ -49,7 +50,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
return degrees + minutes / 60;
}
- private void decodeStatus(Position position, ChannelBuffer buf) {
+ private void decodeStatus(Position position, ByteBuf buf) {
int value = buf.readUnsignedByte();
@@ -84,7 +85,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
}
- private List<Position> decodeBinary(ChannelBuffer buf, Channel channel, SocketAddress remoteAddress) {
+ private List<Position> decodeBinary(ByteBuf buf, Channel channel, SocketAddress remoteAddress) {
List<Position> positions = new LinkedList<>();
@@ -92,7 +93,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
boolean longFormat = buf.getUnsignedByte(buf.readerIndex()) == 0x75;
- String id = String.valueOf(Long.parseLong(ChannelBuffers.hexDump(buf.readBytes(5))));
+ String id = String.valueOf(Long.parseLong(ByteBufUtil.hexDump(buf.readSlice(5))));
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id);
if (deviceSession == null) {
return null;
@@ -332,9 +333,9 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
if (channel != null) {
if (type.equals("U01") || type.equals("U02") || type.equals("U03")) {
- channel.write("(S39)");
+ channel.writeAndFlush(new NetworkMessage("(S39)", remoteAddress));
} else if (type.equals("U06")) {
- channel.write("(S20)");
+ channel.writeAndFlush(new NetworkMessage("(S20)", remoteAddress));
}
}
@@ -345,7 +346,7 @@ public class Jt600ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
char first = (char) buf.getByte(0);
if (first == '$') {
diff --git a/src/org/traccar/protocol/Jt600ProtocolEncoder.java b/src/org/traccar/protocol/Jt600ProtocolEncoder.java
index 377f104a3..1d868cbcf 100644
--- a/src/org/traccar/protocol/Jt600ProtocolEncoder.java
+++ b/src/org/traccar/protocol/Jt600ProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import org.traccar.helper.Log;
import org.traccar.model.Command;
public class Jt600ProtocolEncoder extends StringProtocolEncoder {
+
@Override
protected Object encodeCommand(Command command) {
@@ -42,4 +43,5 @@ public class Jt600ProtocolEncoder extends StringProtocolEncoder {
return null;
}
+
}
diff --git a/src/org/traccar/protocol/KenjiProtocol.java b/src/org/traccar/protocol/KenjiProtocol.java
index 8b196a9ed..15eb3d77a 100644
--- a/src/org/traccar/protocol/KenjiProtocol.java
+++ b/src/org/traccar/protocol/KenjiProtocol.java
@@ -1,5 +1,6 @@
/*
- * Copyright 2016 by Carlos Alvarez (carlos.alvarez.rozas@gmail.com)
+ * Copyright 2016 Carlos Alvarez (carlos.alvarez.rozas@gmail.com)
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +16,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -31,12 +31,11 @@ public class KenjiProtocol extends BaseProtocol {
super("kenji");
}
-
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/KenjiProtocolDecoder.java b/src/org/traccar/protocol/KenjiProtocolDecoder.java
index 374cb9c25..1fe1b6b9f 100644
--- a/src/org/traccar/protocol/KenjiProtocolDecoder.java
+++ b/src/org/traccar/protocol/KenjiProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
diff --git a/src/org/traccar/protocol/KhdProtocol.java b/src/org/traccar/protocol/KhdProtocol.java
index 167727191..47a30de5a 100644
--- a/src/org/traccar/protocol/KhdProtocol.java
+++ b/src/org/traccar/protocol/KhdProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -35,9 +34,9 @@ public class KhdProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(512, 3, 2));
pipeline.addLast("objectEncoder", new KhdProtocolEncoder());
pipeline.addLast("objectDecoder", new KhdProtocolDecoder(KhdProtocol.this));
diff --git a/src/org/traccar/protocol/KhdProtocolDecoder.java b/src/org/traccar/protocol/KhdProtocolDecoder.java
index 2f29a16f8..6aa4add9e 100644
--- a/src/org/traccar/protocol/KhdProtocolDecoder.java
+++ b/src/org/traccar/protocol/KhdProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BcdUtil;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
@@ -34,7 +35,7 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private String readSerialNumber(ChannelBuffer buf) {
+ private String readSerialNumber(ByteBuf buf) {
int b1 = buf.readUnsignedByte();
int b2 = buf.readUnsignedByte() - 0x80;
int b3 = buf.readUnsignedByte() - 0x80;
@@ -55,7 +56,7 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
int type = buf.readUnsignedByte();
@@ -129,16 +130,16 @@ public class KhdProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(4); // serial number
buf.readByte(); // reserved
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeByte(0x29); response.writeByte(0x29); // header
response.writeByte(MSG_CONFIRMATION);
response.writeShort(5); // size
response.writeByte(buf.readUnsignedByte());
response.writeByte(type);
response.writeByte(0); // reserved
- response.writeByte(Checksum.xor(response.toByteBuffer()));
+ response.writeByte(Checksum.xor(response.nioBuffer()));
response.writeByte(0x0D); // ending
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
diff --git a/src/org/traccar/protocol/KhdProtocolEncoder.java b/src/org/traccar/protocol/KhdProtocolEncoder.java
index cb26c757a..9c0f0b67a 100644
--- a/src/org/traccar/protocol/KhdProtocolEncoder.java
+++ b/src/org/traccar/protocol/KhdProtocolEncoder.java
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Checksum;
import org.traccar.helper.Log;
@@ -27,9 +27,9 @@ public class KhdProtocolEncoder extends BaseProtocolEncoder {
public static final int MSG_CUT_OIL = 0x39;
public static final int MSG_RESUME_OIL = 0x38;
- private ChannelBuffer encodeCommand(int command, String uniqueId) {
+ private ByteBuf encodeCommand(int command, String uniqueId) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ ByteBuf buf = Unpooled.buffer();
buf.writeByte(0x29);
buf.writeByte(0x29);
@@ -44,7 +44,7 @@ public class KhdProtocolEncoder extends BaseProtocolEncoder {
buf.writeByte(Integer.parseInt(uniqueId.substring(4, 6)) + 0x80);
buf.writeByte(Integer.parseInt(uniqueId.substring(6, 8)));
- buf.writeByte(Checksum.xor(buf.toByteBuffer()));
+ buf.writeByte(Checksum.xor(buf.nioBuffer()));
buf.writeByte(0x0D); // ending
return buf;
diff --git a/src/org/traccar/protocol/L100FrameDecoder.java b/src/org/traccar/protocol/L100FrameDecoder.java
index c8a520772..b7caa14f4 100644
--- a/src/org/traccar/protocol/L100FrameDecoder.java
+++ b/src/org/traccar/protocol/L100FrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,16 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class L100FrameDecoder extends FrameDecoder {
+public class L100FrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 10) {
return null;
@@ -52,7 +52,7 @@ public class L100FrameDecoder extends FrameDecoder {
if (!obd) {
buf.skipBytes(2); // header
}
- ChannelBuffer frame = buf.readBytes(index - buf.readerIndex() - 2);
+ ByteBuf frame = buf.readRetainedSlice(index - buf.readerIndex() - 2);
buf.skipBytes(2); // footer
return frame;
}
diff --git a/src/org/traccar/protocol/L100Protocol.java b/src/org/traccar/protocol/L100Protocol.java
index 245f073fb..2d29bee40 100644
--- a/src/org/traccar/protocol/L100Protocol.java
+++ b/src/org/traccar/protocol/L100Protocol.java
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class L100Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new L100FrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/L100ProtocolDecoder.java b/src/org/traccar/protocol/L100ProtocolDecoder.java
index 5842b35b6..7c652c95a 100644
--- a/src/org/traccar/protocol/L100ProtocolDecoder.java
+++ b/src/org/traccar/protocol/L100ProtocolDecoder.java
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Checksum;
diff --git a/src/org/traccar/protocol/LaipacProtocol.java b/src/org/traccar/protocol/LaipacProtocol.java
index 45b803a0f..aafada331 100644
--- a/src/org/traccar/protocol/LaipacProtocol.java
+++ b/src/org/traccar/protocol/LaipacProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class LaipacProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/LaipacProtocolDecoder.java b/src/org/traccar/protocol/LaipacProtocolDecoder.java
index bfaff9ec4..8634a0e32 100644
--- a/src/org/traccar/protocol/LaipacProtocolDecoder.java
+++ b/src/org/traccar/protocol/LaipacProtocolDecoder.java
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
@@ -93,7 +94,7 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
String sentence = (String) msg;
if (sentence.startsWith("$ECHK") && channel != null) {
- channel.write(sentence + "\r\n"); // heartbeat
+ channel.writeAndFlush(new NetworkMessage(sentence + "\r\n", remoteAddress)); // heartbeat
return null;
}
@@ -146,15 +147,15 @@ public class LaipacProtocolDecoder extends BaseProtocolDecoder {
if (channel != null) {
if (event.equals("3")) {
- channel.write("$AVCFG,00000000,d*31\r\n");
+ channel.writeAndFlush(new NetworkMessage("$AVCFG,00000000,d*31\r\n", remoteAddress));
} else if (event.equals("X") || event.equals("4")) {
- channel.write("$AVCFG,00000000,x*2D\r\n");
+ channel.writeAndFlush(new NetworkMessage("$AVCFG,00000000,x*2D\r\n", remoteAddress));
} else if (event.equals("Z")) {
- channel.write("$AVCFG,00000000,z*2F\r\n");
+ channel.writeAndFlush(new NetworkMessage("$AVCFG,00000000,z*2F\r\n", remoteAddress));
} else if (Character.isLowerCase(status.charAt(0))) {
String response = "$EAVACK," + event + "," + checksum;
response += Checksum.nmea(response) + "\r\n";
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
diff --git a/src/org/traccar/protocol/M2cProtocol.java b/src/org/traccar/protocol/M2cProtocol.java
index 2c3187095..ef16108cd 100644
--- a/src/org/traccar/protocol/M2cProtocol.java
+++ b/src/org/traccar/protocol/M2cProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class M2cProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(32 * 1024, ']'));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/M2cProtocolDecoder.java b/src/org/traccar/protocol/M2cProtocolDecoder.java
index c11136f4c..67b2accb9 100644
--- a/src/org/traccar/protocol/M2cProtocolDecoder.java
+++ b/src/org/traccar/protocol/M2cProtocolDecoder.java
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/M2mProtocol.java b/src/org/traccar/protocol/M2mProtocol.java
index 09393fed0..70dfc7b39 100644
--- a/src/org/traccar/protocol/M2mProtocol.java
+++ b/src/org/traccar/protocol/M2mProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.FixedLengthFrameDecoder;
+import io.netty.handler.codec.FixedLengthFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -31,9 +30,9 @@ public class M2mProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new FixedLengthFrameDecoder(23));
pipeline.addLast("objectDecoder", new M2mProtocolDecoder(M2mProtocol.this));
}
diff --git a/src/org/traccar/protocol/M2mProtocolDecoder.java b/src/org/traccar/protocol/M2mProtocolDecoder.java
index b30919865..7bb704904 100644
--- a/src/org/traccar/protocol/M2mProtocolDecoder.java
+++ b/src/org/traccar/protocol/M2mProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
@@ -36,7 +36,7 @@ public class M2mProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
// Remove offset
for (int i = 0; i < buf.readableBytes(); i++) {
diff --git a/src/org/traccar/protocol/MaestroProtocol.java b/src/org/traccar/protocol/MaestroProtocol.java
index 5e0b69916..5a7cbcf4d 100644
--- a/src/org/traccar/protocol/MaestroProtocol.java
+++ b/src/org/traccar/protocol/MaestroProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.FixedLengthFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.FixedLengthFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class MaestroProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new FixedLengthFrameDecoder(160));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/MaestroProtocolDecoder.java b/src/org/traccar/protocol/MaestroProtocolDecoder.java
index 6068c93b9..32072007e 100644
--- a/src/org/traccar/protocol/MaestroProtocolDecoder.java
+++ b/src/org/traccar/protocol/MaestroProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/ManPowerProtocol.java b/src/org/traccar/protocol/ManPowerProtocol.java
index 60ce8b282..5567cdccb 100644
--- a/src/org/traccar/protocol/ManPowerProtocol.java
+++ b/src/org/traccar/protocol/ManPowerProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class ManPowerProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/ManPowerProtocolDecoder.java b/src/org/traccar/protocol/ManPowerProtocolDecoder.java
index 0b1c410c3..d1b6bdc72 100644
--- a/src/org/traccar/protocol/ManPowerProtocolDecoder.java
+++ b/src/org/traccar/protocol/ManPowerProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/MegastekFrameDecoder.java b/src/org/traccar/protocol/MegastekFrameDecoder.java
index d9cb07108..347fa24b1 100644
--- a/src/org/traccar/protocol/MegastekFrameDecoder.java
+++ b/src/org/traccar/protocol/MegastekFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,19 +15,19 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.traccar.helper.StringFinder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
+import org.traccar.helper.BufferUtil;
import java.nio.charset.StandardCharsets;
-public class MegastekFrameDecoder extends FrameDecoder {
+public class MegastekFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 10) {
return null;
@@ -36,18 +36,18 @@ public class MegastekFrameDecoder extends FrameDecoder {
if (Character.isDigit(buf.getByte(buf.readerIndex()))) {
int length = 4 + Integer.parseInt(buf.toString(buf.readerIndex(), 4, StandardCharsets.US_ASCII));
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
} else {
while (buf.getByte(buf.readerIndex()) == '\r' || buf.getByte(buf.readerIndex()) == '\n') {
buf.skipBytes(1);
}
- int delimiter = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("\r\n"));
+ int delimiter = BufferUtil.indexOf("\r\n", buf);
if (delimiter == -1) {
delimiter = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '!');
}
if (delimiter != -1) {
- ChannelBuffer result = buf.readBytes(delimiter - buf.readerIndex());
+ ByteBuf result = buf.readRetainedSlice(delimiter - buf.readerIndex());
buf.skipBytes(1);
return result;
}
diff --git a/src/org/traccar/protocol/MegastekProtocol.java b/src/org/traccar/protocol/MegastekProtocol.java
index b28a05b92..862d1abd2 100644
--- a/src/org/traccar/protocol/MegastekProtocol.java
+++ b/src/org/traccar/protocol/MegastekProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class MegastekProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new MegastekFrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/MegastekProtocolDecoder.java b/src/org/traccar/protocol/MegastekProtocolDecoder.java
index 14d39e0cc..15f7be582 100644
--- a/src/org/traccar/protocol/MegastekProtocolDecoder.java
+++ b/src/org/traccar/protocol/MegastekProtocolDecoder.java
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/MeiligaoFrameDecoder.java b/src/org/traccar/protocol/MeiligaoFrameDecoder.java
index 9340b6198..52f9ae26d 100644
--- a/src/org/traccar/protocol/MeiligaoFrameDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,21 +15,21 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class MeiligaoFrameDecoder extends FrameDecoder {
+public class MeiligaoFrameDecoder extends BaseFrameDecoder {
private static final int MESSAGE_HEADER = 4;
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
// Strip not '$' (0x24) bytes from the beginning
- while (buf.readable() && buf.getUnsignedByte(buf.readerIndex()) != 0x24) {
+ while (buf.isReadable() && buf.getUnsignedByte(buf.readerIndex()) != 0x24) {
buf.readByte();
}
@@ -37,7 +37,7 @@ public class MeiligaoFrameDecoder extends FrameDecoder {
if (buf.readableBytes() >= MESSAGE_HEADER) {
int length = buf.getUnsignedShort(buf.readerIndex() + 2);
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
}
diff --git a/src/org/traccar/protocol/MeiligaoProtocol.java b/src/org/traccar/protocol/MeiligaoProtocol.java
index c72262017..0b745f0c6 100644
--- a/src/org/traccar/protocol/MeiligaoProtocol.java
+++ b/src/org/traccar/protocol/MeiligaoProtocol.java
@@ -15,10 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -41,17 +39,17 @@ public class MeiligaoProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new MeiligaoFrameDecoder());
pipeline.addLast("objectEncoder", new MeiligaoProtocolEncoder());
pipeline.addLast("objectDecoder", new MeiligaoProtocolDecoder(MeiligaoProtocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectEncoder", new MeiligaoProtocolEncoder());
pipeline.addLast("objectDecoder", new MeiligaoProtocolDecoder(MeiligaoProtocol.this));
}
diff --git a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
index 5ff0dedc7..30905076e 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolDecoder.java
@@ -15,12 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
@@ -39,7 +40,7 @@ import java.util.regex.Pattern;
public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
- private Map<Byte, ChannelBuffer> photos = new HashMap<>();
+ private Map<Byte, ByteBuf> photos = new HashMap<>();
public MeiligaoProtocolDecoder(MeiligaoProtocol protocol) {
super(protocol);
@@ -153,7 +154,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_UPLOAD_COMPLETE = 0x0f80;
public static final int MSG_REBOOT_GPS = 0x4902;
- private DeviceSession identify(ChannelBuffer buf, Channel channel, SocketAddress remoteAddress) {
+ private DeviceSession identify(ByteBuf buf, Channel channel, SocketAddress remoteAddress) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 7; i++) {
@@ -184,10 +185,10 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
}
private static void sendResponse(
- Channel channel, SocketAddress remoteAddress, ChannelBuffer id, int type, ChannelBuffer msg) {
+ Channel channel, SocketAddress remoteAddress, ByteBuf id, int type, ByteBuf msg) {
if (channel != null) {
- ChannelBuffer buf = ChannelBuffers.buffer(
+ ByteBuf buf = Unpooled.buffer(
2 + 2 + id.readableBytes() + 2 + msg.readableBytes() + 2 + 2);
buf.writeByte('@');
@@ -196,18 +197,19 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
buf.writeBytes(id);
buf.writeShort(type);
buf.writeBytes(msg);
- buf.writeShort(Checksum.crc16(Checksum.CRC16_CCITT_FALSE, buf.toByteBuffer()));
+ msg.release();
+ buf.writeShort(Checksum.crc16(Checksum.CRC16_CCITT_FALSE, buf.nioBuffer()));
buf.writeByte('\r');
buf.writeByte('\n');
- channel.write(buf, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(buf, remoteAddress));
}
}
private String getServer(Channel channel) {
String server = Context.getConfig().getString(getProtocolName() + ".server");
if (server == null && channel != null) {
- InetSocketAddress address = (InetSocketAddress) channel.getLocalAddress();
+ InetSocketAddress address = (InetSocketAddress) channel.localAddress();
server = address.getAddress().getHostAddress() + ":" + address.getPort();
}
return server;
@@ -357,7 +359,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private List<Position> decodeRetransmission(ChannelBuffer buf, DeviceSession deviceSession) {
+ private List<Position> decodeRetransmission(ByteBuf buf, DeviceSession deviceSession) {
List<Position> positions = new LinkedList<>();
int count = buf.readUnsignedByte();
@@ -370,7 +372,7 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
endIndex = buf.writerIndex() - 4;
}
- String sentence = buf.readBytes(endIndex - buf.readerIndex()).toString(StandardCharsets.US_ASCII);
+ String sentence = buf.readSlice(endIndex - buf.readerIndex()).toString(StandardCharsets.US_ASCII);
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -394,34 +396,33 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
buf.readShort(); // length
- ChannelBuffer id = buf.readBytes(7);
+ ByteBuf id = buf.readSlice(7);
int command = buf.readUnsignedShort();
- ChannelBuffer response;
if (command == MSG_LOGIN) {
- response = ChannelBuffers.wrappedBuffer(new byte[]{0x01});
+ ByteBuf response = Unpooled.wrappedBuffer(new byte[]{0x01});
sendResponse(channel, remoteAddress, id, MSG_LOGIN_RESPONSE, response);
return null;
} else if (command == MSG_HEARTBEAT) {
- response = ChannelBuffers.wrappedBuffer(new byte[]{0x01});
+ ByteBuf response = Unpooled.wrappedBuffer(new byte[]{0x01});
sendResponse(channel, remoteAddress, id, MSG_HEARTBEAT, response);
return null;
} else if (command == MSG_SERVER) {
- response = ChannelBuffers.copiedBuffer(getServer(channel), StandardCharsets.US_ASCII);
+ ByteBuf response = Unpooled.copiedBuffer(getServer(channel), StandardCharsets.US_ASCII);
sendResponse(channel, remoteAddress, id, MSG_SERVER, response);
return null;
} else if (command == MSG_UPLOAD_PHOTO) {
byte imageIndex = buf.readByte();
- photos.put(imageIndex, ChannelBuffers.dynamicBuffer());
- response = ChannelBuffers.copiedBuffer(new byte[]{imageIndex});
+ photos.put(imageIndex, Unpooled.buffer());
+ ByteBuf response = Unpooled.copiedBuffer(new byte[]{imageIndex});
sendResponse(channel, remoteAddress, id, MSG_UPLOAD_PHOTO_RESPONSE, response);
return null;
} else if (command == MSG_UPLOAD_COMPLETE) {
byte imageIndex = buf.readByte();
- response = ChannelBuffers.copiedBuffer(new byte[]{imageIndex, 0, 0});
+ ByteBuf response = Unpooled.copiedBuffer(new byte[]{imageIndex, 0, 0});
sendResponse(channel, remoteAddress, id, MSG_RETRANSMISSION, response);
return null;
}
@@ -475,8 +476,12 @@ public class MeiligaoProtocolDecoder extends BaseProtocolDecoder {
byte imageIndex = buf.readByte();
buf.readUnsignedByte(); // image upload type
String uniqueId = Context.getIdentityManager().getById(deviceSession.getDeviceId()).getUniqueId();
- String file = Context.getMediaManager().writeFile(uniqueId, photos.remove(imageIndex), "jpg");
- position.set(Position.KEY_IMAGE, file);
+ ByteBuf photo = photos.remove(imageIndex);
+ try {
+ position.set(Position.KEY_IMAGE, Context.getMediaManager().writeFile(uniqueId, photo, "jpg"));
+ } finally {
+ photo.release();
+ }
}
String sentence = buf.toString(buf.readerIndex(), buf.readableBytes() - 4, StandardCharsets.US_ASCII);
diff --git a/src/org/traccar/protocol/MeiligaoProtocolEncoder.java b/src/org/traccar/protocol/MeiligaoProtocolEncoder.java
index 1b444e90a..6052b2617 100644
--- a/src/org/traccar/protocol/MeiligaoProtocolEncoder.java
+++ b/src/org/traccar/protocol/MeiligaoProtocolEncoder.java
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Checksum;
import org.traccar.helper.DataConverter;
@@ -28,9 +28,9 @@ import java.util.TimeZone;
public class MeiligaoProtocolEncoder extends BaseProtocolEncoder {
- private ChannelBuffer encodeContent(long deviceId, int type, ChannelBuffer content) {
+ private ByteBuf encodeContent(long deviceId, int type, ByteBuf content) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ ByteBuf buf = Unpooled.buffer();
buf.writeByte('@');
buf.writeByte('@');
@@ -43,7 +43,7 @@ public class MeiligaoProtocolEncoder extends BaseProtocolEncoder {
buf.writeBytes(content);
- buf.writeShort(Checksum.crc16(Checksum.CRC16_CCITT_FALSE, buf.toByteBuffer()));
+ buf.writeShort(Checksum.crc16(Checksum.CRC16_CCITT_FALSE, buf.nioBuffer()));
buf.writeByte('\r');
buf.writeByte('\n');
@@ -54,7 +54,7 @@ public class MeiligaoProtocolEncoder extends BaseProtocolEncoder {
@Override
protected Object encodeCommand(Command command) {
- ChannelBuffer content = ChannelBuffers.dynamicBuffer();
+ ByteBuf content = Unpooled.buffer();
switch (command.getType()) {
case Command.TYPE_POSITION_SINGLE:
diff --git a/src/org/traccar/protocol/MeitrackFrameDecoder.java b/src/org/traccar/protocol/MeitrackFrameDecoder.java
index 1eb0dae0f..d122bca0c 100644
--- a/src/org/traccar/protocol/MeitrackFrameDecoder.java
+++ b/src/org/traccar/protocol/MeitrackFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,18 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
import java.nio.charset.StandardCharsets;
-public class MeitrackFrameDecoder extends FrameDecoder {
+public class MeitrackFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 10) {
return null;
@@ -37,7 +37,7 @@ public class MeitrackFrameDecoder extends FrameDecoder {
int length = index - buf.readerIndex() + Integer.parseInt(
buf.toString(buf.readerIndex() + 3, index - buf.readerIndex() - 3, StandardCharsets.US_ASCII));
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
}
diff --git a/src/org/traccar/protocol/MeitrackProtocol.java b/src/org/traccar/protocol/MeitrackProtocol.java
index e89825da5..b9be2a8fd 100644
--- a/src/org/traccar/protocol/MeitrackProtocol.java
+++ b/src/org/traccar/protocol/MeitrackProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,15 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
-import java.nio.ByteOrder;
import java.util.List;
public class MeitrackProtocol extends BaseProtocol {
@@ -42,27 +39,23 @@ public class MeitrackProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new MeitrackFrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new MeitrackProtocolEncoder());
pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(MeitrackProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
- server = new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ });
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new MeitrackProtocolEncoder());
pipeline.addLast("objectDecoder", new MeitrackProtocolDecoder(MeitrackProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/MeitrackProtocolDecoder.java b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
index 9109323ec..465cfd9fa 100644
--- a/src/org/traccar/protocol/MeitrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/MeitrackProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Checksum;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -38,7 +39,7 @@ import java.util.regex.Pattern;
public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
- private ChannelBuffer photo;
+ private ByteBuf photo;
public MeitrackProtocolDecoder(MeitrackProtocol protocol) {
super(protocol);
@@ -119,7 +120,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
}
}
- private Position decodeRegular(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private Position decodeRegular(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
Parser parser = new Parser(PATTERN, buf.toString(StandardCharsets.US_ASCII));
if (!parser.matches()) {
@@ -270,7 +271,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
}
- private List<Position> decodeBinaryC(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private List<Position> decodeBinaryC(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
List<Position> positions = new LinkedList<>();
String flag = buf.toString(2, 1, StandardCharsets.US_ASCII);
@@ -291,38 +292,38 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_EVENT, buf.readUnsignedByte());
- position.setLatitude(buf.readInt() * 0.000001);
- position.setLongitude(buf.readInt() * 0.000001);
+ position.setLatitude(buf.readIntLE() * 0.000001);
+ position.setLongitude(buf.readIntLE() * 0.000001);
- position.setTime(new Date((946684800 + buf.readUnsignedInt()) * 1000)); // 946684800 = 2000-01-01
+ position.setTime(new Date((946684800 + buf.readUnsignedIntLE()) * 1000)); // 946684800 = 2000-01-01
position.setValid(buf.readUnsignedByte() == 1);
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
int rssi = buf.readUnsignedByte();
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort()));
- position.setCourse(buf.readUnsignedShort());
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShortLE()));
+ position.setCourse(buf.readUnsignedShortLE());
- position.set(Position.KEY_HDOP, buf.readUnsignedShort() * 0.1);
+ position.set(Position.KEY_HDOP, buf.readUnsignedShortLE() * 0.1);
- position.setAltitude(buf.readUnsignedShort());
+ position.setAltitude(buf.readUnsignedShortLE());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
- position.set("runtime", buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
+ position.set("runtime", buf.readUnsignedIntLE());
position.setNetwork(new Network(CellTower.from(
- buf.readUnsignedShort(), buf.readUnsignedShort(),
- buf.readUnsignedShort(), buf.readUnsignedShort(),
+ buf.readUnsignedShortLE(), buf.readUnsignedShortLE(),
+ buf.readUnsignedShortLE(), buf.readUnsignedShortLE(),
rssi)));
- position.set(Position.KEY_STATUS, buf.readUnsignedShort());
+ position.set(Position.KEY_STATUS, buf.readUnsignedShortLE());
- position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.01);
- position.set(Position.KEY_POWER, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShortLE());
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.01);
+ position.set(Position.KEY_POWER, buf.readUnsignedShortLE());
- buf.readUnsignedInt(); // geo-fence
+ buf.readUnsignedIntLE(); // geo-fence
positions.add(position);
}
@@ -337,17 +338,17 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
}
command.append(String.format("%02x", checksum & 0xff).toUpperCase());
command.append("\r\n");
- channel.write(command.toString()); // delete processed data
+ channel.writeAndFlush(new NetworkMessage(command.toString(), remoteAddress)); // delete processed data
}
return positions;
}
- private List<Position> decodeBinaryE(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private List<Position> decodeBinaryE(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
List<Position> positions = new LinkedList<>();
buf.readerIndex(buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ',') + 1);
- String imei = buf.readBytes(15).toString(StandardCharsets.US_ASCII);
+ String imei = buf.readSlice(15).toString(StandardCharsets.US_ASCII);
buf.skipBytes(1 + 3 + 1);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
@@ -355,15 +356,15 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- buf.readUnsignedInt(); // remaining cache
- int count = buf.readUnsignedShort();
+ buf.readUnsignedIntLE(); // remaining cache
+ int count = buf.readUnsignedShortLE();
for (int i = 0; i < count; i++) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- buf.readUnsignedShort(); // length
- buf.readUnsignedShort(); // index
+ buf.readUnsignedShortLE(); // length
+ buf.readUnsignedShortLE(); // index
int paramCount = buf.readUnsignedByte();
for (int j = 0; j < paramCount; j++) {
@@ -392,22 +393,22 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
int id = buf.readUnsignedByte();
switch (id) {
case 0x08:
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort()));
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShortLE()));
break;
case 0x09:
- position.setCourse(buf.readUnsignedShort());
+ position.setCourse(buf.readUnsignedShortLE());
break;
case 0x0B:
- position.setAltitude(buf.readShort());
+ position.setAltitude(buf.readShortLE());
break;
case 0x19:
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.01);
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.01);
break;
case 0x1A:
- position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.01);
+ position.set(Position.KEY_POWER, buf.readUnsignedShortLE() * 0.01);
break;
default:
- buf.readUnsignedShort();
+ buf.readUnsignedShortLE();
break;
}
}
@@ -417,19 +418,19 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
int id = buf.readUnsignedByte();
switch (id) {
case 0x02:
- position.setLatitude(buf.readInt() * 0.000001);
+ position.setLatitude(buf.readIntLE() * 0.000001);
break;
case 0x03:
- position.setLongitude(buf.readInt() * 0.000001);
+ position.setLongitude(buf.readIntLE() * 0.000001);
break;
case 0x04:
- position.setTime(new Date((946684800 + buf.readUnsignedInt()) * 1000)); // 2000-01-01
+ position.setTime(new Date((946684800 + buf.readUnsignedIntLE()) * 1000)); // 2000-01-01
break;
case 0x0D:
- position.set("runtime", buf.readUnsignedInt());
+ position.set("runtime", buf.readUnsignedIntLE());
break;
default:
- buf.readUnsignedInt();
+ buf.readUnsignedIntLE();
break;
}
}
@@ -446,13 +447,13 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
return positions;
}
- private void requestPhotoPacket(Channel channel, String imei, String file, int index) {
+ private void requestPhotoPacket(Channel channel, SocketAddress socketAddress, String imei, String file, int index) {
if (channel != null) {
String content = "D00," + file + "," + index;
int length = 1 + imei.length() + 1 + content.length() + 5;
String response = String.format("@@O%02d,%s,%s*", length, imei, content);
response += Checksum.sum(response) + "\r\n";
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, socketAddress));
}
}
@@ -460,7 +461,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ',');
String imei = buf.toString(index + 1, 15, StandardCharsets.US_ASCII);
@@ -470,7 +471,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
switch (type) {
case "D00":
if (photo == null) {
- photo = ChannelBuffers.dynamicBuffer();
+ photo = Unpooled.buffer();
}
index = index + 1 + type.length() + 1;
@@ -484,7 +485,7 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
int current = Integer.parseInt(buf.toString(index, endIndex - index, StandardCharsets.US_ASCII));
buf.readerIndex(endIndex + 1);
- photo.writeBytes(buf.readBytes(buf.readableBytes() - 1 - 2 - 2));
+ photo.writeBytes(buf.readSlice(buf.readableBytes() - 1 - 2 - 2));
if (current == total - 1) {
Position position = new Position(getProtocolName());
@@ -493,18 +494,19 @@ public class MeitrackProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
position.set(Position.KEY_IMAGE, Context.getMediaManager().writeFile(imei, photo, "jpg"));
+ photo.release();
photo = null;
return position;
} else {
if ((current + 1) % 8 == 0) {
- requestPhotoPacket(channel, imei, file, current + 1);
+ requestPhotoPacket(channel, remoteAddress, imei, file, current + 1);
}
return null;
}
case "D03":
- photo = ChannelBuffers.dynamicBuffer();
- requestPhotoPacket(channel, imei, "camera_picture.jpg", 0);
+ photo = Unpooled.buffer();
+ requestPhotoPacket(channel, remoteAddress, imei, "camera_picture.jpg", 0);
return null;
case "CCC":
return decodeBinaryC(channel, remoteAddress, buf);
diff --git a/src/org/traccar/protocol/MiniFinderProtocol.java b/src/org/traccar/protocol/MiniFinderProtocol.java
index c36acb238..05641dcbe 100644
--- a/src/org/traccar/protocol/MiniFinderProtocol.java
+++ b/src/org/traccar/protocol/MiniFinderProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -46,9 +45,9 @@ public class MiniFinderProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ';'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
index ab046eca3..d7af66ba7 100644
--- a/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
+++ b/src/org/traccar/protocol/MiniFinderProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
diff --git a/src/org/traccar/protocol/Mta6Protocol.java b/src/org/traccar/protocol/Mta6Protocol.java
index 65a48808d..e0b3f6063 100644
--- a/src/org/traccar/protocol/Mta6Protocol.java
+++ b/src/org/traccar/protocol/Mta6Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
-import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpRequestDecoder;
+import io.netty.handler.codec.http.HttpResponseEncoder;
import org.traccar.BaseProtocol;
import org.traccar.Context;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,11 +33,12 @@ public class Mta6Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
+ pipeline.addLast("httpAggregator", new HttpObjectAggregator(65535));
pipeline.addLast("objectDecoder", new Mta6ProtocolDecoder(
Mta6Protocol.this, !Context.getConfig().getBoolean(getName() + ".can")));
}
diff --git a/src/org/traccar/protocol/Mta6ProtocolDecoder.java b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
index 13b187e80..94b624612 100644
--- a/src/org/traccar/protocol/Mta6ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Mta6ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,17 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
-import org.jboss.netty.handler.codec.http.HttpRequest;
-import org.jboss.netty.handler.codec.http.HttpResponse;
-import org.jboss.netty.handler.codec.http.HttpResponseStatus;
-import org.jboss.netty.handler.codec.http.HttpVersion;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.handler.codec.http.DefaultFullHttpResponse;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.FullHttpResponse;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.handler.codec.http.HttpVersion;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.Protocol;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
@@ -48,30 +49,28 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
}
private void sendContinue(Channel channel) {
- HttpResponse response = new DefaultHttpResponse(
+ FullHttpResponse response = new DefaultFullHttpResponse(
HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
private void sendResponse(Channel channel, short packetId, short packetCount) {
- HttpResponse response = new DefaultHttpResponse(
- HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
-
- ChannelBuffer begin = ChannelBuffers.copiedBuffer("#ACK#", StandardCharsets.US_ASCII);
- ChannelBuffer end = ChannelBuffers.directBuffer(3);
+ ByteBuf begin = Unpooled.copiedBuffer("#ACK#", StandardCharsets.US_ASCII);
+ ByteBuf end = Unpooled.buffer(3);
end.writeByte(packetId);
end.writeByte(packetCount);
end.writeByte(0);
- response.setContent(ChannelBuffers.wrappedBuffer(begin, end));
- channel.write(response);
+ FullHttpResponse response = new DefaultFullHttpResponse(
+ HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.wrappedBuffer(begin, end));
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
private static class FloatReader {
private int previousFloat;
- public float readFloat(ChannelBuffer buf) {
+ public float readFloat(ByteBuf buf) {
switch (buf.getUnsignedByte(buf.readerIndex()) >> 6) {
case 0:
previousFloat = buf.readInt() << 2;
@@ -98,7 +97,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
private long weekNumber;
- public Date readTime(ChannelBuffer buf) {
+ public Date readTime(ByteBuf buf) {
long weekTime = (long) (readFloat(buf) * 1000);
if (weekNumber == 0) {
weekNumber = buf.readUnsignedShort();
@@ -112,7 +111,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
}
- private List<Position> parseFormatA(DeviceSession deviceSession, ChannelBuffer buf) {
+ private List<Position> parseFormatA(DeviceSession deviceSession, ByteBuf buf) {
List<Position> positions = new LinkedList<>();
FloatReader latitudeReader = new FloatReader();
@@ -120,7 +119,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
TimeReader timeReader = new TimeReader();
try {
- while (buf.readable()) {
+ while (buf.isReadable()) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -199,7 +198,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
return positions;
}
- private Position parseFormatA1(DeviceSession deviceSession, ChannelBuffer buf) {
+ private Position parseFormatA1(DeviceSession deviceSession, ByteBuf buf) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -278,8 +277,8 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- HttpRequest request = (HttpRequest) msg;
- ChannelBuffer buf = request.getContent();
+ FullHttpRequest request = (FullHttpRequest) msg;
+ ByteBuf buf = request.content();
buf.skipBytes("id=".length());
int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '&');
@@ -309,7 +308,7 @@ public class Mta6ProtocolDecoder extends BaseProtocolDecoder {
} else {
return parseFormatA(deviceSession, buf);
}
- } //else if (0x34 0x38 0x4F 0x59)
+ } // else if (0x34 0x38 0x4F 0x59)
return null;
}
diff --git a/src/org/traccar/protocol/MtxProtocol.java b/src/org/traccar/protocol/MtxProtocol.java
index 58b2361cd..2f33909db 100644
--- a/src/org/traccar/protocol/MtxProtocol.java
+++ b/src/org/traccar/protocol/MtxProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class MtxProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/MtxProtocolDecoder.java b/src/org/traccar/protocol/MtxProtocolDecoder.java
index 412eac493..18bce399f 100644
--- a/src/org/traccar/protocol/MtxProtocolDecoder.java
+++ b/src/org/traccar/protocol/MtxProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.model.Position;
@@ -60,7 +61,7 @@ public class MtxProtocolDecoder extends BaseProtocolDecoder {
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
if (channel != null) {
- channel.write("#ACK");
+ channel.writeAndFlush(new NetworkMessage("#ACK", remoteAddress));
}
Parser parser = new Parser(PATTERN, (String) msg);
diff --git a/src/org/traccar/protocol/MxtFrameDecoder.java b/src/org/traccar/protocol/MxtFrameDecoder.java
index b2cd6de93..d70e92da1 100644
--- a/src/org/traccar/protocol/MxtFrameDecoder.java
+++ b/src/org/traccar/protocol/MxtFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,21 +15,17 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-import java.nio.ByteOrder;
-
-public class MxtFrameDecoder extends FrameDecoder {
+public class MxtFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 2) {
return null;
@@ -37,7 +33,7 @@ public class MxtFrameDecoder extends FrameDecoder {
int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0x04);
if (index != -1) {
- ChannelBuffer result = ChannelBuffers.buffer(ByteOrder.LITTLE_ENDIAN, index + 1 - buf.readerIndex());
+ ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex());
while (buf.readerIndex() <= index) {
int b = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/MxtProtocol.java b/src/org/traccar/protocol/MxtProtocol.java
index 03c1da71e..8bfb958ab 100644
--- a/src/org/traccar/protocol/MxtProtocol.java
+++ b/src/org/traccar/protocol/MxtProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
-import java.nio.ByteOrder;
import java.util.List;
public class MxtProtocol extends BaseProtocol {
@@ -31,15 +29,13 @@ public class MxtProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new MxtFrameDecoder());
pipeline.addLast("objectDecoder", new MxtProtocolDecoder(MxtProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/MxtProtocolDecoder.java b/src/org/traccar/protocol/MxtProtocolDecoder.java
index a97ae380d..d6029c6d0 100644
--- a/src/org/traccar/protocol/MxtProtocolDecoder.java
+++ b/src/org/traccar/protocol/MxtProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
@@ -27,7 +28,6 @@ import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
public class MxtProtocolDecoder extends BaseProtocolDecoder {
@@ -41,17 +41,17 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
private static void sendResponse(Channel channel, int device, long id, int crc) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf response = Unpooled.buffer();
response.writeByte(device);
response.writeByte(MSG_ACK);
- response.writeInt((int) id);
- response.writeShort(crc);
- response.writeShort(Checksum.crc16(
- Checksum.CRC16_XMODEM, response.toByteBuffer()));
+ response.writeIntLE((int) id);
+ response.writeShortLE(crc);
+ response.writeShortLE(Checksum.crc16(
+ Checksum.CRC16_XMODEM, response.nioBuffer()));
- ChannelBuffer encoded = ChannelBuffers.dynamicBuffer();
+ ByteBuf encoded = Unpooled.buffer();
encoded.writeByte(0x01); // header
- while (response.readable()) {
+ while (response.isReadable()) {
int b = response.readByte();
if (b == 0x01 || b == 0x04 || b == 0x10 || b == 0x11 || b == 0x13) {
encoded.writeByte(0x10);
@@ -59,8 +59,9 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
}
encoded.writeByte(b);
}
+ response.release();
encoded.writeByte(0x04); // ending
- channel.write(encoded);
+ channel.writeAndFlush(new NetworkMessage(encoded, channel.remoteAddress()));
}
}
@@ -68,13 +69,13 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.readUnsignedByte(); // start
int device = buf.readUnsignedByte(); // device descriptor
int type = buf.readUnsignedByte();
- long id = buf.readUnsignedInt();
+ long id = buf.readUnsignedIntLE();
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, String.valueOf(id));
if (deviceSession == null) {
return null;
@@ -88,11 +89,11 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // protocol
int infoGroups = buf.readUnsignedByte();
- position.set(Position.KEY_INDEX, buf.readUnsignedShort());
+ position.set(Position.KEY_INDEX, buf.readUnsignedShortLE());
DateBuilder dateBuilder = new DateBuilder().setDate(2000, 1, 1);
- long date = buf.readUnsignedInt();
+ long date = buf.readUnsignedIntLE();
long days = BitUtil.from(date, 6 + 6 + 5);
long hours = BitUtil.between(date, 6 + 6, 6 + 6 + 5);
@@ -104,10 +105,10 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
position.setTime(dateBuilder.getDate());
position.setValid(true);
- position.setLatitude(buf.readInt() / 1000000.0);
- position.setLongitude(buf.readInt() / 1000000.0);
+ position.setLatitude(buf.readIntLE() / 1000000.0);
+ position.setLongitude(buf.readIntLE() / 1000000.0);
- long flags = buf.readUnsignedInt();
+ long flags = buf.readUnsignedIntLE();
position.set(Position.KEY_IGNITION, BitUtil.check(flags, 0));
if (BitUtil.check(flags, 1)) {
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
@@ -115,7 +116,7 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_INPUT, BitUtil.between(flags, 2, 7));
position.set(Position.KEY_OUTPUT, BitUtil.between(flags, 7, 10));
position.setCourse(BitUtil.between(flags, 10, 13) * 45);
- //position.setValid(BitUtil.check(flags, 15));
+ // position.setValid(BitUtil.check(flags, 15));
position.set(Position.KEY_CHARGE, BitUtil.check(flags, 20));
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
@@ -135,34 +136,34 @@ public class MxtProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_HDOP, buf.readUnsignedByte());
position.setAccuracy(buf.readUnsignedByte());
position.set(Position.KEY_RSSI, buf.readUnsignedByte());
- buf.readUnsignedShort(); // time since boot
+ buf.readUnsignedShortLE(); // time since boot
position.set(Position.KEY_POWER, buf.readUnsignedByte());
position.set(Position.PREFIX_TEMP + 1, buf.readByte());
}
if (BitUtil.check(infoGroups, 3)) {
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
}
if (BitUtil.check(infoGroups, 4)) {
- position.set(Position.KEY_HOURS, UnitsConverter.msFromMinutes(buf.readUnsignedInt()));
+ position.set(Position.KEY_HOURS, UnitsConverter.msFromMinutes(buf.readUnsignedIntLE()));
}
if (BitUtil.check(infoGroups, 5)) {
- buf.readUnsignedInt(); // reason
+ buf.readUnsignedIntLE(); // reason
}
if (BitUtil.check(infoGroups, 6)) {
- position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.001);
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort());
+ position.set(Position.KEY_POWER, buf.readUnsignedShortLE() * 0.001);
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE());
}
if (BitUtil.check(infoGroups, 7)) {
- position.set(Position.KEY_DRIVER_UNIQUE_ID, String.valueOf(buf.readUnsignedInt()));
+ position.set(Position.KEY_DRIVER_UNIQUE_ID, String.valueOf(buf.readUnsignedIntLE()));
}
buf.readerIndex(buf.writerIndex() - 3);
- sendResponse(channel, device, id, buf.readUnsignedShort());
+ sendResponse(channel, device, id, buf.readUnsignedShortLE());
return position;
}
diff --git a/src/org/traccar/protocol/NavigilFrameDecoder.java b/src/org/traccar/protocol/NavigilFrameDecoder.java
index 34eb28941..e8b6bea52 100644
--- a/src/org/traccar/protocol/NavigilFrameDecoder.java
+++ b/src/org/traccar/protocol/NavigilFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,21 +15,19 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class NavigilFrameDecoder extends FrameDecoder {
+public class NavigilFrameDecoder extends BaseFrameDecoder {
private static final int MESSAGE_HEADER = 20;
private static final long PREAMBLE = 0x2477F5F6;
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
// Check minimum length
if (buf.readableBytes() < MESSAGE_HEADER) {
@@ -38,18 +36,18 @@ public class NavigilFrameDecoder extends FrameDecoder {
// Check for preamble
boolean hasPreamble = false;
- if (buf.getUnsignedInt(buf.readerIndex()) == PREAMBLE) {
+ if (buf.getUnsignedIntLE(buf.readerIndex()) == PREAMBLE) {
hasPreamble = true;
}
// Check length and return buffer
- int length = buf.getUnsignedShort(buf.readerIndex() + 6);
+ int length = buf.getUnsignedShortLE(buf.readerIndex() + 6);
if (buf.readableBytes() >= length) {
if (hasPreamble) {
- buf.readUnsignedInt();
+ buf.readUnsignedIntLE();
length -= 4;
}
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
return null;
diff --git a/src/org/traccar/protocol/NavigilProtocol.java b/src/org/traccar/protocol/NavigilProtocol.java
index 6646c6cc6..82f4af17d 100644
--- a/src/org/traccar/protocol/NavigilProtocol.java
+++ b/src/org/traccar/protocol/NavigilProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
-import java.nio.ByteOrder;
import java.util.List;
public class NavigilProtocol extends BaseProtocol {
@@ -31,15 +29,13 @@ public class NavigilProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new NavigilFrameDecoder());
pipeline.addLast("objectDecoder", new NavigilProtocolDecoder(NavigilProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/NavigilProtocolDecoder.java b/src/org/traccar/protocol/NavigilProtocolDecoder.java
index 4f3b4ad74..19eb37c27 100644
--- a/src/org/traccar/protocol/NavigilProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavigilProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,18 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Checksum;
import org.traccar.helper.Log;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.util.Date;
public class NavigilProtocolDecoder extends BaseProtocolDecoder {
@@ -60,106 +60,106 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
private int senderSequenceNumber = 1;
private void sendAcknowledgment(Channel channel, int sequenceNumber) {
- ChannelBuffer data = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 4);
- data.writeShort(sequenceNumber);
- data.writeShort(0); // OK
+ ByteBuf data = Unpooled.buffer(4);
+ data.writeShortLE(sequenceNumber);
+ data.writeShortLE(0); // OK
- ChannelBuffer header = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 20);
+ ByteBuf header = Unpooled.buffer(20);
header.writeByte(1); header.writeByte(0);
- header.writeShort(senderSequenceNumber++);
- header.writeShort(MSG_ACKNOWLEDGEMENT);
- header.writeShort(header.capacity() + data.capacity());
- header.writeShort(0);
- header.writeShort(Checksum.crc16(Checksum.CRC16_CCITT_FALSE, data.toByteBuffer()));
- header.writeInt(0);
- header.writeInt((int) (System.currentTimeMillis() / 1000) + LEAP_SECONDS_DELTA);
+ header.writeShortLE(senderSequenceNumber++);
+ header.writeShortLE(MSG_ACKNOWLEDGEMENT);
+ header.writeShortLE(header.capacity() + data.capacity());
+ header.writeShortLE(0);
+ header.writeShortLE(Checksum.crc16(Checksum.CRC16_CCITT_FALSE, data.nioBuffer()));
+ header.writeIntLE(0);
+ header.writeIntLE((int) (System.currentTimeMillis() / 1000) + LEAP_SECONDS_DELTA);
if (channel != null) {
- channel.write(ChannelBuffers.copiedBuffer(header, data));
+ channel.writeAndFlush(new NetworkMessage(Unpooled.wrappedBuffer(header, data), channel.remoteAddress()));
}
}
private Position parseUnitReport(
- DeviceSession deviceSession, ChannelBuffer buf, int sequenceNumber) {
+ DeviceSession deviceSession, ByteBuf buf, int sequenceNumber) {
Position position = new Position(getProtocolName());
position.setValid(true);
position.set(Position.KEY_INDEX, sequenceNumber);
position.setDeviceId(deviceSession.getDeviceId());
- buf.readUnsignedShort(); // report trigger
- position.set(Position.KEY_FLAGS, buf.readUnsignedShort());
+ buf.readUnsignedShortLE(); // report trigger
+ position.set(Position.KEY_FLAGS, buf.readUnsignedShortLE());
- position.setLatitude(buf.readInt() * 0.0000001);
- position.setLongitude(buf.readInt() * 0.0000001);
- position.setAltitude(buf.readUnsignedShort());
+ position.setLatitude(buf.readIntLE() * 0.0000001);
+ position.setLongitude(buf.readIntLE() * 0.0000001);
+ position.setAltitude(buf.readUnsignedShortLE());
- position.set(Position.KEY_SATELLITES, buf.readUnsignedShort());
- position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedShort());
- position.set("gpsAntennaState", buf.readUnsignedShort());
+ position.set(Position.KEY_SATELLITES, buf.readUnsignedShortLE());
+ position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedShortLE());
+ position.set("gpsAntennaState", buf.readUnsignedShortLE());
- position.setSpeed(buf.readUnsignedShort() * 0.194384);
- position.setCourse(buf.readUnsignedShort());
+ position.setSpeed(buf.readUnsignedShortLE() * 0.194384);
+ position.setCourse(buf.readUnsignedShortLE());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
- position.set(Position.KEY_DISTANCE, buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
+ position.set(Position.KEY_DISTANCE, buf.readUnsignedIntLE());
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001);
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.001);
- position.set(Position.KEY_CHARGE, buf.readUnsignedShort());
+ position.set(Position.KEY_CHARGE, buf.readUnsignedShortLE());
- position.setTime(convertTimestamp(buf.readUnsignedInt()));
+ position.setTime(convertTimestamp(buf.readUnsignedIntLE()));
return position;
}
private Position parseTg2Report(
- DeviceSession deviceSession, ChannelBuffer buf, int sequenceNumber) {
+ DeviceSession deviceSession, ByteBuf buf, int sequenceNumber) {
Position position = new Position(getProtocolName());
position.setValid(true);
position.set(Position.KEY_INDEX, sequenceNumber);
position.setDeviceId(deviceSession.getDeviceId());
- buf.readUnsignedShort(); // report trigger
+ buf.readUnsignedShortLE(); // report trigger
buf.readUnsignedByte(); // reserved
buf.readUnsignedByte(); // assisted GPS age
- position.setTime(convertTimestamp(buf.readUnsignedInt()));
+ position.setTime(convertTimestamp(buf.readUnsignedIntLE()));
- position.setLatitude(buf.readInt() * 0.0000001);
- position.setLongitude(buf.readInt() * 0.0000001);
- position.setAltitude(buf.readUnsignedShort());
+ position.setLatitude(buf.readIntLE() * 0.0000001);
+ position.setLongitude(buf.readIntLE() * 0.0000001);
+ position.setAltitude(buf.readUnsignedShortLE());
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedByte());
- position.setSpeed(buf.readUnsignedShort() * 0.194384);
- position.setCourse(buf.readUnsignedShort());
+ position.setSpeed(buf.readUnsignedShortLE() * 0.194384);
+ position.setCourse(buf.readUnsignedShortLE());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
- position.set("maximumSpeed", buf.readUnsignedShort());
- position.set("minimumSpeed", buf.readUnsignedShort());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
+ position.set("maximumSpeed", buf.readUnsignedShortLE());
+ position.set("minimumSpeed", buf.readUnsignedShortLE());
- position.set(Position.PREFIX_IO + 1, buf.readUnsignedShort()); // VSAUT1 voltage
- position.set(Position.PREFIX_IO + 2, buf.readUnsignedShort()); // VSAUT2 voltage
- position.set(Position.PREFIX_IO + 3, buf.readUnsignedShort()); // solar voltage
+ position.set(Position.PREFIX_IO + 1, buf.readUnsignedShortLE()); // VSAUT1 voltage
+ position.set(Position.PREFIX_IO + 2, buf.readUnsignedShortLE()); // VSAUT2 voltage
+ position.set(Position.PREFIX_IO + 3, buf.readUnsignedShortLE()); // solar voltage
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001);
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.001);
return position;
}
private Position parsePositionReport(
- DeviceSession deviceSession, ChannelBuffer buf, int sequenceNumber, long timestamp) {
+ DeviceSession deviceSession, ByteBuf buf, int sequenceNumber, long timestamp) {
Position position = new Position(getProtocolName());
position.set(Position.KEY_INDEX, sequenceNumber);
position.setDeviceId(deviceSession.getDeviceId());
position.setTime(convertTimestamp(timestamp));
- position.setLatitude(buf.readMedium() * 0.00002);
- position.setLongitude(buf.readMedium() * 0.00002);
+ position.setLatitude(buf.readMediumLE() * 0.00002);
+ position.setLongitude(buf.readMediumLE() * 0.00002);
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
position.setCourse(buf.readUnsignedByte() * 2);
@@ -173,15 +173,15 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
}
private Position parsePositionReport2(
- DeviceSession deviceSession, ChannelBuffer buf, int sequenceNumber, long timestamp) {
+ DeviceSession deviceSession, ByteBuf buf, int sequenceNumber, long timestamp) {
Position position = new Position(getProtocolName());
position.set(Position.KEY_INDEX, sequenceNumber);
position.setDeviceId(deviceSession.getDeviceId());
position.setTime(convertTimestamp(timestamp));
- position.setLatitude(buf.readInt() * 0.0000001);
- position.setLongitude(buf.readInt() * 0.0000001);
+ position.setLatitude(buf.readIntLE() * 0.0000001);
+ position.setLongitude(buf.readIntLE() * 0.0000001);
buf.readUnsignedByte(); // report trigger
@@ -191,13 +191,13 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
position.setValid((flags & 0x80) == 0x80 && (flags & 0x40) == 0x40);
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
return position;
}
private Position parseSnapshot4(
- DeviceSession deviceSession, ChannelBuffer buf, int sequenceNumber) {
+ DeviceSession deviceSession, ByteBuf buf, int sequenceNumber) {
Position position = new Position(getProtocolName());
position.set(Position.KEY_INDEX, sequenceNumber);
@@ -208,34 +208,34 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // GNSS fix quality
buf.readUnsignedByte(); // GNSS assistance age
- long flags = buf.readUnsignedInt();
+ long flags = buf.readUnsignedIntLE();
position.setValid((flags & 0x0400) == 0x0400);
- position.setTime(convertTimestamp(buf.readUnsignedInt()));
+ position.setTime(convertTimestamp(buf.readUnsignedIntLE()));
- position.setLatitude(buf.readInt() * 0.0000001);
- position.setLongitude(buf.readInt() * 0.0000001);
- position.setAltitude(buf.readUnsignedShort());
+ position.setLatitude(buf.readIntLE() * 0.0000001);
+ position.setLongitude(buf.readIntLE() * 0.0000001);
+ position.setAltitude(buf.readUnsignedShortLE());
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedByte());
- position.setSpeed(buf.readUnsignedShort() * 0.194384);
- position.setCourse(buf.readUnsignedShort() * 0.1);
+ position.setSpeed(buf.readUnsignedShortLE() * 0.194384);
+ position.setCourse(buf.readUnsignedShortLE() * 0.1);
position.set("maximumSpeed", buf.readUnsignedByte());
position.set("minimumSpeed", buf.readUnsignedByte());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
position.set(Position.PREFIX_IO + 1, buf.readUnsignedByte()); // supply voltage 1
position.set(Position.PREFIX_IO + 2, buf.readUnsignedByte()); // supply voltage 2
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001);
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.001);
return position;
}
private Position parseTrackingData(
- DeviceSession deviceSession, ChannelBuffer buf, int sequenceNumber, long timestamp) {
+ DeviceSession deviceSession, ByteBuf buf, int sequenceNumber, long timestamp) {
Position position = new Position(getProtocolName());
position.set(Position.KEY_INDEX, sequenceNumber);
@@ -247,17 +247,17 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
short flags = buf.readUnsignedByte();
position.setValid((flags & 0x01) == 0x01);
- buf.readUnsignedShort(); // duration
+ buf.readUnsignedShortLE(); // duration
- position.setLatitude(buf.readInt() * 0.0000001);
- position.setLongitude(buf.readInt() * 0.0000001);
+ position.setLatitude(buf.readIntLE() * 0.0000001);
+ position.setLongitude(buf.readIntLE() * 0.0000001);
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
position.setCourse(buf.readUnsignedByte() * 2.0);
position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.001);
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE() * 0.001);
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
return position;
}
@@ -266,22 +266,22 @@ public class NavigilProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.readUnsignedByte(); // protocol version
buf.readUnsignedByte(); // version id
- int sequenceNumber = buf.readUnsignedShort();
- int messageId = buf.readUnsignedShort();
- buf.readUnsignedShort(); // length
- int flags = buf.readUnsignedShort();
- buf.readUnsignedShort(); // checksum
+ int sequenceNumber = buf.readUnsignedShortLE();
+ int messageId = buf.readUnsignedShortLE();
+ buf.readUnsignedShortLE(); // length
+ int flags = buf.readUnsignedShortLE();
+ buf.readUnsignedShortLE(); // checksum
- DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, String.valueOf(buf.readUnsignedInt()));
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, String.valueOf(buf.readUnsignedIntLE()));
if (deviceSession == null) {
return null;
}
- long timestamp = buf.readUnsignedInt();
+ long timestamp = buf.readUnsignedIntLE();
if ((flags & 0x1) == 0x0) {
sendAcknowledgment(channel, sequenceNumber);
diff --git a/src/org/traccar/protocol/NavisProtocol.java b/src/org/traccar/protocol/NavisProtocol.java
index 771c9d61d..92b705517 100644
--- a/src/org/traccar/protocol/NavisProtocol.java
+++ b/src/org/traccar/protocol/NavisProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.nio.ByteOrder;
@@ -32,15 +31,14 @@ public class NavisProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(4 * 1024, 12, 2, 2, 0));
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
+ pipeline.addLast("frameDecoder",
+ new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 4 * 1024, 12, 2, 2, 0, true));
pipeline.addLast("objectDecoder", new NavisProtocolDecoder(NavisProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/NavisProtocolDecoder.java b/src/org/traccar/protocol/NavisProtocolDecoder.java
index 6881fb8ed..8da94b9aa 100644
--- a/src/org/traccar/protocol/NavisProtocolDecoder.java
+++ b/src/org/traccar/protocol/NavisProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,18 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.List;
@@ -75,23 +75,23 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
}
}
- private ParseResult parsePosition(DeviceSession deviceSession, ChannelBuffer buf) {
+ private ParseResult parsePosition(DeviceSession deviceSession, ByteBuf buf) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
int format;
if (buf.getUnsignedByte(buf.readerIndex()) == 0) {
- format = buf.readUnsignedShort();
+ format = buf.readUnsignedShortLE();
} else {
format = buf.readUnsignedByte();
}
position.set("format", format);
- long index = buf.readUnsignedInt();
+ long index = buf.readUnsignedIntLE();
position.set(Position.KEY_INDEX, index);
- position.set(Position.KEY_EVENT, buf.readUnsignedShort());
+ position.set(Position.KEY_EVENT, buf.readUnsignedShortLE());
buf.skipBytes(6); // event time
@@ -104,33 +104,33 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_RSSI, buf.readUnsignedByte());
if (isFormat(format, F10, F20, F30)) {
- position.set(Position.KEY_OUTPUT, buf.readUnsignedShort());
+ position.set(Position.KEY_OUTPUT, buf.readUnsignedShortLE());
} else if (isFormat(format, F40, F50, F51, F52)) {
position.set(Position.KEY_OUTPUT, buf.readUnsignedByte());
}
if (isFormat(format, F10, F20, F30, F40)) {
- position.set(Position.KEY_INPUT, buf.readUnsignedShort());
+ position.set(Position.KEY_INPUT, buf.readUnsignedShortLE());
} else if (isFormat(format, F50, F51, F52)) {
position.set(Position.KEY_INPUT, buf.readUnsignedByte());
}
- position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.001);
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort());
+ position.set(Position.KEY_POWER, buf.readUnsignedShortLE() * 0.001);
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE());
if (isFormat(format, F10, F20, F30)) {
- position.set(Position.PREFIX_TEMP + 1, buf.readShort());
+ position.set(Position.PREFIX_TEMP + 1, buf.readShortLE());
}
if (isFormat(format, F10, F20, F50, F52)) {
- position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShort());
- position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + 1, buf.readUnsignedShortLE());
+ position.set(Position.PREFIX_ADC + 2, buf.readUnsignedShortLE());
}
// Impulse counters
if (isFormat(format, F20, F50, F51, F52)) {
- buf.readUnsignedInt();
- buf.readUnsignedInt();
+ buf.readUnsignedIntLE();
+ buf.readUnsignedIntLE();
}
if (isFormat(format, F20, F50, F51, F52)) {
@@ -142,30 +142,30 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
.setDateReverse(buf.readUnsignedByte(), buf.readUnsignedByte() + 1, buf.readUnsignedByte());
position.setTime(dateBuilder.getDate());
- position.setLatitude(buf.readFloat() / Math.PI * 180);
- position.setLongitude(buf.readFloat() / Math.PI * 180);
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readFloat()));
- position.setCourse(buf.readUnsignedShort());
+ position.setLatitude(buf.readFloatLE() / Math.PI * 180);
+ position.setLongitude(buf.readFloatLE() / Math.PI * 180);
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readFloatLE()));
+ position.setCourse(buf.readUnsignedShortLE());
- position.set(Position.KEY_ODOMETER, buf.readFloat() * 1000);
- position.set(Position.KEY_DISTANCE, buf.readFloat());
+ position.set(Position.KEY_ODOMETER, buf.readFloatLE() * 1000);
+ position.set(Position.KEY_DISTANCE, buf.readFloatLE());
// Segment times
- buf.readUnsignedShort();
- buf.readUnsignedShort();
+ buf.readUnsignedShortLE();
+ buf.readUnsignedShortLE();
}
// Other
if (isFormat(format, F51, F52)) {
- buf.readUnsignedShort();
+ buf.readUnsignedShortLE();
buf.readByte();
- buf.readUnsignedShort();
- buf.readUnsignedShort();
+ buf.readUnsignedShortLE();
+ buf.readUnsignedShortLE();
buf.readByte();
- buf.readUnsignedShort();
- buf.readUnsignedShort();
+ buf.readUnsignedShortLE();
+ buf.readUnsignedShortLE();
buf.readByte();
- buf.readUnsignedShort();
+ buf.readUnsignedShortLE();
}
// Four temperature sensors
@@ -179,12 +179,12 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
return new ParseResult(index, position);
}
- private Object processSingle(DeviceSession deviceSession, Channel channel, ChannelBuffer buf) {
+ private Object processSingle(DeviceSession deviceSession, Channel channel, ByteBuf buf) {
ParseResult result = parsePosition(deviceSession, buf);
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 8);
- response.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "*<T", StandardCharsets.US_ASCII));
- response.writeInt((int) result.getId());
+ ByteBuf response = Unpooled.buffer(8);
+ response.writeCharSequence("*<T", StandardCharsets.US_ASCII);
+ response.writeIntLE((int) result.getId());
sendReply(channel, response);
if (result.getPosition().getFixTime() == null) {
@@ -194,7 +194,7 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
return result.getPosition();
}
- private Object processArray(DeviceSession deviceSession, Channel channel, ChannelBuffer buf) {
+ private Object processArray(DeviceSession deviceSession, Channel channel, ByteBuf buf) {
List<Position> positions = new LinkedList<>();
int count = buf.readUnsignedByte();
@@ -205,8 +205,8 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
}
}
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 8);
- response.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "*<A", StandardCharsets.US_ASCII));
+ ByteBuf response = Unpooled.buffer(8);
+ response.writeCharSequence("*<A", StandardCharsets.US_ASCII);
response.writeByte(count);
sendReply(channel, response);
@@ -217,15 +217,15 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
return positions;
}
- private Object processHandshake(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private Object processHandshake(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
buf.readByte(); // semicolon symbol
if (getDeviceSession(channel, remoteAddress, buf.toString(StandardCharsets.US_ASCII)) != null) {
- sendReply(channel, ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "*<S", StandardCharsets.US_ASCII));
+ sendReply(channel, Unpooled.copiedBuffer("*<S", StandardCharsets.US_ASCII));
}
return null;
}
- private static short checksum(ChannelBuffer buf) {
+ private static short checksum(ByteBuf buf) {
short sum = 0;
for (int i = 0; i < buf.readableBytes(); i++) {
sum ^= buf.getUnsignedByte(i);
@@ -233,17 +233,17 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
return sum;
}
- private void sendReply(Channel channel, ChannelBuffer data) {
- ChannelBuffer header = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 16);
- header.writeBytes(ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, prefix, StandardCharsets.US_ASCII));
- header.writeInt((int) deviceUniqueId);
- header.writeInt((int) serverId);
- header.writeShort(data.readableBytes());
- header.writeByte(checksum(data));
- header.writeByte(checksum(header));
-
+ private void sendReply(Channel channel, ByteBuf data) {
if (channel != null) {
- channel.write(ChannelBuffers.copiedBuffer(header, data));
+ ByteBuf header = Unpooled.buffer(16);
+ header.writeCharSequence(prefix, StandardCharsets.US_ASCII);
+ header.writeIntLE((int) deviceUniqueId);
+ header.writeIntLE((int) serverId);
+ header.writeShortLE(data.readableBytes());
+ header.writeByte(checksum(data));
+ header.writeByte(checksum(header));
+
+ channel.writeAndFlush(new NetworkMessage(Unpooled.wrappedBuffer(header, data), channel.remoteAddress()));
}
}
@@ -251,13 +251,13 @@ public class NavisProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
prefix = buf.toString(buf.readerIndex(), 4, StandardCharsets.US_ASCII);
buf.skipBytes(prefix.length()); // prefix @NTC by default
- serverId = buf.readUnsignedInt();
- deviceUniqueId = buf.readUnsignedInt();
- int length = buf.readUnsignedShort();
+ serverId = buf.readUnsignedIntLE();
+ deviceUniqueId = buf.readUnsignedIntLE();
+ int length = buf.readUnsignedShortLE();
buf.skipBytes(2); // header and data XOR checksum
if (length == 0) {
diff --git a/src/org/traccar/protocol/NoranProtocol.java b/src/org/traccar/protocol/NoranProtocol.java
index 7d3dc4852..9cae57b32 100644
--- a/src/org/traccar/protocol/NoranProtocol.java
+++ b/src/org/traccar/protocol/NoranProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
-import java.nio.ByteOrder;
import java.util.List;
public class NoranProtocol extends BaseProtocol {
@@ -38,15 +36,13 @@ public class NoranProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectEncoder", new NoranProtocolEncoder());
pipeline.addLast("objectDecoder", new NoranProtocolDecoder(NoranProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/NoranProtocolDecoder.java b/src/org/traccar/protocol/NoranProtocolDecoder.java
index e10332ece..65bd64384 100644
--- a/src/org/traccar/protocol/NoranProtocolDecoder.java
+++ b/src/org/traccar/protocol/NoranProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,18 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -51,24 +51,22 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
- buf.readUnsignedShort(); // length
- int type = buf.readUnsignedShort();
+ buf.readUnsignedShortLE(); // length
+ int type = buf.readUnsignedShortLE();
if (type == MSG_SHAKE_HAND && channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 13);
- response.writeBytes(
- ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "\r\n*KW", StandardCharsets.US_ASCII));
+ ByteBuf response = Unpooled.buffer(13);
+ response.writeCharSequence("\r\n*KW", StandardCharsets.US_ASCII);
response.writeByte(0);
- response.writeShort(response.capacity());
- response.writeShort(MSG_SHAKE_HAND_RESPONSE);
+ response.writeShortLE(response.capacity());
+ response.writeShortLE(MSG_SHAKE_HAND_RESPONSE);
response.writeByte(1); // status
- response.writeBytes(
- ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "\r\n", StandardCharsets.US_ASCII));
+ response.writeCharSequence("\r\n", StandardCharsets.US_ASCII);
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
} else if (type == MSG_UPLOAD_POSITION || type == MSG_UPLOAD_POSITION_NEW
|| type == MSG_CONTROL_RESPONSE || type == MSG_ALARM) {
@@ -83,8 +81,8 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
if (type == MSG_CONTROL_RESPONSE) {
- buf.readUnsignedInt(); // GIS ip
- buf.readUnsignedInt(); // GIS port
+ buf.readUnsignedIntLE(); // GIS ip
+ buf.readUnsignedIntLE(); // GIS port
}
position.setValid(BitUtil.check(buf.readUnsignedByte(), 0));
@@ -108,17 +106,17 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
}
if (newFormat) {
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedInt()));
- position.setCourse(buf.readFloat());
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedIntLE()));
+ position.setCourse(buf.readFloatLE());
} else {
position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
- position.setCourse(buf.readUnsignedShort());
+ position.setCourse(buf.readUnsignedShortLE());
}
- position.setLongitude(buf.readFloat());
- position.setLatitude(buf.readFloat());
+ position.setLongitude(buf.readFloatLE());
+ position.setLatitude(buf.readFloatLE());
if (!newFormat) {
- long timeValue = buf.readUnsignedInt();
+ long timeValue = buf.readUnsignedIntLE();
DateBuilder dateBuilder = new DateBuilder()
.setYear((int) BitUtil.from(timeValue, 26))
.setMonth((int) BitUtil.between(timeValue, 22, 26))
@@ -129,11 +127,11 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
position.setTime(dateBuilder.getDate());
}
- ChannelBuffer rawId;
+ ByteBuf rawId;
if (newFormat) {
- rawId = buf.readBytes(12);
+ rawId = buf.readSlice(12);
} else {
- rawId = buf.readBytes(11);
+ rawId = buf.readSlice(11);
}
String id = rawId.toString(StandardCharsets.US_ASCII).replaceAll("[^\\p{Print}]", "");
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id);
@@ -144,7 +142,7 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
if (newFormat) {
DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
- position.setTime(dateFormat.parse(buf.readBytes(17).toString(StandardCharsets.US_ASCII)));
+ position.setTime(dateFormat.parse(buf.readSlice(17).toString(StandardCharsets.US_ASCII)));
buf.readByte();
}
@@ -152,8 +150,8 @@ public class NoranProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.PREFIX_IO + 1, buf.readUnsignedByte());
position.set(Position.KEY_FUEL_LEVEL, buf.readUnsignedByte());
} else if (type == MSG_UPLOAD_POSITION_NEW) {
- position.set(Position.PREFIX_TEMP + 1, buf.readShort());
- position.set(Position.KEY_ODOMETER, buf.readFloat());
+ position.set(Position.PREFIX_TEMP + 1, buf.readShortLE());
+ position.set(Position.KEY_ODOMETER, buf.readFloatLE());
}
return position;
diff --git a/src/org/traccar/protocol/NoranProtocolEncoder.java b/src/org/traccar/protocol/NoranProtocolEncoder.java
index 25b510a73..53b0c54ba 100644
--- a/src/org/traccar/protocol/NoranProtocolEncoder.java
+++ b/src/org/traccar/protocol/NoranProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,32 +15,29 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Log;
import org.traccar.model.Command;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
public class NoranProtocolEncoder extends BaseProtocolEncoder {
- private ChannelBuffer encodeContent(String content) {
+ private ByteBuf encodeContent(String content) {
- ChannelBuffer buf = ChannelBuffers.buffer(ByteOrder.LITTLE_ENDIAN, 12 + 56);
+ ByteBuf buf = Unpooled.buffer(12 + 56);
- buf.writeBytes(
- ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "\r\n*KW", StandardCharsets.US_ASCII));
+ buf.writeCharSequence("\r\n*KW", StandardCharsets.US_ASCII);
buf.writeByte(0);
- buf.writeShort(buf.capacity());
- buf.writeShort(NoranProtocolDecoder.MSG_CONTROL);
+ buf.writeShortLE(buf.capacity());
+ buf.writeShortLE(NoranProtocolDecoder.MSG_CONTROL);
buf.writeInt(0); // gis ip
- buf.writeShort(0); // gis port
+ buf.writeShortLE(0); // gis port
buf.writeBytes(content.getBytes(StandardCharsets.US_ASCII));
buf.writerIndex(buf.writerIndex() + 50 - content.length());
- buf.writeBytes(
- ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, "\r\n", StandardCharsets.US_ASCII));
+ buf.writeCharSequence("\r\n", StandardCharsets.US_ASCII);
return buf;
}
diff --git a/src/org/traccar/protocol/NvsFrameDecoder.java b/src/org/traccar/protocol/NvsFrameDecoder.java
index 598bb1e4c..e93a58cf6 100644
--- a/src/org/traccar/protocol/NvsFrameDecoder.java
+++ b/src/org/traccar/protocol/NvsFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,16 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class NvsFrameDecoder extends FrameDecoder {
+public class NvsFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 4 + 2) {
return null;
@@ -40,7 +38,7 @@ public class NvsFrameDecoder extends FrameDecoder {
}
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
return null;
diff --git a/src/org/traccar/protocol/NvsProtocol.java b/src/org/traccar/protocol/NvsProtocol.java
index fdcb2bbcf..aaf447120 100644
--- a/src/org/traccar/protocol/NvsProtocol.java
+++ b/src/org/traccar/protocol/NvsProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class NvsProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new NvsFrameDecoder());
pipeline.addLast("objectDecoder", new NvsProtocolDecoder(NvsProtocol.this));
}
diff --git a/src/org/traccar/protocol/NvsProtocolDecoder.java b/src/org/traccar/protocol/NvsProtocolDecoder.java
index db8347d3c..46909ff0c 100644
--- a/src/org/traccar/protocol/NvsProtocolDecoder.java
+++ b/src/org/traccar/protocol/NvsProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -35,9 +36,10 @@ public class NvsProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private void sendResponse(Channel channel, String response) {
+ private void sendResponse(Channel channel, SocketAddress remoteAddress, String response) {
if (channel != null) {
- channel.write(ChannelBuffers.copiedBuffer(response, StandardCharsets.US_ASCII));
+ channel.writeAndFlush(new NetworkMessage(
+ Unpooled.copiedBuffer(response, StandardCharsets.US_ASCII), remoteAddress));
}
}
@@ -45,7 +47,7 @@ public class NvsProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (buf.getUnsignedByte(buf.readerIndex()) == 0) {
@@ -55,9 +57,9 @@ public class NvsProtocolDecoder extends BaseProtocolDecoder {
String imei = buf.toString(buf.readerIndex(), 15, StandardCharsets.US_ASCII);
if (getDeviceSession(channel, remoteAddress, imei) != null) {
- sendResponse(channel, "OK");
+ sendResponse(channel, remoteAddress, "OK");
} else {
- sendResponse(channel, "NO01");
+ sendResponse(channel, remoteAddress, "NO01");
}
} else {
diff --git a/src/org/traccar/protocol/ObdDongleProtocol.java b/src/org/traccar/protocol/ObdDongleProtocol.java
index 6547a31ab..5f50b16ae 100644
--- a/src/org/traccar/protocol/ObdDongleProtocol.java
+++ b/src/org/traccar/protocol/ObdDongleProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -31,9 +30,9 @@ public class ObdDongleProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1099, 20, 2, 3, 0));
pipeline.addLast("objectDecoder", new ObdDongleProtocolDecoder(ObdDongleProtocol.this));
}
diff --git a/src/org/traccar/protocol/ObdDongleProtocolDecoder.java b/src/org/traccar/protocol/ObdDongleProtocolDecoder.java
index 5310c90fd..2f96bbac5 100644
--- a/src/org/traccar/protocol/ObdDongleProtocolDecoder.java
+++ b/src/org/traccar/protocol/ObdDongleProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -42,18 +43,19 @@ public class ObdDongleProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_TYPE_PINGRESP = 0x0D;
public static final int MSG_TYPE_DISCONNECT = 0x0E;
- private static void sendResponse(Channel channel, int type, int index, String imei, ChannelBuffer content) {
+ private static void sendResponse(Channel channel, int type, int index, String imei, ByteBuf content) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeShort(0x5555); // header
response.writeShort(index);
response.writeBytes(imei.getBytes(StandardCharsets.US_ASCII));
response.writeByte(type);
response.writeShort(content.readableBytes());
response.writeBytes(content);
+ content.release();
response.writeByte(0); // checksum
response.writeShort(0xAAAA);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
@@ -61,12 +63,12 @@ public class ObdDongleProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
int index = buf.readUnsignedShort();
- String imei = buf.readBytes(15).toString(StandardCharsets.US_ASCII);
+ String imei = buf.readSlice(15).toString(StandardCharsets.US_ASCII);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession == null) {
return null;
@@ -78,7 +80,7 @@ public class ObdDongleProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_TYPE_CONNECT) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeByte(1);
response.writeShort(0);
response.writeInt(0);
@@ -112,7 +114,7 @@ public class ObdDongleProtocolDecoder extends BaseProtocolDecoder {
position.setSpeed(UnitsConverter.knotsFromMph(BitUtil.from(speedCourse, 10) * 0.1));
position.setCourse(BitUtil.to(speedCourse, 10));
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeByte(typeMajor);
response.writeByte(typeMinor);
sendResponse(channel, MSG_TYPE_PUBACK, index, imei, response);
diff --git a/src/org/traccar/protocol/OigoProtocol.java b/src/org/traccar/protocol/OigoProtocol.java
index 4b6ad0dd0..b4f2b4163 100644
--- a/src/org/traccar/protocol/OigoProtocol.java
+++ b/src/org/traccar/protocol/OigoProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class OigoProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectDecoder", new OigoProtocolDecoder(OigoProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/OigoProtocolDecoder.java b/src/org/traccar/protocol/OigoProtocolDecoder.java
index 2874d0455..fe356f7cf 100644
--- a/src/org/traccar/protocol/OigoProtocolDecoder.java
+++ b/src/org/traccar/protocol/OigoProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
@@ -39,7 +41,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_ACKNOWLEDGEMENT = 0xE0;
- private Position decodeArMessage(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private Position decodeArMessage(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
buf.skipBytes(1); // header
buf.readUnsignedShort(); // length
@@ -51,12 +53,12 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
DeviceSession deviceSession;
switch (BitUtil.to(tag, 3)) {
case 0:
- String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1);
+ String imei = ByteBufUtil.hexDump(buf.readSlice(8)).substring(1);
deviceSession = getDeviceSession(channel, remoteAddress, imei);
break;
case 1:
buf.skipBytes(1);
- String meid = buf.readBytes(14).toString(StandardCharsets.US_ASCII);
+ String meid = buf.readSlice(14).toString(StandardCharsets.US_ASCII);
deviceSession = getDeviceSession(channel, remoteAddress, meid);
break;
default:
@@ -159,7 +161,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
return negative ? -degrees : degrees;
}
- private Position decodeMgMessage(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private Position decodeMgMessage(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
buf.readUnsignedByte(); // tag
int flags = buf.getUnsignedByte(buf.readerIndex());
@@ -169,7 +171,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
buf.readUnsignedByte(); // flags
deviceSession = getDeviceSession(channel, remoteAddress);
} else {
- String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1);
+ String imei = ByteBufUtil.hexDump(buf.readSlice(8)).substring(1);
deviceSession = getDeviceSession(channel, remoteAddress, imei);
}
@@ -211,11 +213,11 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ODOMETER, (long) (buf.readUnsignedInt() * 1609.34));
if (channel != null && BitUtil.check(flags, 7)) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeByte(MSG_ACKNOWLEDGEMENT);
response.writeByte(index);
response.writeByte(0x00);
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
return position;
@@ -225,7 +227,7 @@ public class OigoProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (buf.getUnsignedByte(buf.readerIndex()) == 0x7e) {
return decodeArMessage(channel, remoteAddress, buf);
diff --git a/src/org/traccar/protocol/OkoProtocol.java b/src/org/traccar/protocol/OkoProtocol.java
index 0b38741e5..21f06cca0 100644
--- a/src/org/traccar/protocol/OkoProtocol.java
+++ b/src/org/traccar/protocol/OkoProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringDecoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class OkoProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '}'));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new OkoProtocolDecoder(OkoProtocol.this));
diff --git a/src/org/traccar/protocol/OkoProtocolDecoder.java b/src/org/traccar/protocol/OkoProtocolDecoder.java
index 0ebe63ca3..0318c30c7 100644
--- a/src/org/traccar/protocol/OkoProtocolDecoder.java
+++ b/src/org/traccar/protocol/OkoProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/OpenGtsProtocol.java b/src/org/traccar/protocol/OpenGtsProtocol.java
index a0246ba1b..afc0b0c60 100644
--- a/src/org/traccar/protocol/OpenGtsProtocol.java
+++ b/src/org/traccar/protocol/OpenGtsProtocol.java
@@ -15,11 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
-import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpRequestDecoder;
+import io.netty.handler.codec.http.HttpResponseEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,11 +32,12 @@ public class OpenGtsProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
+ pipeline.addLast("httpAggregator", new HttpObjectAggregator(16384));
pipeline.addLast("objectDecoder", new OpenGtsProtocolDecoder(OpenGtsProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/OpenGtsProtocolDecoder.java b/src/org/traccar/protocol/OpenGtsProtocolDecoder.java
index ba8f434d8..b61426085 100644
--- a/src/org/traccar/protocol/OpenGtsProtocolDecoder.java
+++ b/src/org/traccar/protocol/OpenGtsProtocolDecoder.java
@@ -15,10 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.handler.codec.http.HttpRequest;
-import org.jboss.netty.handler.codec.http.HttpResponseStatus;
-import org.jboss.netty.handler.codec.http.QueryStringDecoder;
+import io.netty.channel.Channel;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.handler.codec.http.QueryStringDecoder;
import org.traccar.BaseHttpProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
@@ -55,9 +55,9 @@ public class OpenGtsProtocolDecoder extends BaseHttpProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- HttpRequest request = (HttpRequest) msg;
- QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());
- Map<String, List<String>> params = decoder.getParameters();
+ FullHttpRequest request = (FullHttpRequest) msg;
+ QueryStringDecoder decoder = new QueryStringDecoder(request.uri());
+ Map<String, List<String>> params = decoder.parameters();
Position position = new Position();
position.setProtocol(getProtocolName());
diff --git a/src/org/traccar/protocol/OrionFrameDecoder.java b/src/org/traccar/protocol/OrionFrameDecoder.java
index f7371747a..948806609 100644
--- a/src/org/traccar/protocol/OrionFrameDecoder.java
+++ b/src/org/traccar/protocol/OrionFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,16 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class OrionFrameDecoder extends FrameDecoder {
+public class OrionFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
int length = 6;
@@ -51,14 +49,14 @@ public class OrionFrameDecoder extends FrameDecoder {
}
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
} else if (type == OrionProtocolDecoder.MSG_SYSLOG && buf.readableBytes() >= length + 12) {
- length += buf.getUnsignedShort(buf.readerIndex() + 8);
+ length += buf.getUnsignedShortLE(buf.readerIndex() + 8);
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
}
diff --git a/src/org/traccar/protocol/OrionProtocol.java b/src/org/traccar/protocol/OrionProtocol.java
index f4bfef985..ba7044cce 100644
--- a/src/org/traccar/protocol/OrionProtocol.java
+++ b/src/org/traccar/protocol/OrionProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
-import java.nio.ByteOrder;
import java.util.List;
public class OrionProtocol extends BaseProtocol {
@@ -31,15 +29,13 @@ public class OrionProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new OrionFrameDecoder());
pipeline.addLast("objectDecoder", new OrionProtocolDecoder(OrionProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/OrionProtocolDecoder.java b/src/org/traccar/protocol/OrionProtocolDecoder.java
index ada864fba..bbc509bec 100644
--- a/src/org/traccar/protocol/OrionProtocolDecoder.java
+++ b/src/org/traccar/protocol/OrionProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.model.Position;
@@ -36,13 +37,13 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_USERLOG = 0;
public static final int MSG_SYSLOG = 3;
- private static void sendResponse(Channel channel, ChannelBuffer buf) {
+ private static void sendResponse(Channel channel, ByteBuf buf) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(4);
+ ByteBuf response = Unpooled.buffer(4);
response.writeByte('*');
response.writeShort(buf.getUnsignedShort(buf.writerIndex() - 2));
response.writeByte(buf.getUnsignedByte(buf.writerIndex() - 3));
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
@@ -56,7 +57,7 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
int type = buf.readUnsignedByte() & 0x0f;
@@ -84,13 +85,13 @@ public class OrionProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_EVENT, buf.readUnsignedByte());
buf.readUnsignedByte(); // length
- position.set(Position.KEY_FLAGS, buf.readUnsignedShort());
+ position.set(Position.KEY_FLAGS, buf.readUnsignedShortLE());
- position.setLatitude(convertCoordinate(buf.readInt()));
- position.setLongitude(convertCoordinate(buf.readInt()));
- position.setAltitude(buf.readShort() / 10.0);
- position.setCourse(buf.readUnsignedShort());
- position.setSpeed(buf.readUnsignedShort() * 0.0539957);
+ position.setLatitude(convertCoordinate(buf.readIntLE()));
+ position.setLongitude(convertCoordinate(buf.readIntLE()));
+ position.setAltitude(buf.readShortLE() / 10.0);
+ position.setCourse(buf.readUnsignedShortLE());
+ position.setSpeed(buf.readUnsignedShortLE() * 0.0539957);
DateBuilder dateBuilder = new DateBuilder()
.setDate(buf.readUnsignedByte(), buf.readUnsignedByte(), buf.readUnsignedByte())
diff --git a/src/org/traccar/protocol/OsmAndProtocol.java b/src/org/traccar/protocol/OsmAndProtocol.java
index 785f4bd75..a199f067a 100644
--- a/src/org/traccar/protocol/OsmAndProtocol.java
+++ b/src/org/traccar/protocol/OsmAndProtocol.java
@@ -15,11 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
-import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpRequestDecoder;
+import io.netty.handler.codec.http.HttpResponseEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,11 +32,12 @@ public class OsmAndProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
+ pipeline.addLast("httpAggregator", new HttpObjectAggregator(16384));
pipeline.addLast("objectDecoder", new OsmAndProtocolDecoder(OsmAndProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/OsmAndProtocolDecoder.java b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
index 03abdd588..c75e9519c 100644
--- a/src/org/traccar/protocol/OsmAndProtocolDecoder.java
+++ b/src/org/traccar/protocol/OsmAndProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.handler.codec.http.HttpRequest;
-import org.jboss.netty.handler.codec.http.HttpResponseStatus;
-import org.jboss.netty.handler.codec.http.QueryStringDecoder;
+import io.netty.channel.Channel;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.handler.codec.http.QueryStringDecoder;
import org.joda.time.format.ISODateTimeFormat;
import org.traccar.BaseHttpProtocolDecoder;
import org.traccar.DeviceSession;
@@ -42,15 +42,14 @@ public class OsmAndProtocolDecoder extends BaseHttpProtocolDecoder {
}
@Override
- protected Object decode(
- Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
+ protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- HttpRequest request = (HttpRequest) msg;
- QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());
- Map<String, List<String>> params = decoder.getParameters();
+ FullHttpRequest request = (FullHttpRequest) msg;
+ QueryStringDecoder decoder = new QueryStringDecoder(request.uri());
+ Map<String, List<String>> params = decoder.parameters();
if (params.isEmpty()) {
- decoder = new QueryStringDecoder(request.getContent().toString(StandardCharsets.US_ASCII), false);
- params = decoder.getParameters();
+ decoder = new QueryStringDecoder(request.content().toString(StandardCharsets.US_ASCII), false);
+ params = decoder.parameters();
}
Position position = new Position(getProtocolName());
diff --git a/src/org/traccar/protocol/OwnTracksProtocol.java b/src/org/traccar/protocol/OwnTracksProtocol.java
index c4a6ab163..275bb739a 100644
--- a/src/org/traccar/protocol/OwnTracksProtocol.java
+++ b/src/org/traccar/protocol/OwnTracksProtocol.java
@@ -1,6 +1,6 @@
/*
* Copyright 2017 Jan-Piet Mens (jpmens@gmail.com)
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,11 +16,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
-import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpRequestDecoder;
+import io.netty.handler.codec.http.HttpResponseEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,11 +33,12 @@ public class OwnTracksProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
+ pipeline.addLast("httpAggregator", new HttpObjectAggregator(16384));
pipeline.addLast("objectDecoder", new OwnTracksProtocolDecoder(OwnTracksProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/OwnTracksProtocolDecoder.java b/src/org/traccar/protocol/OwnTracksProtocolDecoder.java
index 120995dfb..00a63d712 100644
--- a/src/org/traccar/protocol/OwnTracksProtocolDecoder.java
+++ b/src/org/traccar/protocol/OwnTracksProtocolDecoder.java
@@ -1,6 +1,6 @@
/*
* Copyright 2017 Jan-Piet Mens (jpmens@gmail.com)
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.handler.codec.http.HttpRequest;
-import org.jboss.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.channel.Channel;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.HttpResponseStatus;
import org.traccar.BaseHttpProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.UnitsConverter;
@@ -41,9 +41,9 @@ public class OwnTracksProtocolDecoder extends BaseHttpProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- HttpRequest request = (HttpRequest) msg;
+ FullHttpRequest request = (FullHttpRequest) msg;
JsonObject root = Json.createReader(
- new StringReader(request.getContent().toString(StandardCharsets.US_ASCII))).readObject();
+ new StringReader(request.content().toString(StandardCharsets.US_ASCII))).readObject();
if (!root.containsKey("_type") || !root.getString("_type").equals("location")) {
sendResponse(channel, HttpResponseStatus.OK);
@@ -98,4 +98,5 @@ public class OwnTracksProtocolDecoder extends BaseHttpProtocolDecoder {
sendResponse(channel, HttpResponseStatus.OK);
return position;
}
+
}
diff --git a/src/org/traccar/protocol/PathAwayProtocol.java b/src/org/traccar/protocol/PathAwayProtocol.java
index a41692750..7cb5a3fca 100644
--- a/src/org/traccar/protocol/PathAwayProtocol.java
+++ b/src/org/traccar/protocol/PathAwayProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
-import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpRequestDecoder;
+import io.netty.handler.codec.http.HttpResponseEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,11 +32,12 @@ public class PathAwayProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
+ pipeline.addLast("httpAggregator", new HttpObjectAggregator(16384));
pipeline.addLast("objectDecoder", new PathAwayProtocolDecoder(PathAwayProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/PathAwayProtocolDecoder.java b/src/org/traccar/protocol/PathAwayProtocolDecoder.java
index 845a5e892..40e68a5d2 100644
--- a/src/org/traccar/protocol/PathAwayProtocolDecoder.java
+++ b/src/org/traccar/protocol/PathAwayProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,17 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelFutureListener;
-import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
-import org.jboss.netty.handler.codec.http.HttpRequest;
-import org.jboss.netty.handler.codec.http.HttpResponse;
-import org.jboss.netty.handler.codec.http.HttpResponseStatus;
-import org.jboss.netty.handler.codec.http.HttpVersion;
-import org.jboss.netty.handler.codec.http.QueryStringDecoder;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelFutureListener;
+import io.netty.handler.codec.http.DefaultFullHttpResponse;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.FullHttpResponse;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.handler.codec.http.HttpVersion;
+import io.netty.handler.codec.http.QueryStringDecoder;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.model.Position;
@@ -58,16 +59,16 @@ public class PathAwayProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- HttpRequest request = (HttpRequest) msg;
- QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());
+ FullHttpRequest request = (FullHttpRequest) msg;
+ QueryStringDecoder decoder = new QueryStringDecoder(request.uri());
DeviceSession deviceSession = getDeviceSession(
- channel, remoteAddress, decoder.getParameters().get("UserName").get(0));
+ channel, remoteAddress, decoder.parameters().get("UserName").get(0));
if (deviceSession == null) {
return null;
}
- Parser parser = new Parser(PATTERN, decoder.getParameters().get("LOC").get(0));
+ Parser parser = new Parser(PATTERN, decoder.parameters().get("LOC").get(0));
if (!parser.matches()) {
return null;
}
@@ -85,8 +86,8 @@ public class PathAwayProtocolDecoder extends BaseProtocolDecoder {
position.setCourse(parser.nextDouble(0));
if (channel != null) {
- HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
- channel.write(response).addListener(ChannelFutureListener.CLOSE);
+ FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress)).addListener(ChannelFutureListener.CLOSE);
}
return position;
diff --git a/src/org/traccar/protocol/PiligrimProtocol.java b/src/org/traccar/protocol/PiligrimProtocol.java
index a2960f762..ff602d366 100644
--- a/src/org/traccar/protocol/PiligrimProtocol.java
+++ b/src/org/traccar/protocol/PiligrimProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
-import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
-import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpRequestDecoder;
+import io.netty.handler.codec.http.HttpResponseEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,12 +32,12 @@ public class PiligrimProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
- pipeline.addLast("httpAggregator", new HttpChunkAggregator(16384));
+ pipeline.addLast("httpAggregator", new HttpObjectAggregator(16384));
pipeline.addLast("objectDecoder", new PiligrimProtocolDecoder(PiligrimProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/PiligrimProtocolDecoder.java b/src/org/traccar/protocol/PiligrimProtocolDecoder.java
index f2ec16c59..a1850df54 100644
--- a/src/org/traccar/protocol/PiligrimProtocolDecoder.java
+++ b/src/org/traccar/protocol/PiligrimProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,23 +15,23 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.handler.codec.http.DefaultHttpResponse;
-import org.jboss.netty.handler.codec.http.HttpRequest;
-import org.jboss.netty.handler.codec.http.HttpResponse;
-import org.jboss.netty.handler.codec.http.HttpResponseStatus;
-import org.jboss.netty.handler.codec.http.HttpVersion;
-import org.jboss.netty.handler.codec.http.QueryStringDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.handler.codec.http.DefaultFullHttpResponse;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.FullHttpResponse;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.handler.codec.http.HttpVersion;
+import io.netty.handler.codec.http.QueryStringDecoder;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.LinkedList;
import java.util.List;
@@ -44,11 +44,10 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder {
private void sendResponse(Channel channel, String message) {
if (channel != null) {
- HttpResponse response = new DefaultHttpResponse(
- HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
- response.setContent(ChannelBuffers.copiedBuffer(
- ByteOrder.BIG_ENDIAN, message, StandardCharsets.US_ASCII));
- channel.write(response);
+ FullHttpResponse response = new DefaultFullHttpResponse(
+ HttpVersion.HTTP_1_1, HttpResponseStatus.OK,
+ Unpooled.copiedBuffer(message, StandardCharsets.US_ASCII));
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
@@ -60,8 +59,8 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- HttpRequest request = (HttpRequest) msg;
- String uri = request.getUri();
+ FullHttpRequest request = (FullHttpRequest) msg;
+ String uri = request.uri();
if (uri.startsWith("/config")) {
@@ -79,15 +78,15 @@ public class PiligrimProtocolDecoder extends BaseProtocolDecoder {
sendResponse(channel, "BINGPS: OK");
- QueryStringDecoder decoder = new QueryStringDecoder(request.getUri());
+ QueryStringDecoder decoder = new QueryStringDecoder(request.uri());
DeviceSession deviceSession = getDeviceSession(
- channel, remoteAddress, decoder.getParameters().get("imei").get(0));
+ channel, remoteAddress, decoder.parameters().get("imei").get(0));
if (deviceSession == null) {
return null;
}
List<Position> positions = new LinkedList<>();
- ChannelBuffer buf = request.getContent();
+ ByteBuf buf = request.content();
while (buf.readableBytes() > 2) {
diff --git a/src/org/traccar/protocol/PretraceProtocol.java b/src/org/traccar/protocol/PretraceProtocol.java
index 8f0a22851..456807c1b 100644
--- a/src/org/traccar/protocol/PretraceProtocol.java
+++ b/src/org/traccar/protocol/PretraceProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class PretraceProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ')'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/PretraceProtocolDecoder.java b/src/org/traccar/protocol/PretraceProtocolDecoder.java
index 24d707a1c..e4306a429 100644
--- a/src/org/traccar/protocol/PretraceProtocolDecoder.java
+++ b/src/org/traccar/protocol/PretraceProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/PricolProtocol.java b/src/org/traccar/protocol/PricolProtocol.java
index 0005dc3c1..ca52e2734 100644
--- a/src/org/traccar/protocol/PricolProtocol.java
+++ b/src/org/traccar/protocol/PricolProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.FixedLengthFrameDecoder;
+import io.netty.handler.codec.FixedLengthFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,16 +30,16 @@ public class PricolProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new FixedLengthFrameDecoder(64));
pipeline.addLast("objectDecoder", new PricolProtocolDecoder(PricolProtocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectDecoder", new PricolProtocolDecoder(PricolProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/PricolProtocolDecoder.java b/src/org/traccar/protocol/PricolProtocolDecoder.java
index 577665dcc..b76e5f27f 100644
--- a/src/org/traccar/protocol/PricolProtocolDecoder.java
+++ b/src/org/traccar/protocol/PricolProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -37,12 +38,12 @@ public class PricolProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.readUnsignedByte(); // header
DeviceSession deviceSession = getDeviceSession(
- channel, remoteAddress, buf.readBytes(7).toString(StandardCharsets.US_ASCII));
+ channel, remoteAddress, buf.readSlice(7).toString(StandardCharsets.US_ASCII));
if (deviceSession == null) {
return null;
}
@@ -86,7 +87,8 @@ public class PricolProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_RPM, buf.readUnsignedShort());
if (channel != null) {
- channel.write(ChannelBuffers.copiedBuffer("ACK", StandardCharsets.US_ASCII), remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(
+ Unpooled.copiedBuffer("ACK", StandardCharsets.US_ASCII), remoteAddress));
}
return position;
diff --git a/src/org/traccar/protocol/ProgressProtocol.java b/src/org/traccar/protocol/ProgressProtocol.java
index 6e2093346..22fdfbd48 100644
--- a/src/org/traccar/protocol/ProgressProtocol.java
+++ b/src/org/traccar/protocol/ProgressProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.nio.ByteOrder;
@@ -32,15 +31,14 @@ public class ProgressProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2, 2, 4, 0));
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
+ pipeline.addLast("frameDecoder",
+ new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 1024, 2, 2, 4, 0, true));
pipeline.addLast("objectDecoder", new ProgressProtocolDecoder(ProgressProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/ProgressProtocolDecoder.java b/src/org/traccar/protocol/ProgressProtocolDecoder.java
index d85b6acb3..dca0e649e 100644
--- a/src/org/traccar/protocol/ProgressProtocolDecoder.java
+++ b/src/org/traccar/protocol/ProgressProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,17 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.LinkedList;
@@ -53,12 +54,12 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder {
if (lastIndex == 0) {
lastIndex = newIndex;
} else if (newIndex > lastIndex) {
- ChannelBuffer request = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, 12);
- request.writeShort(MSG_LOG_SYNC);
- request.writeShort(4);
- request.writeInt((int) lastIndex);
- request.writeInt(0);
- channel.write(request);
+ ByteBuf request = Unpooled.buffer(12);
+ request.writeShortLE(MSG_LOG_SYNC);
+ request.writeShortLE(4);
+ request.writeIntLE((int) lastIndex);
+ request.writeIntLE(0);
+ channel.writeAndFlush(new NetworkMessage(request, channel.remoteAddress()));
}
}
@@ -66,19 +67,19 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
- int type = buf.readUnsignedShort();
- buf.readUnsignedShort(); // length
+ ByteBuf buf = (ByteBuf) msg;
+ int type = buf.readUnsignedShortLE();
+ buf.readUnsignedShortLE(); // length
if (type == MSG_IDENT || type == MSG_IDENT_FULL) {
- buf.readUnsignedInt(); // id
- int length = buf.readUnsignedShort();
+ buf.readUnsignedIntLE(); // id
+ int length = buf.readUnsignedShortLE();
buf.skipBytes(length);
- length = buf.readUnsignedShort();
+ length = buf.readUnsignedShortLE();
buf.skipBytes(length);
- length = buf.readUnsignedShort();
- String imei = buf.readBytes(length).toString(StandardCharsets.US_ASCII);
+ length = buf.readUnsignedShortLE();
+ String imei = buf.readSlice(length).toString(StandardCharsets.US_ASCII);
getDeviceSession(channel, remoteAddress, imei);
} else if (type == MSG_POINT || type == MSG_ALARM || type == MSG_LOGMSG) {
@@ -92,7 +93,7 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder {
int recordCount = 1;
if (type == MSG_LOGMSG) {
- recordCount = buf.readUnsignedShort();
+ recordCount = buf.readUnsignedShortLE();
}
for (int j = 0; j < recordCount; j++) {
@@ -101,61 +102,60 @@ public class ProgressProtocolDecoder extends BaseProtocolDecoder {
if (type == MSG_LOGMSG) {
position.set(Position.KEY_ARCHIVE, true);
- int subtype = buf.readUnsignedShort();
+ int subtype = buf.readUnsignedShortLE();
if (subtype == MSG_ALARM) {
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
}
- if (buf.readUnsignedShort() > buf.readableBytes()) {
+ if (buf.readUnsignedShortLE() > buf.readableBytes()) {
lastIndex += 1;
break; // workaround for device bug
}
- lastIndex = buf.readUnsignedInt();
+ lastIndex = buf.readUnsignedIntLE();
position.set(Position.KEY_INDEX, lastIndex);
} else {
- newIndex = buf.readUnsignedInt();
+ newIndex = buf.readUnsignedIntLE();
}
- position.setTime(new Date(buf.readUnsignedInt() * 1000));
- position.setLatitude(buf.readInt() * 180.0 / 0x7FFFFFFF);
- position.setLongitude(buf.readInt() * 180.0 / 0x7FFFFFFF);
- position.setSpeed(buf.readUnsignedInt() * 0.01);
- position.setCourse(buf.readUnsignedShort() * 0.01);
- position.setAltitude(buf.readUnsignedShort() * 0.01);
+ position.setTime(new Date(buf.readUnsignedIntLE() * 1000));
+ position.setLatitude(buf.readIntLE() * 180.0 / 0x7FFFFFFF);
+ position.setLongitude(buf.readIntLE() * 180.0 / 0x7FFFFFFF);
+ position.setSpeed(buf.readUnsignedIntLE() * 0.01);
+ position.setCourse(buf.readUnsignedShortLE() * 0.01);
+ position.setAltitude(buf.readUnsignedShortLE() * 0.01);
int satellites = buf.readUnsignedByte();
position.setValid(satellites >= 3);
position.set(Position.KEY_SATELLITES, satellites);
position.set(Position.KEY_RSSI, buf.readUnsignedByte());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
- long extraFlags = buf.readLong();
+ long extraFlags = buf.readLongLE();
if (BitUtil.check(extraFlags, 0)) {
- int count = buf.readUnsignedShort();
+ int count = buf.readUnsignedShortLE();
for (int i = 1; i <= count; i++) {
- position.set(Position.PREFIX_ADC + i, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + i, buf.readUnsignedShortLE());
}
}
if (BitUtil.check(extraFlags, 1)) {
- int size = buf.readUnsignedShort();
+ int size = buf.readUnsignedShortLE();
position.set("can", buf.toString(buf.readerIndex(), size, StandardCharsets.US_ASCII));
buf.skipBytes(size);
}
if (BitUtil.check(extraFlags, 2)) {
- position.set("passenger",
- ChannelBuffers.hexDump(buf.readBytes(buf.readUnsignedShort())));
+ position.set("passenger", ByteBufUtil.hexDump(buf.readSlice(buf.readUnsignedShortLE())));
}
if (type == MSG_ALARM) {
position.set(Position.KEY_ALARM, true);
byte[] response = {(byte) 0xC9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
- channel.write(ChannelBuffers.wrappedBuffer(response));
+ channel.writeAndFlush(new NetworkMessage(Unpooled.wrappedBuffer(response), remoteAddress));
}
- buf.readUnsignedInt(); // crc
+ buf.readUnsignedIntLE(); // crc
positions.add(position);
}
diff --git a/src/org/traccar/protocol/Pt3000Protocol.java b/src/org/traccar/protocol/Pt3000Protocol.java
index 9c9da3301..03cc493d9 100644
--- a/src/org/traccar/protocol/Pt3000Protocol.java
+++ b/src/org/traccar/protocol/Pt3000Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class Pt3000Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, 'd')); // probably wrong
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java
index f4540afe8..8e9d99d14 100644
--- a/src/org/traccar/protocol/Pt3000ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt3000ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/Pt502FrameDecoder.java b/src/org/traccar/protocol/Pt502FrameDecoder.java
index 4d3e9b4d5..316cd987f 100644
--- a/src/org/traccar/protocol/Pt502FrameDecoder.java
+++ b/src/org/traccar/protocol/Pt502FrameDecoder.java
@@ -15,20 +15,20 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
import java.nio.charset.StandardCharsets;
-public class Pt502FrameDecoder extends FrameDecoder {
+public class Pt502FrameDecoder extends BaseFrameDecoder {
private static final int BINARY_HEADER = 5;
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 10) {
return null;
@@ -37,10 +37,10 @@ public class Pt502FrameDecoder extends FrameDecoder {
if (buf.getUnsignedByte(buf.readerIndex()) == 0xbf
&& buf.toString(buf.readerIndex() + BINARY_HEADER, 4, StandardCharsets.US_ASCII).equals("$PHD")) {
- int length = buf.getUnsignedShort(buf.readerIndex() + 3);
+ int length = buf.getUnsignedShortLE(buf.readerIndex() + 3);
if (buf.readableBytes() >= length) {
buf.skipBytes(BINARY_HEADER);
- ChannelBuffer result = buf.readBytes(length - BINARY_HEADER - 2);
+ ByteBuf result = buf.readRetainedSlice(length - BINARY_HEADER - 2);
buf.skipBytes(2); // line break
return result;
}
@@ -57,8 +57,8 @@ public class Pt502FrameDecoder extends FrameDecoder {
}
if (index > 0) {
- ChannelBuffer result = buf.readBytes(index - buf.readerIndex());
- while (buf.readable()
+ ByteBuf result = buf.readRetainedSlice(index - buf.readerIndex());
+ while (buf.isReadable()
&& (buf.getByte(buf.readerIndex()) == '\r' || buf.getByte(buf.readerIndex()) == '\n')) {
buf.skipBytes(1);
}
diff --git a/src/org/traccar/protocol/Pt502Protocol.java b/src/org/traccar/protocol/Pt502Protocol.java
index f7d0d04a2..fe8a0bb6c 100644
--- a/src/org/traccar/protocol/Pt502Protocol.java
+++ b/src/org/traccar/protocol/Pt502Protocol.java
@@ -15,14 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
-import java.nio.ByteOrder;
import java.util.List;
public class Pt502Protocol extends BaseProtocol {
@@ -39,17 +37,15 @@ public class Pt502Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new Pt502FrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new Pt502ProtocolEncoder());
pipeline.addLast("objectDecoder", new Pt502ProtocolDecoder(Pt502Protocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/Pt502ProtocolDecoder.java b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
index 76e7ee1bf..e0aea693a 100644
--- a/src/org/traccar/protocol/Pt502ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt502ProtocolDecoder.java
@@ -16,12 +16,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -35,7 +36,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
private static final int MAX_CHUNK_SIZE = 960;
- private ChannelBuffer photo;
+ private ByteBuf photo;
public Pt502ProtocolDecoder(Pt502Protocol protocol) {
super(protocol);
@@ -144,7 +145,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
if (channel != null) {
int offset = photo.writerIndex();
int size = Math.min(photo.writableBytes(), MAX_CHUNK_SIZE);
- channel.write("#PHD" + offset + "," + size + "\r\n");
+ channel.writeAndFlush(new NetworkMessage("#PHD" + offset + "," + size + "\r\n", channel.remoteAddress()));
}
}
@@ -152,7 +153,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
int typeEndIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ',');
String type = buf.toString(buf.readerIndex(), typeEndIndex - buf.readerIndex(), StandardCharsets.US_ASCII);
@@ -164,7 +165,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
if (photo != null) {
- photo.writeBytes(buf.readBytes(buf.readableBytes()));
+ photo.writeBytes(buf.readSlice(buf.readableBytes()));
if (photo.writableBytes() > 0) {
@@ -181,7 +182,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, null);
position.set(Position.KEY_IMAGE, Context.getMediaManager().writeFile(uniqueId, photo, "jpg"));
-
+ photo.release();
photo = null;
return position;
@@ -195,7 +196,7 @@ public class Pt502ProtocolDecoder extends BaseProtocolDecoder {
if (type.startsWith("$PHO")) {
int size = Integer.parseInt(type.split("-")[0].substring(4));
if (size > 0) {
- photo = ChannelBuffers.buffer(size);
+ photo = Unpooled.buffer(size);
requestPhotoFragment(channel);
}
}
diff --git a/src/org/traccar/protocol/Pt60Protocol.java b/src/org/traccar/protocol/Pt60Protocol.java
index 857790efd..6c03f209e 100644
--- a/src/org/traccar/protocol/Pt60Protocol.java
+++ b/src/org/traccar/protocol/Pt60Protocol.java
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class Pt60Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "@R#@"));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/Pt60ProtocolDecoder.java b/src/org/traccar/protocol/Pt60ProtocolDecoder.java
index 26f07a0a9..63dd3c90b 100644
--- a/src/org/traccar/protocol/Pt60ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Pt60ProtocolDecoder.java
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.model.Position;
@@ -49,10 +50,11 @@ public class Pt60ProtocolDecoder extends BaseProtocolDecoder {
.expression("(.*)") // data
.compile();
- private void sendResponse(Channel channel) {
+ private void sendResponse(Channel channel, SocketAddress remoteAddress) {
if (channel != null) {
DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
- channel.write("@G#@,V01,38," + dateFormat.format(new Date()) + ",@R#@");
+ channel.writeAndFlush(new NetworkMessage(
+ "@G#@,V01,38," + dateFormat.format(new Date()) + ",@R#@", remoteAddress));
}
}
@@ -60,7 +62,7 @@ public class Pt60ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- sendResponse(channel);
+ sendResponse(channel, remoteAddress);
Parser parser = new Parser(PATTERN, (String) msg);
if (!parser.matches()) {
diff --git a/src/org/traccar/protocol/RaveonProtocol.java b/src/org/traccar/protocol/RaveonProtocol.java
index e4e100e0b..3dfca17fb 100644
--- a/src/org/traccar/protocol/RaveonProtocol.java
+++ b/src/org/traccar/protocol/RaveonProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class RaveonProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/RaveonProtocolDecoder.java b/src/org/traccar/protocol/RaveonProtocolDecoder.java
index ac52493ad..099c188ac 100644
--- a/src/org/traccar/protocol/RaveonProtocolDecoder.java
+++ b/src/org/traccar/protocol/RaveonProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/RecodaProtocol.java b/src/org/traccar/protocol/RecodaProtocol.java
index daf167fd9..ac8f772b6 100644
--- a/src/org/traccar/protocol/RecodaProtocol.java
+++ b/src/org/traccar/protocol/RecodaProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.nio.ByteOrder;
@@ -32,15 +31,14 @@ public class RecodaProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 4, 4, -8, 0));
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
+ pipeline.addLast("frameDecoder",
+ new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 1024, 4, 4, -8, 0, true));
pipeline.addLast("objectDecoder", new RecodaProtocolDecoder(RecodaProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/RecodaProtocolDecoder.java b/src/org/traccar/protocol/RecodaProtocolDecoder.java
index 7bd4d3dae..eef1cb5af 100644
--- a/src/org/traccar/protocol/RecodaProtocolDecoder.java
+++ b/src/org/traccar/protocol/RecodaProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
@@ -43,19 +43,19 @@ public class RecodaProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
- int type = buf.readInt();
- buf.readUnsignedInt(); // length
+ int type = buf.readIntLE();
+ buf.readUnsignedIntLE(); // length
if (type != MSG_HEARTBEAT) {
- buf.readUnsignedShort(); // version
- buf.readUnsignedShort(); // index
+ buf.readUnsignedShortLE(); // version
+ buf.readUnsignedShortLE(); // index
}
if (type == MSG_SIGNAL_LINK_REGISTRATION) {
- getDeviceSession(channel, remoteAddress, buf.readBytes(12).toString(StandardCharsets.US_ASCII));
+ getDeviceSession(channel, remoteAddress, buf.readSlice(12).toString(StandardCharsets.US_ASCII));
} else if (type == MSG_GPS_DATA) {
@@ -67,21 +67,21 @@ public class RecodaProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.setTime(new Date(buf.readLong()));
+ position.setTime(new Date(buf.readLongLE()));
int flags = buf.readUnsignedByte();
if (BitUtil.check(flags, 0)) {
- buf.readUnsignedShort(); // declination
+ buf.readUnsignedShortLE(); // declination
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShort()));
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedShortLE()));
position.setLongitude(buf.readUnsignedByte() + buf.readUnsignedByte() / 60.0);
position.setLatitude(buf.readUnsignedByte() + buf.readUnsignedByte() / 60.0);
- position.setLongitude(position.getLongitude() + buf.readUnsignedInt() / 3600.0);
- position.setLatitude(position.getLatitude() + buf.readUnsignedInt() / 3600.0);
+ position.setLongitude(position.getLongitude() + buf.readUnsignedIntLE() / 3600.0);
+ position.setLatitude(position.getLatitude() + buf.readUnsignedIntLE() / 3600.0);
int status = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/RitiProtocol.java b/src/org/traccar/protocol/RitiProtocol.java
index 0ff3ce87b..9c2b93feb 100644
--- a/src/org/traccar/protocol/RitiProtocol.java
+++ b/src/org/traccar/protocol/RitiProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.nio.ByteOrder;
@@ -32,15 +31,14 @@ public class RitiProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
- pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 105, 2, 3, 0));
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
+ pipeline.addLast("frameDecoder",
+ new LengthFieldBasedFrameDecoder(ByteOrder.LITTLE_ENDIAN, 1024, 105, 2, 3, 0, true));
pipeline.addLast("objectDecoder", new RitiProtocolDecoder(RitiProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/RitiProtocolDecoder.java b/src/org/traccar/protocol/RitiProtocolDecoder.java
index 637867908..4488db006 100644
--- a/src/org/traccar/protocol/RitiProtocolDecoder.java
+++ b/src/org/traccar/protocol/RitiProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
@@ -52,7 +52,7 @@ public class RitiProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
@@ -66,14 +66,14 @@ public class RitiProtocolDecoder extends BaseProtocolDecoder {
position.set("mode", buf.readUnsignedByte());
position.set(Position.KEY_COMMAND, buf.readUnsignedByte());
- position.set(Position.KEY_POWER, buf.readUnsignedShort() * 0.001);
+ position.set(Position.KEY_POWER, buf.readUnsignedShortLE() * 0.001);
buf.skipBytes(5); // status
- buf.readUnsignedShort(); // idleCount
- buf.readUnsignedShort(); // idleTime in seconds
+ buf.readUnsignedShortLE(); // idleCount
+ buf.readUnsignedShortLE(); // idleTime in seconds
- position.set(Position.KEY_DISTANCE, buf.readUnsignedInt());
- position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedInt());
+ position.set(Position.KEY_DISTANCE, buf.readUnsignedIntLE());
+ position.set(Position.KEY_ODOMETER_TRIP, buf.readUnsignedIntLE());
// Parse GPRMC
int end = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*');
diff --git a/src/org/traccar/protocol/RoboTrackFrameDecoder.java b/src/org/traccar/protocol/RoboTrackFrameDecoder.java
index af215103c..aecbaaa3b 100644
--- a/src/org/traccar/protocol/RoboTrackFrameDecoder.java
+++ b/src/org/traccar/protocol/RoboTrackFrameDecoder.java
@@ -15,14 +15,14 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class RoboTrackFrameDecoder extends FrameDecoder {
+public class RoboTrackFrameDecoder extends BaseFrameDecoder {
- private int messageLength(ChannelBuffer buf) {
+ private int messageLength(ByteBuf buf) {
switch ((int) buf.getByte(buf.readerIndex())) {
case RoboTrackProtocolDecoder.MSG_ID:
return 69;
@@ -33,7 +33,7 @@ public class RoboTrackFrameDecoder extends FrameDecoder {
case RoboTrackProtocolDecoder.MSG_IMAGE_START:
return 24;
case RoboTrackProtocolDecoder.MSG_IMAGE_DATA:
- return 8 + buf.getUnsignedShort(buf.readerIndex() + 1);
+ return 8 + buf.getUnsignedShortLE(buf.readerIndex() + 1);
case RoboTrackProtocolDecoder.MSG_IMAGE_END:
return 6;
default:
@@ -43,12 +43,12 @@ public class RoboTrackFrameDecoder extends FrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
int length = messageLength(buf);
if (buf.readableBytes() >= length) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
return null;
diff --git a/src/org/traccar/protocol/RoboTrackProtocol.java b/src/org/traccar/protocol/RoboTrackProtocol.java
index 382cb1c2f..6ff670042 100644
--- a/src/org/traccar/protocol/RoboTrackProtocol.java
+++ b/src/org/traccar/protocol/RoboTrackProtocol.java
@@ -15,12 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
-import java.nio.ByteOrder;
import java.util.List;
public class RoboTrackProtocol extends BaseProtocol {
@@ -31,15 +29,13 @@ public class RoboTrackProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new RoboTrackFrameDecoder());
pipeline.addLast("objectDecoder", new RoboTrackProtocolDecoder(RoboTrackProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/RoboTrackProtocolDecoder.java b/src/org/traccar/protocol/RoboTrackProtocolDecoder.java
index 4f27fb08e..587f9b8f7 100644
--- a/src/org/traccar/protocol/RoboTrackProtocolDecoder.java
+++ b/src/org/traccar/protocol/RoboTrackProtocolDecoder.java
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.CellTower;
@@ -27,7 +28,6 @@ import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
@@ -49,7 +49,7 @@ public class RoboTrackProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
int type = buf.readUnsignedByte();
@@ -57,14 +57,14 @@ public class RoboTrackProtocolDecoder extends BaseProtocolDecoder {
buf.skipBytes(16); // name
- String imei = buf.readBytes(15).toString(StandardCharsets.US_ASCII);
+ String imei = buf.readSlice(15).toString(StandardCharsets.US_ASCII);
if (getDeviceSession(channel, remoteAddress, imei) != null && channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer(ByteOrder.LITTLE_ENDIAN, 0);
+ ByteBuf response = Unpooled.buffer();
response.writeByte(MSG_ACK);
response.writeByte(0x01); // success
response.writeByte(0x66); // checksum
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
} else if (type == MSG_GPS || type == MSG_GSM) {
@@ -77,14 +77,14 @@ public class RoboTrackProtocolDecoder extends BaseProtocolDecoder {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
- position.setDeviceTime(new Date(buf.readUnsignedInt() * 1000));
+ position.setDeviceTime(new Date(buf.readUnsignedIntLE() * 1000));
if (type == MSG_GPS) {
position.setValid(true);
position.setFixTime(position.getDeviceTime());
- position.setLatitude(buf.readInt() * 0.000001);
- position.setLongitude(buf.readInt() * 0.000001);
+ position.setLatitude(buf.readIntLE() * 0.000001);
+ position.setLongitude(buf.readIntLE() * 0.000001);
position.setSpeed(UnitsConverter.knotsFromKph(buf.readByte()));
} else {
@@ -92,8 +92,8 @@ public class RoboTrackProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, position.getDeviceTime());
position.setNetwork(new Network(CellTower.from(
- buf.readUnsignedShort(), buf.readUnsignedShort(),
- buf.readUnsignedShort(), buf.readUnsignedShort())));
+ buf.readUnsignedShortLE(), buf.readUnsignedShortLE(),
+ buf.readUnsignedShortLE(), buf.readUnsignedShortLE())));
buf.readUnsignedByte(); // reserved
@@ -117,7 +117,7 @@ public class RoboTrackProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_DEVICE_TEMP, buf.readByte());
for (int i = 1; i <= 3; i++) {
- position.set(Position.PREFIX_ADC + i, buf.readUnsignedShort());
+ position.set(Position.PREFIX_ADC + i, buf.readUnsignedShortLE());
}
return position;
diff --git a/src/org/traccar/protocol/RuptelaProtocol.java b/src/org/traccar/protocol/RuptelaProtocol.java
index fc3b17dd9..eb9bdada7 100644
--- a/src/org/traccar/protocol/RuptelaProtocol.java
+++ b/src/org/traccar/protocol/RuptelaProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -40,9 +39,9 @@ public class RuptelaProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 0, 2, 2, 0));
pipeline.addLast("objectEncoder", new RuptelaProtocolEncoder());
pipeline.addLast("objectDecoder", new RuptelaProtocolDecoder(RuptelaProtocol.this));
diff --git a/src/org/traccar/protocol/RuptelaProtocolDecoder.java b/src/org/traccar/protocol/RuptelaProtocolDecoder.java
index 7b11cc5c3..e5d196fed 100644
--- a/src/org/traccar/protocol/RuptelaProtocolDecoder.java
+++ b/src/org/traccar/protocol/RuptelaProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DataConverter;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -48,7 +49,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_SET_IO = 17;
public static final int MSG_EXTENDED_RECORDS = 68;
- private Position decodeCommandResponse(DeviceSession deviceSession, int type, ChannelBuffer buf) {
+ private Position decodeCommandResponse(DeviceSession deviceSession, int type, ByteBuf buf) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
@@ -73,7 +74,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
}
}
- private long readValue(ChannelBuffer buf, int length, boolean signed) {
+ private long readValue(ByteBuf buf, int length, boolean signed) {
switch (length) {
case 1:
return signed ? buf.readByte() : buf.readUnsignedByte();
@@ -86,7 +87,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeParameter(Position position, int id, ChannelBuffer buf, int length) {
+ private void decodeParameter(Position position, int id, ByteBuf buf, int length) {
switch (id) {
case 2:
case 3:
@@ -114,7 +115,7 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.readUnsignedShort(); // data length
@@ -196,7 +197,8 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
}
if (channel != null) {
- channel.write(ChannelBuffers.wrappedBuffer(DataConverter.parseHex("0002640113bc")));
+ channel.writeAndFlush(new NetworkMessage(
+ Unpooled.wrappedBuffer(DataConverter.parseHex("0002640113bc")), remoteAddress));
}
return positions;
@@ -223,13 +225,14 @@ public class RuptelaProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_ARCHIVE, true);
}
- position.set(Position.KEY_DTCS, buf.readBytes(5).toString(StandardCharsets.US_ASCII));
+ position.set(Position.KEY_DTCS, buf.readSlice(5).toString(StandardCharsets.US_ASCII));
positions.add(position);
}
if (channel != null) {
- channel.write(ChannelBuffers.wrappedBuffer(DataConverter.parseHex("00026d01c4a4")));
+ channel.writeAndFlush(new NetworkMessage(
+ Unpooled.wrappedBuffer(DataConverter.parseHex("00026d01c4a4")), remoteAddress));
}
return positions;
diff --git a/src/org/traccar/protocol/RuptelaProtocolEncoder.java b/src/org/traccar/protocol/RuptelaProtocolEncoder.java
index 564d80869..28aa65273 100644
--- a/src/org/traccar/protocol/RuptelaProtocolEncoder.java
+++ b/src/org/traccar/protocol/RuptelaProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Checksum;
import org.traccar.helper.Log;
@@ -26,14 +26,14 @@ import java.nio.charset.StandardCharsets;
public class RuptelaProtocolEncoder extends BaseProtocolEncoder {
- private ChannelBuffer encodeContent(int type, ChannelBuffer content) {
+ private ByteBuf encodeContent(int type, ByteBuf content) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ ByteBuf buf = Unpooled.buffer();
buf.writeShort(1 + content.readableBytes());
buf.writeByte(100 + type);
buf.writeBytes(content);
- buf.writeShort(Checksum.crc16(Checksum.CRC16_KERMIT, buf.toByteBuffer(2, buf.writerIndex() - 2)));
+ buf.writeShort(Checksum.crc16(Checksum.CRC16_KERMIT, buf.nioBuffer(2, buf.writerIndex() - 2)));
return buf;
}
@@ -41,7 +41,7 @@ public class RuptelaProtocolEncoder extends BaseProtocolEncoder {
@Override
protected Object encodeCommand(Command command) {
- ChannelBuffer content = ChannelBuffers.dynamicBuffer();
+ ByteBuf content = Unpooled.buffer();
switch (command.getType()) {
case Command.TYPE_CUSTOM:
diff --git a/src/org/traccar/protocol/SabertekFrameDecoder.java b/src/org/traccar/protocol/SabertekFrameDecoder.java
index bf7af81da..771ef9cfb 100644
--- a/src/org/traccar/protocol/SabertekFrameDecoder.java
+++ b/src/org/traccar/protocol/SabertekFrameDecoder.java
@@ -15,23 +15,23 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class SabertekFrameDecoder extends FrameDecoder {
+public class SabertekFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
int beginIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x02);
if (beginIndex >= 0) {
int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0x03);
if (beginIndex >= 0) {
buf.readerIndex(beginIndex + 1);
- ChannelBuffer frame = buf.readBytes(endIndex - beginIndex - 1);
+ ByteBuf frame = buf.readRetainedSlice(endIndex - beginIndex - 1);
buf.readerIndex(endIndex + 1);
buf.skipBytes(2); // end line
return frame;
diff --git a/src/org/traccar/protocol/SabertekProtocol.java b/src/org/traccar/protocol/SabertekProtocol.java
index 0be4da8c6..55cb346ca 100644
--- a/src/org/traccar/protocol/SabertekProtocol.java
+++ b/src/org/traccar/protocol/SabertekProtocol.java
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -31,9 +30,9 @@ public class SabertekProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new SabertekFrameDecoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new SabertekProtocolDecoder(SabertekProtocol.this));
diff --git a/src/org/traccar/protocol/SabertekProtocolDecoder.java b/src/org/traccar/protocol/SabertekProtocolDecoder.java
index 715aa37f2..8b7f2fb44 100644
--- a/src/org/traccar/protocol/SabertekProtocolDecoder.java
+++ b/src/org/traccar/protocol/SabertekProtocolDecoder.java
@@ -15,10 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -71,7 +72,8 @@ public class SabertekProtocolDecoder extends BaseProtocolDecoder {
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (channel != null) {
- channel.write(ChannelBuffers.wrappedBuffer(new byte[]{(byte) (deviceSession != null ? 0x06 : 0x15)}));
+ channel.writeAndFlush(new NetworkMessage(
+ Unpooled.wrappedBuffer(new byte[]{(byte) (deviceSession != null ? 0x06 : 0x15)}), remoteAddress));
}
if (deviceSession == null) {
return null;
diff --git a/src/org/traccar/protocol/SanavProtocol.java b/src/org/traccar/protocol/SanavProtocol.java
index 4f463725e..7a8a7ebf0 100644
--- a/src/org/traccar/protocol/SanavProtocol.java
+++ b/src/org/traccar/protocol/SanavProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class SanavProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '*'));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/SanavProtocolDecoder.java b/src/org/traccar/protocol/SanavProtocolDecoder.java
index 714bb15d5..6bbcd05b7 100644
--- a/src/org/traccar/protocol/SanavProtocolDecoder.java
+++ b/src/org/traccar/protocol/SanavProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
@@ -59,12 +59,12 @@ public class SanavProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Position position = new Position(getProtocolName());
-
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, parser.next());
if (deviceSession == null) {
return null;
}
+
+ Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
DateBuilder dateBuilder = new DateBuilder()
diff --git a/src/org/traccar/protocol/SigfoxProtocol.java b/src/org/traccar/protocol/SigfoxProtocol.java
index 9feaea12d..4968a04ef 100644
--- a/src/org/traccar/protocol/SigfoxProtocol.java
+++ b/src/org/traccar/protocol/SigfoxProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
-import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
-import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpRequestDecoder;
+import io.netty.handler.codec.http.HttpResponseEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,12 +32,12 @@ public class SigfoxProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
- pipeline.addLast("httpAggregator", new HttpChunkAggregator(65535));
+ pipeline.addLast("httpAggregator", new HttpObjectAggregator(65535));
pipeline.addLast("objectDecoder", new SigfoxProtocolDecoder(SigfoxProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/SigfoxProtocolDecoder.java b/src/org/traccar/protocol/SigfoxProtocolDecoder.java
index b454e00fa..f18eb015b 100644
--- a/src/org/traccar/protocol/SigfoxProtocolDecoder.java
+++ b/src/org/traccar/protocol/SigfoxProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.handler.codec.http.HttpRequest;
-import org.jboss.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.HttpResponseStatus;
import org.traccar.BaseHttpProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DataConverter;
@@ -31,7 +31,6 @@ import javax.json.JsonObject;
import java.io.StringReader;
import java.net.SocketAddress;
import java.net.URLDecoder;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.util.Date;
@@ -45,9 +44,9 @@ public class SigfoxProtocolDecoder extends BaseHttpProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- HttpRequest request = (HttpRequest) msg;
+ FullHttpRequest request = (FullHttpRequest) msg;
JsonObject json = Json.createReader(new StringReader(URLDecoder.decode(
- request.getContent().toString(StandardCharsets.UTF_8).split("=")[0], "UTF-8"))).readObject();
+ request.content().toString(StandardCharsets.UTF_8).split("=")[0], "UTF-8"))).readObject();
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, json.getString("device"));
if (deviceSession == null) {
@@ -60,24 +59,26 @@ public class SigfoxProtocolDecoder extends BaseHttpProtocolDecoder {
position.setTime(new Date(json.getInt("time") * 1000L));
- ChannelBuffer buf = ChannelBuffers.wrappedBuffer(
- ByteOrder.LITTLE_ENDIAN, DataConverter.parseHex(json.getString("data")));
+ ByteBuf buf = Unpooled.wrappedBuffer(DataConverter.parseHex(json.getString("data")));
+ try {
+ int type = buf.readUnsignedByte() >> 4;
+ if (type == 0) {
- int type = buf.readUnsignedByte() >> 4;
- if (type == 0) {
+ position.setValid(true);
+ position.setLatitude(buf.readIntLE() * 0.0000001);
+ position.setLongitude(buf.readIntLE() * 0.0000001);
+ position.setCourse(buf.readUnsignedByte() * 2);
+ position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
- position.setValid(true);
- position.setLatitude(buf.readInt() * 0.0000001);
- position.setLongitude(buf.readInt() * 0.0000001);
- position.setCourse(buf.readUnsignedByte() * 2);
- position.setSpeed(UnitsConverter.knotsFromKph(buf.readUnsignedByte()));
+ position.set(Position.KEY_BATTERY, buf.readUnsignedByte() * 0.025);
- position.set(Position.KEY_BATTERY, buf.readUnsignedByte() * 0.025);
+ } else {
- } else {
-
- getLastLocation(position, position.getDeviceTime());
+ getLastLocation(position, position.getDeviceTime());
+ }
+ } finally {
+ buf.release();
}
position.set(Position.KEY_RSSI, json.getJsonNumber("rssi").doubleValue());
diff --git a/src/org/traccar/protocol/SiwiProtocol.java b/src/org/traccar/protocol/SiwiProtocol.java
index 667e083f1..dba11f647 100644
--- a/src/org/traccar/protocol/SiwiProtocol.java
+++ b/src/org/traccar/protocol/SiwiProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class SiwiProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new SiwiProtocolDecoder(SiwiProtocol.this));
diff --git a/src/org/traccar/protocol/SiwiProtocolDecoder.java b/src/org/traccar/protocol/SiwiProtocolDecoder.java
index 66b6465fa..fc1296c64 100644
--- a/src/org/traccar/protocol/SiwiProtocolDecoder.java
+++ b/src/org/traccar/protocol/SiwiProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/SkypatrolProtocol.java b/src/org/traccar/protocol/SkypatrolProtocol.java
index fba432522..2ce018dc8 100644
--- a/src/org/traccar/protocol/SkypatrolProtocol.java
+++ b/src/org/traccar/protocol/SkypatrolProtocol.java
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class SkypatrolProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectDecoder", new SkypatrolProtocolDecoder(SkypatrolProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
index a85595a07..054171914 100644
--- a/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
+++ b/src/org/traccar/protocol/SkypatrolProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
@@ -54,7 +54,7 @@ public class SkypatrolProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
int apiNumber = buf.readUnsignedShort();
int commandType = buf.readUnsignedByte();
diff --git a/src/org/traccar/protocol/SmokeyProtocol.java b/src/org/traccar/protocol/SmokeyProtocol.java
index 4f9a8dd74..7a4f416e6 100644
--- a/src/org/traccar/protocol/SmokeyProtocol.java
+++ b/src/org/traccar/protocol/SmokeyProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class SmokeyProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectDecoder", new SmokeyProtocolDecoder(SmokeyProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/SmokeyProtocolDecoder.java b/src/org/traccar/protocol/SmokeyProtocolDecoder.java
index 9c4cb4e21..825108ed2 100644
--- a/src/org/traccar/protocol/SmokeyProtocolDecoder.java
+++ b/src/org/traccar/protocol/SmokeyProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +15,16 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Seconds;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.model.CellTower;
import org.traccar.model.Network;
@@ -42,10 +44,10 @@ public class SmokeyProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_DATE_RECORD_ACK = 1;
private static void sendResponse(
- Channel channel, SocketAddress remoteAddress, ChannelBuffer id, int index, int report) {
+ Channel channel, SocketAddress remoteAddress, ByteBuf id, int index, int report) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeBytes("SM".getBytes(StandardCharsets.US_ASCII));
response.writeByte(3); // protocol version
response.writeByte(MSG_DATE_RECORD_ACK);
@@ -57,11 +59,11 @@ public class SmokeyProtocolDecoder extends BaseProtocolDecoder {
short checksum = (short) 0xF5A0;
for (int i = 0; i < response.readableBytes(); i += 2) {
- checksum ^= ChannelBuffers.swapShort(response.getShort(i));
+ checksum ^= response.getShortLE(i);
}
response.writeShort(checksum);
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
@@ -69,15 +71,15 @@ public class SmokeyProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
buf.readUnsignedByte(); // protocol version
int type = buf.readUnsignedByte();
- ChannelBuffer id = buf.readBytes(8);
- DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, ChannelBuffers.hexDump(id));
+ ByteBuf id = buf.readSlice(8);
+ DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, ByteBufUtil.hexDump(id));
if (deviceSession == null) {
return null;
}
diff --git a/src/org/traccar/protocol/SpotProtocol.java b/src/org/traccar/protocol/SpotProtocol.java
index cd5ab90f6..f06eea17a 100644
--- a/src/org/traccar/protocol/SpotProtocol.java
+++ b/src/org/traccar/protocol/SpotProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
-import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
-import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpRequestDecoder;
+import io.netty.handler.codec.http.HttpResponseEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,12 +32,12 @@ public class SpotProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("httpEncoder", new HttpResponseEncoder());
pipeline.addLast("httpDecoder", new HttpRequestDecoder());
- pipeline.addLast("httpAggregator", new HttpChunkAggregator(65535));
+ pipeline.addLast("httpAggregator", new HttpObjectAggregator(65535));
pipeline.addLast("objectDecoder", new SpotProtocolDecoder(SpotProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/SpotProtocolDecoder.java b/src/org/traccar/protocol/SpotProtocolDecoder.java
index a8e666a32..16e287b6c 100644
--- a/src/org/traccar/protocol/SpotProtocolDecoder.java
+++ b/src/org/traccar/protocol/SpotProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,9 +16,9 @@
package org.traccar.protocol;
import com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.handler.codec.http.HttpRequest;
-import org.jboss.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.channel.Channel;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.HttpResponseStatus;
import org.traccar.BaseHttpProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateUtil;
@@ -60,9 +60,9 @@ public class SpotProtocolDecoder extends BaseHttpProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- HttpRequest request = (HttpRequest) msg;
+ FullHttpRequest request = (FullHttpRequest) msg;
- Document document = documentBuilder.parse(new ByteBufferBackedInputStream(request.getContent().toByteBuffer()));
+ Document document = documentBuilder.parse(new ByteBufferBackedInputStream(request.content().nioBuffer()));
NodeList nodes = (NodeList) messageExpression.evaluate(document, XPathConstants.NODESET);
List<Position> positions = new LinkedList<>();
diff --git a/src/org/traccar/protocol/StarLinkProtocol.java b/src/org/traccar/protocol/StarLinkProtocol.java
index e71d94fd0..78178078c 100644
--- a/src/org/traccar/protocol/StarLinkProtocol.java
+++ b/src/org/traccar/protocol/StarLinkProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class StarLinkProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/StarLinkProtocolDecoder.java b/src/org/traccar/protocol/StarLinkProtocolDecoder.java
index f2c9d2c50..16c467e69 100644
--- a/src/org/traccar/protocol/StarLinkProtocolDecoder.java
+++ b/src/org/traccar/protocol/StarLinkProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
diff --git a/src/org/traccar/protocol/Stl060FrameDecoder.java b/src/org/traccar/protocol/Stl060FrameDecoder.java
index 455a869ee..f72474e2b 100644
--- a/src/org/traccar/protocol/Stl060FrameDecoder.java
+++ b/src/org/traccar/protocol/Stl060FrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
import org.traccar.CharacterDelimiterFrameDecoder;
public class Stl060FrameDecoder extends CharacterDelimiterFrameDecoder {
@@ -27,10 +26,9 @@ public class Stl060FrameDecoder extends CharacterDelimiterFrameDecoder {
}
@Override
- protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ protected Object decode(ChannelHandlerContext ctx, ByteBuf buf) throws Exception {
- ChannelBuffer result = (ChannelBuffer) super.decode(ctx, channel, buf);
+ ByteBuf result = (ByteBuf) super.decode(ctx, buf);
if (result != null) {
@@ -39,7 +37,7 @@ public class Stl060FrameDecoder extends CharacterDelimiterFrameDecoder {
return result;
} else {
result.skipBytes(index);
- return result.readBytes(result.readableBytes());
+ return result.readRetainedSlice(result.readableBytes());
}
}
diff --git a/src/org/traccar/protocol/Stl060Protocol.java b/src/org/traccar/protocol/Stl060Protocol.java
index 6fe2c5181..91440baa9 100644
--- a/src/org/traccar/protocol/Stl060Protocol.java
+++ b/src/org/traccar/protocol/Stl060Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class Stl060Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new Stl060FrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/Stl060ProtocolDecoder.java b/src/org/traccar/protocol/Stl060ProtocolDecoder.java
index 64d4655c5..d997d2379 100644
--- a/src/org/traccar/protocol/Stl060ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Stl060ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/SuntechProtocol.java b/src/org/traccar/protocol/SuntechProtocol.java
index 03a979d04..fdb8041cb 100644
--- a/src/org/traccar/protocol/SuntechProtocol.java
+++ b/src/org/traccar/protocol/SuntechProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -42,9 +41,9 @@ public class SuntechProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '\r'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/SuntechProtocolDecoder.java b/src/org/traccar/protocol/SuntechProtocolDecoder.java
index efaf19b93..b076546a6 100644
--- a/src/org/traccar/protocol/SuntechProtocolDecoder.java
+++ b/src/org/traccar/protocol/SuntechProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
diff --git a/src/org/traccar/protocol/SupermateProtocol.java b/src/org/traccar/protocol/SupermateProtocol.java
index c9ae86fc1..847f9095c 100644
--- a/src/org/traccar/protocol/SupermateProtocol.java
+++ b/src/org/traccar/protocol/SupermateProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class SupermateProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "#"));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
@@ -43,4 +42,5 @@ public class SupermateProtocol extends BaseProtocol {
}
});
}
+
}
diff --git a/src/org/traccar/protocol/SupermateProtocolDecoder.java b/src/org/traccar/protocol/SupermateProtocolDecoder.java
index be325ea29..a5e93a673 100644
--- a/src/org/traccar/protocol/SupermateProtocolDecoder.java
+++ b/src/org/traccar/protocol/SupermateProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -110,7 +111,8 @@ public class SupermateProtocolDecoder extends BaseProtocolDecoder {
String content = String.format("#1:%s:1:*,00000000,UP,%02x%02x%02x,%02x%02x%02x#", imei,
calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH),
calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), calendar.get(Calendar.SECOND));
- channel.write(ChannelBuffers.copiedBuffer(content, StandardCharsets.US_ASCII));
+ channel.writeAndFlush(new NetworkMessage(
+ Unpooled.copiedBuffer(content, StandardCharsets.US_ASCII), remoteAddress));
}
return position;
diff --git a/src/org/traccar/protocol/T55Protocol.java b/src/org/traccar/protocol/T55Protocol.java
index 402fd46b8..b69cfab6f 100644
--- a/src/org/traccar/protocol/T55Protocol.java
+++ b/src/org/traccar/protocol/T55Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -34,18 +32,18 @@ public class T55Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new T55ProtocolDecoder(T55Protocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new T55ProtocolDecoder(T55Protocol.this));
diff --git a/src/org/traccar/protocol/T55ProtocolDecoder.java b/src/org/traccar/protocol/T55ProtocolDecoder.java
index dfe0d541f..8aa7fae8f 100644
--- a/src/org/traccar/protocol/T55ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T55ProtocolDecoder.java
@@ -15,17 +15,18 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.socket.DatagramChannel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.model.Position;
import java.net.SocketAddress;
+import java.nio.channels.DatagramChannel;
import java.util.Date;
import java.util.regex.Pattern;
@@ -102,7 +103,7 @@ public class T55ProtocolDecoder extends BaseProtocolDecoder {
if (deviceSession != null && channel != null && !(channel instanceof DatagramChannel)
&& Context.getIdentityManager().lookupAttributeBoolean(
deviceSession.getDeviceId(), getProtocolName() + ".ack", false, true)) {
- channel.write("OK1\r\n");
+ channel.writeAndFlush(new NetworkMessage("OK1\r\n", remoteAddress));
}
Parser parser = new Parser(PATTERN_GPRMC, sentence);
diff --git a/src/org/traccar/protocol/T57FrameDecoder.java b/src/org/traccar/protocol/T57FrameDecoder.java
index b3b456516..14ba31453 100644
--- a/src/org/traccar/protocol/T57FrameDecoder.java
+++ b/src/org/traccar/protocol/T57FrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,18 +15,18 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
import java.nio.charset.StandardCharsets;
-public class T57FrameDecoder extends FrameDecoder {
+public class T57FrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 10) {
return null;
@@ -43,7 +43,7 @@ public class T57FrameDecoder extends FrameDecoder {
}
}
- return index > 0 ? buf.readBytes(index + 1 - buf.readerIndex()) : null;
+ return index > 0 ? buf.readRetainedSlice(index + 1 - buf.readerIndex()) : null;
}
}
diff --git a/src/org/traccar/protocol/T57Protocol.java b/src/org/traccar/protocol/T57Protocol.java
index 5149929e9..9f3dd62a3 100644
--- a/src/org/traccar/protocol/T57Protocol.java
+++ b/src/org/traccar/protocol/T57Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class T57Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new T57FrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/T57ProtocolDecoder.java b/src/org/traccar/protocol/T57ProtocolDecoder.java
index 65dfc46e3..441f8cf8a 100644
--- a/src/org/traccar/protocol/T57ProtocolDecoder.java
+++ b/src/org/traccar/protocol/T57ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/T800xProtocol.java b/src/org/traccar/protocol/T800xProtocol.java
index 830ff4de6..26f34ee77 100644
--- a/src/org/traccar/protocol/T800xProtocol.java
+++ b/src/org/traccar/protocol/T800xProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -34,9 +33,9 @@ public class T800xProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 3, 2, -5, 0));
pipeline.addLast("objectEncoder", new T800xProtocolEncoder());
pipeline.addLast("objectDecoder", new T800xProtocolDecoder(T800xProtocol.this));
diff --git a/src/org/traccar/protocol/T800xProtocolDecoder.java b/src/org/traccar/protocol/T800xProtocolDecoder.java
index 7bc780c83..d5504c190 100644
--- a/src/org/traccar/protocol/T800xProtocolDecoder.java
+++ b/src/org/traccar/protocol/T800xProtocolDecoder.java
@@ -15,11 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BcdUtil;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
@@ -29,7 +31,6 @@ import org.traccar.model.Network;
import org.traccar.model.Position;
import java.net.SocketAddress;
-import java.nio.ByteOrder;
public class T800xProtocolDecoder extends BaseProtocolDecoder {
@@ -43,21 +44,15 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
public static final int MSG_ALARM = 0x04;
public static final int MSG_COMMAND = 0x81;
- private static float readSwappedFloat(ChannelBuffer buf) {
- byte[] bytes = new byte[4];
- buf.readBytes(bytes);
- return ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, bytes).readFloat();
- }
-
- private void sendResponse(Channel channel, short header, int type, ChannelBuffer imei) {
+ private void sendResponse(Channel channel, short header, int type, ByteBuf imei) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(15);
+ ByteBuf response = Unpooled.buffer(15);
response.writeShort(header);
response.writeByte(type);
response.writeShort(response.capacity()); // length
response.writeShort(0x0001); // index
response.writeBytes(imei);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
@@ -84,16 +79,16 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
short header = buf.readShort();
int type = buf.readUnsignedByte();
buf.readUnsignedShort(); // length
int index = buf.readUnsignedShort();
- ChannelBuffer imei = buf.readBytes(8);
+ ByteBuf imei = buf.readSlice(8);
DeviceSession deviceSession = getDeviceSession(
- channel, remoteAddress, ChannelBuffers.hexDump(imei).substring(1));
+ channel, remoteAddress, ByteBufUtil.hexDump(imei).substring(1));
if (deviceSession == null) {
return null;
}
@@ -154,29 +149,24 @@ public class T800xProtocolDecoder extends BaseProtocolDecoder {
position.setValid(!BitUtil.check(status, 7));
position.setTime(dateBuilder.getDate());
- position.setAltitude(readSwappedFloat(buf));
- position.setLongitude(readSwappedFloat(buf));
- position.setLatitude(readSwappedFloat(buf));
- position.setSpeed(UnitsConverter.knotsFromKph(
- BcdUtil.readInteger(buf, 4) * 0.1));
+ position.setAltitude(buf.readFloatLE());
+ position.setLongitude(buf.readFloatLE());
+ position.setLatitude(buf.readFloatLE());
+ position.setSpeed(UnitsConverter.knotsFromKph(BcdUtil.readInteger(buf, 4) * 0.1));
position.setCourse(buf.readUnsignedShort());
} else {
getLastLocation(position, dateBuilder.getDate());
- byte[] array = new byte[16];
- buf.readBytes(array);
- ChannelBuffer swapped = ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, array);
-
- int mcc = swapped.readUnsignedShort();
- int mnc = swapped.readUnsignedShort();
+ int mcc = buf.readUnsignedShortLE();
+ int mnc = buf.readUnsignedShortLE();
if (mcc != 0xffff && mnc != 0xffff) {
Network network = new Network();
for (int i = 0; i < 3; i++) {
network.addCellTower(CellTower.from(
- mcc, mnc, swapped.readUnsignedShort(), swapped.readUnsignedShort()));
+ mcc, mnc, buf.readUnsignedShortLE(), buf.readUnsignedShortLE()));
}
position.setNetwork(network);
}
diff --git a/src/org/traccar/protocol/T800xProtocolEncoder.java b/src/org/traccar/protocol/T800xProtocolEncoder.java
index 038a5e51a..ba17c9d75 100644
--- a/src/org/traccar/protocol/T800xProtocolEncoder.java
+++ b/src/org/traccar/protocol/T800xProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.DataConverter;
import org.traccar.helper.Log;
@@ -30,9 +30,9 @@ public class T800xProtocolEncoder extends BaseProtocolEncoder {
public static final int MODE_BROADCAST = 0x02;
public static final int MODE_FORWARD = 0x03;
- private ChannelBuffer encodeContent(Command command, String content) {
+ private ByteBuf encodeContent(Command command, String content) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ ByteBuf buf = Unpooled.buffer();
buf.writeByte('#');
buf.writeByte('#');
diff --git a/src/org/traccar/protocol/TaipProtocol.java b/src/org/traccar/protocol/TaipProtocol.java
index cbfc44122..bfecf9b39 100644
--- a/src/org/traccar/protocol/TaipProtocol.java
+++ b/src/org/traccar/protocol/TaipProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -34,18 +32,18 @@ public class TaipProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '<'));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new TaipProtocolDecoder(TaipProtocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new TaipProtocolDecoder(TaipProtocol.this));
diff --git a/src/org/traccar/protocol/TaipProtocolDecoder.java b/src/org/traccar/protocol/TaipProtocolDecoder.java
index ea5492462..31b435bce 100644
--- a/src/org/traccar/protocol/TaipProtocolDecoder.java
+++ b/src/org/traccar/protocol/TaipProtocolDecoder.java
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
@@ -271,9 +272,9 @@ public class TaipProtocolDecoder extends BaseProtocolDecoder {
if (messageIndex != null) {
String response = ">ACK;ID=" + uniqueId + ";" + messageIndex + ";*";
response += String.format("%02X", Checksum.xor(response)) + "<";
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
} else {
- channel.write(uniqueId, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(uniqueId, remoteAddress));
}
}
return position;
diff --git a/src/org/traccar/protocol/TelemaxProtocol.java b/src/org/traccar/protocol/TelemaxProtocol.java
index 5dee95c8e..f2208741a 100644
--- a/src/org/traccar/protocol/TelemaxProtocol.java
+++ b/src/org/traccar/protocol/TelemaxProtocol.java
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class TelemaxProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/TelemaxProtocolDecoder.java b/src/org/traccar/protocol/TelemaxProtocolDecoder.java
index a52a83133..fd2f03e1c 100644
--- a/src/org/traccar/protocol/TelemaxProtocolDecoder.java
+++ b/src/org/traccar/protocol/TelemaxProtocolDecoder.java
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
diff --git a/src/org/traccar/protocol/TelicFrameDecoder.java b/src/org/traccar/protocol/TelicFrameDecoder.java
index 245be28fb..d1fef1b5b 100644
--- a/src/org/traccar/protocol/TelicFrameDecoder.java
+++ b/src/org/traccar/protocol/TelicFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,32 +15,33 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import org.traccar.BaseFrameDecoder;
-public class TelicFrameDecoder extends FrameDecoder {
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+
+public class TelicFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 4) {
return null;
}
- long length = buf.getUnsignedInt(buf.readerIndex());
+ long length = buf.getUnsignedIntLE(buf.readerIndex());
if (length < 1024) {
if (buf.readableBytes() >= length + 4) {
- buf.readUnsignedInt();
- return buf.readBytes((int) length);
+ buf.readUnsignedIntLE();
+ return buf.readRetainedSlice((int) length);
}
} else {
int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) 0);
if (endIndex >= 0) {
- ChannelBuffer frame = buf.readBytes(endIndex - buf.readerIndex());
+ ByteBuf frame = buf.readRetainedSlice(endIndex - buf.readerIndex());
buf.readByte();
if (frame.readableBytes() > 0) {
return frame;
diff --git a/src/org/traccar/protocol/TelicProtocol.java b/src/org/traccar/protocol/TelicProtocol.java
index fdd0b94c6..0ee4cf165 100644
--- a/src/org/traccar/protocol/TelicProtocol.java
+++ b/src/org/traccar/protocol/TelicProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
-import java.nio.ByteOrder;
import java.util.List;
public class TelicProtocol extends BaseProtocol {
@@ -33,17 +31,15 @@ public class TelicProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new TelicFrameDecoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new TelicProtocolDecoder(TelicProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/TelicProtocolDecoder.java b/src/org/traccar/protocol/TelicProtocolDecoder.java
index 197db059b..3a9962361 100644
--- a/src/org/traccar/protocol/TelicProtocolDecoder.java
+++ b/src/org/traccar/protocol/TelicProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/TeltonikaFrameDecoder.java b/src/org/traccar/protocol/TeltonikaFrameDecoder.java
index e7313b722..4d4d79d8d 100644
--- a/src/org/traccar/protocol/TeltonikaFrameDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,20 +15,19 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import org.traccar.BaseFrameDecoder;
-public class TeltonikaFrameDecoder extends FrameDecoder {
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+
+public class TeltonikaFrameDecoder extends BaseFrameDecoder {
private static final int MESSAGE_MINIMUM_LENGTH = 12;
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
// Check minimum length
if (buf.readableBytes() < MESSAGE_MINIMUM_LENGTH) {
@@ -39,12 +38,12 @@ public class TeltonikaFrameDecoder extends FrameDecoder {
int length = buf.getUnsignedShort(buf.readerIndex());
if (length > 0) {
if (buf.readableBytes() >= (length + 2)) {
- return buf.readBytes(length + 2);
+ return buf.readRetainedSlice(length + 2);
}
} else {
int dataLength = buf.getInt(buf.readerIndex() + 4);
if (buf.readableBytes() >= (dataLength + 12)) {
- return buf.readBytes(dataLength + 12);
+ return buf.readRetainedSlice(dataLength + 12);
}
}
diff --git a/src/org/traccar/protocol/TeltonikaProtocol.java b/src/org/traccar/protocol/TeltonikaProtocol.java
index d0177da97..d5e10de03 100644
--- a/src/org/traccar/protocol/TeltonikaProtocol.java
+++ b/src/org/traccar/protocol/TeltonikaProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -34,17 +32,17 @@ public class TeltonikaProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new TeltonikaFrameDecoder());
pipeline.addLast("objectEncoder", new TeltonikaProtocolEncoder());
pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(TeltonikaProtocol.this, false));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectEncoder", new TeltonikaProtocolEncoder());
pipeline.addLast("objectDecoder", new TeltonikaProtocolDecoder(TeltonikaProtocol.this, true));
}
diff --git a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 230db5dde..5e9b6640e 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -15,12 +15,14 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.CellTower;
@@ -48,20 +50,20 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
this.extended = Context.getConfig().getBoolean(getProtocolName() + ".extended");
}
- private DeviceSession parseIdentification(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private DeviceSession parseIdentification(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
int length = buf.readUnsignedShort();
String imei = buf.toString(buf.readerIndex(), length, StandardCharsets.US_ASCII);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.directBuffer(1);
+ ByteBuf response = Unpooled.buffer(1);
if (deviceSession != null) {
response.writeByte(1);
} else {
response.writeByte(0);
}
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
return deviceSession;
}
@@ -71,17 +73,17 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
public static final int CODEC_12 = 0x0C;
public static final int CODEC_16 = 0x10;
- private void decodeSerial(Position position, ChannelBuffer buf) {
+ private void decodeSerial(Position position, ByteBuf buf) {
getLastLocation(position, null);
position.set(Position.KEY_TYPE, buf.readUnsignedByte());
- position.set(Position.KEY_RESULT, buf.readBytes(buf.readInt()).toString(StandardCharsets.US_ASCII));
+ position.set(Position.KEY_RESULT, buf.readSlice(buf.readInt()).toString(StandardCharsets.US_ASCII));
}
- private long readValue(ChannelBuffer buf, int length, boolean signed) {
+ private long readValue(ByteBuf buf, int length, boolean signed) {
switch (length) {
case 1:
return signed ? buf.readByte() : buf.readUnsignedByte();
@@ -94,7 +96,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeOtherParameter(Position position, int id, ChannelBuffer buf, int length) {
+ private void decodeOtherParameter(Position position, int id, ByteBuf buf, int length) {
switch (id) {
case 1:
case 2:
@@ -149,7 +151,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
case 134:
String driver = id == 129 || id == 132 ? "" : position.getString("driver1");
position.set("driver" + (id >= 132 ? 2 : 1),
- driver + buf.readBytes(length).toString(StandardCharsets.US_ASCII).trim());
+ driver + buf.readSlice(length).toString(StandardCharsets.US_ASCII).trim());
break;
case 179:
position.set(Position.PREFIX_OUT + 1, readValue(buf, length, false) == 1);
@@ -201,7 +203,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeGh3000Parameter(Position position, int id, ChannelBuffer buf, int length) {
+ private void decodeGh3000Parameter(Position position, int id, ByteBuf buf, int length) {
switch (id) {
case 1:
position.set(Position.KEY_BATTERY_LEVEL, readValue(buf, length, false));
@@ -244,7 +246,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeParameter(Position position, int id, ChannelBuffer buf, int length, int codec) {
+ private void decodeParameter(Position position, int id, ByteBuf buf, int length, int codec) {
if (codec == CODEC_GH3000) {
decodeGh3000Parameter(position, id, buf, length);
} else {
@@ -265,7 +267,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeLocation(Position position, ChannelBuffer buf, int codec) {
+ private void decodeLocation(Position position, ByteBuf buf, int codec) {
int globalMask = 0x0f;
@@ -392,7 +394,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (extended) {
int cnt = buf.readUnsignedByte();
for (int j = 0; j < cnt; j++) {
- position.set(Position.PREFIX_IO + buf.readUnsignedByte(), ChannelBuffers.hexDump(buf.readBytes(16)));
+ position.set(Position.PREFIX_IO + buf.readUnsignedByte(), ByteBufUtil.hexDump(buf.readSlice(16)));
}
}
@@ -401,7 +403,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
private List<Position> parseData(
- Channel channel, SocketAddress remoteAddress, ChannelBuffer buf, int locationPacketId, String... imei) {
+ Channel channel, SocketAddress remoteAddress, ByteBuf buf, int locationPacketId, String... imei) {
List<Position> positions = new LinkedList<>();
if (!connectionless) {
@@ -433,17 +435,17 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
if (channel != null) {
if (connectionless) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeShort(5);
response.writeShort(0);
response.writeByte(0x01);
response.writeByte(locationPacketId);
response.writeByte(count);
- channel.write(response, remoteAddress);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
} else {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeInt(count);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
@@ -453,7 +455,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
@Override
protected Object decode(Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (connectionless) {
return decodeUdp(channel, remoteAddress, buf);
@@ -462,7 +464,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
}
}
- private Object decodeTcp(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception {
+ private Object decodeTcp(Channel channel, SocketAddress remoteAddress, ByteBuf buf) throws Exception {
if (buf.getUnsignedShort(0) > 0) {
parseIdentification(channel, remoteAddress, buf);
@@ -474,13 +476,13 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- private Object decodeUdp(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) throws Exception {
+ private Object decodeUdp(Channel channel, SocketAddress remoteAddress, ByteBuf buf) throws Exception {
buf.readUnsignedShort(); // length
buf.readUnsignedShort(); // packet id
buf.readUnsignedByte(); // packet type
int locationPacketId = buf.readUnsignedByte();
- String imei = buf.readBytes(buf.readUnsignedShort()).toString(StandardCharsets.US_ASCII);
+ String imei = buf.readSlice(buf.readUnsignedShort()).toString(StandardCharsets.US_ASCII);
return parseData(channel, remoteAddress, buf, locationPacketId, imei);
diff --git a/src/org/traccar/protocol/TeltonikaProtocolEncoder.java b/src/org/traccar/protocol/TeltonikaProtocolEncoder.java
index fd6eae744..f2680c27c 100644
--- a/src/org/traccar/protocol/TeltonikaProtocolEncoder.java
+++ b/src/org/traccar/protocol/TeltonikaProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,20 +15,21 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
import org.traccar.BaseProtocolEncoder;
import org.traccar.helper.Checksum;
import org.traccar.helper.Log;
import org.traccar.model.Command;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+
import java.nio.charset.StandardCharsets;
public class TeltonikaProtocolEncoder extends BaseProtocolEncoder {
- private ChannelBuffer encodeContent(String content) {
+ private ByteBuf encodeContent(String content) {
- ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ ByteBuf buf = Unpooled.buffer();
buf.writeInt(0);
buf.writeInt(content.length() + 10);
@@ -40,7 +41,7 @@ public class TeltonikaProtocolEncoder extends BaseProtocolEncoder {
buf.writeByte('\r');
buf.writeByte('\n');
buf.writeByte(1); // quantity
- buf.writeInt(Checksum.crc16(Checksum.CRC16_IBM, buf.toByteBuffer(8, buf.writerIndex() - 8)));
+ buf.writeInt(Checksum.crc16(Checksum.CRC16_IBM, buf.nioBuffer(8, buf.writerIndex() - 8)));
return buf;
}
diff --git a/src/org/traccar/protocol/ThinkRaceProtocol.java b/src/org/traccar/protocol/ThinkRaceProtocol.java
index 98f43e2e3..644e16ca7 100644
--- a/src/org/traccar/protocol/ThinkRaceProtocol.java
+++ b/src/org/traccar/protocol/ThinkRaceProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -31,9 +30,9 @@ public class ThinkRaceProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 2 + 12 + 1 + 1, 2, 2, 0));
pipeline.addLast("objectDecoder", new ThinkRaceProtocolDecoder(ThinkRaceProtocol.this));
}
diff --git a/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java b/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java
index f7dd18f51..451f1c448 100644
--- a/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java
+++ b/src/org/traccar/protocol/ThinkRaceProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.model.CellTower;
import org.traccar.model.Network;
@@ -52,10 +53,10 @@ public class ThinkRaceProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
- ChannelBuffer id = buf.readBytes(12);
+ ByteBuf id = buf.readSlice(12);
buf.readUnsignedByte(); // separator
int type = buf.readUnsignedByte();
buf.readUnsignedShort(); // length
@@ -68,7 +69,7 @@ public class ThinkRaceProtocolDecoder extends BaseProtocolDecoder {
String imei = buf.toString(buf.readerIndex(), 15, StandardCharsets.US_ASCII);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession != null && channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeByte(0x48); response.writeByte(0x52); // header
response.writeBytes(id);
response.writeByte(0x2c); // separator
@@ -76,7 +77,7 @@ public class ThinkRaceProtocolDecoder extends BaseProtocolDecoder {
response.writeShort(0x0002); // length
response.writeShort(0x8000);
response.writeShort(0x0000); // checksum
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
diff --git a/src/org/traccar/protocol/Tk102Protocol.java b/src/org/traccar/protocol/Tk102Protocol.java
index 962f2401b..2eff262f0 100644
--- a/src/org/traccar/protocol/Tk102Protocol.java
+++ b/src/org/traccar/protocol/Tk102Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -31,9 +30,9 @@ public class Tk102Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1024, 1 + 1 + 10, 1, 1, 0));
pipeline.addLast("objectDecoder", new Tk102ProtocolDecoder(Tk102Protocol.this));
}
diff --git a/src/org/traccar/protocol/Tk102ProtocolDecoder.java b/src/org/traccar/protocol/Tk102ProtocolDecoder.java
index 50dd45676..c3ba6d303 100644
--- a/src/org/traccar/protocol/Tk102ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk102ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -59,16 +60,17 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
.text(")")
.compile();
- private void sendResponse(Channel channel, int type, ChannelBuffer dataSequence, ChannelBuffer content) {
+ private void sendResponse(Channel channel, int type, ByteBuf dataSequence, ByteBuf content) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeByte('[');
response.writeByte(type);
response.writeBytes(dataSequence);
response.writeByte(content.readableBytes());
response.writeBytes(content);
+ content.release();
response.writeByte(']');
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
}
@@ -76,16 +78,16 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(1); // header
int type = buf.readUnsignedByte();
- ChannelBuffer dataSequence = buf.readBytes(10);
+ ByteBuf dataSequence = buf.readSlice(10);
int length = buf.readUnsignedByte();
if (type == MSG_LOGIN_REQUEST || type == MSG_LOGIN_REQUEST_2) {
- ChannelBuffer data = buf.readBytes(length);
+ ByteBuf data = buf.readSlice(length);
String id;
if (type == MSG_LOGIN_REQUEST) {
@@ -95,7 +97,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
}
if (getDeviceSession(channel, remoteAddress, id) != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeByte(MODE_GPRS);
response.writeBytes(data);
sendResponse(channel, MSG_LOGIN_RESPONSE, dataSequence, response);
@@ -103,7 +105,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
} else if (type == MSG_HEARTBEAT_REQUEST) {
- sendResponse(channel, MSG_HEARTBEAT_RESPONSE, dataSequence, buf.readBytes(length));
+ sendResponse(channel, MSG_HEARTBEAT_RESPONSE, dataSequence, buf.readRetainedSlice(length));
} else {
@@ -112,7 +114,7 @@ public class Tk102ProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- Parser parser = new Parser(PATTERN, buf.readBytes(length).toString(StandardCharsets.US_ASCII));
+ Parser parser = new Parser(PATTERN, buf.readSlice(length).toString(StandardCharsets.US_ASCII));
if (!parser.matches()) {
return null;
}
diff --git a/src/org/traccar/protocol/Tk103FrameDecoder.java b/src/org/traccar/protocol/Tk103FrameDecoder.java
index 390e38906..b61a42563 100644
--- a/src/org/traccar/protocol/Tk103FrameDecoder.java
+++ b/src/org/traccar/protocol/Tk103FrameDecoder.java
@@ -1,6 +1,6 @@
/*
* Copyright 2017 Valerii Vyshniak (val@val.one)
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,16 +16,16 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-public class Tk103FrameDecoder extends FrameDecoder {
+public class Tk103FrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 2) {
return null;
@@ -69,7 +69,7 @@ public class Tk103FrameDecoder extends FrameDecoder {
buf.readerIndex(frameStartIndex);
- return buf.readBytes(frameEndIndex + 1 - frameStartIndex);
+ return buf.readRetainedSlice(frameEndIndex + 1 - frameStartIndex);
}
}
diff --git a/src/org/traccar/protocol/Tk103Protocol.java b/src/org/traccar/protocol/Tk103Protocol.java
index e23982c74..ff31f16bc 100644
--- a/src/org/traccar/protocol/Tk103Protocol.java
+++ b/src/org/traccar/protocol/Tk103Protocol.java
@@ -1,6 +1,6 @@
/*
* Copyright 2017 Christoph Krey (c@ckrey.de)
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +16,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -53,9 +51,9 @@ public class Tk103Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new Tk103FrameDecoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
@@ -63,9 +61,9 @@ public class Tk103Protocol extends BaseProtocol {
pipeline.addLast("objectDecoder", new Tk103ProtocolDecoder(Tk103Protocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new Tk103ProtocolEncoder());
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
index 22a73469f..fd208d526 100644
--- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
@@ -349,10 +350,10 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
String id = sentence.substring(1, 13);
String type = sentence.substring(13, 17);
if (type.equals("BP00")) {
- channel.write("(" + id + "AP01HSO)");
+ channel.writeAndFlush(new NetworkMessage("(" + id + "AP01HSO)", remoteAddress));
return null;
} else if (type.equals("BP05")) {
- channel.write("(" + id + "AP05)");
+ channel.writeAndFlush(new NetworkMessage("(" + id + "AP05)", remoteAddress));
}
}
diff --git a/src/org/traccar/protocol/Tlt2hProtocol.java b/src/org/traccar/protocol/Tlt2hProtocol.java
index 752b0d8ef..1a23dee40 100644
--- a/src/org/traccar/protocol/Tlt2hProtocol.java
+++ b/src/org/traccar/protocol/Tlt2hProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class Tlt2hProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(32 * 1024, "##\r\n"));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
index a5a195afa..780785247 100644
--- a/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tlt2hProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/TlvProtocol.java b/src/org/traccar/protocol/TlvProtocol.java
index da8d88b8a..ddc8d2a6e 100644
--- a/src/org/traccar/protocol/TlvProtocol.java
+++ b/src/org/traccar/protocol/TlvProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,10 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -31,9 +30,9 @@ public class TlvProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder('\0'));
pipeline.addLast("objectDecoder", new TlvProtocolDecoder(TlvProtocol.this));
}
diff --git a/src/org/traccar/protocol/TlvProtocolDecoder.java b/src/org/traccar/protocol/TlvProtocolDecoder.java
index 0cf68acb8..d3ce4e072 100644
--- a/src/org/traccar/protocol/TlvProtocolDecoder.java
+++ b/src/org/traccar/protocol/TlvProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -33,43 +34,43 @@ public class TlvProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private void sendResponse(Channel channel, String type, String... arguments) {
+ private void sendResponse(Channel channel, SocketAddress remoteAddress, String type, String... arguments) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
- response.writeBytes(ChannelBuffers.copiedBuffer(type, StandardCharsets.US_ASCII));
+ ByteBuf response = Unpooled.buffer();
+ response.writeCharSequence(type, StandardCharsets.US_ASCII);
for (String argument : arguments) {
response.writeByte(argument.length());
- response.writeBytes(ChannelBuffers.copiedBuffer(argument, StandardCharsets.US_ASCII));
+ response.writeCharSequence(argument, StandardCharsets.US_ASCII);
}
response.writeByte(0);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
}
- private String readArgument(ChannelBuffer buf) {
- return buf.readBytes(buf.readUnsignedByte()).toString(StandardCharsets.US_ASCII);
+ private String readArgument(ByteBuf buf) {
+ return buf.readSlice(buf.readUnsignedByte()).toString(StandardCharsets.US_ASCII);
}
@Override
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
- String type = buf.readBytes(2).toString(StandardCharsets.US_ASCII);
+ String type = buf.readSlice(2).toString(StandardCharsets.US_ASCII);
if (channel != null) {
switch (type) {
case "0A":
case "0C":
- sendResponse(channel, type);
+ sendResponse(channel, remoteAddress, type);
break;
case "0B":
- sendResponse(channel, type, "1482202689", "10", "20", "15");
+ sendResponse(channel, remoteAddress, type, "1482202689", "10", "20", "15");
break;
case "0E":
case "0F":
- sendResponse(channel, type, "30", "Unknown");
+ sendResponse(channel, remoteAddress, type, "30", "Unknown");
break;
default:
break;
diff --git a/src/org/traccar/protocol/TmgFrameDecoder.java b/src/org/traccar/protocol/TmgFrameDecoder.java
index c39cf03ac..205adaa51 100644
--- a/src/org/traccar/protocol/TmgFrameDecoder.java
+++ b/src/org/traccar/protocol/TmgFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,34 +15,37 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBufferIndexFinder;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import org.traccar.BaseFrameDecoder;
-public class TmgFrameDecoder extends FrameDecoder {
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+
+public class TmgFrameDecoder extends BaseFrameDecoder {
private boolean isLetter(byte c) {
return c >= 'a' && c <= 'z';
}
- @Override
- protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
-
- int beginIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new ChannelBufferIndexFinder() {
- @Override
- public boolean find(ChannelBuffer buffer, int guessedIndex) {
- if (buffer.getByte(guessedIndex) != (byte) '$' || buffer.writerIndex() - guessedIndex < 5) {
- return false;
- }
- return buffer.getByte(guessedIndex + 4) == ','
+ private int findHeader(ByteBuf buffer) {
+ int guessedIndex = buffer.indexOf(buffer.readerIndex(), buffer.writerIndex(), (byte) '$');
+ while (guessedIndex != -1 && buffer.writerIndex() - guessedIndex >= 5) {
+ if (buffer.getByte(guessedIndex + 4) == ','
&& isLetter(buffer.getByte(guessedIndex + 1))
&& isLetter(buffer.getByte(guessedIndex + 2))
- && isLetter(buffer.getByte(guessedIndex + 3));
+ && isLetter(buffer.getByte(guessedIndex + 3))) {
+ return guessedIndex;
}
- });
+ guessedIndex = buffer.indexOf(guessedIndex, buffer.writerIndex(), (byte) '$');
+ }
+ return -1;
+ }
+
+ @Override
+ protected Object decode(
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
+
+ int beginIndex = findHeader(buf);
if (beginIndex >= 0) {
@@ -51,7 +54,7 @@ public class TmgFrameDecoder extends FrameDecoder {
int endIndex = buf.indexOf(beginIndex, buf.writerIndex(), (byte) '\n');
if (endIndex >= 0) {
- ChannelBuffer frame = buf.readBytes(endIndex - beginIndex);
+ ByteBuf frame = buf.readRetainedSlice(endIndex - beginIndex);
buf.readByte(); // delimiter
return frame;
}
diff --git a/src/org/traccar/protocol/TmgProtocol.java b/src/org/traccar/protocol/TmgProtocol.java
index c11762cac..192891100 100644
--- a/src/org/traccar/protocol/TmgProtocol.java
+++ b/src/org/traccar/protocol/TmgProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class TmgProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new TmgFrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/TmgProtocolDecoder.java b/src/org/traccar/protocol/TmgProtocolDecoder.java
index cb10eedd7..7ac443d5c 100644
--- a/src/org/traccar/protocol/TmgProtocolDecoder.java
+++ b/src/org/traccar/protocol/TmgProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
diff --git a/src/org/traccar/protocol/TopflytechProtocol.java b/src/org/traccar/protocol/TopflytechProtocol.java
index 7d4b13ee6..03eb4b3ea 100644
--- a/src/org/traccar/protocol/TopflytechProtocol.java
+++ b/src/org/traccar/protocol/TopflytechProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class TopflytechProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, ')'));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/TopflytechProtocolDecoder.java b/src/org/traccar/protocol/TopflytechProtocolDecoder.java
index b3a8fa845..4ce161b1c 100644
--- a/src/org/traccar/protocol/TopflytechProtocolDecoder.java
+++ b/src/org/traccar/protocol/TopflytechProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/TotemFrameDecoder.java b/src/org/traccar/protocol/TotemFrameDecoder.java
index 70dc5db3b..3fa5abc7a 100644
--- a/src/org/traccar/protocol/TotemFrameDecoder.java
+++ b/src/org/traccar/protocol/TotemFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,25 +15,26 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.traccar.helper.StringFinder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
import java.nio.charset.StandardCharsets;
-public class TotemFrameDecoder extends FrameDecoder {
+import org.traccar.BaseFrameDecoder;
+import org.traccar.helper.BufferUtil;
+
+public class TotemFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 10) {
return null;
}
- int beginIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("$$"));
+ int beginIndex = BufferUtil.indexOf("$$", buf);
if (beginIndex == -1) {
return null;
} else if (beginIndex > buf.readerIndex()) {
@@ -49,7 +50,7 @@ public class TotemFrameDecoder extends FrameDecoder {
}
if (length <= buf.readableBytes()) {
- return buf.readBytes(length);
+ return buf.readRetainedSlice(length);
}
return null;
diff --git a/src/org/traccar/protocol/TotemProtocol.java b/src/org/traccar/protocol/TotemProtocol.java
index 1c5cf5b02..c533268cc 100644
--- a/src/org/traccar/protocol/TotemProtocol.java
+++ b/src/org/traccar/protocol/TotemProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
@@ -37,9 +36,9 @@ public class TotemProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new TotemFrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/TotemProtocolDecoder.java b/src/org/traccar/protocol/TotemProtocolDecoder.java
index c200129d2..c1ee8bf20 100644
--- a/src/org/traccar/protocol/TotemProtocolDecoder.java
+++ b/src/org/traccar/protocol/TotemProtocolDecoder.java
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
@@ -411,9 +412,9 @@ public class TotemProtocolDecoder extends BaseProtocolDecoder {
if (pattern == PATTERN4) {
String response = "$$0014AA" + sentence.substring(sentence.length() - 6, sentence.length() - 2);
response += String.format("%02X", Checksum.xor(response)).toUpperCase();
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
} else {
- channel.write("ACK OK\r\n");
+ channel.writeAndFlush(new NetworkMessage("ACK OK\r\n", remoteAddress));
}
}
diff --git a/src/org/traccar/protocol/Tr20Protocol.java b/src/org/traccar/protocol/Tr20Protocol.java
index 8de004be9..629d8b961 100644
--- a/src/org/traccar/protocol/Tr20Protocol.java
+++ b/src/org/traccar/protocol/Tr20Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class Tr20Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/Tr20ProtocolDecoder.java b/src/org/traccar/protocol/Tr20ProtocolDecoder.java
index 579d575b0..0c4c12f60 100644
--- a/src/org/traccar/protocol/Tr20ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tr20ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
@@ -60,7 +61,8 @@ public class Tr20ProtocolDecoder extends BaseProtocolDecoder {
Parser parser = new Parser(PATTERN_PING, (String) msg);
if (parser.matches()) {
if (channel != null) {
- channel.write("&&" + parser.next() + "\r\n"); // keep-alive response
+ channel.writeAndFlush(new NetworkMessage(
+ "&&" + parser.next() + "\r\n", remoteAddress)); // keep-alive response
}
return null;
}
diff --git a/src/org/traccar/protocol/Tr900Protocol.java b/src/org/traccar/protocol/Tr900Protocol.java
index 40f287efa..80ad76087 100644
--- a/src/org/traccar/protocol/Tr900Protocol.java
+++ b/src/org/traccar/protocol/Tr900Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -34,18 +32,18 @@ public class Tr900Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new Tr900ProtocolDecoder(Tr900Protocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new Tr900ProtocolDecoder(Tr900Protocol.this));
diff --git a/src/org/traccar/protocol/Tr900ProtocolDecoder.java b/src/org/traccar/protocol/Tr900ProtocolDecoder.java
index 0ce4158e4..8200884ac 100644
--- a/src/org/traccar/protocol/Tr900ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tr900ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 -2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/TrackboxProtocol.java b/src/org/traccar/protocol/TrackboxProtocol.java
index c1aa5ac6a..c86870aec 100644
--- a/src/org/traccar/protocol/TrackboxProtocol.java
+++ b/src/org/traccar/protocol/TrackboxProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class TrackboxProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/TrackboxProtocolDecoder.java b/src/org/traccar/protocol/TrackboxProtocolDecoder.java
index 2c113fb76..fff60ae70 100644
--- a/src/org/traccar/protocol/TrackboxProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrackboxProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -46,9 +47,9 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder {
.number("(d+)") // satellites
.compile();
- private void sendResponse(Channel channel) {
+ private void sendResponse(Channel channel, SocketAddress remoteAddress) {
if (channel != null) {
- channel.write("=OK=\r\n");
+ channel.writeAndFlush(new NetworkMessage("=OK=\r\n", remoteAddress));
}
}
@@ -61,7 +62,7 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder {
if (sentence.startsWith("a=connect")) {
String id = sentence.substring(sentence.indexOf("i=") + 2);
if (getDeviceSession(channel, remoteAddress, id) != null) {
- sendResponse(channel);
+ sendResponse(channel, remoteAddress);
}
return null;
}
@@ -75,7 +76,7 @@ public class TrackboxProtocolDecoder extends BaseProtocolDecoder {
if (!parser.matches()) {
return null;
}
- sendResponse(channel);
+ sendResponse(channel, remoteAddress);
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
diff --git a/src/org/traccar/protocol/TrakMateProtocol.java b/src/org/traccar/protocol/TrakMateProtocol.java
index f6d9bf457..506408d65 100644
--- a/src/org/traccar/protocol/TrakMateProtocol.java
+++ b/src/org/traccar/protocol/TrakMateProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class TrakMateProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/TrakMateProtocolDecoder.java b/src/org/traccar/protocol/TrakMateProtocolDecoder.java
index 293c13fad..9fd7af542 100644
--- a/src/org/traccar/protocol/TrakMateProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrakMateProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/TramigoFrameDecoder.java b/src/org/traccar/protocol/TramigoFrameDecoder.java
index 20992c04b..fae9efecf 100644
--- a/src/org/traccar/protocol/TramigoFrameDecoder.java
+++ b/src/org/traccar/protocol/TramigoFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,45 +15,32 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+import org.traccar.BaseFrameDecoder;
-import java.nio.ByteOrder;
-
-public class TramigoFrameDecoder extends LengthFieldBasedFrameDecoder {
-
- public TramigoFrameDecoder() {
- super(1024, 6, 2, -8, 0);
- }
+public class TramigoFrameDecoder extends BaseFrameDecoder {
@Override
- protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ protected Object decode(ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 20) {
return null;
}
- // Swap byte order for legacy protocol
+ int length;
if (buf.getUnsignedByte(buf.readerIndex()) == 0x80) {
- int length = buf.readableBytes();
- byte[] bytes = new byte[length];
- buf.getBytes(buf.readerIndex(), bytes);
-
- ChannelBuffer result = (ChannelBuffer) super.decode(
- ctx, channel, ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, bytes));
- if (result != null) {
- buf.skipBytes(result.readableBytes());
- }
- return result;
+ length = buf.getUnsignedShort(buf.readerIndex() + 6);
+ } else {
+ length = buf.getUnsignedShortLE(buf.readerIndex() + 6);
+ }
+
+ if (length >= buf.readableBytes()) {
+ return buf.readRetainedSlice(length);
}
- return super.decode(ctx, channel, buf);
+ return null;
}
}
diff --git a/src/org/traccar/protocol/TramigoProtocol.java b/src/org/traccar/protocol/TramigoProtocol.java
index 28673c97b..74c673967 100644
--- a/src/org/traccar/protocol/TramigoProtocol.java
+++ b/src/org/traccar/protocol/TramigoProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
-import java.nio.ByteOrder;
import java.util.List;
public class TramigoProtocol extends BaseProtocol {
@@ -31,15 +29,13 @@ public class TramigoProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- TrackerServer server = new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new TramigoFrameDecoder());
pipeline.addLast("objectDecoder", new TramigoProtocolDecoder(TramigoProtocol.this));
}
- };
- server.setEndianness(ByteOrder.LITTLE_ENDIAN);
- serverList.add(server);
+ });
}
}
diff --git a/src/org/traccar/protocol/TramigoProtocolDecoder.java b/src/org/traccar/protocol/TramigoProtocolDecoder.java
index 2605346a9..a54a4de68 100644
--- a/src/org/traccar/protocol/TramigoProtocolDecoder.java
+++ b/src/org/traccar/protocol/TramigoProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateUtil;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -49,16 +50,18 @@ public class TramigoProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
int protocol = buf.readUnsignedByte();
+ boolean legacy = protocol == 0x80;
+
buf.readUnsignedByte(); // version id
- int index = buf.readUnsignedShort();
- int type = buf.readUnsignedShort();
+ int index = legacy ? buf.readUnsignedShort() : buf.readUnsignedShortLE();
+ int type = legacy ? buf.readUnsignedShort() : buf.readUnsignedShortLE();
buf.readUnsignedShort(); // length
buf.readUnsignedShort(); // mask
buf.readUnsignedShort(); // checksum
- long id = buf.readUnsignedInt();
+ long id = legacy ? buf.readUnsignedInt() : buf.readUnsignedIntLE();
buf.readUnsignedInt(); // time
Position position = new Position(getProtocolName());
@@ -75,36 +78,37 @@ public class TramigoProtocolDecoder extends BaseProtocolDecoder {
// need to send ack?
- buf.readUnsignedShort(); // report trigger
- buf.readUnsignedShort(); // state flag
+ buf.readUnsignedShortLE(); // report trigger
+ buf.readUnsignedShortLE(); // state flag
- position.setLatitude(buf.readUnsignedInt() * 0.0000001);
- position.setLongitude(buf.readUnsignedInt() * 0.0000001);
+ position.setLatitude(buf.readUnsignedIntLE() * 0.0000001);
+ position.setLongitude(buf.readUnsignedIntLE() * 0.0000001);
- position.set(Position.KEY_RSSI, buf.readUnsignedShort());
- position.set(Position.KEY_SATELLITES, buf.readUnsignedShort());
- position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedShort());
- position.set("gpsAntennaStatus", buf.readUnsignedShort());
+ position.set(Position.KEY_RSSI, buf.readUnsignedShortLE());
+ position.set(Position.KEY_SATELLITES, buf.readUnsignedShortLE());
+ position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedShortLE());
+ position.set("gpsAntennaStatus", buf.readUnsignedShortLE());
- position.setSpeed(buf.readUnsignedShort() * 0.194384);
- position.setCourse(buf.readUnsignedShort());
+ position.setSpeed(buf.readUnsignedShortLE() * 0.194384);
+ position.setCourse(buf.readUnsignedShortLE());
- position.set(Position.KEY_ODOMETER, buf.readUnsignedInt());
+ position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
- position.set(Position.KEY_BATTERY, buf.readUnsignedShort());
+ position.set(Position.KEY_BATTERY, buf.readUnsignedShortLE());
- position.set(Position.KEY_CHARGE, buf.readUnsignedShort());
+ position.set(Position.KEY_CHARGE, buf.readUnsignedShortLE());
- position.setTime(new Date(buf.readUnsignedInt() * 1000));
+ position.setTime(new Date(buf.readUnsignedIntLE() * 1000));
// parse other data
return position;
- } else if (protocol == 0x80) {
+ } else if (legacy) {
if (channel != null) {
- channel.write(ChannelBuffers.copiedBuffer("gprs,ack," + index, StandardCharsets.US_ASCII));
+ channel.writeAndFlush(new NetworkMessage(
+ Unpooled.copiedBuffer("gprs,ack," + index, StandardCharsets.US_ASCII), remoteAddress));
}
String sentence = buf.toString(StandardCharsets.US_ASCII);
diff --git a/src/org/traccar/protocol/TrvProtocol.java b/src/org/traccar/protocol/TrvProtocol.java
index 348ccd92a..7167ab674 100644
--- a/src/org/traccar/protocol/TrvProtocol.java
+++ b/src/org/traccar/protocol/TrvProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class TrvProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/TrvProtocolDecoder.java b/src/org/traccar/protocol/TrvProtocolDecoder.java
index e0cebc9a5..9c4968974 100644
--- a/src/org/traccar/protocol/TrvProtocolDecoder.java
+++ b/src/org/traccar/protocol/TrvProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -119,11 +120,11 @@ public class TrvProtocolDecoder extends BaseProtocolDecoder {
String responseHeader = id + (char) (type.charAt(0) + 1) + type.substring(1);
if (type.equals("AP00") && id.equals("IW")) {
String time = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
- channel.write(responseHeader + "," + time + ",0#");
+ channel.writeAndFlush(new NetworkMessage(responseHeader + "," + time + ",0#", remoteAddress));
} else if (type.equals("AP14")) {
- channel.write(responseHeader + ",0.000,0.000#");
+ channel.writeAndFlush(new NetworkMessage(responseHeader + ",0.000,0.000#", remoteAddress));
} else {
- channel.write(responseHeader + "#");
+ channel.writeAndFlush(new NetworkMessage(responseHeader + "#", remoteAddress));
}
}
diff --git a/src/org/traccar/protocol/Tt8850Protocol.java b/src/org/traccar/protocol/Tt8850Protocol.java
index 79dc031bc..7d3c6a437 100644
--- a/src/org/traccar/protocol/Tt8850Protocol.java
+++ b/src/org/traccar/protocol/Tt8850Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class Tt8850Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "$"));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/Tt8850ProtocolDecoder.java b/src/org/traccar/protocol/Tt8850ProtocolDecoder.java
index 0134f4764..46220e143 100644
--- a/src/org/traccar/protocol/Tt8850ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Tt8850ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/TytanProtocol.java b/src/org/traccar/protocol/TytanProtocol.java
index 0c27fb12b..7c424981b 100644
--- a/src/org/traccar/protocol/TytanProtocol.java
+++ b/src/org/traccar/protocol/TytanProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class TytanProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectDecoder", new TytanProtocolDecoder(TytanProtocol.this));
}
});
diff --git a/src/org/traccar/protocol/TytanProtocolDecoder.java b/src/org/traccar/protocol/TytanProtocolDecoder.java
index a65ad4cfc..6788fd7b9 100644
--- a/src/org/traccar/protocol/TytanProtocolDecoder.java
+++ b/src/org/traccar/protocol/TytanProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -36,7 +38,7 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
super(protocol);
}
- private void decodeExtraData(Position position, ChannelBuffer buf, int end) {
+ private void decodeExtraData(Position position, ByteBuf buf, int end) {
while (buf.readerIndex() < end) {
int type = buf.readUnsignedByte();
@@ -73,10 +75,10 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
position.set("antihijack", buf.readUnsignedByte());
break;
case 9:
- position.set("unauthorized", ChannelBuffers.hexDump(buf.readBytes(8)));
+ position.set("unauthorized", ByteBufUtil.hexDump(buf.readSlice(8)));
break;
case 10:
- position.set("authorized", ChannelBuffers.hexDump(buf.readBytes(8)));
+ position.set("authorized", ByteBufUtil.hexDump(buf.readSlice(8)));
break;
case 24:
for (int i = 0; i < length / 2; i++) {
@@ -124,16 +126,15 @@ public class TytanProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.readUnsignedByte(); // protocol
buf.readUnsignedShort(); // length
int index = buf.readUnsignedByte() >> 3;
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.copiedBuffer(
- "^" + index, StandardCharsets.US_ASCII);
- channel.write(response, remoteAddress);
+ ByteBuf response = Unpooled.copiedBuffer("^" + index, StandardCharsets.US_ASCII);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
String id = String.valueOf(buf.readUnsignedInt());
diff --git a/src/org/traccar/protocol/TzoneProtocol.java b/src/org/traccar/protocol/TzoneProtocol.java
index 38d5b139a..21a304402 100644
--- a/src/org/traccar/protocol/TzoneProtocol.java
+++ b/src/org/traccar/protocol/TzoneProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LengthFieldBasedFrameDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
+import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
+
import java.util.List;
public class TzoneProtocol extends BaseProtocol {
@@ -31,9 +31,9 @@ public class TzoneProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(256, 2, 2, 2, 0));
pipeline.addLast("objectDecoder", new TzoneProtocolDecoder(TzoneProtocol.this));
}
diff --git a/src/org/traccar/protocol/TzoneProtocolDecoder.java b/src/org/traccar/protocol/TzoneProtocolDecoder.java
index 984891bb6..6f6ff3878 100644
--- a/src/org/traccar/protocol/TzoneProtocolDecoder.java
+++ b/src/org/traccar/protocol/TzoneProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BitUtil;
@@ -57,7 +57,7 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
}
}
- private void decodeCards(Position position, ChannelBuffer buf) {
+ private void decodeCards(Position position, ByteBuf buf) {
int index = 1;
for (int i = 0; i < 4; i++) {
@@ -77,7 +77,7 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
length += 1;
}
- String num = ChannelBuffers.hexDump(buf.readBytes(length / 2));
+ String num = ByteBufUtil.hexDump(buf.readSlice(length / 2));
if (odd) {
num = num.substring(1);
@@ -92,7 +92,7 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
}
- private void decodePassengers(Position position, ChannelBuffer buf) {
+ private void decodePassengers(Position position, ByteBuf buf) {
int blockLength = buf.readUnsignedShort();
int blockEnd = buf.readerIndex() + blockLength;
@@ -112,7 +112,7 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(2); // header
buf.readUnsignedShort(); // length
@@ -122,7 +122,7 @@ public class TzoneProtocolDecoder extends BaseProtocolDecoder {
int hardware = buf.readUnsignedShort();
long firmware = buf.readUnsignedInt();
- String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1);
+ String imei = ByteBufUtil.hexDump(buf.readSlice(8)).substring(1);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession == null) {
return null;
diff --git a/src/org/traccar/protocol/UlbotechFrameDecoder.java b/src/org/traccar/protocol/UlbotechFrameDecoder.java
index 8e7b497c5..f141dc9b7 100644
--- a/src/org/traccar/protocol/UlbotechFrameDecoder.java
+++ b/src/org/traccar/protocol/UlbotechFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,19 +15,18 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import org.traccar.BaseFrameDecoder;
-public class UlbotechFrameDecoder extends FrameDecoder {
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+
+public class UlbotechFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx,
- Channel channel,
- ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 2) {
return null;
@@ -37,7 +36,7 @@ public class UlbotechFrameDecoder extends FrameDecoder {
int index = buf.indexOf(buf.readerIndex() + 1, buf.writerIndex(), (byte) 0xF8);
if (index != -1) {
- ChannelBuffer result = ChannelBuffers.buffer(index + 1 - buf.readerIndex());
+ ByteBuf result = Unpooled.buffer(index + 1 - buf.readerIndex());
while (buf.readerIndex() <= index) {
int b = buf.readUnsignedByte();
@@ -60,7 +59,7 @@ public class UlbotechFrameDecoder extends FrameDecoder {
int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '#');
if (index != -1) {
- return buf.readBytes(index + 1 - buf.readerIndex());
+ return buf.readRetainedSlice(index + 1 - buf.readerIndex());
}
}
diff --git a/src/org/traccar/protocol/UlbotechProtocol.java b/src/org/traccar/protocol/UlbotechProtocol.java
index 40f4594a5..7d6d95706 100644
--- a/src/org/traccar/protocol/UlbotechProtocol.java
+++ b/src/org/traccar/protocol/UlbotechProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class UlbotechProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new UlbotechFrameDecoder());
pipeline.addLast("objectDecoder", new UlbotechProtocolDecoder(UlbotechProtocol.this));
}
diff --git a/src/org/traccar/protocol/UlbotechProtocolDecoder.java b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
index 5499518a1..ed4695a44 100644
--- a/src/org/traccar/protocol/UlbotechProtocolDecoder.java
+++ b/src/org/traccar/protocol/UlbotechProtocolDecoder.java
@@ -15,11 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
import org.traccar.helper.DateBuilder;
@@ -58,18 +60,18 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
private static final short DATA_RFID = 0x0E;
private static final short DATA_EVENT = 0x10;
- private void decodeObd(Position position, ChannelBuffer buf, int length) {
+ private void decodeObd(Position position, ByteBuf buf, int length) {
int end = buf.readerIndex() + length;
while (buf.readerIndex() < end) {
int parameterLength = buf.getUnsignedByte(buf.readerIndex()) >> 4;
int mode = buf.readUnsignedByte() & 0x0F;
- position.add(ObdDecoder.decode(mode, ChannelBuffers.hexDump(buf.readBytes(parameterLength - 1))));
+ position.add(ObdDecoder.decode(mode, ByteBufUtil.hexDump(buf.readSlice(parameterLength - 1))));
}
}
- private void decodeJ1708(Position position, ChannelBuffer buf, int length) {
+ private void decodeJ1708(Position position, ByteBuf buf, int length) {
int end = buf.readerIndex() + length;
@@ -81,14 +83,14 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
if (type == 3) {
id += 256;
}
- String value = ChannelBuffers.hexDump(buf.readBytes(len - 1));
+ String value = ByteBufUtil.hexDump(buf.readSlice(len - 1));
if (type == 2 || type == 3) {
position.set("pid" + id, value);
}
}
}
- private void decodeDriverBehavior(Position position, ChannelBuffer buf) {
+ private void decodeDriverBehavior(Position position, ByteBuf buf) {
int value = buf.readUnsignedByte();
@@ -137,7 +139,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
return null;
}
- private void decodeAdc(Position position, ChannelBuffer buf, int length) {
+ private void decodeAdc(Position position, ByteBuf buf, int length) {
for (int i = 0; i < length / 2; i++) {
int value = buf.readUnsignedShort();
int id = BitUtil.from(value, 12);
@@ -198,13 +200,13 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
return position;
}
- private Object decodeBinary(Channel channel, SocketAddress remoteAddress, ChannelBuffer buf) {
+ private Object decodeBinary(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
buf.readUnsignedByte(); // header
buf.readUnsignedByte(); // version
buf.readUnsignedByte(); // type
- String imei = ChannelBuffers.hexDump(buf.readBytes(8)).substring(1);
+ String imei = ByteBufUtil.hexDump(buf.readSlice(8)).substring(1);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession == null) {
@@ -294,7 +296,7 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
break;
case DATA_CANBUS:
- position.set("can", ChannelBuffers.hexDump(buf.readBytes(length)));
+ position.set("can", ByteBufUtil.hexDump(buf.readSlice(length)));
break;
case DATA_J1708:
@@ -302,12 +304,12 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
break;
case DATA_VIN:
- position.set(Position.KEY_VIN, buf.readBytes(length).toString(StandardCharsets.US_ASCII));
+ position.set(Position.KEY_VIN, buf.readSlice(length).toString(StandardCharsets.US_ASCII));
break;
case DATA_RFID:
position.set(Position.KEY_DRIVER_UNIQUE_ID,
- buf.readBytes(length - 1).toString(StandardCharsets.US_ASCII));
+ buf.readSlice(length - 1).toString(StandardCharsets.US_ASCII));
position.set("authorized", buf.readUnsignedByte() != 0);
break;
@@ -337,28 +339,28 @@ public class UlbotechProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (buf.getUnsignedByte(buf.readerIndex()) == 0xF8) {
if (channel != null) {
- ChannelBuffer response = ChannelBuffers.dynamicBuffer();
+ ByteBuf response = Unpooled.buffer();
response.writeByte(0xF8);
response.writeByte(DATA_GPS);
response.writeByte(0xFE);
response.writeShort(buf.getShort(response.writerIndex() - 1 - 2));
- response.writeShort(Checksum.crc16(Checksum.CRC16_XMODEM, response.toByteBuffer(1, 4)));
+ response.writeShort(Checksum.crc16(Checksum.CRC16_XMODEM, response.nioBuffer(1, 4)));
response.writeByte(0xF8);
- channel.write(response);
+ channel.writeAndFlush(new NetworkMessage(response, remoteAddress));
}
return decodeBinary(channel, remoteAddress, buf);
} else {
if (channel != null) {
- channel.write(ChannelBuffers.copiedBuffer(String.format("*TS01,ACK:%04X#",
- Checksum.crc16(Checksum.CRC16_XMODEM, buf.toByteBuffer(1, buf.writerIndex() - 2))),
- StandardCharsets.US_ASCII));
+ channel.writeAndFlush(new NetworkMessage(Unpooled.copiedBuffer(String.format("*TS01,ACK:%04X#",
+ Checksum.crc16(Checksum.CRC16_XMODEM, buf.nioBuffer(1, buf.writerIndex() - 2))),
+ StandardCharsets.US_ASCII), remoteAddress));
}
return decodeText(channel, remoteAddress, buf.toString(StandardCharsets.US_ASCII));
diff --git a/src/org/traccar/protocol/UproProtocol.java b/src/org/traccar/protocol/UproProtocol.java
index c00f859ee..832121ec1 100644
--- a/src/org/traccar/protocol/UproProtocol.java
+++ b/src/org/traccar/protocol/UproProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -32,9 +31,9 @@ public class UproProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new UproProtocolDecoder(UproProtocol.this));
diff --git a/src/org/traccar/protocol/UproProtocolDecoder.java b/src/org/traccar/protocol/UproProtocolDecoder.java
index 28f3d0249..1c2944a6c 100644
--- a/src/org/traccar/protocol/UproProtocolDecoder.java
+++ b/src/org/traccar/protocol/UproProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
@@ -92,7 +93,7 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (buf.getByte(buf.readerIndex()) != '*') {
throw new ParseException(null, 0);
@@ -102,7 +103,7 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
if (headerIndex < 0) {
headerIndex = buf.writerIndex();
}
- String header = buf.readBytes(headerIndex - buf.readerIndex()).toString(StandardCharsets.US_ASCII);
+ String header = buf.readSlice(headerIndex - buf.readerIndex()).toString(StandardCharsets.US_ASCII);
Parser parser = new Parser(PATTERN_HEADER, header);
if (!parser.matches()) {
@@ -123,10 +124,10 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
String subtype = parser.next();
if (reply && channel != null) {
- channel.write("*MG20Y" + type + subtype + "#");
+ channel.writeAndFlush(new NetworkMessage("*MG20Y" + type + subtype + "#", remoteAddress));
}
- while (buf.readable()) {
+ while (buf.isReadable()) {
buf.readByte(); // skip delimiter
@@ -137,7 +138,7 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
delimiterIndex = buf.writerIndex();
}
- ChannelBuffer data = buf.readBytes(delimiterIndex - buf.readerIndex());
+ ByteBuf data = buf.readSlice(delimiterIndex - buf.readerIndex());
switch (dataType) {
case 'A':
@@ -148,7 +149,7 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
break;
case 'C':
long odometer = 0;
- while (data.readable()) {
+ while (data.isReadable()) {
odometer <<= 4;
odometer += data.readByte() - (byte) '0';
}
@@ -156,19 +157,19 @@ public class UproProtocolDecoder extends BaseProtocolDecoder {
break;
case 'P':
position.setNetwork(new Network(CellTower.from(
- Integer.parseInt(data.readBytes(4).toString(StandardCharsets.US_ASCII)),
- Integer.parseInt(data.readBytes(4).toString(StandardCharsets.US_ASCII)),
- Integer.parseInt(data.readBytes(4).toString(StandardCharsets.US_ASCII), 16),
- Integer.parseInt(data.readBytes(4).toString(StandardCharsets.US_ASCII), 16))));
+ Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII)),
+ Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII)),
+ Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII), 16),
+ Integer.parseInt(data.readSlice(4).toString(StandardCharsets.US_ASCII), 16))));
break;
case 'Q':
- position.set("obd-pid", ChannelBuffers.hexDump(data));
+ position.set("obd-pid", ByteBufUtil.hexDump(data));
break;
case 'R':
- position.set("odb-travel", ChannelBuffers.hexDump(data));
+ position.set("odb-travel", ByteBufUtil.hexDump(data));
break;
case 'S':
- position.set("obd-traffic", ChannelBuffers.hexDump(data));
+ position.set("obd-traffic", ByteBufUtil.hexDump(data));
break;
default:
break;
diff --git a/src/org/traccar/protocol/V680Protocol.java b/src/org/traccar/protocol/V680Protocol.java
index 98c64830b..eb9111578 100644
--- a/src/org/traccar/protocol/V680Protocol.java
+++ b/src/org/traccar/protocol/V680Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -34,18 +32,18 @@ public class V680Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "##"));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new V680ProtocolDecoder(V680Protocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectDecoder", new V680ProtocolDecoder(V680Protocol.this));
diff --git a/src/org/traccar/protocol/V680ProtocolDecoder.java b/src/org/traccar/protocol/V680ProtocolDecoder.java
index caa06a863..05095e8ba 100644
--- a/src/org/traccar/protocol/V680ProtocolDecoder.java
+++ b/src/org/traccar/protocol/V680ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/VisiontekProtocol.java b/src/org/traccar/protocol/VisiontekProtocol.java
index c6dd09562..897c7e6f7 100644
--- a/src/org/traccar/protocol/VisiontekProtocol.java
+++ b/src/org/traccar/protocol/VisiontekProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class VisiontekProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, '#'));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/VisiontekProtocolDecoder.java b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
index 33c555c6b..57ccb5100 100644
--- a/src/org/traccar/protocol/VisiontekProtocolDecoder.java
+++ b/src/org/traccar/protocol/VisiontekProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2014 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/Vt200FrameDecoder.java b/src/org/traccar/protocol/Vt200FrameDecoder.java
index adde12118..0fd83e715 100644
--- a/src/org/traccar/protocol/Vt200FrameDecoder.java
+++ b/src/org/traccar/protocol/Vt200FrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,22 +15,23 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import org.traccar.BaseFrameDecoder;
-public class Vt200FrameDecoder extends FrameDecoder {
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+
+public class Vt200FrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ')') + 1;
if (endIndex > 0) {
- ChannelBuffer frame = ChannelBuffers.dynamicBuffer();
+ ByteBuf frame = Unpooled.buffer();
while (buf.readerIndex() < endIndex) {
int b = buf.readByte();
diff --git a/src/org/traccar/protocol/Vt200Protocol.java b/src/org/traccar/protocol/Vt200Protocol.java
index 59c61cb61..b227020c2 100644
--- a/src/org/traccar/protocol/Vt200Protocol.java
+++ b/src/org/traccar/protocol/Vt200Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class Vt200Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new Vt200FrameDecoder());
pipeline.addLast("objectDecoder", new Vt200ProtocolDecoder(Vt200Protocol.this));
}
diff --git a/src/org/traccar/protocol/Vt200ProtocolDecoder.java b/src/org/traccar/protocol/Vt200ProtocolDecoder.java
index d08107b16..d5035bd5c 100644
--- a/src/org/traccar/protocol/Vt200ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Vt200ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,9 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.BcdUtil;
@@ -42,7 +42,7 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder {
return degrees + minutes * 0.0001 / 60;
}
- protected Date decodeDate(ChannelBuffer buf) {
+ protected Date decodeDate(ByteBuf buf) {
DateBuilder dateBuilder = new DateBuilder()
.setDateReverse(BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2))
.setTime(BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2), BcdUtil.readInteger(buf, 2));
@@ -53,11 +53,11 @@ public class Vt200ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(1); // header
- String id = ChannelBuffers.hexDump(buf.readBytes(6));
+ String id = ByteBufUtil.hexDump(buf.readSlice(6));
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id);
if (deviceSession == null) {
return null;
diff --git a/src/org/traccar/protocol/VtfmsFrameDecoder.java b/src/org/traccar/protocol/VtfmsFrameDecoder.java
index 2e6033fcc..62a189960 100644
--- a/src/org/traccar/protocol/VtfmsFrameDecoder.java
+++ b/src/org/traccar/protocol/VtfmsFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,22 +15,23 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import org.traccar.BaseFrameDecoder;
-public class VtfmsFrameDecoder extends FrameDecoder {
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+
+public class VtfmsFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
int endIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) ')');
if (endIndex > 0) {
endIndex += 1 + 3;
if (buf.writerIndex() >= endIndex) {
- return buf.readBytes(endIndex - buf.readerIndex());
+ return buf.readRetainedSlice(endIndex - buf.readerIndex());
}
}
diff --git a/src/org/traccar/protocol/VtfmsProtocol.java b/src/org/traccar/protocol/VtfmsProtocol.java
index 61e0bf2b9..dee72aaa8 100644
--- a/src/org/traccar/protocol/VtfmsProtocol.java
+++ b/src/org/traccar/protocol/VtfmsProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
+import io.netty.handler.codec.string.StringDecoder;
+
import java.util.List;
public class VtfmsProtocol extends BaseProtocol {
@@ -32,17 +31,17 @@ public class VtfmsProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new VtfmsFrameDecoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new VtfmsProtocolDecoder(VtfmsProtocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectDecoder", new VtfmsProtocolDecoder(VtfmsProtocol.this));
}
diff --git a/src/org/traccar/protocol/VtfmsProtocolDecoder.java b/src/org/traccar/protocol/VtfmsProtocolDecoder.java
index 736a27a64..5e5e5c9b5 100644
--- a/src/org/traccar/protocol/VtfmsProtocolDecoder.java
+++ b/src/org/traccar/protocol/VtfmsProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/WatchFrameDecoder.java b/src/org/traccar/protocol/WatchFrameDecoder.java
index 0009ef30f..1e2f0cea3 100644
--- a/src/org/traccar/protocol/WatchFrameDecoder.java
+++ b/src/org/traccar/protocol/WatchFrameDecoder.java
@@ -15,19 +15,20 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
import java.nio.charset.StandardCharsets;
-public class WatchFrameDecoder extends FrameDecoder {
+import org.traccar.BaseFrameDecoder;
+
+public class WatchFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
int idIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*') + 1;
if (idIndex <= 0) {
@@ -56,7 +57,7 @@ public class WatchFrameDecoder extends FrameDecoder {
int length = Integer.parseInt(
buf.toString(lengthIndex, payloadIndex - lengthIndex, StandardCharsets.US_ASCII), 16);
if (buf.readableBytes() >= payloadIndex + 1 + length + 1) {
- ChannelBuffer frame = ChannelBuffers.dynamicBuffer();
+ ByteBuf frame = Unpooled.buffer();
int endIndex = buf.readerIndex() + payloadIndex + 1 + length + 1;
while (buf.readerIndex() < endIndex) {
byte b = buf.readByte();
diff --git a/src/org/traccar/protocol/WatchProtocol.java b/src/org/traccar/protocol/WatchProtocol.java
index 2be2dc9ae..6f9a4a882 100644
--- a/src/org/traccar/protocol/WatchProtocol.java
+++ b/src/org/traccar/protocol/WatchProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
+import io.netty.handler.codec.string.StringEncoder;
+
import java.util.List;
public class WatchProtocol extends BaseProtocol {
@@ -47,9 +47,9 @@ public class WatchProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new WatchFrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new WatchProtocolEncoder());
diff --git a/src/org/traccar/protocol/WatchProtocolDecoder.java b/src/org/traccar/protocol/WatchProtocolDecoder.java
index f55b6f7be..4e5d8c377 100644
--- a/src/org/traccar/protocol/WatchProtocolDecoder.java
+++ b/src/org/traccar/protocol/WatchProtocolDecoder.java
@@ -15,11 +15,12 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -63,11 +64,11 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
private void sendResponse(Channel channel, String id, String index, String content) {
if (channel != null) {
if (index != null) {
- channel.write(String.format(
- "[%s*%s*%s*%04x*%s]", manufacturer, id, index, content.length(), content));
+ channel.writeAndFlush(new NetworkMessage(String.format("[%s*%s*%s*%04x*%s]",
+ manufacturer, id, index, content.length(), content), channel.remoteAddress()));
} else {
- channel.write(String.format(
- "[%s*%s*%04x*%s]", manufacturer, id, content.length(), content));
+ channel.writeAndFlush(new NetworkMessage(String.format("[%s*%s*%04x*%s]",
+ manufacturer, id, content.length(), content), channel.remoteAddress()));
}
}
}
@@ -176,14 +177,14 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
buf.skipBytes(1); // header
- manufacturer = buf.readBytes(2).toString(StandardCharsets.US_ASCII);
+ manufacturer = buf.readSlice(2).toString(StandardCharsets.US_ASCII);
buf.skipBytes(1); // delimiter
int idIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*');
- String id = buf.readBytes(idIndex - buf.readerIndex()).toString(StandardCharsets.US_ASCII);
+ String id = buf.readSlice(idIndex - buf.readerIndex()).toString(StandardCharsets.US_ASCII);
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, id);
if (deviceSession == null) {
return null;
@@ -197,7 +198,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
&& buf.toString(contentIndex + 1, 4, StandardCharsets.US_ASCII).matches("\\p{XDigit}+")) {
int indexLength = buf.indexOf(buf.readerIndex(), buf.writerIndex(), (byte) '*') - buf.readerIndex();
hasIndex = true;
- index = buf.readBytes(indexLength).toString(StandardCharsets.US_ASCII);
+ index = buf.readSlice(indexLength).toString(StandardCharsets.US_ASCII);
buf.skipBytes(1); // delimiter
}
@@ -211,7 +212,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
contentIndex = buf.writerIndex();
}
- String type = buf.readBytes(contentIndex - buf.readerIndex()).toString(StandardCharsets.US_ASCII);
+ String type = buf.readSlice(contentIndex - buf.readerIndex()).toString(StandardCharsets.US_ASCII);
if (contentIndex < buf.writerIndex()) {
buf.readerIndex(contentIndex + 1);
@@ -225,7 +226,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
sendResponse(channel, id, index, "LK");
- if (buf.readable()) {
+ if (buf.isReadable()) {
String[] values = buf.toString(StandardCharsets.US_ASCII).split(",");
if (values.length >= 3) {
Position position = new Position(getProtocolName());
@@ -259,7 +260,7 @@ public class WatchProtocolDecoder extends BaseProtocolDecoder {
} else if (type.equals("PULSE") || type.equals("heart") || type.equals("bphrt")) {
- if (buf.readable()) {
+ if (buf.isReadable()) {
Position position = new Position(getProtocolName());
position.setDeviceId(deviceSession.getDeviceId());
diff --git a/src/org/traccar/protocol/WatchProtocolEncoder.java b/src/org/traccar/protocol/WatchProtocolEncoder.java
index 4c87f3abd..b2d35e702 100644
--- a/src/org/traccar/protocol/WatchProtocolEncoder.java
+++ b/src/org/traccar/protocol/WatchProtocolEncoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.StringProtocolEncoder;
import org.traccar.helper.DataConverter;
import org.traccar.helper.Log;
@@ -47,7 +47,7 @@ public class WatchProtocolEncoder extends StringProtocolEncoder implements Strin
boolean hasIndex = false;
String manufacturer = "CS";
if (channel != null) {
- WatchProtocolDecoder decoder = channel.getPipeline().get(WatchProtocolDecoder.class);
+ WatchProtocolDecoder decoder = channel.pipeline().get(WatchProtocolDecoder.class);
if (decoder != null) {
hasIndex = decoder.getHasIndex();
manufacturer = decoder.getManufacturer();
diff --git a/src/org/traccar/protocol/WialonProtocol.java b/src/org/traccar/protocol/WialonProtocol.java
index 02da154e2..119d9899b 100644
--- a/src/org/traccar/protocol/WialonProtocol.java
+++ b/src/org/traccar/protocol/WialonProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,16 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.Context;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+
import java.nio.charset.StandardCharsets;
import java.util.List;
@@ -41,9 +41,9 @@ public class WialonProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(4 * 1024));
pipeline.addLast("stringEncoder", new StringEncoder());
boolean utf8 = Context.getConfig().getBoolean(getName() + ".utf8");
diff --git a/src/org/traccar/protocol/WialonProtocolDecoder.java b/src/org/traccar/protocol/WialonProtocolDecoder.java
index 5bc3e9972..805c12cf9 100644
--- a/src/org/traccar/protocol/WialonProtocolDecoder.java
+++ b/src/org/traccar/protocol/WialonProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.helper.UnitsConverter;
@@ -57,14 +58,14 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
.groupEnd("?")
.compile();
- private void sendResponse(Channel channel, String prefix, Integer number) {
+ private void sendResponse(Channel channel, SocketAddress remoteAddress, String prefix, Integer number) {
if (channel != null) {
StringBuilder response = new StringBuilder(prefix);
if (number != null) {
response.append(number);
}
response.append("\r\n");
- channel.write(response.toString());
+ channel.writeAndFlush(new NetworkMessage(response.toString(), remoteAddress));
}
}
@@ -140,12 +141,12 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
String imei = values[0].indexOf('.') >= 0 ? values[1] : values[0];
DeviceSession deviceSession = getDeviceSession(channel, remoteAddress, imei);
if (deviceSession != null) {
- sendResponse(channel, "#AL#", 1);
+ sendResponse(channel, remoteAddress, "#AL#", 1);
}
} else if (sentence.startsWith("#P#")) {
- sendResponse(channel, "#AP#", null); // heartbeat
+ sendResponse(channel, remoteAddress, "#AP#", null); // heartbeat
} else if (sentence.startsWith("#SD#") || sentence.startsWith("#D#")) {
@@ -153,7 +154,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
channel, remoteAddress, sentence.substring(sentence.indexOf('#', 1) + 1));
if (position != null) {
- sendResponse(channel, "#AD#", 1);
+ sendResponse(channel, remoteAddress, "#AD#", 1);
return position;
}
@@ -170,7 +171,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
}
}
- sendResponse(channel, "#AB#", messages.length);
+ sendResponse(channel, remoteAddress, "#AB#", messages.length);
if (!positions.isEmpty()) {
return positions;
}
@@ -183,7 +184,7 @@ public class WialonProtocolDecoder extends BaseProtocolDecoder {
getLastLocation(position, new Date());
position.setValid(false);
position.set(Position.KEY_RESULT, sentence.substring(sentence.indexOf('#', 1) + 1));
- sendResponse(channel, "#AM#", 1);
+ sendResponse(channel, remoteAddress, "#AM#", 1);
return position;
}
}
diff --git a/src/org/traccar/protocol/WondexFrameDecoder.java b/src/org/traccar/protocol/WondexFrameDecoder.java
index db65ff80f..39d83d761 100644
--- a/src/org/traccar/protocol/WondexFrameDecoder.java
+++ b/src/org/traccar/protocol/WondexFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,19 +15,21 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.traccar.helper.StringFinder;
+import org.traccar.BaseFrameDecoder;
+import org.traccar.NetworkMessage;
+import org.traccar.helper.BufferUtil;
-public class WondexFrameDecoder extends FrameDecoder {
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+
+public class WondexFrameDecoder extends BaseFrameDecoder {
private static final int KEEP_ALIVE_LENGTH = 8;
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < KEEP_ALIVE_LENGTH) {
return null;
@@ -36,17 +38,18 @@ public class WondexFrameDecoder extends FrameDecoder {
if (buf.getUnsignedByte(buf.readerIndex()) == 0xD0) {
// Send response
- ChannelBuffer frame = buf.readBytes(KEEP_ALIVE_LENGTH);
+ ByteBuf frame = buf.readRetainedSlice(KEEP_ALIVE_LENGTH);
if (channel != null) {
- channel.write(frame);
+ frame.retain();
+ channel.writeAndFlush(new NetworkMessage(frame, channel.remoteAddress()));
}
return frame;
} else {
- int index = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("\r\n"));
+ int index = BufferUtil.indexOf("\r\n", buf);
if (index != -1) {
- ChannelBuffer frame = buf.readBytes(index - buf.readerIndex());
+ ByteBuf frame = buf.readRetainedSlice(index - buf.readerIndex());
buf.skipBytes(2);
return frame;
}
diff --git a/src/org/traccar/protocol/WondexProtocol.java b/src/org/traccar/protocol/WondexProtocol.java
index ef25265aa..a43c8b06a 100644
--- a/src/org/traccar/protocol/WondexProtocol.java
+++ b/src/org/traccar/protocol/WondexProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +15,13 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
+import io.netty.handler.codec.string.StringEncoder;
+
import java.util.List;
public class WondexProtocol extends BaseProtocol {
@@ -41,18 +40,18 @@ public class WondexProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new WondexFrameDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new WondexProtocolEncoder());
pipeline.addLast("objectDecoder", new WondexProtocolDecoder(WondexProtocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("objectEncoder", new WondexProtocolEncoder());
pipeline.addLast("objectDecoder", new WondexProtocolDecoder(WondexProtocol.this));
diff --git a/src/org/traccar/protocol/WondexProtocolDecoder.java b/src/org/traccar/protocol/WondexProtocolDecoder.java
index a0fa436e4..7845cb26a 100644
--- a/src/org/traccar/protocol/WondexProtocolDecoder.java
+++ b/src/org/traccar/protocol/WondexProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
@@ -60,7 +60,7 @@ public class WondexProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
if (buf.getUnsignedByte(0) == 0xD0) {
diff --git a/src/org/traccar/protocol/XexunFrameDecoder.java b/src/org/traccar/protocol/XexunFrameDecoder.java
index 801fb4d59..114e94061 100644
--- a/src/org/traccar/protocol/XexunFrameDecoder.java
+++ b/src/org/traccar/protocol/XexunFrameDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,31 +15,32 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
-import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.traccar.helper.StringFinder;
+import org.traccar.BaseFrameDecoder;
+import org.traccar.helper.BufferUtil;
-public class XexunFrameDecoder extends FrameDecoder {
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandlerContext;
+
+public class XexunFrameDecoder extends BaseFrameDecoder {
@Override
protected Object decode(
- ChannelHandlerContext ctx, Channel channel, ChannelBuffer buf) throws Exception {
+ ChannelHandlerContext ctx, Channel channel, ByteBuf buf) throws Exception {
if (buf.readableBytes() < 80) {
return null;
}
- int beginIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("GPRMC"));
+ int beginIndex = BufferUtil.indexOf("GPRMC", buf);
if (beginIndex == -1) {
- beginIndex = buf.indexOf(buf.readerIndex(), buf.writerIndex(), new StringFinder("GNRMC"));
+ beginIndex = BufferUtil.indexOf("GNRMC", buf);
if (beginIndex == -1) {
return null;
}
}
- int identifierIndex = buf.indexOf(beginIndex, buf.writerIndex(), new StringFinder("imei:"));
+ int identifierIndex = BufferUtil.indexOf("imei:", buf, beginIndex, buf.writerIndex());
if (identifierIndex == -1) {
return null;
}
@@ -51,7 +52,7 @@ public class XexunFrameDecoder extends FrameDecoder {
buf.skipBytes(beginIndex - buf.readerIndex());
- return buf.readBytes(endIndex - beginIndex + 1);
+ return buf.readRetainedSlice(endIndex - beginIndex + 1);
}
}
diff --git a/src/org/traccar/protocol/XexunProtocol.java b/src/org/traccar/protocol/XexunProtocol.java
index b90cbfaaf..11e0e0761 100644
--- a/src/org/traccar/protocol/XexunProtocol.java
+++ b/src/org/traccar/protocol/XexunProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2016 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,16 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.Context;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+
import java.util.List;
public class XexunProtocol extends BaseProtocol {
@@ -38,9 +38,9 @@ public class XexunProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
boolean full = Context.getConfig().getBoolean(getName() + ".extended");
if (full) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024)); // tracker bug \n\r
diff --git a/src/org/traccar/protocol/XexunProtocolDecoder.java b/src/org/traccar/protocol/XexunProtocolDecoder.java
index a06a86021..42699c272 100644
--- a/src/org/traccar/protocol/XexunProtocolDecoder.java
+++ b/src/org/traccar/protocol/XexunProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.DateBuilder;
diff --git a/src/org/traccar/protocol/XirgoProtocol.java b/src/org/traccar/protocol/XirgoProtocol.java
index 13aa8fde1..18017bcdb 100644
--- a/src/org/traccar/protocol/XirgoProtocol.java
+++ b/src/org/traccar/protocol/XirgoProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,15 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
import org.traccar.CharacterDelimiterFrameDecoder;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import org.traccar.model.Command;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+
import java.util.List;
public class XirgoProtocol extends BaseProtocol {
@@ -37,9 +36,9 @@ public class XirgoProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new CharacterDelimiterFrameDecoder(1024, "##"));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
@@ -47,9 +46,9 @@ public class XirgoProtocol extends BaseProtocol {
pipeline.addLast("objectDecoder", new XirgoProtocolDecoder(XirgoProtocol.this));
}
});
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("objectEncoder", new XirgoProtocolEncoder());
diff --git a/src/org/traccar/protocol/XirgoProtocolDecoder.java b/src/org/traccar/protocol/XirgoProtocolDecoder.java
index 5cda4aed3..878715e40 100644
--- a/src/org/traccar/protocol/XirgoProtocolDecoder.java
+++ b/src/org/traccar/protocol/XirgoProtocolDecoder.java
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/Xt013Protocol.java b/src/org/traccar/protocol/Xt013Protocol.java
index ad3e24df0..8e43e8f0b 100644
--- a/src/org/traccar/protocol/Xt013Protocol.java
+++ b/src/org/traccar/protocol/Xt013Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,14 +15,14 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
+
import java.util.List;
public class Xt013Protocol extends BaseProtocol {
@@ -33,9 +33,9 @@ public class Xt013Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringDecoder", new StringDecoder());
pipeline.addLast("stringEncoder", new StringEncoder());
diff --git a/src/org/traccar/protocol/Xt013ProtocolDecoder.java b/src/org/traccar/protocol/Xt013ProtocolDecoder.java
index a92afd778..fda7c59ea 100644
--- a/src/org/traccar/protocol/Xt013ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xt013ProtocolDecoder.java
@@ -15,7 +15,7 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
import org.traccar.helper.Parser;
diff --git a/src/org/traccar/protocol/Xt2400Protocol.java b/src/org/traccar/protocol/Xt2400Protocol.java
index 0c5e9cd4c..08b281554 100644
--- a/src/org/traccar/protocol/Xt2400Protocol.java
+++ b/src/org/traccar/protocol/Xt2400Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ConnectionlessBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -30,9 +29,9 @@ public class Xt2400Protocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ConnectionlessBootstrap(), getName()) {
+ serverList.add(new TrackerServer(true, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("objectDecoder", new Xt2400ProtocolDecoder(Xt2400Protocol.this));
}
});
diff --git a/src/org/traccar/protocol/Xt2400ProtocolDecoder.java b/src/org/traccar/protocol/Xt2400ProtocolDecoder.java
index 1be943e98..a01a64b5b 100644
--- a/src/org/traccar/protocol/Xt2400ProtocolDecoder.java
+++ b/src/org/traccar/protocol/Xt2400ProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.channel.Channel;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
@@ -103,7 +103,7 @@ public class Xt2400ProtocolDecoder extends BaseProtocolDecoder {
protected Object decode(
Channel channel, SocketAddress remoteAddress, Object msg) throws Exception {
- ChannelBuffer buf = (ChannelBuffer) msg;
+ ByteBuf buf = (ByteBuf) msg;
byte[] format = null;
if (formats.size() > 1) {
@@ -174,10 +174,10 @@ public class Xt2400ProtocolDecoder extends BaseProtocolDecoder {
position.set(Position.KEY_OBD_SPEED, UnitsConverter.knotsFromKph(buf.readUnsignedShort()));
break;
case 0x65:
- position.set(Position.KEY_VIN, buf.readBytes(17).toString(StandardCharsets.US_ASCII));
+ position.set(Position.KEY_VIN, buf.readSlice(17).toString(StandardCharsets.US_ASCII));
break;
case 0x73:
- position.set(Position.KEY_VERSION_FW, buf.readBytes(16).toString(StandardCharsets.US_ASCII).trim());
+ position.set(Position.KEY_VERSION_FW, buf.readSlice(16).toString(StandardCharsets.US_ASCII).trim());
break;
default:
buf.skipBytes(getTagLength(tag));
diff --git a/src/org/traccar/protocol/YwtProtocol.java b/src/org/traccar/protocol/YwtProtocol.java
index 412365ecb..c026fc61a 100644
--- a/src/org/traccar/protocol/YwtProtocol.java
+++ b/src/org/traccar/protocol/YwtProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,12 +15,11 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.bootstrap.ServerBootstrap;
-import org.jboss.netty.channel.ChannelPipeline;
-import org.jboss.netty.handler.codec.frame.LineBasedFrameDecoder;
-import org.jboss.netty.handler.codec.string.StringDecoder;
-import org.jboss.netty.handler.codec.string.StringEncoder;
+import io.netty.handler.codec.LineBasedFrameDecoder;
+import io.netty.handler.codec.string.StringDecoder;
+import io.netty.handler.codec.string.StringEncoder;
import org.traccar.BaseProtocol;
+import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
import java.util.List;
@@ -33,9 +32,9 @@ public class YwtProtocol extends BaseProtocol {
@Override
public void initTrackerServers(List<TrackerServer> serverList) {
- serverList.add(new TrackerServer(new ServerBootstrap(), getName()) {
+ serverList.add(new TrackerServer(false, getName()) {
@Override
- protected void addSpecificHandlers(ChannelPipeline pipeline) {
+ protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast("frameDecoder", new LineBasedFrameDecoder(1024));
pipeline.addLast("stringEncoder", new StringEncoder());
pipeline.addLast("stringDecoder", new StringDecoder());
diff --git a/src/org/traccar/protocol/YwtProtocolDecoder.java b/src/org/traccar/protocol/YwtProtocolDecoder.java
index 3182b838d..4c71b0aea 100644
--- a/src/org/traccar/protocol/YwtProtocolDecoder.java
+++ b/src/org/traccar/protocol/YwtProtocolDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2013 - 2014 Anton Tananaev (anton@traccar.org)
+ * Copyright 2013 - 2018 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,10 @@
*/
package org.traccar.protocol;
-import org.jboss.netty.channel.Channel;
+import io.netty.channel.Channel;
import org.traccar.BaseProtocolDecoder;
import org.traccar.DeviceSession;
+import org.traccar.NetworkMessage;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
import org.traccar.model.Position;
@@ -67,7 +68,7 @@ public class YwtProtocolDecoder extends BaseProtocolDecoder {
end = sentence.length();
}
- channel.write("%AT+SN=" + sentence.substring(start, end));
+ channel.writeAndFlush(new NetworkMessage("%AT+SN=" + sentence.substring(start, end), remoteAddress));
return null;
}
@@ -104,7 +105,7 @@ public class YwtProtocolDecoder extends BaseProtocolDecoder {
// Send response
if ((type.equals("KP") || type.equals("EP")) && channel != null) {
- channel.write("%AT+" + type + "=" + reportId + "\r\n");
+ channel.writeAndFlush(new NetworkMessage("%AT+" + type + "=" + reportId + "\r\n", remoteAddress));
}
return position;
diff --git a/src/org/traccar/smpp/SmppClient.java b/src/org/traccar/smpp/SmppClient.java
index bf395f90e..967eed82c 100644
--- a/src/org/traccar/smpp/SmppClient.java
+++ b/src/org/traccar/smpp/SmppClient.java
@@ -48,7 +48,7 @@ public class SmppClient {
private SmppSession smppSession;
private DefaultSmppSessionHandler sessionHandler = new ClientSmppSessionHandler(this);
private ExecutorService executorService = Executors.newCachedThreadPool();
- private DefaultSmppClient clientBootstrap = new DefaultSmppClient(executorService, 1);
+ private DefaultSmppClient clientBootstrap = new DefaultSmppClient();
private ScheduledExecutorService enquireLinkExecutor;
private ScheduledFuture<?> enquireLinkTask;
diff --git a/test/org/traccar/FilterHandlerTest.java b/test/org/traccar/FilterHandlerTest.java
index 8b1ba3b1f..a8fa14fac 100644
--- a/test/org/traccar/FilterHandlerTest.java
+++ b/test/org/traccar/FilterHandlerTest.java
@@ -67,22 +67,22 @@ public class FilterHandlerTest {
Position position = createPosition(0, new Date(), true, 10, 10, 10, 10, 10);
- assertNotNull(filtingHandler.decode(null, null, position));
- assertNotNull(passingHandler.decode(null, null, position));
+ assertNotNull(filtingHandler.handlePosition(position));
+ assertNotNull(passingHandler.handlePosition(position));
position = createPosition(0, new Date(Long.MAX_VALUE), true, 10, 10, 10, 10, 10);
- assertNull(filtingHandler.decode(null, null, position));
- assertNotNull(passingHandler.decode(null, null, position));
+ assertNull(filtingHandler.handlePosition(position));
+ assertNotNull(passingHandler.handlePosition(position));
position = createPosition(0, new Date(), false, 10, 10, 10, 10, 10);
- assertNull(filtingHandler.decode(null, null, position));
- assertNotNull(passingHandler.decode(null, null, position));
+ assertNull(filtingHandler.handlePosition(position));
+ assertNotNull(passingHandler.handlePosition(position));
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
filtingHandler.setSkipAttributes(true);
- assertNotNull(filtingHandler.decode(null, null, position));
+ assertNotNull(filtingHandler.handlePosition(position));
}
}
diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java
index 47c620d13..e6a718d22 100644
--- a/test/org/traccar/ProtocolTest.java
+++ b/test/org/traccar/ProtocolTest.java
@@ -1,16 +1,16 @@
package org.traccar;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.jboss.netty.handler.codec.http.DefaultHttpRequest;
-import org.jboss.netty.handler.codec.http.HttpMethod;
-import org.jboss.netty.handler.codec.http.HttpVersion;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.buffer.Unpooled;
+import io.netty.handler.codec.http.DefaultFullHttpRequest;
+import io.netty.handler.codec.http.HttpMethod;
+import io.netty.handler.codec.http.HttpVersion;
import org.traccar.helper.DataConverter;
import org.traccar.model.CellTower;
import org.traccar.model.Command;
import org.traccar.model.Position;
-import java.nio.ByteOrder;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.ParseException;
@@ -50,35 +50,28 @@ public class ProtocolTest extends BaseTest {
return builder.toString();
}
- protected ChannelBuffer binary(String... data) {
- return binary(ByteOrder.BIG_ENDIAN, data);
- }
-
- protected ChannelBuffer binary(ByteOrder endianness, String... data) {
- return ChannelBuffers.wrappedBuffer(
- endianness, DataConverter.parseHex(concatenateStrings(data)));
+ protected ByteBuf binary(String... data) {
+ return Unpooled.wrappedBuffer(DataConverter.parseHex(concatenateStrings(data)));
}
protected String text(String... data) {
return concatenateStrings(data);
}
- protected ChannelBuffer buffer(String... data) {
- return ChannelBuffers.copiedBuffer(concatenateStrings(data), StandardCharsets.ISO_8859_1);
+ protected ByteBuf buffer(String... data) {
+ return Unpooled.copiedBuffer(concatenateStrings(data), StandardCharsets.ISO_8859_1);
}
- protected DefaultHttpRequest request(String url) {
+ protected DefaultFullHttpRequest request(String url) {
return request(HttpMethod.GET, url);
}
- protected DefaultHttpRequest request(HttpMethod method, String url) {
- return new DefaultHttpRequest(HttpVersion.HTTP_1_1, method, url);
+ protected DefaultFullHttpRequest request(HttpMethod method, String url) {
+ return new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, method, url);
}
- protected DefaultHttpRequest request(HttpMethod method, String url, ChannelBuffer data) {
- DefaultHttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, method, url);
- request.setContent(data);
- return request;
+ protected DefaultFullHttpRequest request(HttpMethod method, String url, ByteBuf data) {
+ return new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, method, url, data);
}
protected void verifyNotNull(BaseProtocolDecoder decoder, Object object) throws Exception {
@@ -292,14 +285,14 @@ public class ProtocolTest extends BaseTest {
}
protected void verifyCommand(
- BaseProtocolEncoder encoder, Command command, ChannelBuffer expected) throws Exception {
+ BaseProtocolEncoder encoder, Command command, ByteBuf expected) throws Exception {
verifyFrame(expected, encoder.encodeCommand(command));
}
- protected void verifyFrame(ChannelBuffer expected, Object object) {
+ protected void verifyFrame(ByteBuf expected, Object object) {
assertNotNull("buffer is null", object);
- assertTrue("not a buffer", object instanceof ChannelBuffer);
- assertEquals(ChannelBuffers.hexDump(expected), ChannelBuffers.hexDump((ChannelBuffer) object));
+ assertTrue("not a buffer", object instanceof ByteBuf);
+ assertEquals(ByteBufUtil.hexDump(expected), ByteBufUtil.hexDump((ByteBuf) object));
}
}
diff --git a/test/org/traccar/helper/BcdUtilTest.java b/test/org/traccar/helper/BcdUtilTest.java
index e97aad09f..86a32f725 100644
--- a/test/org/traccar/helper/BcdUtilTest.java
+++ b/test/org/traccar/helper/BcdUtilTest.java
@@ -1,6 +1,6 @@
package org.traccar.helper;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.Unpooled;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@@ -10,16 +10,14 @@ public class BcdUtilTest {
@Test
public void testReadInteger() {
byte[] buf = {0x01, (byte) 0x90, 0x34};
- int result = BcdUtil.readInteger(
- ChannelBuffers.wrappedBuffer(buf), 5);
+ int result = BcdUtil.readInteger(Unpooled.wrappedBuffer(buf), 5);
assertEquals(1903, result);
}
@Test
public void testReadCoordinate() {
byte[] buf = {0x03, (byte) 0x85, 0x22, 0x59, 0x34};
- double result = BcdUtil.readCoordinate(
- ChannelBuffers.wrappedBuffer(buf));
+ double result = BcdUtil.readCoordinate(Unpooled.wrappedBuffer(buf));
assertEquals(38.870989, result, 0.00001);
}
diff --git a/test/org/traccar/helper/ChecksumTest.java b/test/org/traccar/helper/ChecksumTest.java
index 3bd51448d..5737b9ff5 100644
--- a/test/org/traccar/helper/ChecksumTest.java
+++ b/test/org/traccar/helper/ChecksumTest.java
@@ -1,7 +1,7 @@
package org.traccar.helper;
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
@@ -12,22 +12,22 @@ public class ChecksumTest {
@Test
public void testCrc8() {
- ChannelBuffer buf = ChannelBuffers.copiedBuffer("123456789", StandardCharsets.US_ASCII);
+ ByteBuf buf = Unpooled.copiedBuffer("123456789", StandardCharsets.US_ASCII);
- assertEquals(0xF7, Checksum.crc8(Checksum.CRC8_EGTS, buf.toByteBuffer()));
- assertEquals(0xD0, Checksum.crc8(Checksum.CRC8_ROHC, buf.toByteBuffer()));
+ assertEquals(0xF7, Checksum.crc8(Checksum.CRC8_EGTS, buf.nioBuffer()));
+ assertEquals(0xD0, Checksum.crc8(Checksum.CRC8_ROHC, buf.nioBuffer()));
}
@Test
public void testCrc16() {
- ChannelBuffer buf = ChannelBuffers.copiedBuffer("123456789", StandardCharsets.US_ASCII);
-
- assertEquals(0xBB3D, Checksum.crc16(Checksum.CRC16_IBM, buf.toByteBuffer()));
- assertEquals(0x4B37, Checksum.crc16(Checksum.CRC16_MODBUS, buf.toByteBuffer()));
- assertEquals(0x906e, Checksum.crc16(Checksum.CRC16_X25, buf.toByteBuffer()));
- assertEquals(0x29b1, Checksum.crc16(Checksum.CRC16_CCITT_FALSE, buf.toByteBuffer()));
- assertEquals(0x2189, Checksum.crc16(Checksum.CRC16_KERMIT, buf.toByteBuffer()));
- assertEquals(0x31c3, Checksum.crc16(Checksum.CRC16_XMODEM, buf.toByteBuffer()));
+ ByteBuf buf = Unpooled.copiedBuffer("123456789", StandardCharsets.US_ASCII);
+
+ assertEquals(0xBB3D, Checksum.crc16(Checksum.CRC16_IBM, buf.nioBuffer()));
+ assertEquals(0x4B37, Checksum.crc16(Checksum.CRC16_MODBUS, buf.nioBuffer()));
+ assertEquals(0x906e, Checksum.crc16(Checksum.CRC16_X25, buf.nioBuffer()));
+ assertEquals(0x29b1, Checksum.crc16(Checksum.CRC16_CCITT_FALSE, buf.nioBuffer()));
+ assertEquals(0x2189, Checksum.crc16(Checksum.CRC16_KERMIT, buf.nioBuffer()));
+ assertEquals(0x31c3, Checksum.crc16(Checksum.CRC16_XMODEM, buf.nioBuffer()));
}
@Test
diff --git a/test/org/traccar/helper/StringFinderTest.java b/test/org/traccar/helper/StringFinderTest.java
deleted file mode 100644
index f35f9a759..000000000
--- a/test/org/traccar/helper/StringFinderTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.traccar.helper;
-
-import org.jboss.netty.buffer.ChannelBuffer;
-import org.jboss.netty.buffer.ChannelBuffers;
-import org.junit.Test;
-
-import java.nio.charset.StandardCharsets;
-
-import static org.junit.Assert.assertEquals;
-
-public class StringFinderTest {
-
- @Test
- public void testFind() {
-
- ChannelBuffer buf = ChannelBuffers.copiedBuffer("hello world", StandardCharsets.US_ASCII);
-
- assertEquals(-1, buf.indexOf(0, buf.writerIndex(), new StringFinder("bar")));
- assertEquals(6, buf.indexOf(0, buf.writerIndex(), new StringFinder("world")));
- assertEquals(-1, buf.indexOf(0, buf.writerIndex(), new StringFinder("worlds")));
- assertEquals(0, buf.indexOf(0, buf.writerIndex(), new StringFinder("hell")));
-
- }
-
-}
diff --git a/test/org/traccar/protocol/AdmProtocolDecoderTest.java b/test/org/traccar/protocol/AdmProtocolDecoderTest.java
index 9a7f91d26..86ce1c8f8 100644
--- a/test/org/traccar/protocol/AdmProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/AdmProtocolDecoderTest.java
@@ -3,8 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
public class AdmProtocolDecoderTest extends ProtocolTest {
@Test
@@ -12,25 +10,25 @@ public class AdmProtocolDecoderTest extends ProtocolTest {
AdmProtocolDecoder decoder = new AdmProtocolDecoder(new AdmProtocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"010042033836313331313030323639343838320501000000000000000000000000000000000000000000000000000000000000000000000000000000000000000073"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01002680336510002062A34C423DCF8E42A50B1700005801140767E30F568F2534107D220000"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"010022003300072020000000000000000044062A330000000000107F10565D4A8310"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"0100268033641080207AA34C424CCF8E4239030800005B01140755E30F560000F00F70220000"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01002680336510002062A34C423DCF8E42A50B1700005801140767E30F568F2534107D220000"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01002200333508202000000000000000007F0D9F030000000000E39A1056E24A8210"));
- verifyNotNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNotNull(decoder, binary(
"01008449443d3120536f66743d30783531204750533d313036382054696d653d30383a35393a32302031302e30392e31372056616c3d30204c61743d36312e36373738204c6f6e3d35302e3832343520563d3020536174436e743d342b3720537461743d30783030313020496e5f616c61726d3d30783030000000000000000000000000"));
}
diff --git a/test/org/traccar/protocol/At2000FrameDecoderTest.java b/test/org/traccar/protocol/At2000FrameDecoderTest.java
index 5613f832e..c5829d588 100644
--- a/test/org/traccar/protocol/At2000FrameDecoderTest.java
+++ b/test/org/traccar/protocol/At2000FrameDecoderTest.java
@@ -3,10 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
-import static org.junit.Assert.assertEquals;
-
public class At2000FrameDecoderTest extends ProtocolTest {
@Test
@@ -14,13 +10,13 @@ public class At2000FrameDecoderTest extends ProtocolTest {
At2000FrameDecoder decoder = new At2000FrameDecoder();
- assertEquals(
- binary(ByteOrder.LITTLE_ENDIAN, "01012f00000000000000000000000000003335363137333036343430373439320fad981997ae8e031fe10c0ea7641903ca32c0331df467233d2a9cd886fbeef8"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "01012f00000000000000000000000000003335363137333036343430373439320fad981997ae8e031fe10c0ea7641903ca32c0331df467233d2a9cd886fbeef8")));
+ verifyFrame(
+ binary("01012f00000000000000000000000000003335363137333036343430373439320fad981997ae8e031fe10c0ea7641903ca32c0331df467233d2a9cd886fbeef8"),
+ decoder.decode(null, null, binary("01012f00000000000000000000000000003335363137333036343430373439320fad981997ae8e031fe10c0ea7641903ca32c0331df467233d2a9cd886fbeef8")));
- assertEquals(
- binary(ByteOrder.LITTLE_ENDIAN, "893f0000000000000000000000000000e048b1a31deba3f5dbe8877f574877e6ed4d022b6611a10d80dfc4c0c11fa8aacf4a9de61528327e2b66843dd9c5d3a7cc9ee1d9c71a34bb482145d88b4fda3e"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "893f0000000000000000000000000000e048b1a31deba3f5dbe8877f574877e6ed4d022b6611a10d80dfc4c0c11fa8aacf4a9de61528327e2b66843dd9c5d3a7cc9ee1d9c71a34bb482145d88b4fda3e")));
+ verifyFrame(
+ binary("893f0000000000000000000000000000e048b1a31deba3f5dbe8877f574877e6ed4d022b6611a10d80dfc4c0c11fa8aacf4a9de61528327e2b66843dd9c5d3a7cc9ee1d9c71a34bb482145d88b4fda3e"),
+ decoder.decode(null, null, binary("893f0000000000000000000000000000e048b1a31deba3f5dbe8877f574877e6ed4d022b6611a10d80dfc4c0c11fa8aacf4a9de61528327e2b66843dd9c5d3a7cc9ee1d9c71a34bb482145d88b4fda3e")));
}
diff --git a/test/org/traccar/protocol/At2000ProtocolDecoderTest.java b/test/org/traccar/protocol/At2000ProtocolDecoderTest.java
index 532baa764..492d72c80 100644
--- a/test/org/traccar/protocol/At2000ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/At2000ProtocolDecoderTest.java
@@ -3,8 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
import static org.junit.Assume.assumeTrue;
public class At2000ProtocolDecoderTest extends ProtocolTest {
@@ -18,42 +16,42 @@ public class At2000ProtocolDecoderTest extends ProtocolTest {
decoder = new At2000ProtocolDecoder(new At2000Protocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"01012f00000000000000000000000000003335373435343037313632373539388b57ec3a6ec7e3310a1ceb0a70fd751b8f2e7be6df1d6dcd80129f66fff0ea1c"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"89000000000000000000000000000000"));
decoder = new At2000ProtocolDecoder(new At2000Protocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"01012f0000000000000000000000000000333537343534303731363036313936ddf189075add9a32d97b54073025963e65849a3a59940d05fd8db655fc84bc6d"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"893b01000000000000000000000000003b40bcdab6387d829146701d8cb53daaa87b84d24b40cb24fd86da5d3f5f02b0f6f603c43c5a513418a0b2bdcaba603dbe737687cfe9082c57668eb6789d2b029a35aeac6a609558b96de5d7ad37917c902efc878ca9aff474f9d5d2417191285b8d5749bd3ffa86cc99096ce24c1f6ac350ae9adf3d5c788f80b4e3d3dc2dbb8abc1414ea1b52fdb55b2bb8af223ec528245f99d451b715e5774c5397db645d9ae441e645f8dae70230b728e81f51240868712d6f426fd694dbad8026fcf487c268939f04593ad86391cc829b1a1bdac8804ff7507544a69dc0b1b3927d7344e8a5b26fa56825283b3e476330b36d15011e1647ebd9f2ef71844ed32c0dc050457bfbd79160e6d1d8cda00a0927c8957631770e98eb20735aa46b0b18502baf4c45d2623ee51a4320cf3018010e7bbf8bc0dd79eb28e88b727ea67e980b8a91"));
decoder = new At2000ProtocolDecoder(new At2000Protocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"01012f000000000000000000000000000033353734353430373136303631393637f5441a9862260117858237fe3160388490f0df7d46c09112ee087235a92101"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"89043203000000000000000000000000d01ff1df1b56ba9185bb741ddc253f3cee093b1f8193100cd95777b5288a6f29d1b343a952f882ce8825679f7e27ad88ed7898bff92f716acadfc3c17fa8c1a6b9d0934e8f042433a183776c06c1acd73efb4b9f19030debb4dceb161fb3e6630757d25c3e995b7cf5f446318dcc1677eb215d1af49f11cd7300598bcdc40cc25466ed2391d836c782e44bc04a332e902b2b34f5597a542af4ca670cdfc18d87ce2a225c3e6f2f32359d4914c6df09aa5ee306c229260d4a56da53f93398bc8a6e77095305ee214cf605de20d3876a993fb810486f75bcd514c12442bf4dc3fbe7963b20d5100b5ecff1c1aef4c4b3736a04e245d50f538327db21d55270b279db5ac5a9658876bae3d9b5026b8975bb2bf4d100b8492760d66ae31f27bf9c525c2d794860eabca9c788b91152dbce79f336daaf6a7a9547bf1dd8e3334c891f4548fd6d112ebf45125c2a8abd3a786ebbcfdd03101b524bbf465f14a9a424305ce7de56ffca85b4657fc8c03e4349c0ca6be64d1cf595ee91f8173678ef2267dae54dd00028450c48d9b74c925af0f245d409d8773238dce5832747587f53a12155869c1d464eb0630f94cf8dceb76aa39995411d4ce7743b1501692425afec498535526067e79f568b7f71ee47d8b4929118d57b13d56cdbfd26582d579dee"));
decoder = new At2000ProtocolDecoder(new At2000Protocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"01012f0000000000000000000000000000333537343534303731363035353033dd529a1eb5df9f3b6d320b38250e03306692957e8c2127d8e381a717f639b4c9"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"89898701000000000000000000000000ae99e38f13d44f536769eb4930a6826dfebe5b98a6048941e89b17c9cdcb276be4af7c0d188d07c90d6e94aa9efcb465fe7aeaff4d85caf837483b4e9b32fbbacfbc4e175eebf57a27f552a64fc3419565d2dfbea668511a08d5a526342fad0e93b20c4449ad8defab4a9ac68cf7dad86971eb2cd96810d9d6a9c56e07fd90e4c28cfc53a069b63efe37a0523a69b607a2dc011ba17b177c5332c04be1faeeabed24539b3b790fa8a8610ab3633e0140ed79690fcae9dea43c7daad780d95a511d8f4875e621bcfe7516a03b80eb3c473ffd4bc1eda298dfa7d994a2cfeaa5d24c190d52d72fd90975a2e6f9ed3b95017133952262f91787c46839738a80c333dc53ee4d8afe75315d801efe17bc7309f30cfce64906bf70e6844c835781cbb64b49e9315ca3c2cd39d00a03cc7178a4ebc5df230dcdfd44ec588791d488f96bb6ff4007a753f552bda4d1766632aa3ec5eb38feb23ed6efb8f382a7f22b70adc9cb533c09bf749190c36d63b572c1acfc3a59138d51273835ab13c4689df01e3d2c2dd1829e00aac5c56b5d51e60d6731833f82c7464d88df663ca28a20eedeecb60f3704ae78281838caa116184e414db459768321bbfa1e83ad59fe168eb81f3b41cfe0e39c8aa78cbbe5825620bf053a1cb62e04d4cdf17ca2dc9305d47c"));
decoder = new At2000ProtocolDecoder(new At2000Protocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"01012f00000000000000000000000000003335363137333036343430373439320fad981997ae8e031fe10c0ea7641903ca32c0331df467233d2a9cd886fbeef8"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"893f0000000000000000000000000000e048b1a31deba3f5dbe8877f574877e6ed4d022b6611a10d80dfc4c0c11fa8aacf4a9de61528327e2b66843dd9c5d3a7cc9ee1d9c71a34bb482145d88b4fda3e"));
}
diff --git a/test/org/traccar/protocol/AtrackFrameDecoderTest.java b/test/org/traccar/protocol/AtrackFrameDecoderTest.java
index 52ac18026..df775021a 100644
--- a/test/org/traccar/protocol/AtrackFrameDecoderTest.java
+++ b/test/org/traccar/protocol/AtrackFrameDecoderTest.java
@@ -3,8 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import static org.junit.Assert.assertEquals;
-
public class AtrackFrameDecoderTest extends ProtocolTest {
@Test
@@ -12,19 +10,19 @@ public class AtrackFrameDecoderTest extends ProtocolTest {
AtrackFrameDecoder decoder = new AtrackFrameDecoder();
- assertEquals(
+ verifyFrame(
binary("40502c373542332c3132302c37393737392c3335383930313034383039313535342c32303138303431323134323531342c32303138303431323134323531342c32303138303431333030303635352c31363432333338392c34383137383730302c3130382c322c362e352c392c302c302c302c302c302c323030302c323030302c1a0d0a"),
decoder.decode(null, null, binary("40502c373542332c3132302c37393737392c3335383930313034383039313535342c32303138303431323134323531342c32303138303431323134323531342c32303138303431333030303635352c31363432333338392c34383137383730302c3130382c322c362e352c392c302c302c302c302c302c323030302c323030302c1a0d0a")));
- assertEquals(
+ verifyFrame(
binary("244F4B0D0A"),
decoder.decode(null, null, binary("244F4B0D0A")));
- assertEquals(
+ verifyFrame(
binary("fe0200014104d8f196820001"),
decoder.decode(null, null, binary("fe0200014104d8f196820001")));
- assertEquals(
+ verifyFrame(
binary("40501e58003301e000014104d8f19682525ecd5d525ee344525ee35effc88815026ab4d70000020000104403de01000b0000000007d007d000"),
decoder.decode(null, null, binary("40501e58003301e000014104d8f19682525ecd5d525ee344525ee35effc88815026ab4d70000020000104403de01000b0000000007d007d000")));
diff --git a/test/org/traccar/protocol/BceProtocolDecoderTest.java b/test/org/traccar/protocol/BceProtocolDecoderTest.java
index 53daf5ff3..e2a5aa213 100644
--- a/test/org/traccar/protocol/BceProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/BceProtocolDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -12,25 +10,25 @@ public class BceProtocolDecoderTest extends ProtocolTest {
BceProtocolDecoder decoder = new BceProtocolDecoder(new BceProtocol());
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"789622d1cb1303003401a53365b70f4a9babc0ffd700c04400f0b6c741e63933428f1c431c015468de43f18221341b007e0ae20001430a698f003f008d000000000031f85900000000f0831c018400000000000000000000000000000000000209000000000000000000000000000000030065f70f4a9babc0ffd700c0440069bcc741e73733427f1c431a01a9378343f1829c391b00a80be2000170056da7003e007c000000000031c04e00000000f0831c01810000000000000000000000000000000000060100000000000000000000000000000003006537104a9babc0ffd700c0440051c1c74129363342721c421801e4809543f18210341b00710ae2000170056da7003e0072000000000031c04800000000b8841c017e00000000000000000000000000000000000306000000000000000000000000000000030069"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"be76619c834601004200a0003fd769c568ffc3db0079161d420683a9414918b1150000000000d102660167040000000000009f06357f0000a401042ea415e10232000000000000000000000051"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"be76619c834601004200a0003ff76cc568ffc3db00bd151d423c8ca9410a18af150000000000d1023a0160040000000000009f06427f0000a401042ea416e1003e00000000000000000000009a"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"be76619c834601004202a5863f57f8b868ffc3db0001712642b70b9d41221946200246d23342d1023e016404000000000000a0065a7f0000a4010496f277e3064300000000000000000000003f97f8b868ffc3db0074712642ae0a9d412919452102fff19042d102a4026304000000000000a006487f0000a4010496f277e3064300000000000000000000003fb7f8b868ffc3db00c6712642000a9d413019442002a6074542d102300165040000000000009f064f7f0000a4010496f277e3064300000000000000000000003fd7f8b868ffc3db002872264245099d413518421f02bea35e42d1021e0164040000000000009f06377f0000a4010496f277e3064300000000000000000000003fe7f8b868ffc3db0061722642e3089d413a28421f02a05ff641d102580163040000000000009f06577f0000a4010496f277e3064300000000000000000000003f17f9b868ffc3db0021732642a3079d414119411d02d69fcc42d102440165040000000000009f06437f0000a4010496f277e3064300000000000000000000003f37f9b868ffc3db00ae732642b4069d414628421b02e0629742d1024c0167040000000000009f06557f0000a4010496f277e3064300000000000000000000003f57f9b868ffc3db0044742642ae059d414c28421a027540a342d102860163040000000000009f065b7f0000a4010496f277e3064300000000000000000000003f97f9b868ffc3db007275264256039d4153284417029e1f2f43d1024a016704000000000000a0064e7f0000a4010496f277e306430000000000000000000000db"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"2d41abfa2e4501004e02a5a0068609f96a009106260af96a00a006260af96a009106960af96a00a306a60af96a008f06b60af96a009106960cf96a00a03e0715f96affc300804000e6a23a4230ccc441001f47850200000000a0000000bd6542651a110d004b1000000000a401045a56bf4d02480000000000000000061623f96a00a0062623f96a00913ea728f96affc300804000e6a23a4230ccc441001f7f850200000000a0000000bd6542651a110d004a1000000000a401045a56bf4d02480000000000000000069639f96a00a006a639f96a00913e373cf96affc300804000e6a23a4230ccc441001f7f850200000000a0000000ad6534651a110d004a1000000000a401045a56bf4d024800000000000000003ed74ff96affc300804000e6a23a4230ccc441001f7f850200000000a0000000ad6534651a111b004a1000000000a401045a56bf4d01480000000000000000061650f96a00a0062650f96a00913e6763f96affc300804000e6a23a4230ccc441001f7f850200000000a0000000ad6534651a110d004a1000000000a401045a56bf4d01480000000000000000069666f96a00a006a666f96a00913e0777f96affc300804000e6a23a4230ccc441001f7f850200000000a0000000ad6534651a110d004a1000000000a401045a56bf4d0148000000000000000006067df96a00a006167df96a0091063687f96a00a3064687f96a008f065687f96a0091063689f96a00a03e978af96affc300804000e6a23a4230ccc441001f87850200000000a0000000ad6527651a110d004a1000000000a401045a56bf4d024800000000000000000e"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"be76619c834601003302a5e8327764726bff432fc52a420e2c93410028afd2070000000080024a0005040000000000008e06547f0000a401043cf21f390e54328764726bff432fc52a420e2c93410028afd2070000000080024c0005040000000000008e064f7f0000a401043cf21f390e54329764726bff432fc52a420e2c93410028afd2070000000080024e0002040000000000008d064f7f0000a401043cf21f390e5432a764726bff432fc52a420e2c93410028afd2070000000080024e0004040000000000008e06587f0000a401043cf21f390e5432b764726bff432fc52a420e2c93410028afd207000000008002460005040000000000008e06557f0000a401043cf21f390e5432c764726bff432fc52a420e2c93410028afd2070000000080024e0004040000000000008e06347f0000a401043cf21f390e5432d764726bff432fc52a420e2c93410028afd2070000000080024e0002040000000000008e06547f0000a401043cf21f390e5432e764726bff432fc52a420e2c93410028afd207000000008002540002040000000000008e06477f0000a401043cf21f390e5432f764726bff432fc52a420e2c93410028afd207000000008002540004040000000000008d064f7f0000a401043cf21f390e54320765726bff432fc52a420e2c93410028afd207000000008002540004040000000000008e064d7f0000a401043cf21f390e54321765726bff432fc52a420e2c93410028afd207000000008002540004040000000000008e06467f0000a401043cf21f390e544200a0003f3743c96bffc3db0060c81c42d885ab41002aaf060000000000d102380167040000000000008a064f7f0000a4010412a46b330033000000000000000000000025"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"ca07629c834601002702a58f3c278ff96a0bc000a0c00140bc3a42508bc541002a70a905000000009000c101a40103d904440e003000000000000000000000000000000000000001013c878ff96a0bc000a0c00140bc3a42508bc541002970a905000000009000c301a40103d904440e003000000000000000000000000000000000000001013cb7d2f96a0bc000a0c00124bc3a426b8fc5410428000404000000009000c401a40103d904440e003500000000000000000000000000000000000001013cc7d2f96a0bc000a0c00124bc3a426b8fc5410428000404000000009000c301a40103d904440e003500000000000000000000000000000000000001013cd7f2f96a0bc000a0c00114bc3a42a48fc5410029027e03000000009000c301a40103d904440e003000000000000000000000000000000000000001013c670dfa6a0bc000a0c001f1bb3a42418dc541002a484904000000009000c001a40103d904440e003a00000000000000000000000000000000000001013c770dfa6a0bc000a0c001f1bb3a42418dc5410028484904000000009000bf01a40103d904440e003a00000000000000000000000000000000000001013c470efa6a0bc000a0c001f1bb3a42418dc5410029484904000000009000bf01a40103d904440e003a00000000000000000000000000000000000001013c5711fa6a0bc000a0c001f1bb3a42418dc5410029484904000000009000c101a40103d904440e003000000000000000000000000000000000000001013f00a0003cc795866b0bc000a0c00144bc3a423a90c541003697cb03000000008000cf01a40103d9040d0f0030000000000000000000000000000000000000010100"));
}
diff --git a/test/org/traccar/protocol/BlackKiteProtocolDecoderTest.java b/test/org/traccar/protocol/BlackKiteProtocolDecoderTest.java
index 503f51f3a..0a4d44150 100644
--- a/test/org/traccar/protocol/BlackKiteProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/BlackKiteProtocolDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -12,10 +10,10 @@ public class BlackKiteProtocolDecoderTest extends ProtocolTest {
BlackKiteProtocolDecoder decoder = new BlackKiteProtocolDecoder(new BlackKiteProtocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"01150003313131313131313131313131313131209836055605BA"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"0136000331313131313131313131313131313120523905563000010000000100000033000000003400004000004500004600005000005100009F76"));
}
diff --git a/test/org/traccar/protocol/CastelProtocolDecoderTest.java b/test/org/traccar/protocol/CastelProtocolDecoderTest.java
index 2baee5494..826ac7d2e 100644
--- a/test/org/traccar/protocol/CastelProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CastelProtocolDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -12,133 +10,133 @@ public class CastelProtocolDecoderTest extends ProtocolTest {
CastelProtocolDecoder decoder = new CastelProtocolDecoder(new CastelProtocol());
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"40403a00043231335750323031373030363135360000000000a00200000100000101201100344a474446364545374a4230373632363056ff0d0a"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"4040560004323133474c3230313630303033363400000000004002a122a05a5423a05abe0f2a000000000007f1f90014000000040001640011170003001e000505210b210c210d210f2101062b58ef02001a25950d0a"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"404057000431303031313132353239393837000000000000004002C1F06952F0F169529C9111000000000069830000470000000400036401014C01030078000505210C210D210F21102101073BE8030064280AEB930D0A"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"40405f000536303331353030303335313200000000000000004001040212102a2f72b29302a0af8512b40787018e000000000043e4ae000000007ca0f7224d5049503632305f56312e312e30004d5049502d3632302056322e300072140d0a"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"24245000363137313135313243333133360000000000000040011b011207133ac49a390464514a15000000008e480c00000917000000000000ffafffaf00010000ffff7800ffffffffffffff003c0d0a"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"40408200033231334c32303137303031313039000000000000100136477b5964477b590400000000000000dc410f000000000204000709207910008304011c07110e110dd41a160714a95a0f00001e058c4944442d3231334c2056312e312e3120323031372d30352d3038004944442d3231334c2056312e312e300000006da10d0a"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"40408200033231334c323031373030303131370000000000001001000c6759a10d67590a9e1200000000000e3e0000000000020000000e4e791c000004010d0711060515083017086cd1181f000040067d4944442d3231334c2056312e312e3120323031372d30352d3038004944442d3231334c2056312e312e3000000066e30d0a"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"404043000432313345503230313630303035383500000000004006a2021d5810031d58ae940400da050000f6040000070000000400076401680000000001001bd20d0a"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"4040d0000432313345503230313630303035383500000000001001831c1c58b1fc1c58ae94040012220000f60400005800000000000763016800008484004944445f3231335730315f532056312e302e37004944445f3231335730315f482056312e302e370032000110021003100410051006100710081009100a100b100c100d100e1011100111021103110411051106110711011202120312041201130213031301160216011701180218011b011c011d011e011f021f031f041f051f061f071f0121022101260127012861780d0a"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"404029000432313345503230313630303035383500000000009001ffffffff0000b4fc1c582b6e0d0a"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"40406000043231334550323031363030303538350000000000400708000000831c1c58f4fb1c58ae94040012220000f604000058000000200007630168000084c401040b10090c3532db3f07f07f7520090100000101010e00000000c7920d0a"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"404042000432313345503230313630303035383500000000001002831c1c58b7fc1c58ae94040012220000f604000058000000000007630168000084840072a20d0a"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"4040d0000432313345503230313630303035383500000000001001831c1c5805fe1c58ae94040012220000f60400005800000000000763016800008484004944445f3231335730315f532056312e302e37004944445f3231335730315f482056312e302e370032000110021003100410051006100710081009100a100b100c100d100e1011100111021103110411051106110711011202120312041201130213031301160216011701180218011b011c011d011e011f021f031f041f051f061f071f012102210126012701284eb10d0a"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"40405700043231334e583230313630303131373700000000004002c458ce572159ce57a9e2020082030000500c00000f0000000400036401240e0403023c000505210c210d210f21102101075b14030121330269430d0a"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"40407800043231334e583230313630303131373700000000004004fa52ce574b53ce57cad1020041020000050c00000d0000000400036401240b0503001b042105210c210d210f211021112113211c211f212121232124212c212d213021312133213e2141214221452149214a214c214f215021384e0d0a"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"4040a600043231334e583230313630303131373700000000004005fa52ce575053ce57cad102006b020000050c00000d0000000400036401240b050300001b042105210c210d210f211021112113211c211f212121232124212c212d213021312133213e2141214221452149214a214c214f215021015bd604301f500600000653000000bc0bffff78250000ff2d98642401000f8080e038000f0f0000000000000077b10d0a"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"40404300043231334e583230313630303131373700000000004006fa52ce574e53ce57cad1020053020000050c00000d0000000400036401240b0503000000feec0d0a"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"40403600043231334e583230313630303033343600000000004009ad31a457050810061a35b29bf80ae6da83180300320bbe32580d0a40403600043231334e583230313630303033343600000000004009ad31a457050810061a35b29bf80ae6da83180300320bbe32580d0a"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"4040d400043535333133350000000000000000000000000000100196d499574bd899570000000000000000010000000000000000000000002410000000004944445f3231334730325f532056322e332e345f4e004944445f3231334730325f482056322e332e345f4e0032000110021003100410051006100710081009100a100b100c100d100e1011100111021103110411051106110711011202120312041201130213031301160216011701180218011b011c011d011e011f021f031f041f051f061f071f012102210126012701285b410d0a"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"24243f00676e6768656636313031313132393030313734002001840d0000d2deb556020602100b35360456cf09e6ebac0200000000030000000001abc10d0a"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"24243f00676e6768656636313031313132393030313734002001840d000000dfb556020602100b36298256cf0956ebac020000990c7f0000000001b4830d0a"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"4040590004313030303030303030303800000000000000000040010072f53f56c25240560000000078b00900000000009c3100000000030100011900030001090b0f080106c04fe40b4037310c0060e001ff018d01e05e0d0a"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"40405900043231334e5832303135303030303336000000000040010073dd735600df7356b9220000270b000000000000000000000400000000240e03000201120c0f0a19050c1e5808ca35530dd902540d9c010000e5300d0a"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"404055000431303031313132353239393837000000000000001002C1F0695230086A529C911100000000000F890000A60500000000036301014CFF000001190A0D0539191480D60488C5721800000000BF8A640D0A"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"40406000043130303131313235323939383700000000000000400705000000C1F0695249F469529C9111000000000069830000D80040000400036401014C04030001190A0D04201E1480D60488C5721800000000AF0101060F000F00EA1E0D0A"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"404057000431303031313132353239393837000000000000004002C1F06952F0F169529C9111000000000069830000470000000400036401014C01030078000505210C210D210F21102101073BE8030064280AEB930D0A"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"40405900043130303131313235323939383700000000000000400101C1F06952E7F069529C9111000000000069830000070000000400036401014C00030001190A0D0412041480D60488C57218000000009F01E803ED9A0D0A"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"4040B9000431303031313132353239393837000000000000004005C1F069521BF169529C9111000000000069830000130000000400036401014C0003000022032104210521062107210C210D210E210F2110211121132115211C211F21212124212E212F2130213121322133213C214221432144214521472149214A214C214D214E210100643B6232E803003E64280A3C24FE00010E010F00D5805A483C640000000000010000E02E000000066400000500000000A7710D0A"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"404043000431303031313132353239393837000000000000004006C1F0695209F169529C91110000000000698300000D0000000400036401014C00030000009AF40D0A"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"404086000431303031313132353239393837000000000000004004C1F0695200F169529C91110000000000698300000D0000000400036401014C00030022032104210521062107210C210D210E210F2110211121132115211C211F21212124212E212F2130213121322133213C214221432144214521472149214A214C214D214E219AE90D0A"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"40407F000431303031313132353239393837000000000000001001C1F06952FDF069529C91110000000000698300000C0000000000036401014C00030001190A0D04121A1480D60488C5721800000000AF4944445F3231364730325F532056312E322E31004944445F3231364730325F482056312E322E31000000DF640D0A"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"404044000c3631313135303030303935360000000000000000420600011e0a0f0b1312864fcd08c07a13030100640acf000004000a000000000000007ba083a66ad80d0a"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"40405c000c363131313530303030393536000000000000000040011c0a0f0e362dca53cd0860831303000000000300000000ff000000000000007ba083a650542d3639305f56312e312e320050542d3639302056312e32008a020d0a"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"4040450004323132474c31313433303035303033000000000040082ca89b55a6a99b555c57000000000000c40200000b0000001400036401111f000302f5533bd653f10d0a"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"40404d0004323132474c3131343330303530303300000000004007120000002ca89b55cba99b555c57000000000000c40200000b0000000000036401111f000102000101170000000068850d0a"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"4040420004323132474c31313433303035303033000000000010022ca89b55cca99b555c57000000000000cf0200000b0000000000036401111f0000020013be0d0a"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"4040870004323132474c31313433303035303033000000000040052ca89b55e3a89b555c57000000000000c4020000040000001400036401111f0003000012042105210b210c210d210f211021112113211c2121212321242133213421422146214f212b50663603003ce9030dff060000600dffffc25865ffff9e02b43624000000003cbc0d0a"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"4040d00004323132474c31313433303035303033000000000010013ec09b5596c29b555c57000000000000de0200000f0000000000036401111f000000004944445f3231334730325f532056322e322e36004944445f3231334730325f482056322e322e360032000110021003100410051006100710081009100a100b100c100d100e1011100111021103110411051106110711011202120312041201130213031301160216011701180218011b011c011d011e011f021f031f041f051f061f071f012102210126012701288a690d0a"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"40404d0004323132474c3131343330303530303300000000004007050000003ec09b5564c29b555c57000000000000de0200000f0000002000036401111f0000020001010e00000000237e0d0a"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"40401F00043130303131313235323939383700000000000000100303320D0A"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"40407F000431303031313132353239393837000000000000001001C1F06952FDF069529C91110000000000698300000C0000000000036401014C00030001190A0D04121A1480D60488C5721800000000AF4944445F3231364730325F532056312E322E31004944445F3231364730325F482056312E322E31000000DF640D0A"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"40405900043130303131313235323939383700000000000000400101C1F06952E7F069529C9111000000000069830000070000000400036401014C00030001190A0D0412041480D60488C57218000000009F01E803ED9A0D0A"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"40405900043335343034333035303834343134330000000000400100f61a7355c11b7355710000000b00000000000000000000000400000000240e0200020106060f100b2d5a78a7076ec0fb1d00008c065f010000ac220d0a"));
}
diff --git a/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java b/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java
index cdda0fca7..17854c824 100644
--- a/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CellocatorProtocolDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -12,19 +10,19 @@ public class CellocatorProtocolDecoderTest extends ProtocolTest {
CellocatorProtocolDecoder decoder = new CellocatorProtocolDecoder(new CellocatorProtocol());
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"4D434750008AD01500080103011804000000460020000000005E750000000000000000000000C34300040204DA4DA30367195703E803000000000000000001030F0802E10778"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"4D434750008AD01500080102011804000000360060000000005E750000000000000000000000C24300040204DA4DA30367195703E80300000000000000003B020F0802E107DF"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"4D4347500006000000081A02021204000000210062300000006B00E100000000000000000000E5A100040206614EA303181A57034E1200000000000000001525071403D60749"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"4d434750000101000008011f041804000000200100000000005e750000000000000000000000548500040204da4da30367195703e80300000000000000002014151007dd07f7"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"4d434750005e930100080102041804000000200f20000000005e7500000000000000000000005af400040204da4da30367195703e8030000000000000000021a111e08dd0760"));
}
diff --git a/test/org/traccar/protocol/DmtHttpProtocolDecoderTest.java b/test/org/traccar/protocol/DmtHttpProtocolDecoderTest.java
index e7fd086a7..99154e0f6 100644
--- a/test/org/traccar/protocol/DmtHttpProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/DmtHttpProtocolDecoderTest.java
@@ -1,6 +1,6 @@
package org.traccar.protocol;
-import org.jboss.netty.handler.codec.http.HttpMethod;
+import io.netty.handler.codec.http.HttpMethod;
import org.junit.Test;
import org.traccar.ProtocolTest;
diff --git a/test/org/traccar/protocol/DmtProtocolDecoderTest.java b/test/org/traccar/protocol/DmtProtocolDecoderTest.java
index 2e386c48e..09ffca100 100644
--- a/test/org/traccar/protocol/DmtProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/DmtProtocolDecoderTest.java
@@ -3,8 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
public class DmtProtocolDecoderTest extends ProtocolTest {
@Test
@@ -12,31 +10,31 @@ public class DmtProtocolDecoderTest extends ProtocolTest {
DmtProtocolDecoder decoder = new DmtProtocolDecoder(new DmtProtocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"0255003300001b00003335333232393032373533393235310038393931353030303030303030313330343539340000000403041910780603"));
- verifyPositions(decoder, false, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, false, binary(
"02551040000eaca40d00d2b8e562c51f9912f39a6bee00007e420091090903070100000000008b1065360000000000007fd401c4fcf2feffffffffffffffffee0000003f1b"));
- verifyPositions(decoder, false, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, false, binary(
"02551080000eada40d00d2b8e58ac51f9912f39a6bee00007e42007e090709070000000000009010fc330000000000007fc201a0fc04ffffffffffffffffffe5000000c5d00eaea40d00d2b8e58ac51f9912f39a6bee00007e42007e09070207000000000000851008340000000000007fc201a0fc04ff0000000000000000e5000000c96d"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"025500310038f90100333533333233303831363639373330003839363130313835303031383234383434363330002202010900000000"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"0255220000"));
- verifyPositions(decoder, false, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, false, binary(
"025504d80352000602000052185c0803001552185c0842ee19eaba2524682d000d060973112b0302080100000000000300060901421003e40604140007190b300000000c030000000de80100000ec90e00000f0700000052000702000069185c0803001569185c089ac019ea0ad223682300fb02047d152f03020801000000000003000609013f1003fc0604140007190b300000000c030000000de90100000ecb0e00000f0700000052000802000092185c0803001592185c0800a619eaa5e7226821009c0506880e250302080100000000000300060901411003f30604140007190b300000000c030000000dea0100000ef10e00000f07000000520009020000a9185c08030015a9185c0818ae19ea1e62226826001e05038e0e2203020801000000000003000609013f1003030704140007190b300000000c030000000deb0100000ef60e00000f0700000052000a020000c0185c08030015c0185c0893b619ea7fd321681a00640403860f1d0302080100000000000300060901401003ff0604140007190b300000000c030000000dec0100000ef80e00000f0700000052000b020000d7185c08030015d7185c08e08519eab7c921682300fd04035510270302080100000000000300060901401003ea0604140007190b300000000c030000000ded0100000efa0e00000f0700000052000c020000ee185c08030015ee185c08f61719ea61e221682c004c0503540f190302080100000000000300060901421003dd0604140007190b300000000c030000000dee0100000efc0e00000f0700000052000d02000005195c0803001505195c0836b518eac9f221683000fa0107740e2d03020801000000000003000609013f1003fe0604140007190b300000000c030000000def0100000efe0e00000f0700000052000e0200001d195c080300151d195c08d1b518ea2d6721682300980502870e1d0302080100000000000300060901411003ed0604140007190b300000000c030000000df00100000e000f00000f0700000052000f02000034195c0803001534195c086acd18ea742b2168400006020500132903020801000000000003000609013d10030d0704140007190b300000000c030000000df10100000e030f00000f070000005200100200004d195c080300154d195c08dfba18eab81721684e003000093b0e1e03020801000000000003000609013e1003130704140007190b300000000c030000000df20100000e050f00000f0700000052001102000065195c0803001565195c081db318ea871f216822000400080416250302080100000000000300060901401003060704140007190b300000000c030000000df30100000e090f00000f07000000"));
- verifyPositions(decoder, false, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, false, binary(
"025504e9032f000d000000000000001501222700524553455420446172742033342e322e312e3920666c6167733d312057443d303f000e0000000000000015013214004e6f2041646d696e20706172616d7320666f756e64202d207573696e672064656661756c7473202b204175746f41504e37000f00000000000000090015000000000000000000000000000000000000000000020805000000000007000609012b1002400003700e37001000000000000000090015000000000000000000000000000000000000000000020801000000000007000609012b1002400003700e37001100000000000000090015000000000000000000000000000000000000000000020800000000000007000609012b1002400003700e37001200000000000000020015000000000000000000000000000000000000000000020800000000000006000609012b1002400003700e370013000000000000000f001500000000000000000000000000000000000000000002080000000000000200060901271002370003670e2e0014000000000000001501211300526f6c6c20646574656374656420636f735e32203c203338333535333838343700150000000000000017001500000000000000000000000000000000000000000002080000000000000200060901071002300003d60e2a00160000000000000015011d130054756d626c65722074726967676572656420636f735e32203c20302e0017000000000000001501211300526f6c6c20646574656374656420636f735e32203c203338333535333838343700180000000000000017001500000000000000000000000000000000000000000002080000000000000200060901071002300003f70e2a00190000000000000015011d130054756d626c65722074726967676572656420636f735e32203c203026001a000000000000001501190b0047534d3a20544350206261642053594e432063686172732e001b000000000000001501211300526f6c6c20646574656374656420636f735e32203c203338333535333838343a001c0000000000000017001500000000000000000000000000000000000000000002080000000000000200060c01c90f02300003e20f041f002a001d0000000000000015011d130054756d626c65722074726967676572656420636f735e32203c20302e001e000000000000001501211300526f6c6c20646574656374656420636f735e32203c203338333535333838343a001f0000000000000017001500000000000000000000000000000000000000000002080000000000000200060c01d80f02300003ff0f0418002a00200000000000000015011d130054756d626c65722074726967676572656420636f735e32203c2030"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"025500310038f90100333533333233303831363639373330003839363130313435363839393333303030303835002202010900000000"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"0255043D003D004746000096D684020B001502D48402F043F4EC2A6909452B001F00050011230302080000000000000A00060F041D0001FE0F021E0005000003BF08"));
}
diff --git a/test/org/traccar/protocol/EgtsFrameDecoderTest.java b/test/org/traccar/protocol/EgtsFrameDecoderTest.java
index 91a53525e..237c849c5 100644
--- a/test/org/traccar/protocol/EgtsFrameDecoderTest.java
+++ b/test/org/traccar/protocol/EgtsFrameDecoderTest.java
@@ -3,8 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
public class EgtsFrameDecoderTest extends ProtocolTest {
@Test
@@ -14,7 +12,7 @@ public class EgtsFrameDecoderTest extends ProtocolTest {
verifyFrame(
binary("0100020B0025003A5701C91A003A5701CD6E68490202101700CBB4740F7617FD924364104F116A0000000000010300001EC2"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "0100020B0025003A5701C91A003A5701CD6E68490202101700CBB4740F7617FD924364104F116A0000000000010300001EC2")));
+ decoder.decode(null, null, binary("0100020B0025003A5701C91A003A5701CD6E68490202101700CBB4740F7617FD924364104F116A0000000000010300001EC2")));
}
diff --git a/test/org/traccar/protocol/EgtsProtocolDecoderTest.java b/test/org/traccar/protocol/EgtsProtocolDecoderTest.java
index 3639c6416..b3fe99751 100644
--- a/test/org/traccar/protocol/EgtsProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/EgtsProtocolDecoderTest.java
@@ -3,8 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
public class EgtsProtocolDecoderTest extends ProtocolTest {
@Test
@@ -12,26 +10,26 @@ public class EgtsProtocolDecoderTest extends ProtocolTest {
EgtsProtocolDecoder decoder = new EgtsProtocolDecoder(new EgtsProtocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"0100010b002200c06401f21700c1640171360d00010101140071360d000238363539303500000000000000000047fc"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"0100000b002400a0d601f01900030081030000000101011600030000004238363434393530333436343333373600014cdc"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"0100000b002700030e01211800030e8573890100845e980f0202101500f85d980fb37f50aae9653c2b193708317b00000001c51b"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"0100010b00a308c26401029808c3640171360d000202101800e19a7b0fcfb4c49a0bfdb87a911801b70000000010d90000180400021c0000120300000000101800f39a7b0f2fc9c39a9bf2b87a914001b50000000010da0000180400021c0000120300000000101800fa9a7b0fc663c39a21eeb87a914001b60000000010da0000180400021c0000120300000000101800069b7b0f56d8c29a26ebb87a919600ab0000000010da0000180400021c00001203000000001018000a9b7b0fb2c5c29a19f4b87a915a007d0000000010da0000180400021c0000120300000000101800089b7b0f68ccc29a21eeb87a9164008f0000000010da0000180400021c0000120300000000101800079b7b0fa0d1c29aa4ecb87a918200980000000010da0000180400021c00001203000000001018000b9b7b0f34c4c29ad3f7b87a915a00670000000010da0000180400021c00001203000000001018000f9b7b0f3dbec29aaf0fb97a91c8005e0000000010dc0000180400021c0000120300000000101800199b7b0f42bbc29a0855b97a9178006b0000000010db0000180400021c00001203000000001018001b9b7b0fc8b6c29a3c5db97a916e007e0000000010db0000180400021c00001203000000001018001a9b7b0fc4b9c29a8159b97a916e00750000000010db0000180400021c00001203000000001018001d9b7b0f94aec29a3363b97a916400930000000010db0000180400021c00001203000000001018001c9b7b0fcdb3c29a3760b97a916e008a0000000010db0000180400021c0000120300000000101800209b7b0f28a1c29af263b97a918200ba0000000010db0000180400021c00001203000000001018001f9b7b0f61a6c29af263b97a917800b30000000010db0000180400021c00001203000000001018001e9b7b0f58acc29af263b97a916400a50000000010db0000180400021c0000120300000000101800299b7b0ff26fc29ab561b97a916e00b20000000010d90000180400021c00001203000000001018002d9b7b0fd05bc29a3760b97a916e00bd0000000010d80000180400021c0000120300000000101800359b7b0f4f31c29abe5bb97a916400b50000000010d70000180400021c0000120300000000101800379b7b0f5d28c29abe5bb97a916e00b40000000010d60000180400021c0000120300000000101800369b7b0fd62cc29abe5bb97a916400bd0000000010d60000180400021c00001203000000001018003c9b7b0fca09c29a0358b97a918c00bc0000000010d50000180400021c0000120300000000101800419b7b0f38ebc19a0855b97a916e00b40000000010d60000180400021c0000120300000000101800449b7b0f4edcc19a8a53b97a916400c30000000010d60000180400021c0000120300000000101800469b7b0fded1c19acb52b97a916e00b70000000010d60000180400021c0000120300000000101800649b7b0f7a69c19a154cb97a810000bc0000000010d60000180400021c0000120300000000101800709b7b0fcc5cc19a114fb97a915000970000000010d70000180400021c0000120300000000101800729b7b0fda53c19a8a53b97a91a0007d0000000010d70000180400021c0000120300000000101800749b7b0fa24ec19a3c5db97a91a000650000000010d70000180400021c0000120300000000101800789b7b0fe74ac19aca7eb97a910e015c0000000010d80000180400021c00001203000000001018007f9b7b0f6e46c19a78e0b97a9190015c0000000010d80000180400021c0000120300000000101800869b7b0f3641c19a144eba7a9190015c0000000010d60000180400021c00001203000000001018008d9b7b0ffd3bc19a74b9ba7a9190015c0000000010d40000180400021c0000120300000000101800949b7b0fc536c19a1524bb7a9186015b0000000010d20000180400021c00001203000000001018009b9b7b0fce30c19af78dbb7a919a015c0000000010d00000180400021c0000120300000000101800a29b7b0f552cc19a93fbbb7a9172015d0000000010cd0000180400021c0000120300000000101800b09b7b0f2521c19a6ec0bc7a9186015b0000000010c90000180400021c0000120300000000101800a99b7b0f5e26c19a8759bc7a915e015b0000000010cb0000180400021c0000120300000000101800b79b7b0fa81fc19a1328bd7a9172015b0000000010c70000180400021c0000120300000000101800be9b7b0f6b1dc19ac686bd7a914a015c0000000010c60000180400021c0000120300000000101800c19b7b0fed1bc19ad2a9bd7a912201530000000010c60000180400021c0000120300000000101800c39b7b0f6223c19af4bdbd7a910401420000000010c60000180400021c0000120300000000101800c29b7b0fe91ec19a42b4bd7a910e014c0000000010c60000180400021c0000120300000000101800c59b7b0f502fc19a1acfbd7a91fa00300000000010c60000180400021c0000120300000000101800c49b7b0fdb27c19ae6c6bd7a91fa00390000000010c60000180400021c0000120300000000101800c79b7b0fb83fc19a8ad9bd7a91f000180000000010c60000180400021b0000120300000000101800c69b7b0fc536c19a52d4bd7a91f000250000000010c60000180400021b0000120300000000101800ca9b7b0fc85fc19a81dfbd7a910401030000000010c50000180400021b0000120300000000101800c89b7b0fe74ac19a86dcbd7a91fa000e0000000010c50000180400021b0000120300000000101800d29b7b0f06b7c19afbe3bd7a91a000100000000010c50000180400021c0000120300000000101800d59b7b0ff0c5c19a6beebd7a91b400410000000010c40000180400021c0000120300000000101800d49b7b0ff4c2c19af2e9bd7a91a000310000000010c40000180400021c0000120300000000101800d39b7b0f3ebcc19a79e5bd7a9196001e0000000010c40000180400021c0000120300000000101800d69b7b0f6dc7c19ae0f5bd7a91c800570000000010c40000180400021c000012030000000016b7"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"0100020B0025003A5701C91A003A5701CD6E68490202101700CBB4740F7617FD924364104F116A0000000000010300001EC2"),
position("2018-03-21 05:38:19.000", true, 51.67569, 55.59189));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"0100020B0079000000011F6A001424951CA5CB0F23B5740F020210180023B5740F0A301994DA9C524C9128000A000000100082000011040018110300120900000003150100E803001B0700010000340900001B0700420000000000001B0700430000000000001B0700440000000000001B0700450000000000001B0700460000000000008020"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"0100020B00F200000001D66A001224951CA5CB0FFCB4740F0202101800FCB4740F502119943D9F524C9119805C000000100084000011040018110300120900000003150100E803001B0700410000000000001B0700420000000000001B0700430000000000001B0700440000000000001B0700450000000000001B0700460000000000006A001324951CA5CB0F05B5740F020210180005B5740F222519942D9E524C9100008B000000100083000011040018110300120900000003160100E803001B0700010000310900001B0700420000000000001B0700430000000000001B0700440000000000001B0700450000000000001B070046000000000000134E"));
}
diff --git a/test/org/traccar/protocol/FlespiProtocolDecoderTest.java b/test/org/traccar/protocol/FlespiProtocolDecoderTest.java
index 923deb26b..edc9f5558 100644
--- a/test/org/traccar/protocol/FlespiProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/FlespiProtocolDecoderTest.java
@@ -1,6 +1,6 @@
package org.traccar.protocol;
-import org.jboss.netty.handler.codec.http.HttpMethod;
+import io.netty.handler.codec.http.HttpMethod;
import org.junit.Test;
import org.traccar.ProtocolTest;
diff --git a/test/org/traccar/protocol/GalileoFrameDecoderTest.java b/test/org/traccar/protocol/GalileoFrameDecoderTest.java
index 7a7c97ba6..4f4972895 100644
--- a/test/org/traccar/protocol/GalileoFrameDecoderTest.java
+++ b/test/org/traccar/protocol/GalileoFrameDecoderTest.java
@@ -3,8 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
import static org.junit.Assert.assertEquals;
public class GalileoFrameDecoderTest extends ProtocolTest {
@@ -15,12 +13,12 @@ public class GalileoFrameDecoderTest extends ProtocolTest {
GalileoFrameDecoder decoder = new GalileoFrameDecoder();
assertEquals(
- binary(ByteOrder.LITTLE_ENDIAN, "011780011102e603383633353931303238393630323437043200801c"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "011780011102e603383633353931303238393630323437043200801c")));
+ binary("011780011102e603383633353931303238393630323437043200801c"),
+ decoder.decode(null, null, binary("011780011102e603383633353931303238393630323437043200801c")));
assertEquals(
- binary(ByteOrder.LITTLE_ENDIAN, "01d48304320010020520a5829f58300f50dc8a024c0965013300000000344102350740003a41e14b426610431b4459fa672a4500004601a050364c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e293000000043200100105202d829f58300f50dc8a024c0965013300000000344102350740003a41d04b426110431b445702882a4500004601a050374c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29400000004320010000520b5819f58300f50dc8a024c0965013300000000344102350740003a419e4b426a10431c4456fab72a4500004601a050434c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010ff04203d819f58300f50dc8a024c0965013300000000344102350740003a41874b426310431c4454fe572a4500004601a050334c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29600000004320010fe0420c5809f58300f50dc8a024c0965013300000000344102350840003a41a24b426710431c4457fea72a4500004601a050214c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fd04204d809f58300f50dc8a024c0965013300000000344102350840003a41a34b426310431c4455f6772a4500004601a0502e4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29900000004320010fc0420d57f9f58300f50dc8a024c0965013300000000344102350840003a41bd4b426510431d4458fe672a4500004601a0501f4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fb04205d7f9f58300f50dc8a024c0965013300000000344102350840003a41b54b426310431d4456fa772a4500004601a0502d4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010fa0420e57e9f58300f50dc8a024c0965013300000000344102350840003a41b24b426210431e4454fa872a4500004601a050fe4b510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29000000004320010f904206d7e9f58300f50dc8a024c0965013300000000344102350a40003a41af4b426710431f4458fea72a4500004601a0500a4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e28900000067c5"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "01d48304320010020520a5829f58300f50dc8a024c0965013300000000344102350740003a41e14b426610431b4459fa672a4500004601a050364c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e293000000043200100105202d829f58300f50dc8a024c0965013300000000344102350740003a41d04b426110431b445702882a4500004601a050374c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29400000004320010000520b5819f58300f50dc8a024c0965013300000000344102350740003a419e4b426a10431c4456fab72a4500004601a050434c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010ff04203d819f58300f50dc8a024c0965013300000000344102350740003a41874b426310431c4454fe572a4500004601a050334c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29600000004320010fe0420c5809f58300f50dc8a024c0965013300000000344102350840003a41a24b426710431c4457fea72a4500004601a050214c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fd04204d809f58300f50dc8a024c0965013300000000344102350840003a41a34b426310431c4455f6772a4500004601a0502e4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29900000004320010fc0420d57f9f58300f50dc8a024c0965013300000000344102350840003a41bd4b426510431d4458fe672a4500004601a0501f4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fb04205d7f9f58300f50dc8a024c0965013300000000344102350840003a41b54b426310431d4456fa772a4500004601a0502d4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010fa0420e57e9f58300f50dc8a024c0965013300000000344102350840003a41b24b426210431e4454fa872a4500004601a050fe4b510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29000000004320010f904206d7e9f58300f50dc8a024c0965013300000000344102350a40003a41af4b426710431f4458fea72a4500004601a0500a4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e28900000067c5")));
+ binary("01d48304320010020520a5829f58300f50dc8a024c0965013300000000344102350740003a41e14b426610431b4459fa672a4500004601a050364c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e293000000043200100105202d829f58300f50dc8a024c0965013300000000344102350740003a41d04b426110431b445702882a4500004601a050374c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29400000004320010000520b5819f58300f50dc8a024c0965013300000000344102350740003a419e4b426a10431c4456fab72a4500004601a050434c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010ff04203d819f58300f50dc8a024c0965013300000000344102350740003a41874b426310431c4454fe572a4500004601a050334c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29600000004320010fe0420c5809f58300f50dc8a024c0965013300000000344102350840003a41a24b426710431c4457fea72a4500004601a050214c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fd04204d809f58300f50dc8a024c0965013300000000344102350840003a41a34b426310431c4455f6772a4500004601a0502e4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29900000004320010fc0420d57f9f58300f50dc8a024c0965013300000000344102350840003a41bd4b426510431d4458fe672a4500004601a0501f4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fb04205d7f9f58300f50dc8a024c0965013300000000344102350840003a41b54b426310431d4456fa772a4500004601a0502d4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010fa0420e57e9f58300f50dc8a024c0965013300000000344102350840003a41b24b426210431e4454fa872a4500004601a050fe4b510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29000000004320010f904206d7e9f58300f50dc8a024c0965013300000000344102350a40003a41af4b426710431f4458fea72a4500004601a0500a4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e28900000067c5"),
+ decoder.decode(null, null, binary("01d48304320010020520a5829f58300f50dc8a024c0965013300000000344102350740003a41e14b426610431b4459fa672a4500004601a050364c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e293000000043200100105202d829f58300f50dc8a024c0965013300000000344102350740003a41d04b426110431b445702882a4500004601a050374c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29400000004320010000520b5819f58300f50dc8a024c0965013300000000344102350740003a419e4b426a10431c4456fab72a4500004601a050434c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010ff04203d819f58300f50dc8a024c0965013300000000344102350740003a41874b426310431c4454fe572a4500004601a050334c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29600000004320010fe0420c5809f58300f50dc8a024c0965013300000000344102350840003a41a24b426710431c4457fea72a4500004601a050214c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fd04204d809f58300f50dc8a024c0965013300000000344102350840003a41a34b426310431c4455f6772a4500004601a0502e4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29900000004320010fc0420d57f9f58300f50dc8a024c0965013300000000344102350840003a41bd4b426510431d4458fe672a4500004601a0501f4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fb04205d7f9f58300f50dc8a024c0965013300000000344102350840003a41b54b426310431d4456fa772a4500004601a0502d4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010fa0420e57e9f58300f50dc8a024c0965013300000000344102350840003a41b24b426210431e4454fa872a4500004601a050fe4b510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29000000004320010f904206d7e9f58300f50dc8a024c0965013300000000344102350a40003a41af4b426710431f4458fea72a4500004601a0500a4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e28900000067c5")));
}
diff --git a/test/org/traccar/protocol/GalileoProtocolDecoderTest.java b/test/org/traccar/protocol/GalileoProtocolDecoderTest.java
index 6f2f1f90a..d6563453a 100644
--- a/test/org/traccar/protocol/GalileoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/GalileoProtocolDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -12,25 +10,25 @@ public class GalileoProtocolDecoderTest extends ProtocolTest {
GalileoProtocolDecoder decoder = new GalileoProtocolDecoder(new GalileoProtocol());
- verifyPositions(decoder, false, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, false, binary(
"01560003383636303530303338343337353836044701e000000000e13c494e414c4c3a696e303d31313230362c696e313d302c696e323d302c696e333d302c696e343d302c696e353d302c4163633d3536363932343732353bfdef"));
- verifyPositions(decoder, false, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, false, binary(
"012a0003383633353931303233353137333732046600e000000000e1104f555428332e2e3029203d2031313130bb29"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"0144030338363832303430303132363939333404320010ee0f20f5a86c57300570172f03bc7dfd023363002604343e00351c40092a414a6842af0e432445000046030050246b51666a524c055300000338363832303430303132363939333404320010ed0f20f4a86c57300570172f03b47dfd023363000d05343e00351140090a41c56742a60e432445000046030050b56a514f6a521b045300000338363832303430303132363939333404320010ec0f20e6a86c57300b34172f03287efd023300000000344900350d40290a41562742030b43234500004603205023455190445295005300000338363832303430303132363939333404320010eb0f20e4a86c57300b34172f03287efd023300000000344900350d40290b41000042bd0b432345000046032050dc31518c315200005300000338363832303430303132363939333404320010ea0f20c7a86c57300b34172f03287efd023300000000344900350d40a90b41000042050d43234500004600205000005100005200005300000338363832303430303132363939333404320010e90f204fa86c57300b34172f03287efd023300000000344900350d40a90b41000042ff0c43244500004600205000005100005200005300000338363832303430303132363939333404320010e80f20d7a76c57300b34172f03287efd023300000000344900350d40a90b41000042fd0c43244500004600205000005100005200005300000338363832303430303132363939333404320010e70f205fa76c57300b34172f03287efd023300000000344900350d40a90b41000042fd0c43254500004600205000005100005200005300000338363832303430303132363939333404320010e60f20e7a66c57300b34172f03287efd023300000000344900350d40a90b41000042fd0c43264500004600205000005100005200005300000338363832303430303132363939333404320010e50f206fa66c57300468172f03907cfd023300007a0a343600352b40a90b41000042030d43274500004600205000005100005200005300000338363832303430303132363939333404320010e40f2051a66c5730048c172f03ac7cfd02335300980a341600352b40a12b41000042040d43274500004600e0500000510000520000530000abde"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"011380033836383230343030313534393038370432008590"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"01cf030446ba10630320a7054c533008f86c8e0310062c043347049e02344000350940013241506b428f10432244aeea572045f9004604a0500000510000529a6b5300000446ba10712420ce1c4b533009b4f06703043df4033381037b0a343800350a40093241db6b428f10432544c05ef81f45f9004604a050000051000052886b5300000446ba10702420c11c4b53300a54f16703c450f403336e034e0a343900350840093241dd6b428f1043254491eaf71f45f9004604a050000051000052c26b5300000446ba106f2420b31c4b53300cecf267033865f403336a03300a343800350740093241e66b429010432544b446582045f9004604a050000051000052f76b5300000446ba106e2420a61c4b53300c9cf467038878f403337b03370a343800350740093241b56b428f10432544ba46f81f45f9004604a050000051000052c66b5300000446ba106d2420991c4b53300bc8f56703508cf403338d036e0a343700350840093241d66b428f10432544b4ea572045f9004604a050000051000052846b5300000446ba106c24208c1c4b533008c8f5670370a0f403338703920a343a00350e40093241c76b428f10432544c0fef71f45f9004604a0500000510000528d6b5300000446ba106b24207f1c4b533009a4f5670338b4f403337603920a343c00350a40093241d06b428f104325449146a81f45f9004604a0500000510000528a6b5300000446ba106a2420721c4b53300b9cf56703ecc7f403337103810a343a00350840093241ca6b428f10432544d12e582045f9004604a050000051000052996b5300000446ba10692420651c4b53300a64f6670358dbf403337a03490a343900350840093241e56b429010432544aed2f71f45f9004604a050000051000052b26b5300000446ba10682420581c4b5330094cf86703e0eef4033381030c0a343a00350940093241f96b428f10432544cb2e182145f9004604a050000051000052926b5300000446ba106724204b1c4b533009f8fa67032802f503337b03fc09343b00350a40093241d86b428f10432544c0ea772145f9004604a0500000510000529e6b5300000446ba106624203e1c4b533009a0fd67036815f503338403fd09343c00350a40093241a86b428f10432544ae2e582045f9004604a050000051000052a86b5300000446ba10652420311c4b53300944006803b028f503338003ff09343d00350940093241dc6b428e10432544a8fea71f45f9004604a050000051000052e26b5300000446ba10642420241c4b533008f0026803083cf503338b03f909343c00350d40093241d36b428f10432544c0eaa71f45f9004604a050000051000052ab6b530000ff3f"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"011e8304320010270220dbd2f051300a90cf740328ac59033300000000347600351240012a41e92e42500f431f440006c814450f00460020500000510000520000530000540000550000560000570000580000600000610000620000a000a100a200a300a400a500a600a700a800a900aa00ab00ac00ad00ae00af00b00000b10000b20000b30000b40000b50000b60000b70000b80000b90000c000000000c100000000c200000000c300000000c400c500c600c700c800c900ca00cb00cc00cd00ce00cf00d000d100d200d471020000d60000d70000d80000d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f30000000004320010260220bdd2f051300590cf740328ac59033300000000347600351440090a41f02e427b0f431f44ff0db814450f00460000500000510000520000530000540000550000560000570000580000600000610000620000a000a100a200a300a400a500a600a700a800a900aa00ab00ac00ad00ae00af00b00000b10000b20000b30000b40000b50000b60000b70000b80000b90000c000000000c100000000c200000000c300000000c400c500c600c700c800c900ca00cb00cc00cd00ce00cf00d000d100d200d471020000d60000d70000d80000d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f300000000043200102502208ed2f051300ed8d0740304ac5903330000000034a500350a40012a41ec2e422d0f431f440016b814450f00460020500000510000520000530000540000550000560000570000580000600000610000620000a000a100a200a300a400a500a600a700a800a900aa00ab00ac00ad00ae00af00b00000b10000b20000b30000b40000b50000b60000b70000b80000b90000c000000000c100000000c200000000c300000000c400c500c600c700c800c900ca00cb00cc00cd00ce00cf00d000d100d200d44d020000d60000d70000d80000d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f300000000622e"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"01d48304320010020520a5829f58300f50dc8a024c0965013300000000344102350740003a41e14b426610431b4459fa672a4500004601a050364c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e293000000043200100105202d829f58300f50dc8a024c0965013300000000344102350740003a41d04b426110431b445702882a4500004601a050374c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29400000004320010000520b5819f58300f50dc8a024c0965013300000000344102350740003a419e4b426a10431c4456fab72a4500004601a050434c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010ff04203d819f58300f50dc8a024c0965013300000000344102350740003a41874b426310431c4454fe572a4500004601a050334c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29600000004320010fe0420c5809f58300f50dc8a024c0965013300000000344102350840003a41a24b426710431c4457fea72a4500004601a050214c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fd04204d809f58300f50dc8a024c0965013300000000344102350840003a41a34b426310431c4455f6772a4500004601a0502e4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29900000004320010fc0420d57f9f58300f50dc8a024c0965013300000000344102350840003a41bd4b426510431d4458fe672a4500004601a0501f4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29700000004320010fb04205d7f9f58300f50dc8a024c0965013300000000344102350840003a41b54b426310431d4456fa772a4500004601a0502d4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29500000004320010fa0420e57e9f58300f50dc8a024c0965013300000000344102350840003a41b24b426210431e4454fa872a4500004601a050fe4b510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e29000000004320010f904206d7e9f58300f50dc8a024c0965013300000000344102350a40003a41af4b426710431f4458fea72a4500004601a0500a4c510000520000530000c000000000c100000000c200000000c300000000d80000dd00000000e28900000067c5"));
}
diff --git a/test/org/traccar/protocol/GranitFrameDecoderTest.java b/test/org/traccar/protocol/GranitFrameDecoderTest.java
index 130b9dbd7..7c4bb06c2 100644
--- a/test/org/traccar/protocol/GranitFrameDecoderTest.java
+++ b/test/org/traccar/protocol/GranitFrameDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -16,33 +14,31 @@ public class GranitFrameDecoderTest extends ProtocolTest {
assertEquals(
binary("2b525243427e1a003e2934757c57b8b03c38d279b4e61e9bd7006b000000001c00002a4533"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "2b525243427e1a003e2934757c57b8b03c38d279b4e61e9bd7006b000000001c00002a45330d0a")));
+ decoder.decode(null, null, binary("2b525243427e1a003e2934757c57b8b03c38d279b4e61e9bd7006b000000001c00002a45330d0a")));
assertEquals(
binary("2b525243427e1a000d0a34757c57b8b03c38d279b4e61e9bd7006b000000001c00002a4533"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "2b525243427e1a000d0a34757c57b8b03c38d279b4e61e9bd7006b000000001c00002a45330d0a")));
+ decoder.decode(null, null, binary("2b525243427e1a000d0a34757c57b8b03c38d279b4e61e9bd7006b000000001c00002a45330d0a")));
assertEquals(
binary("4f4b"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "4f4b0d0a2b525243427e1a000d0a34757c57b8b03c38d279b4e61e9bd7006b000000001c00002a45330d0a")));
+ decoder.decode(null, null, binary("4f4b0d0a2b525243427e1a000d0a34757c57b8b03c38d279b4e61e9bd7006b000000001c00002a45330d0a")));
assertEquals(
binary("2b444441547e84003e290401d01690737c57b8903c383c7fa0e5081b64006b000000001c0000b8803c388e7fe7e5102197006c000000001c0000b8813c38ad7f02e6042035006c000000001d0000b8813c38bf7f13e6001d1e006c000000001d0000b8813c38bf7f13e6001d00006c000000001d0000b8903c38977f34e6091065006c000000001e000014002a3932"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN,
- "2b444441547e84003e290401d01690737c57b8903c383c7fa0e5081b64006b000000001c0000b8803c388e7fe7e5102197006c000000001c0000b8813c38ad7f02e6042035006c000000001d0000b8813c38bf7f13e6001d1e006c000000001d0000b8813c38bf7f13e6001d00006c000000001d0000b8903c38977f34e6091065006c000000001e000014002a39320d0a")));
+ decoder.decode(null, null, binary("2b444441547e84003e290401d01690737c57b8903c383c7fa0e5081b64006b000000001c0000b8803c388e7fe7e5102197006c000000001c0000b8813c38ad7f02e6042035006c000000001d0000b8813c38bf7f13e6001d1e006c000000001d0000b8813c38bf7f13e6001d00006c000000001d0000b8903c38977f34e6091065006c000000001e000014002a39320d0a")));
assertEquals(
binary("2b444441547e84003e290401d41680747c57f8a03c38987f50e6005300006c000000001c0000f8b03c38987f50e6005300006c000000001c0000fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe14002a4346"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN,
- "2b444441547e84003e290401d41680747c57f8a03c38987f50e6005300006c000000001c0000f8b03c38987f50e6005300006c000000001c0000fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe14002a43460d0a")));
+ decoder.decode(null, null, binary("2b444441547e84003e290401d41680747c57f8a03c38987f50e6005300006c000000001c0000f8b03c38987f50e6005300006c000000001c0000fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe14002a43460d0a")));
assertEquals(
binary("2b49444e543a204e6176696761746f722e30347820204669726d776172652076657273696f6e202030373132474c4e202a3231"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "2b49444e543a204e6176696761746f722e30347820204669726d776172652076657273696f6e202030373132474c4e202a32310d0a")));
+ decoder.decode(null, null, binary("2b49444e543a204e6176696761746f722e30347820204669726d776172652076657273696f6e202030373132474c4e202a32310d0a")));
assertEquals(
binary("4552524f522057524f4e4720434845434b53554d5f31"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "4552524f522057524f4e4720434845434b53554d5f310d0a")));
+ decoder.decode(null, null, binary("4552524f522057524f4e4720434845434b53554d5f310d0a")));
}
diff --git a/test/org/traccar/protocol/GranitProtocolDecoderTest.java b/test/org/traccar/protocol/GranitProtocolDecoderTest.java
index 6e85b5cfc..21f913dbe 100644
--- a/test/org/traccar/protocol/GranitProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/GranitProtocolDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -12,38 +10,38 @@ public class GranitProtocolDecoderTest extends ProtocolTest {
GranitProtocolDecoder decoder = new GranitProtocolDecoder(new GranitProtocol());
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"2b444441547e8400c500040130050c43495808002839aee3150200000000640000000000000008002839aee3150200000000640000000000000008002839aee3150200000000640000000000000008002839aee3150200000000640000000000000008002839aee3150200000000640000000000000008002839aee3150200000000640000000000000014002a37420d0a"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"2b525243427e1a00c5008443495808002839aee315020000000064000000000000002a37410d0a"),
position("2016-12-08 11:27:00.000", false, 57.00888, 40.97143));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"2b525243427e1a00c500ec904858b842283997e30002000000005e000000000d00002a32390d0a"),
position("2016-12-07 22:45:00.000", true, 57.00853, 40.97105));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"2b525243427e1a00c500009148580800283997e30002000000005f000000000000002a33410d0a"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"2b444441547e84003b6d0401b10e9217445800b051398f35d34a313b000072000000010b000080b051398f35d34a313b000072000000010b0000f0b051390f33314c303b900371000000010b0000f0b05139cd31e54c2f3cd0016f000000010b0000f0b051396831204d303d950071000000010b0000f0b051397530aa4d323c610171000000010b00000a002a30420d0a"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"2b525243427e1a003e2934757c57b8b03c38d279b4e61e9bd7006b000000001c00002a4533"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"2b444441547e84003e290401d01690737c57b8903c383c7fa0e5081b64006b000000001c0000b8803c388e7fe7e5102197006c000000001c0000b8813c38ad7f02e6042035006c000000001d0000b8813c38bf7f13e6001d1e006c000000001d0000b8813c38bf7f13e6001d00006c000000001d0000b8903c38977f34e6091065006c000000001e000014002a3932"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"2b444441547e84003e290401d41680747c57f8a03c38987f50e6005300006c000000001c0000f8b03c38987f50e6005300006c000000001c0000fefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefefe14002a4346"));
// +IDNT: Navigator.04x Firmware version 0712GLN *21
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"2b49444e543a204e6176696761746f722e30347820204669726d776172652076657273696f6e202030373132474c4e202a3231"));
// ERROR WRONG CHECKSUM_1
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"4552524f522057524f4e4720434845434b53554d5f31"));
}
diff --git a/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java b/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java
index 8748c751c..96549d865 100644
--- a/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/MeitrackProtocolDecoderTest.java
@@ -1,6 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -11,10 +10,10 @@ public class MeitrackProtocolDecoderTest extends ProtocolTest {
MeitrackProtocolDecoder decoder = new MeitrackProtocolDecoder(new MeitrackProtocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"242441313038362c3836343530373033313231393937342c4430302c3138303232343037323631345f4331453130395f4e31553144312e6a70672c31342c302cffd8ffdb008400140e0f120f0d14121012171514181e32211e1c1c1e3d2c2e243249404c4b47404645505a736250556d5645466488656d777b8182814e608d978c7d96737e817c011517171e1a1e3b21213b7c5346537c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7cffc000110801e0028003012100021101031101ffdd0004000affc401a20000010501010101010100000000000000000102030405060708090a0b100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9fa0100030101010101010101010000000000000102030405060708090a0b1100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00cca69ac8d06e3348569884db4845021b498a60371494008692980119a8ca7a5342101a5cd5221a0ab312ed1ee68b943e80dce2a467ffd0c806a48e592270f13b230e841a0096eeea7bb09e6c85b667033552800069c2980e14f15422418a916ad099228a95455089505584140993a2d5fb598a7cae72bd8fa536ae892e8e69e2b9d971168a459fffd1ece8a0028a006b534f4a68ce5b9130a89ab444919a61a6c634d34d21894952310d25002514084a4a00ffd2d2349564086929082929805250025140094940c4a4a04251400949408292819fffd3cca31591a098a5c62801a45464531098a69a6210d371400629a6980628eb400c64cd3791c1aa16c491479393563343105424fcc4d007ffd4c3463c0a94500381a5e3b8cd000c99e57f2a8f3835402834e0d4d08914d4aa6ac4c954d4aad4c4c955aa647a6496236ab51b552132e412e383d3f955b0722b09ab32a0c5a2a0d0ffd5ece8a0028a0061a6d5193dc8daa36ab422334c34c634"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"24246b3131342c3836353738393032343134303439352c4343452c0000000001005000130006011f05010607071415001b00060800000949010a0c000b9b0119a1011afe010602e934ce0203fc9aeb0004309f13220cafc503000d97741e001c01000000010e0ce8000300092f2e060000b7ff2a33330d0a"));
verifyPosition(decoder, buffer(
@@ -23,7 +22,7 @@ public class MeitrackProtocolDecoderTest extends ProtocolTest {
verifyPosition(decoder, buffer(
"$$S214,864507031219974,AAA,109,13.844643,100.644395,171207021520,A,10,28,0,31,0.8,6,390,421327,520|0|0016|000F2DB0,8400,0000|0000|0000|018D|04C6,,,108,0000,,6,0,,,,,11|171207091500|171207091500|78|3500|000000|000003*12"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"24245f3237382c3836353738393032313434373233322c4343452c5b00000003005000130006012305010608070d15001b0006080000091e010a09000b2e0019a1011af90106025c033300039be60c06044f6678210c6f1806000d48db06001c41000000010e0cf60113002005912b830001ff5000130006012305010608070d15001b0006080000091e010a09000b2e0019a0011af90106025c033300039be60c0604506678210c6f1806000d49db06001c41000000010e0cf60113002005912b830001ff5000130006012305010608070d15001b0006080000091e010a09000b2e0019a1011af90106025c033300039be60c0604516678210c6f1806000d4adb06001c41000000010e0cf60113002005912b830001ff2a37460d0a"));
verifyPosition(decoder, buffer(
@@ -99,11 +98,11 @@ public class MeitrackProtocolDecoderTest extends ProtocolTest {
verifyPosition(decoder, buffer(
"$$J163,123123123123123,AFF,0004,35,58.588926,16.180473,140928192856,A,10,27,0,161,1.2,19,1648894,435695,240|24|88B9|E435,0000,|||0A22|0000,00000001,,50,,,,,,,,,,,,,*70\r\n"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"24245838362c3336393830303031343039303032312c4343432c020134000100000023381f91ffe354b806c5e3121b0009130000000000000000d33801007cbf0200fe0101000435feeb02000500a3010000000000002a62650d0a"),
position("2014-05-24 04:59:49.000", false, -7.26650, 112.74365));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"2424473937302c3336393830303031333436303637342c4343432c020134005b000000010ce304035db9e000ec6f591a000013000000000c001801edb70200c96d0100e60001004838576501000300a101c20400000000010ce304035db9e000ee6f591a000013000000000c001801edb70200ca6d0100e60001004838576501000300a101c20400000000010ce304035db9e000ef6f591a000013000000000c001801edb70200cc6d0100e60001004838576501000300a101c20400000000020ce304035db9e000f76f591a000016000000000c001801edb70200d36d0100e60001004838576502000300a101bf04000000000a0ce304035db9e000f76f591a000016000000000c001801edb70200d46d0100e60001004838576500000300a101bf0400000000020ce304035db9e000fb6f591a000016000000000c001801edb70200d86d0100e60001004838576502000300a101760400000000180ce304035db9e000fc6f591a0000120000000000008c00edb70200d96d0100e60001004838576502000300a10176040000000019b1e2040323b9e0000b70591a0105150600bb0012002901edb70200e76d0100e60001004838576502000300a2017005000000002023e304031fb9e0001070591a010615070027010d001601fcb70200ec6d0100e60001004838576502000300a201800500000000201fe3040302b9e0001170591a010615090019010d001501feb70200ed6d0100e60001004838576502000300a2018005000000002018e30403dcb8e0001270591a0106150b0011010d00150100b80200ee6d0100e60001004838576502000300a2018005000000002036e3040345b8e0001570591a0107150b002d010b0013010ab80200f16d0100e60001004838576502000300a2018005000000002053e3040326b8e0001670591a0107150d0041010b0013010eb80200f26d0100e60001004838576502000300a2018005000000002070e3040310b8e0001770591a0107150e004f010b00130111b80200f36d0100e60001004838576502000300a2018005000000002095e3040306b8e0001870591a0107150d005a010b00140115b80200f46d0100e60001004838576502000300a20180050000000020b3e3040305b8e0001970591a0107150b0060010b00140118b80200f56d0100e60001004838576502000300a20183050000000020cfe3040308b8e0001a70591a0107150b0066010b0014011bb80200f66d0100e60001004838576502000300a20183050000000020eee304030cb8e0001b70591a0106170b0004000d0014011eb80200f76d0100e60001004838576502000300a2018305000000002a62350d0a"));
}
diff --git a/test/org/traccar/protocol/MxtProtocolDecoderTest.java b/test/org/traccar/protocol/MxtProtocolDecoderTest.java
index 014fcb287..2b0ba6755 100644
--- a/test/org/traccar/protocol/MxtProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/MxtProtocolDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -12,34 +10,34 @@ public class MxtProtocolDecoderTest extends ProtocolTest {
MxtProtocolDecoder decoder = new MxtProtocolDecoder(new MxtProtocol());
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01a631144c7e0008643ad2f456fb2d49747cfe4cbe0ffd002008800000001021000fd43d3f1403000000ff300000f42760001031102445a81fda04"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01a631361e7a00082471418b052a2c46b587ffc01ae3fd000008800000000000003345422203000000f000f00000000000ea1e04"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01a63118787d00086440628d226e2bc26a97feac8a3afd10210010308000000000000018003d2b10240000005e2f0000f427f21031feff0000593804"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01a631bd777d0008646e319e17292ce86798fed4cd3afd102110211030800000102403001f15003e2b102400000034300000f4271021007b175535a7be04"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01a631e3f97e00087cf40a98151c2cc46898fee0ce3afd1021001030c0000006102116072e003829bb00000036102100001024000000062b0000f42730004b06a6384b4304"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01a63118787d00086468457a466a2bc26a97feac8a3afd10212010308000000000001fe1053d291024000000922f0000f4271021007b17553599bb04"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01a63118787d0008648645ec486a2bc26a97feac8a3afd1021001030c0000000001419eb05372b1024000000982a0000f4271021007b17000010308c04"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01a631e3f97e00087cfa0af3151c2c126798febace3afd1021801030c0000006102122082f003e29bb00000037102100001024000000ab2f0000f42730004b060000488c04"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01a631e3f97e00087cfe0a4b161c2c126798febace3afd1021801030800000071021240731003e2abb00000038102100001024000000c12f0000f42730004b06a638633104"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"01a63118787d0008648645ec486a2bc26a97feac8a3afd1021001030c0000000001419eb05372b1024000000982a0000f4271021007b17000010308c04"));
}
diff --git a/test/org/traccar/protocol/NavigilProtocolDecoderTest.java b/test/org/traccar/protocol/NavigilProtocolDecoderTest.java
index 6c7612f61..5f4175352 100644
--- a/test/org/traccar/protocol/NavigilProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/NavigilProtocolDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -12,10 +10,10 @@ public class NavigilProtocolDecoderTest extends ProtocolTest {
NavigilProtocolDecoder decoder = new NavigilProtocolDecoder(new NavigilProtocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"01004300040020000000f60203080200e7cd0f510c0000003b00000000000000"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"0100b3000f0024000000f4a803080200ca0c1151ef8885f0b82e6d130400c00403000000"));
}
diff --git a/test/org/traccar/protocol/NavisProtocolDecoderTest.java b/test/org/traccar/protocol/NavisProtocolDecoderTest.java
index 32dd4739f..14a2e1ad3 100644
--- a/test/org/traccar/protocol/NavisProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/NavisProtocolDecoderTest.java
@@ -2,8 +2,6 @@ package org.traccar.protocol;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
import org.junit.Test;
public class NavisProtocolDecoderTest extends ProtocolTest {
@@ -13,23 +11,23 @@ public class NavisProtocolDecoderTest extends ProtocolTest {
NavisProtocolDecoder decoder = new NavisProtocolDecoder(new NavisProtocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"404E5443010000007B000000130044342A3E533A383631373835303035323035303739"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"404e5443010000000000000059009adb2a3e54250000000000ff1500040b0a1008291838001200760ee600000000000000000000000f1500040b0a10ac20703fb1aec23f00000000320149668f430000000000000000000000000000000000000000000000f3808080"),
position("2016-11-11 21:00:04.000", true, 53.74336, 87.14437));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"404e544300000000040000005a00c6812a3e410125e3a60700011705071503011030210c0000fa200910e6000000000000000000000001082106150010ae97643f88a39f3f0000000090001fcc6c450000000000000000000000000000000000000000000000f6808080"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"404e544301000000000000005a002e6c2a3e410125d7540100001512233a0b0a0f08026300000a000b000b00020000000000000000000c12233b0b0a0f03fd6d3f0fde603f00000000ba0051e0c845000000000000000000000000000000000000000000000080808080"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"404E5443010000007B0000005A0050692A3E410125DB0E00000015110707110A0C0880630000AA39A2381600020000000000000000000C110708110A0CB389793F1AEF263F00000000120034F516440000000000000000000000FAFF000000FAFF000000FAFF80808080"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"404E5443010000007B000000130047372A3E533A383631373835303035313236303639"));
}
diff --git a/test/org/traccar/protocol/NoranProtocolDecoderTest.java b/test/org/traccar/protocol/NoranProtocolDecoderTest.java
index 1132ec805..f841b7d96 100644
--- a/test/org/traccar/protocol/NoranProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/NoranProtocolDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -12,34 +10,34 @@ public class NoranProtocolDecoderTest extends ProtocolTest {
NoranProtocolDecoder decoder = new NoranProtocolDecoder(new NoranProtocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"0d0a2a4b57000d000080010d0a"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"34000800010b0000000000003f43bb8da6c2ebe229424e523039423233343439000031362d30392d31352030373a30303a303700"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"28003200c380000000469458408c4ad340ad381e3f4e52303947313336303900000001ff00002041"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"28003200c38000d900fcc97a416b1a7a42b43eef3d4e523039473034383737000000000092fcda4a"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"3400080001090000000000001D43A29BE842E62520424E523039423036363932000031322D30332D30352031313A34373A343300"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"34000800010c000000000080a3438e20944149bd07c24e523039423139323832000031352d30342d32362030383a34333a353300"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"0f0000004e52303946303431353500"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"22000800010c008a007e9daa42317bdd41a7f3e2384e523039463034313535000000"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"34000800010c0000000000001c4291251143388d17c24e523039423131303930000031342d31322d32352030303a33333a303700"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"34000800010c00000000000000006520944141bd07c24e523039423139323832000031352d30342d32352030303a30333a323200"));
}
diff --git a/test/org/traccar/protocol/OrionProtocolDecoderTest.java b/test/org/traccar/protocol/OrionProtocolDecoderTest.java
index 0d0f89af8..8568ab6ce 100644
--- a/test/org/traccar/protocol/OrionProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/OrionProtocolDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -12,19 +10,19 @@ public class OrionProtocolDecoderTest extends ProtocolTest {
OrionProtocolDecoder decoder = new OrionProtocolDecoder(new OrionProtocol());
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"5057000137bf6236235a0331b5c6e402a3b5ecff5102980003000e0c1d172936080e0c1d172936b03b01000882050000008e080000000000008c0300940500000084030085030003067600900113150000000000000000000000000000000000000004a4c8"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"5057004107367C242B440901ADE97D0163143B07B003000000000D041917382D000B0101000511000000000682050000008E080000000000008C0300840300850300090A0000000048010000008AFC"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"5057004107367C242C440901ADE97D0163143B07B003000000000D041917382D000B0101000513000000000682050000008E080000000000008C0300840300850300090A000000003BFEFFFF01FAE5"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"5057004107367C242D440901ADE97D0163143B07B003000000000D041917382D000B0101000514000000000682050000008E080000000000008C0300840300850300090A00000000FDFDFFFF023721"));
- verifyPositions(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPositions(decoder, binary(
"505700412ac86236354009114d20e402210f1f00d204000000000e06110d3414000b0101001228000000000682050000008e080000000000008c030084030085030003067b006801000930"));
}
diff --git a/test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java b/test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java
index 89b994fbe..341662255 100644
--- a/test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java
@@ -1,6 +1,6 @@
package org.traccar.protocol;
-import org.jboss.netty.handler.codec.http.HttpMethod;
+import io.netty.handler.codec.http.HttpMethod;
import org.junit.Test;
import org.traccar.ProtocolTest;
diff --git a/test/org/traccar/protocol/PiligrimProtocolDecoderTest.java b/test/org/traccar/protocol/PiligrimProtocolDecoderTest.java
index d0fbd346f..9833ea519 100644
--- a/test/org/traccar/protocol/PiligrimProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/PiligrimProtocolDecoderTest.java
@@ -1,7 +1,6 @@
package org.traccar.protocol;
-import org.jboss.netty.handler.codec.http.HttpMethod;
-
+import io.netty.handler.codec.http.HttpMethod;
import org.junit.Test;
import org.traccar.ProtocolTest;
diff --git a/test/org/traccar/protocol/ProgressProtocolDecoderTest.java b/test/org/traccar/protocol/ProgressProtocolDecoderTest.java
index deaa8645a..04d00d150 100644
--- a/test/org/traccar/protocol/ProgressProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/ProgressProtocolDecoderTest.java
@@ -3,9 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
-
public class ProgressProtocolDecoderTest extends ProtocolTest {
@Test
@@ -13,7 +10,7 @@ public class ProgressProtocolDecoderTest extends ProtocolTest {
ProgressProtocolDecoder decoder = new ProgressProtocolDecoder(new ProgressProtocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"020037000100000003003131310f003335343836383035313339303036320f00323530303136333832383531353535010000000100000000000000e6bb97b6"));
}
diff --git a/test/org/traccar/protocol/Pt502FrameDecoderTest.java b/test/org/traccar/protocol/Pt502FrameDecoderTest.java
index 6c4dd03bd..487a8500c 100644
--- a/test/org/traccar/protocol/Pt502FrameDecoderTest.java
+++ b/test/org/traccar/protocol/Pt502FrameDecoderTest.java
@@ -3,8 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
public class Pt502FrameDecoderTest extends ProtocolTest {
@Test
@@ -14,27 +12,27 @@ public class Pt502FrameDecoderTest extends ProtocolTest {
verifyFrame(
binary("24504844302c3936302cffd8ffdb008400140e0f120f0d14121012171514181e32211e1c1c1e3d2c2e243249404c4b47404645505a736250556d5645466488656d777b8182814e608d978c7d96737e817c011517171e1a1e3b21213b7c5346537c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7cffc000110800f0014003012100021101031101ffdd0004000affc401a20000010501010101010100000000000000000102030405060708090a0b100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9fa0100030101010101010101010000000000000102030405060708090a0b1100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00e5292800ef450020a2800a2801d49400b450014b40052e2800a69340094a05007fffd0e5d14b10055b51b00c76a00527273494005250014500251400525001450015347c25003a928010d25007ffd1e52909a00290d0014b40052d0014500145002e297b50018a280109a6d002d2e2803fffd2e7a04da3777a94fbd0025140052500145002514005250014940054e381400b494008690d007fffd3e4f345001486800a5a005a2800a2801680280168a002909e280100cd028016a48937bfb5007fffd4c5038a42280128a004a280128a003ad2500251400945002a8cb0a9a80133450026692803ffd5e4e8a004a2801694500145002d18a005c5140052e280109a69a0029680140abb147b139eb401ffd6c62290d00251400949400114940052500252d002525003e31c93525002521a004a4a00ffd7e4a8a00281400a29d40094b40053ba500252d0018a31400d3cd250018cd2d005ab58777ccdd074ab645007ffd0c72290d00348a2801280"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "bffbf6d10324504844302c3936302cffd8ffdb008400140e0f120f0d14121012171514181e32211e1c1c1e3d2c2e243249404c4b47404645505a736250556d5645466488656d777b8182814e608d978c7d96737e817c011517171e1a1e3b21213b7c5346537c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7cffc000110800f0014003012100021101031101ffdd0004000affc401a20000010501010101010100000000000000000102030405060708090a0b100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9fa0100030101010101010101010000000000000102030405060708090a0b1100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00e5292800ef450020a2800a2801d49400b450014b40052e2800a69340094a05007fffd0e5d14b10055b51b00c76a00527273494005250014500251400525001450015347c25003a928010d25007ffd1e52909a00290d0014b40052d0014500145002e297b50018a280109a6d002d2e2803fffd2e7a04da3777a94fbd0025140052500145002514005250014940054e381400b494008690d007fffd3e4f345001486800a5a005a2800a2801680280168a002909e280100cd028016a48937bfb5007fffd4c5038a42280128a004a280128a003ad2500251400945002a8cb0a9a80133450026692803ffd5e4e8a004a2801694500145002d18a005c5140052e280109a69a0029680140abb147b139eb401ffd6c62290d00251400949400114940052500252d002525003e31c93525002521a004a4a00ffd7e4a8a00281400a29d40094b40053ba500252d0018a31400d3cd250018cd2d005ab58777ccdd074ab645007ffd0c72290d00348a28012800d0a")));
+ decoder.decode(null, null, binary("bffbf6d10324504844302c3936302cffd8ffdb008400140e0f120f0d14121012171514181e32211e1c1c1e3d2c2e243249404c4b47404645505a736250556d5645466488656d777b8182814e608d978c7d96737e817c011517171e1a1e3b21213b7c5346537c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7cffc000110800f0014003012100021101031101ffdd0004000affc401a20000010501010101010100000000000000000102030405060708090a0b100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9fa0100030101010101010101010000000000000102030405060708090a0b1100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00e5292800ef450020a2800a2801d49400b450014b40052e2800a69340094a05007fffd0e5d14b10055b51b00c76a00527273494005250014500251400525001450015347c25003a928010d25007ffd1e52909a00290d0014b40052d0014500145002e297b50018a280109a6d002d2e2803fffd2e7a04da3777a94fbd0025140052500145002514005250014940054e381400b494008690d007fffd3e4f345001486800a5a005a2800a2801680280168a002909e280100cd028016a48937bfb5007fffd4c5038a42280128a004a280128a003ad2500251400945002a8cb0a9a80133450026692803ffd5e4e8a004a2801694500145002d18a005c5140052e280109a69a0029680140abb147b139eb401ffd6c62290d00251400949400114940052500252d002525003e31c93525002521a004a4a00ffd7e4a8a00281400a29d40094b40053ba500252d0018a31400d3cd250018cd2d005ab58777ccdd074ab645007ffd0c72290d00348a28012800d0a")));
verifyFrame(
binary("244655533836353332383032363234333836342c3531302d56312e31322c4131312d56332e30"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "bffb192d00244655533836353332383032363234333836342c3531302d56312e31322c4131312d56332e300d0d")));
+ decoder.decode(null, null, binary("bffb192d00244655533836353332383032363234333836342c3531302d56312e31322c4131312d56332e300d0d")));
verifyFrame(
binary("24504f532c313336303030303237372c3138323234312e3030302c412c303834362e303839362c4e2c30373535322e313733382c572c31332e35382c32362e38382c3239313031372c2c2c412f30303030302c30303030302f3134322c302c302c302f36323739323930302f2f6636352f2f23"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "bffb57d50124504f532c313336303030303237372c3138323234312e3030302c412c303834362e303839362c4e2c30373535322e313733382c572c31332e35382c32362e38382c3239313031372c2c2c412f30303030302c30303030302f3134322c302c302c302f36323739323930302f2f6636352f2f230a24504f532c313336303030303237372c3138323235312e3030302c412c303834362e313234382c4e2c30373535322e313534352c572c31352e35322c33362e39332c3239313031372c2c2c412f30303030302c30303030302f3134312c302c302c302f36323739333030302f2f6636382f2f230a24504f532c313336303030303237372c3138323332342e3030302c412c303834362e323633362c4e2c30373535322e303630352c572c31382e39342c32392e39302c3239313031372c2c2c412f30303030302c30303030302f3133652c302c302c302f36323739333330302f2f6639372f2f230a24504f532c313336303030303237372c3138323332362e3030302c412c303834362e323733302c4e2c30373535322e303535342c572c31392e31322c33302e34322c3239313031372c2c2c412f30303030302c30303030302f3134302c302c302c302f36323739333330302f2f6639382f2f230a")));
+ decoder.decode(null, null, binary("bffb57d50124504f532c313336303030303237372c3138323234312e3030302c412c303834362e303839362c4e2c30373535322e313733382c572c31332e35382c32362e38382c3239313031372c2c2c412f30303030302c30303030302f3134322c302c302c302f36323739323930302f2f6636352f2f230a24504f532c313336303030303237372c3138323235312e3030302c412c303834362e313234382c4e2c30373535322e313534352c572c31352e35322c33362e39332c3239313031372c2c2c412f30303030302c30303030302f3134312c302c302c302f36323739333030302f2f6636382f2f230a24504f532c313336303030303237372c3138323332342e3030302c412c303834362e323633362c4e2c30373535322e303630352c572c31382e39342c32392e39302c3239313031372c2c2c412f30303030302c30303030302f3133652c302c302c302f36323739333330302f2f6639372f2f230a24504f532c313336303030303237372c3138323332362e3030302c412c303834362e323733302c4e2c30373535322e303535342c572c31392e31322c33302e34322c3239313031372c2c2c412f30303030302c30303030302f3134302c302c302c302f36323739333330302f2f6639382f2f230a")));
verifyFrame(
binary("24504f532c3836353332383032363234333836342c3134343733352e3030302c412c313333322e373038332c4e2c3230342e363833312c452c302e302c3233302e30302c3032303531372c2c2c412f30303030302c31302f312c302f3233342f2f4646392f"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "24504f532c3836353332383032363234333836342c3134343733352e3030302c412c313333322e373038332c4e2c3230342e363833312c452c302e302c3233302e30302c3032303531372c2c2c412f30303030302c31302f312c302f3233342f2f4646392f0d0a")));
+ decoder.decode(null, null, binary("24504f532c3836353332383032363234333836342c3134343733352e3030302c412c313333322e373038332c4e2c3230342e363833312c452c302e302c3233302e30302c3032303531372c2c2c412f30303030302c31302f312c302f3233342f2f4646392f0d0a")));
verifyFrame(
binary("24504f532c3335333435313030303136342c3038323430352e3030302c412c313235342e383530312c4e2c31303035312e363735322c452c302e30302c3233372e39392c3136303531332c2c2c412f303030302c302f302f35353030302f2f6137312f"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "24504f532c3335333435313030303136342c3038323430352e3030302c412c313235342e383530312c4e2c31303035312e363735322c452c302e30302c3233372e39392c3136303531332c2c2c412f303030302c302f302f35353030302f2f6137312f0d0a")));
+ decoder.decode(null, null, binary("24504f532c3335333435313030303136342c3038323430352e3030302c412c313235342e383530312c4e2c31303035312e363735322c452c302e30302c3233372e39392c3136303531332c2c2c412f303030302c302f302f35353030302f2f6137312f0d0a")));
verifyFrame(
binary("24504f532c3335333435313030303136342c3038323430352e3030302c412c313235342e383530312c4e2c31303035312e363735322c452c302e30302c3233372e39392c3136303531332c2c2c412f303030302c302f302f35353030302f2f6137312f"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "bffb1b6a0024504f532c3335333435313030303136342c3038323430352e3030302c412c313235342e383530312c4e2c31303035312e363735322c452c302e30302c3233372e39392c3136303531332c2c2c412f303030302c302f302f35353030302f2f6137312f0d0a")));
+ decoder.decode(null, null, binary("bffb1b6a0024504f532c3335333435313030303136342c3038323430352e3030302c412c313235342e383530312c4e2c31303035312e363735322c452c302e30302c3233372e39392c3136303531332c2c2c412f303030302c302f302f35353030302f2f6137312f0d0a")));
}
diff --git a/test/org/traccar/protocol/RecodaProtocolDecoderTest.java b/test/org/traccar/protocol/RecodaProtocolDecoderTest.java
index 69adb4905..dc38935fc 100644
--- a/test/org/traccar/protocol/RecodaProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/RecodaProtocolDecoderTest.java
@@ -3,8 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
public class RecodaProtocolDecoderTest extends ProtocolTest {
@Test
@@ -12,13 +10,13 @@ public class RecodaProtocolDecoderTest extends ProtocolTest {
RecodaProtocolDecoder decoder = new RecodaProtocolDecoder(new RecodaProtocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"01100020480000000300000030393535360000000000000001000000303030303000000000000000000000000000000000000000006100004531313037353500ffffffffffff0000"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"01200020100000000300000002000000"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"0110000008000000"));
}
diff --git a/test/org/traccar/protocol/RitiProtocolDecoderTest.java b/test/org/traccar/protocol/RitiProtocolDecoderTest.java
index f7d8fea91..5a3967348 100644
--- a/test/org/traccar/protocol/RitiProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/RitiProtocolDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -12,10 +10,10 @@ public class RitiProtocolDecoderTest extends ProtocolTest {
RitiProtocolDecoder decoder = new RitiProtocolDecoder(new RitiProtocol());
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"3b28a2a2056315316d4000008100000000000000005f710000244750524d432c3138303535332e3030302c412c353532342e383437312c4e2c30313133342e313837382c452c302e30302c2c3032313231332c2c2c412a37340d0a00000000000000000000000000000000040404"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"3b2864a3056300006d40000003000000000000000000000000244750524d432c3231313734332e3030302c412c313335372e333637352c4e2c31303033362e363939322c452c302e30302c2c3031303931342c2c2c412a37380d0a00000000000000000000000000000000040404"));
}
diff --git a/test/org/traccar/protocol/RoboTrackProtocolDecoderTest.java b/test/org/traccar/protocol/RoboTrackProtocolDecoderTest.java
index bd260597f..b68379098 100644
--- a/test/org/traccar/protocol/RoboTrackProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/RoboTrackProtocolDecoderTest.java
@@ -3,8 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
public class RoboTrackProtocolDecoderTest extends ProtocolTest {
@Test
@@ -12,13 +10,13 @@ public class RoboTrackProtocolDecoderTest extends ProtocolTest {
RoboTrackProtocolDecoder decoder = new RoboTrackProtocolDecoder(new RoboTrackProtocol());
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"00524f424f545241434b00000000000000383638323034303032323533343136313233343536373839303132312e313261000000312e353761000000312e3030000000003e"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"03e020bb5a034409034862120210a9e105000000000000b9"));
- verifyPosition(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyPosition(decoder, binary(
"03f120bb5a30460903426312021798e105000000000000cd"));
}
diff --git a/test/org/traccar/protocol/SigfoxProtocolDecoderTest.java b/test/org/traccar/protocol/SigfoxProtocolDecoderTest.java
index 86ae225ee..24c60abe7 100644
--- a/test/org/traccar/protocol/SigfoxProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/SigfoxProtocolDecoderTest.java
@@ -1,6 +1,6 @@
package org.traccar.protocol;
-import org.jboss.netty.handler.codec.http.HttpMethod;
+import io.netty.handler.codec.http.HttpMethod;
import org.junit.Test;
import org.traccar.ProtocolTest;
diff --git a/test/org/traccar/protocol/SpotProtocolDecoderTest.java b/test/org/traccar/protocol/SpotProtocolDecoderTest.java
index 3d6feeca0..d893fa0e2 100644
--- a/test/org/traccar/protocol/SpotProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/SpotProtocolDecoderTest.java
@@ -1,6 +1,6 @@
package org.traccar.protocol;
-import org.jboss.netty.handler.codec.http.HttpMethod;
+import io.netty.handler.codec.http.HttpMethod;
import org.junit.Test;
import org.traccar.ProtocolTest;
diff --git a/test/org/traccar/protocol/TelicFrameDecoderTest.java b/test/org/traccar/protocol/TelicFrameDecoderTest.java
index dd0efacb6..5fcbcbb57 100644
--- a/test/org/traccar/protocol/TelicFrameDecoderTest.java
+++ b/test/org/traccar/protocol/TelicFrameDecoderTest.java
@@ -3,8 +3,6 @@ package org.traccar.protocol;
import org.junit.Test;
import org.traccar.ProtocolTest;
-import java.nio.ByteOrder;
-
public class TelicFrameDecoderTest extends ProtocolTest {
@Test
@@ -13,31 +11,31 @@ public class TelicFrameDecoderTest extends ProtocolTest {
TelicFrameDecoder decoder = new TelicFrameDecoder();
verifyFrame(
- binary(ByteOrder.LITTLE_ENDIAN, "303032363230333339337c3232367c31307c303032303034303130"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "303032363230333339337c3232367c31307c30303230303430313000")));
+ binary("303032363230333339337c3232367c31307c303032303034303130"),
+ decoder.decode(null, null, binary("303032363230333339337c3232367c31307c30303230303430313000")));
verifyFrame(
- binary(ByteOrder.LITTLE_ENDIAN, "3030333032303333393332352c3139303331373038333035322c302c3138303331373130333132372c3235393932342c3434353133332c332c302c302c392c2c2c39332c31323231303134312c2c303031302c30302c34302c3234302c302c30343036"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "630000003030333032303333393332352c3139303331373038333035322c302c3138303331373130333132372c3235393932342c3434353133332c332c302c302c392c2c2c39332c31323231303134312c2c303031302c30302c34302c3234302c302c3034303600")));
+ binary("3030333032303333393332352c3139303331373038333035322c302c3138303331373130333132372c3235393932342c3434353133332c332c302c302c392c2c2c39332c31323231303134312c2c303031302c30302c34302c3234302c302c30343036"),
+ decoder.decode(null, null, binary("630000003030333032303333393332352c3139303331373038333035322c302c3138303331373130333132372c3235393932342c3434353133332c332c302c302c392c2c2c39332c31323231303134312c2c303031302c30302c34302c3234302c302c3034303600")));
verifyFrame(
- binary(ByteOrder.LITTLE_ENDIAN, "303032363239363231385343434530315f534343457c3232367c31307c30323637"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "303032363239363231385343434530315f534343457c3232367c31307c3032363700")));
+ binary("303032363239363231385343434530315f534343457c3232367c31307c30323637"),
+ decoder.decode(null, null, binary("303032363239363231385343434530315f534343457c3232367c31307c3032363700")));
verifyFrame(
- binary(ByteOrder.LITTLE_ENDIAN, "30303434323936323138544c4f43303236372c30302c3031313030393030303239363231382c3139303331373038333033362c3235353137382c3434353037322c332c302c38322c2c2c2c3136382c31343734313239362c2c30302c30302c302c323137"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "6400000030303434323936323138544c4f43303236372c30302c3031313030393030303239363231382c3139303331373038333033362c3235353137382c3434353037322c332c302c38322c2c2c2c3136382c31343734313239362c2c30302c30302c302c32313700")));
+ binary("30303434323936323138544c4f43303236372c30302c3031313030393030303239363231382c3139303331373038333033362c3235353137382c3434353037322c332c302c38322c2c2c2c3136382c31343734313239362c2c30302c30302c302c323137"),
+ decoder.decode(null, null, binary("6400000030303434323936323138544c4f43303236372c30302c3031313030393030303239363231382c3139303331373038333033362c3235353137382c3434353037322c332c302c38322c2c2c2c3136382c31343734313239362c2c30302c30302c302c32313700")));
verifyNull(
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "00303032363937393238317c3233327c30337c30303230303430313000")));
+ decoder.decode(null, null, binary("00303032363937393238317c3233327c30337c30303230303430313000")));
verifyFrame(
- binary(ByteOrder.LITTLE_ENDIAN, "303032363937393238317c3233327c30337c303032303034303130"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "303032363937393238317c3233327c30337c30303230303430313000")));
+ binary("303032363937393238317c3233327c30337c303032303034303130"),
+ decoder.decode(null, null, binary("303032363937393238317c3233327c30337c30303230303430313000")));
verifyFrame(
- binary(ByteOrder.LITTLE_ENDIAN, "3030323039373932383139392c3231303231363038313930302c302c3231303231363038313835392c3031333839333338352c34363635383639352c332c302c302c382c2c2c3534312c36313239382c2c303030302c30302c302c3139362c302c30343037"),
- decoder.decode(null, null, binary(ByteOrder.LITTLE_ENDIAN, "650000003030323039373932383139392c3231303231363038313930302c302c3231303231363038313835392c3031333839333338352c34363635383639352c332c302c302c382c2c2c3534312c36313239382c2c303030302c30302c302c3139362c302c3034303700")));
+ binary("3030323039373932383139392c3231303231363038313930302c302c3231303231363038313835392c3031333839333338352c34363635383639352c332c302c302c382c2c2c3534312c36313239382c2c303030302c30302c302c3139362c302c30343037"),
+ decoder.decode(null, null, binary("650000003030323039373932383139392c3231303231363038313930302c302c3231303231363038313835392c3031333839333338352c34363635383639352c332c302c302c382c2c2c3534312c36313239382c2c303030302c30302c302c3139362c302c3034303700")));
}
diff --git a/test/org/traccar/protocol/Tk103FrameDecoderTest.java b/test/org/traccar/protocol/Tk103FrameDecoderTest.java
index f1169fffb..1f42e588f 100644
--- a/test/org/traccar/protocol/Tk103FrameDecoderTest.java
+++ b/test/org/traccar/protocol/Tk103FrameDecoderTest.java
@@ -1,6 +1,6 @@
package org.traccar.protocol;
-import org.jboss.netty.buffer.ChannelBuffer;
+import io.netty.buffer.ByteBuf;
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -15,7 +15,7 @@ public class Tk103FrameDecoderTest extends ProtocolTest {
binary("283836343735353535353535353535352C445733422C3133313131372C412C353536322E30323837304E2C30313334382E3038313934452C312E3539372C3232333730372C3239312E36352C2D302E31302C3429"),
decoder.decode(null, null, binary("283836343735353535353535353535352C445733422C3133313131372C412C353536322E30323837304E2C30313334382E3038313934452C312E3539372C3232333730372C3239312E36352C2D302E31302C3429283836343735353535353535353535352C5A4332302C3133313131372C3232333730362C362C3339342C36353533352C32353529")));
- ChannelBuffer buf = binary("283836343535353535353535353535352C445735422C3231302C362C353939352C34373730312C352C33303A45453A43433A45373A38363A44442A2D35392A31312C34433A36303A43433A45413A42423A45452A2D36382A312C34323A41413A44453A45413A42423A30302A2D36392A312C33323A43443A42423A43333A34463A43432A2D38362A332C31303A30303A34333A42413A32323A31352A2D38382A312C3135313131372C31363337323229283836343735353535353535353535352C5A4332302C3133313131372C3232333730362C362C3339342C36353533352C32353529");
+ ByteBuf buf = binary("283836343535353535353535353535352C445735422C3231302C362C353939352C34373730312C352C33303A45453A43433A45373A38363A44442A2D35392A31312C34433A36303A43433A45413A42423A45452A2D36382A312C34323A41413A44453A45413A42423A30302A2D36392A312C33323A43443A42423A43333A34463A43432A2D38362A332C31303A30303A34333A42413A32323A31352A2D38382A312C3135313131372C31363337323229283836343735353535353535353535352C5A4332302C3133313131372C3232333730362C362C3339342C36353533352C32353529");
verifyFrame(
binary("283836343535353535353535353535352C445735422C3231302C362C353939352C34373730312C352C33303A45453A43433A45373A38363A44442A2D35392A31312C34433A36303A43433A45413A42423A45452A2D36382A312C34323A41413A44453A45413A42423A30302A2D36392A312C33323A43443A42423A43333A34463A43432A2D38362A332C31303A30303A34333A42413A32323A31352A2D38382A312C3135313131372C31363337323229"),
diff --git a/test/org/traccar/protocol/TramigoProtocolDecoderTest.java b/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
index 3bbfcb126..198edfb53 100644
--- a/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/TramigoProtocolDecoderTest.java
@@ -1,7 +1,5 @@
package org.traccar.protocol;
-import java.nio.ByteOrder;
-
import org.junit.Test;
import org.traccar.ProtocolTest;
@@ -12,52 +10,52 @@ public class TramigoProtocolDecoderTest extends ProtocolTest {
TramigoProtocolDecoder decoder = new TramigoProtocolDecoder(new TramigoProtocol());
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"8000c426b000a6000101c557037598050d5c8a595472616d69676f3a204d6f76696e672c20302e3132206b6d2045206f66204c617275742054696e2049736c616d6963205072696d617279205363686f6f6c2c2054616970696e672c20506572616b2c204d592c20342e38333134392c203130302e37333038352c204e572077697468207370656564203130206b6d2f682c2030303a34393a30382041756720392020454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"8000c526b000a6000101f17d03759805115c8a595472616d69676f3a204d6f76696e672c20302e3133206b6d205345206f66204c617275742054696e2049736c616d6963205072696d617279205363686f6f6c2c2054616970696e672c20506572616b2c204d592c20342e38333132322c203130302e37333037382c204e4520776974682073706565642039206b6d2f682c2030303a34383a35332041756720392020454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"8000d426b0009f00010184f20375980593638a595472616d69676f3a204d6f76696e672c20302e3039206b6d204e57206f66204a616c616e2053696d70616e672042617475204d61726b65742c2054616970696e672c20506572616b2c204d592c20342e38333034332c203130302e37323230342c20532077697468207370656564203130206b6d2f682c2030313a32313a31322041756720392020454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"8000d626b0007f0001013c0b037598051d648a595472616d69676f3a2053746f707065642c206174204a616c616e2053696d70616e672042617475204d61726b65742c2054616970696e672c20506572616b2c204d592c20342e38323937322c203130302e37323233322c2030313a32323a34342041756720392020454f46"));
- verifyNull(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyNull(decoder, binary(
"80003d1ac0001c00010100000367152b13bc1d5970696e6720454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"8000d316b000860001018f8703771bee11fdf2585472616d69676f3a205061726b65642c20302e3131206b6d2053206f6620492e452e532e2050756572746120426f6e6974612c204361726162616e6368656c2c204d61647269642c2045532c2034302e33373736362c202d332e37333833352c2030353a3131204170722031362020454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"80009e08b00086000101bc1803778a59c58dea57546573742054323320547261636b65723a204d6f76696e672c20312e3639206b6d204e57206f66205574656b6f6e2c2045646f2c204e472c20362e34363137302c20352e36313938322c20452077697468207370656564203333206b6d2f682c2031363a3138205365702032372020454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"8000853eb000b8000101fcff032f14665a89e2564176656e7369732053797353657276653a2049676e6974696f6e206f6e2064657465637465642c206d6f76696e672c20302e3135206b6d205357206f66204261626120416e696d61736861756e205374726565742d426f64652054686f6d61732053742e2c20537572756c6572652c204c61676f7320436974792c204e472c20362e34383736352c20332e33343735352c2031303a3031204d6172203131202020454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"8000973eb000b90001012128032f14667794e2564176656e7369732053797353657276653a2049676e6974696f6e206f6e2064657465637465642c2073746f707065642c20302e3134206b6d205357206f66204261626120416e696d61736861756e205374726565742d426f64652054686f6d61732053742e2c20537572756c6572652c204c61676f7320436974792c204e472c20362e34383736372c20332e33343737332c2031303a3438204d6172203131202020454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"8000b73eb000ad000101fdd2032f1466c9cbe2564176656e7369732053797353657276653a2049676e6974696f6e206f6e2064657465637465642c206d6f76696e672c20302e3131206b6d2045206f6620416c68616a69204d6173686120526f616420466f6f746272696467652c20537572756c6572652c204c61676f7320436974792c204e472c20362e35303031342c20332e33353434332c2031343a3434204d6172203131202020454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"8000883eb000d3000101b223032f1466fc89e2564176656e7369732053797353657276653a2049676e6974696f6e206f66662064657465637465642c2049676e4f6e506572696f643a2030303a30323a34312c2073746f707065642c20302e3039206b6d205345206f66204a696e616475205072696d617279205363686f6f6c20416465204f6e6974696d6572696e2053742e2c20537572756c6572652c204c61676f7320436974792c204e472c20362e34383639332c20332e33343636302c2031303a3033204d6172203131202020454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"80009a3eb000d300010109ff032f1466b195e2564176656e7369732053797353657276653a2049676e6974696f6e206f66662064657465637465642c2049676e4f6e506572696f643a2030303a30353a31342c2073746f707065642c20302e3039206b6d205345206f66204a696e616475205072696d617279205363686f6f6c20416465204f6e6974696d6572696e2053742e2c20537572756c6572652c204c61676f7320436974792c204e472c20362e34383639312c20332e33343636322c2031303a3533204d6172203131202020454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"8000bc3eb000ba000101622c032f1466bacce2564176656e7369732053797353657276653a2049676e6974696f6e206f66662064657465637465642c2049676e4f6e506572696f643a2030303a30343a30302c206d6f76696e672c20617420416b6572656c6520526f61642d4f67756e6c616e612044726976652c20537572756c6572652c204c61676f7320436974792c204e472c20362e35303630332c20332e33353232382c2031343a3438204d6172203131202020454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"80001d3cb000b3000101160f032f1466b475e0564176656e7369732053797353657276653a205374617475732c204750533a203931252c2047534d3a203737252c20475052533a20436f6e6e65637465642c20626174746572793a20313030252c207265706f7274733a2049676e6974696f6e20286f6666292c205374617475732028352c322e302c3732302c3330292c20362e34393239382c20332e33343836352c2031393a3038204d6172203920454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"80005408b000af000101b23903677f00c8436d3842616c697365204f6e653a20416c6c756d616765206d61726368652064e974656374e92c20676172e92c20302e3735206b6d20452064652045636f6c65204175746f726f757465206465204b696e73686173612c2056696c6c65206465204b696e73686173612c204b696e73686173612c2043442c202d342e33343130362c2031352e33343931352c2030313a3030204a616e2031202020454f46"));
- verifyAttributes(decoder, binary(ByteOrder.LITTLE_ENDIAN,
+ verifyAttributes(decoder, binary(
"8000011bb0009e0001015b93032ef6f35994a9545472616d69676f3a204d6f76696e672c20302e3930206b6d205345206f66204372616e6562726f6f6b20466972652053746174696f6e2c2050656e726974682c205379646e65792c2041552c202d33332e37303732322c203135302e37313735392c2053452077697468207370656564203337206b6d2f682c2031393a3438204a616e20342020454f46"));
}