-
Notifications
You must be signed in to change notification settings - Fork 0
Home
SDK entry point is the ISwitchGo Interface
public class MainActivity extends AppCompatActivity implements McuUpdateCallback {
...
private UsbHidHelper mUsbHidHelper;
private ISwitchGo mSwitchGo;
...
public void initSwitchGo() {
mUsbHidHelper= new UsbHidHelper(this); // param is of Context type
mSwitchGo = SwitchGoImpl(mUsbHidHelper, this); // param is of McuUpdateCallback type
}
// implement onUpdateStart, onProgress, onFail, onSuccess of McuUpdateCallback
public void someOperation() {
// open all doors
switchGo.controllerAllDoors(1,1,1,1);
}
}
The application must obtain the necessary Android permissions to access the USB device of the Temi Go Pro.
class MainActivity : ComponentActivity() {
lateinit var usbHidHelper: UsbHidHelper
private lateinit var usbManager: UsbManager
private val ACTION_USB_PERMISSION = "your.package.name.USB_PERMISSION"
private lateinit var pendingIntent: PendingIntent
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
usbManager = getSystemService(Context.USB_SERVICE) as UsbManager
usbHidHelper = UsbHidHelper(this)
pendingIntent = PendingIntent.getBroadcast(this, 0, Intent(ACTION_USB_PERMISSION),PendingIntent.FLAG_IMMUTABLE)
for (device in usbManager.deviceList.values) {
val vendorId = device.vendorId
val productId = device.productId
// The Temi Go Pro USB device has the vendor ID 1155 and product ID 22352.
if (vendorId == 1155 && productId == 22352) {
if (usbManager.hasPermission(device)) {
usbHidHelper.openDevice(1155, 22352)
} else {
usbManager.requestPermission(device, pendingIntent)
}
}
}
}
...
}
In the above code snippet, a usbManager is initialized to check the connected USB devices and the permission status. If the permission is granted, usbHidHelper.openDevice(1155, 22352)
will be executed and the application can access the Temi Go Pro component. Otherwise it will request one.
Use this method to get the MCU version.
String getMcuVersion(int MCU_N)
-
Parameters
Parameter Type Description MCU_N int 1 for main MCU, 2 for salve MCU -
Return
0x30 | 0x00 | 0x00 | 0x06 | 0x81 | MCU_N | V4 | V3 | V2 | V1 | ...
A Hexadecimal String with the above format, e.g. 30 00 00 06 81 02 25 06 05 02 00 00 00 00 ...
MCU_N is 1 for the main MCU and 2 for the slave MCU. Version Number = V4<<24 + V3<<16 + V2<<8 + V1
Use this method to update the MCU firmware version.
void updateMcuVersion(int MCU_N, String filePath)
-
Parameters
Parameter Type Description MCU_N int 1 for main MCU, 2 for salve MCU filePath String Path of the firmware file
Use this method to restart the MCU.
void recoveryMcu(int MCU_N, String filePath)
-
Parameters
Parameter Type Description MCU_N int 1 for main MCU, 2 for salve MCU filePath String Path of the firmware file
Use this method to control the doors.
void controlAllDoors(int g1, int g2, int g3, int g4)
-
Parameters
Parameter Type Description g1 int Control door 1, 1 for open, 2 for close, 0 for no action g2 int Control door 2, 1 for open, 2 for close, 0 for no action g3 int Control door 3, 1 for open, 2 for close, 0 for no action g4 int Control door 4, 1 for open, 2 for close, 0 for no action
Use this method to turn on/ off the turn signal light.
void controllerTurnSignal(int left, int right)
-
Parameters
Parameter Type Description left int Control left turn signal, 1 for on, 0 for off right int Control right turn signal, 1 for on, 0 for off
Use this method to configure the ambient light.
void toggleAmbientLight(Byte mode, Byte r, Byte g, Byte b)
-
Parameters
Parameter Type Description mode Byte 0 means off, 1 means flashing, 2 means breathing, 3 means constant, and 4 means gradient mode r Byte Value of R g Byte Value of G b Byte Value of B
In gradient mode, the values of R, G, and B do not affect the color, but the R value can change the gradient speed.
Use this method to get the state of all doors and partition.
String getAllSwitchStates()
- Return
| 0x30 | 0x00 | 0x00 | 0x12 | 0x84 | G1 | G2 | G3 | G4 | G1SC | G1SO |
G2SC | G2SO | G3SC | G3SO | G4SC | G4SO | SPACE1 | SPACE3 | SPACE3 |
SOC | AUXILIARY | G1R | G2R | G3R | G4R |
A hexadecimal string with the above format.
e.g. 30 00 00 12 84 01 03 03 03 01 01 ...
G1 == 0x00 means door 1 motor is stopped.
G1 == 0x01 means door 1 motor is powered and running.
G1 == 0x03 means door 1 motor is powered but not running.
G1 == 0x04 means door1 motor is not powered but detected movement.
G1 == 0xFF means unknown state.
G2, G3, and G4 follow the same logic.
G1SO == 0x00 means the door 1 open limit switch is not triggered.
G1SO == 0x01 means the door 1 open limit switch is triggered, and the door is fully open.
G1SC == 0x00 means the door 1 close limit switch is not triggered.
G1SC == 0x01 means the door 1 close limit switch is triggered, and the door is fully closed.
G1SC and G1SO being 0xFF indicate an unknown limit switch state.
GXSC and GXSO follow the same logic.
SPACE1 == 1 means the partition is installed.
SPACE1 == 2 means the partition is not installed.
SPACE1 == 0xFF indicates an unknown partition state.
SPACE2 and SPACE3 follow the same logic.
SOC represents the battery indicator.
SOC == 0xFF indicates the module is disconnected.
AUXILIARY indicates the slave MCU connection state.
AUXILIARY == 0xFF means the slaveMCU is disconnected.
G1R == 0x80 means door 1 stops due to obstacle.
G2R, G3R and G4R follow the same logic.
Use this method to configure the battery indicator.
void setBatteryIndicator(int soc)
-
Parameters
Parameter Type Description soc int Ranges from 0-100
Use this method to turn on/ off the interior light.
void toggleInteriorLight(int sw)
-
Parameters
Parameter Type Description sw int 1 is on, 0 is off
Use this method to clear the obstruction alarm for the doors.
void clearDoorBlockAlert(int door)
-
Parameters
Parameter Type Description door int Door number
Use this method to reboot the MCU.
void rebootMcu(int MCU_N)
-
Parameters
Parameter Type Description MCU_N int 1 for main MCU, 2 for salve MCU