Skip to content

Commit

Permalink
fix: change TY_ prefix to THING_ in activator module
Browse files Browse the repository at this point in the history
  • Loading branch information
bb441db committed Jun 3, 2024
1 parent 46c3e20 commit 3aafd23
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
- feature/tuya-sdk-upgrade

jobs:
release:
Expand Down
6 changes: 5 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"branches": [
"master"
"master",
{
"name": "feature/tuya-sdk-upgrade",
"prerelease": "RC"
}
],
"plugins": [
"@semantic-release/commit-analyzer",
Expand Down
24 changes: 24 additions & 0 deletions android/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# https://developer.tuya.com/en/docs/app-development/integrated?id=Ka69nt96cw0uj#title-7-Step%205%3A%20Obfuscate%20the%20code

#fastJson
-keep class com.alibaba.fastjson.**{*;}
-dontwarn com.alibaba.fastjson.**

#mqtt
-keep class com.thingclips.smart.mqttclient.mqttv3.** { *; }
-dontwarn com.thingclips.smart.mqttclient.mqttv3.**

#OkHttp3
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**

-keep class okio.** { *; }
-dontwarn okio.**

-keep class com.thingclips.**{*;}
-dontwarn com.thingclips.**

# Matter SDK
-keep class chip.** { *; }
-dontwarn chip.**
25 changes: 25 additions & 0 deletions android/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,28 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# https://developer.tuya.com/en/docs/app-development/integrated?id=Ka69nt96cw0uj#title-7-Step%205%3A%20Obfuscate%20the%20code

#fastJson
-keep class com.alibaba.fastjson.**{*;}
-dontwarn com.alibaba.fastjson.**

#mqtt
-keep class com.thingclips.smart.mqttclient.mqttv3.** { *; }
-dontwarn com.thingclips.smart.mqttclient.mqttv3.**

#OkHttp3
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**

-keep class okio.** { *; }
-dontwarn okio.**

-keep class com.thingclips.**{*;}
-dontwarn com.thingclips.**

# Matter SDK
-keep class chip.** { *; }
-dontwarn chip.**
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,33 @@ class TuyaActivatorModule(reactContext: ReactApplicationContext) : ReactContextB

}

/**
* Maps string value to ActivatorModelEnum
* Returns null on unknown case
*/
private fun getActivatorModelEnumByString(value: String): ActivatorModelEnum? {
return when (value) {
"THING_AP" -> ActivatorModelEnum.THING_AP
"THING_EZ" -> ActivatorModelEnum.THING_EZ
"THING_4G_GATEWAY" -> ActivatorModelEnum.THING_4G_GATEWAY
"THING_QR" -> ActivatorModelEnum.THING_QR
else -> null
}
}

@ReactMethod
fun initActivator(params: ReadableMap, promise: Promise) {
if (ReactParamsCheck.checkParams(arrayOf(HOMEID, SSID, PASSWORD, TIME, TYPE), params)) {
ThingHomeSdk.getActivatorInstance().getActivatorToken(params.getDouble(HOMEID).toLong(), object : IThingActivatorGetToken {
override fun onSuccess(token: String) {
val modeValue = params.getString(TYPE) as String
val mode = getActivatorModelEnumByString(modeValue) ?: ActivatorModelEnum.THING_EZ
mITuyaActivator = ThingHomeSdk.getActivatorInstance().newActivator(
ActivatorBuilder()
.setSsid(params.getString(SSID))
.setContext(reactApplicationContext.applicationContext)
.setPassword(params.getString(PASSWORD))
.setActivatorModel(ActivatorModelEnum.valueOf(params.getString(TYPE) as String))
.setActivatorModel(mode)
.setTimeOut(params.getInt(TIME).toLong())
.setToken(token).setListener(getITuyaSmartActivatorListener(promise)))
mITuyaActivator?.start()
Expand Down
13 changes: 8 additions & 5 deletions ios/RNTuyaSdk/Activator/TuyaRNActivatorModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@ @implementation TuyaRNActivatorModule
NSString *type = params[kTuyaRNActivatorModuleActivatorMode];
// NSString *token = params[kTuyaRNActivatorModuleActivatorToken];

ThingActivatorMode mode = ThingActivatorModeEZ;
if ([type isEqualToString:@"TY_EZ"]) {
mode = ThingActivatorModeEZ;
} else if([type isEqualToString:@"TY_AP"]) {
ThingActivatorMode mode = ThingActivatorModeEZ;

if ([type isEqualToString:@"THING_AP"]) {
mode = ThingActivatorModeAP;
} else if([type isEqualToString:@"TY_QR"]) {
} else if([type isEqualToString:@"THING_EZ"]) {
mode = ThingActivatorModeEZ;
} else if([type isEqualToString:@"THING_4G_GATEWAY"]) {
mode = ThingActivatorModeAP4GGateway;
} else if([type isEqualToString:@"THING_QR"]) {
mode = ThingActivatorModeQRCode;
}

Expand Down
9 changes: 8 additions & 1 deletion src/activator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ export function openNetworkSettings() {
return tuya.openNetworkSettings({});
}

export enum ActivatorType {
AP = 'THING_AP',
EZ = 'THING_EZ',
AP_4G_GATEWAY = 'THING_4G_GATEWAY',
QR = 'THING_QR',
}

export type InitActivatorParams = {
homeId: number;
ssid: string;
password: string;
time: number;
type: 'TY_EZ' | 'TY_AP' | 'TY_QR';
type: ActivatorType;
};

export interface InitBluetoothActivatorParams {
Expand Down

0 comments on commit 3aafd23

Please sign in to comment.