Problem with LBS after adding code for WIFI

gaskoo9 months ago
else if (type == MSG_GPS_MODULAR) {

            while (buf.readableBytes() > 6) {
                int moduleType = buf.readUnsignedShort();
                int moduleLength = buf.readUnsignedShort();

                switch (moduleType) {
                    case 0x01:
                        position.set(Position.KEY_IMEI, ByteBufUtil.hexDump(buf.readSlice(8)));
                        break;
                    case 0x02:
                        position.set(Position.KEY_IMSI, ByteBufUtil.hexDump(buf.readSlice(8)));
                        break;
                    case 0x03:
                        position.set(Position.KEY_ICCID, ByteBufUtil.hexDump(buf.readSlice(10)));
                        break;
                    case 0x09:
                        position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
                        break;
                    case 0x0a:
                        position.set(Position.KEY_SATELLITES_VISIBLE, buf.readUnsignedByte());
                        break;
                    case 0x11:
                        CellTower cellTower = CellTower.from(
                                buf.readUnsignedShort(),
                                buf.readUnsignedShort(),
                                buf.readUnsignedShort(),
                                buf.readUnsignedMedium(),
                                buf.readUnsignedByte());
                        if (cellTower.getCellId() > 0) {
                            position.setNetwork(new Network(cellTower));
                        }
                        break;
                    case 0x18:
                        position.set(Position.KEY_BATTERY, buf.readUnsignedShort() * 0.01);
                        break;
                    case 0x28:
                        position.set(Position.KEY_HDOP, buf.readUnsignedByte() * 0.1);
                        break;
                    case 0x29:
                        position.set(Position.KEY_INDEX, buf.readUnsignedInt());
                        break;
                    case 0x2a:
                        int input = buf.readUnsignedByte();
                        position.set(Position.KEY_DOOR, BitUtil.to(input, 4) > 0);
                        position.set("tamper", BitUtil.from(input, 4) > 0);
                        break;
                    case 0x2b:
                        int event = buf.readUnsignedByte();
                        switch (event) {
                            case 0x11:
                                position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
                                break;
                            case 0x12:
                                position.set(Position.KEY_ALARM, Position.ALARM_LOW_POWER);
                                break;
                            case 0x13:
                                position.set(Position.KEY_ALARM, Position.ALARM_POWER_CUT);
                                break;
                            case 0x14:
                                position.set(Position.KEY_ALARM, Position.ALARM_REMOVING);
                                break;
                            default:
                                break;
                        }
                        position.set(Position.KEY_EVENT, event);
                        break;
                    case 0x2e:
                        position.set(Position.KEY_ODOMETER, buf.readUnsignedIntLE());
                        break;
                    case 0x33:
                        position.setTime(new Date(buf.readUnsignedInt() * 1000L));
                        position.set(Position.KEY_SATELLITES, buf.readUnsignedByte());
                        short rawAltitude = buf.readShort();
                        position.setAltitude((double) rawAltitude);
                        double latitude = buf.readUnsignedInt() / 1800000.0;
                        double longitude = buf.readUnsignedInt() / 1800000.0;
                        position.setSpeed(buf.readUnsignedByte());
                        int flags = buf.readUnsignedShort();
                        position.setCourse((double) (flags & 0x03FF));
                        if ((flags & 0x0400) == 0) { latitude = -latitude; }
                        if ((flags & 0x0800) != 0) { longitude = -longitude; }
                        position.setValid((flags & 0x1000) != 0);
                        position.setLatitude(latitude);
                        position.setLongitude(longitude);
                        break;
                    case 0x36:
                        // Assuming 'buf' is the ByteBuf for the message and is positioned at the start of the 0x36 message payload
                        // and 'position' is your Position object or equivalent where you want to store the Wi-Fi data

                        // First, read the Wi-Fi Hotspot Quantity (assuming it's 1 byte as per typical formats)
                        int wifiHotspotQuantity = buf.readUnsignedByte();

                        // Initialize a new Network object to store the Wi-Fi networks if not already initialized
                        Network network = new Network();

                        for (int i = 0; i < wifiHotspotQuantity; i++) {
                            // Read the MAC address (6 bytes typically)
                            byte[] macBytes = new byte[6];
                            buf.readBytes(macBytes);
                            String macAddress = String.format("%02X:%02X:%02X:%02X:%02X:%02X", macBytes[0], macBytes[1], macBytes[2], macBytes[3], macBytes[4], macBytes[5]);

                            // Read the Wi-Fi signal strength (assuming it's 1 byte)
                            int signalStrength = buf.readUnsignedByte();

                            // Create a new Wi-Fi Access Point object with the MAC address and signal strength
                            WifiAccessPoint wifiAccessPoint = new WifiAccessPoint();
                            wifiAccessPoint.setMacAddress(macAddress);
                            wifiAccessPoint.setSignalStrength(signalStrength);


                            // Add the Wi-Fi Access Point to the Network object
                            network.addWifiAccessPoint(wifiAccessPoint);
                        }

                        // Associate the Network object with the Position object
                            position.setNetwork(network);

                        // Continue processing as needed

                        break;

                    case 0x35:
                        byte gpsRealTimeStatus = buf.readByte(); // Read the GPS real-time/buffered status byte
                        switch (gpsRealTimeStatus) {
                            case 0x00:
                                position.set("gpsStatus", "Real time position");
                                break;
                            case 0x01:
                                position.set("gpsStatus", "Buffered Position");
                                break;
                            case 0x02:
                                position.set("gpsStatus", "Last valid position when currently GPS can't locate and LBS is disabled");
                                break;
                            case 0x03:
                                position.set("gpsStatus", "Last valid position when currently GPS and LBS both can't locate");
                                break;
                            case 0x04:
                                position.set("gpsStatus", "Re-upload 0x02 if upload 0x02 was failed last time");
                                break;
                            case 0x05:
                                position.set("gpsStatus", "Re-upload 0x03 if upload 0x03 was failed last time");
                                break;
                            default:
                                position.set("gpsStatus", "Unknown");
                                break;
                        }
                        break;
                    case 0x34:
                        int events = buf.readUnsignedByte();
                        switch (events) {
                            case 0x12:
                                position.set(Position.KEY_ALARM, Position.ALARM_REMOVING);
                                break;
                            case 0x13:
                                position.set(Position.KEY_ALARM, Position.ALARM_DEVICE_INSTALLED);
                                break;
                            case 0x1a:
                                position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY);
                                break;
                            case 0x1c:
                                position.set(Position.KEY_ALARM, Position.ALARM_POWER_ON);
                                break;
                            case 0x1d:
                                position.set(Position.KEY_ALARM, Position.ALARM_POWER_OFF);
                                break;
                            case 0x1e:
                                position.set(Position.KEY_ALARM, Position.ALARM_BLIND_GPS_IN);
                                break;
                            case 0x1f:
                                position.set(Position.KEY_ALARM, Position.ALARM_BLIND_GPS_OUT);
                                break;
                            case 0x20:
                                position.set(Position.KEY_ALARM, Position.ALARM_VIBRATION);
                                break;
                            case 0x22:
                                position.set(Position.KEY_ALARM, Position.ALARM_LOW_BATTERY_POWER_OFF);
                                break;
                            case 0x23:
                                position.set(Position.KEY_ALARM, Position.ALARM_COVER_REMOVING);
                                break;
                            case 0x19:
                                position.set(Position.KEY_MOTION, false);
                                break;
                            case 0x00:
                            case 0x01:
                            case 0x02:
                                position.set(Position.KEY_MOTION, true);
                                break;
                        }


                            position.set(Position.KEY_EVENT, events);
                            buf.readUnsignedIntLE(); // time
                            buf.skipBytes(buf.readUnsignedByte()); // content
                            break;
                            default:
                                buf.skipBytes(moduleLength);
                                break;
                        }
                }

                if (position.getFixTime() == null) {
                    getLastLocation(position, null);
                }

                sendResponse(channel, false, MSG_GPS_MODULAR, buf.readUnsignedShort(), null);

                return position;

After i add code 0x36 i receive mac data but don't receive data for LBS (mcc, mnc, lac, cid, rssi)

After adding code 0x36

What i do wrong?

Anton Tananaev9 months ago

There's zero context.

gaskoo9 months ago

I have a problem with SIM card after i change SIM card i get LBS. But now cant see WIFI :)))

LBS