Can I invert the D+ and D- in a USB OTG connection?, would it work? I know that in some protocols like PCIe you can do it, but Im not sure about usbOTG.
The device on the other end of the USB OTG connection can still be a regualar USB 2.0 device. Therefore, if you swap the D+ and D- signals, you will effectively be swapping the lines in the cable.
But just to explain here explicitly why this doesn't work, see the blurbs below from the OTG specification. Basically, devices use pull-up or pull-down resistors on specific lines to identify themselves at initial connection time. D+ and D- are therefore not identical in functionality and cannot be swapped.
5.1.6 Data Line Pull-down Resistance
When an A-device is idle or acting as Host, it shall activate pull-down resistors on both the D+ and D- lines. These resistors shall be within the range of 14.25 kΩ to 24.8 kΩ (RPD). When an A-device is acting as a Peripheral, it shall disable the pull-down on the D+ line but shall not disable the pull-down on the D- line. The A-device is allowed to disable both pull-down resistors during the interval of a packet transmission, when acting as either Host or Peripheral.
5.1.7 Data Line Pull-up Resistance
When operating as a Peripheral, the A-device shall enable a pull-up (as defined in the USB 2.0 specification) attached to the D+ line. It is allowed to disable the pull-up resistor during the interval of a packet transmission.
No, I'd say that in a generic case it wouldn't work. The end which is acting as the host would detect the other end to be a low-speed (1.5 Mbps) device and, if it supports low-speed communication at all, it will detect the other end to be a non-otg device and attempt to communicate with it at 1.5 MBps; the device end is expecting a 12 Mbps data packet or a high speed chirp and will not answer to the 1.5 Mbps enumeration attempt. And probably this is just one of many problems.