RCU update TX power level with manufacturer info

Use high power flag at 0x780F0 to set TX power level.
For certain customer, use high power based on VID/PID.
Provide the power setting thru Hardware Revision.
    "V1.0_B35" means 7.5dBm
    "V1.0_A63" means 3.5dBm
Set the version number to 2.18

Bug: b/266562271
Bug: b/268733012
Test: Check the power output added to Hardware Revision string.
Change-Id: I04f793983cab47dd7b2be1b00d22af7639c984b1
diff --git a/8271_ble_remote/makefile b/8271_ble_remote/makefile
index ffbca9c..52d5e79 100644
--- a/8271_ble_remote/makefile
+++ b/8271_ble_remote/makefile
@@ -36,42 +36,42 @@
 
 
 # All Target
-all: GoogleRCU_8271_v2p06.elf secondary-outputs
+all: GoogleRCU_8271.elf secondary-outputs
 
 # Tool invocations
-GoogleRCU_8271_v2p06.elf: $(OBJS) $(USER_OBJS)
+GoogleRCU_8271.elf: $(OBJS) $(USER_OBJS)
 	@echo 'Building target: $@'
 	@echo 'Invoking: TC32 C Linker'
-	tc32-elf-ld --gc-sections -L"../proj_lib" -L"../application\audio" -T ../boot.link -o"GoogleRCU_8271_v2p06.elf" $(OBJS) $(USER_OBJS) $(LIBS)
+	tc32-elf-ld --gc-sections -L"../proj_lib" -L"../application\audio" -T ../boot.link -o"GoogleRCU_8271.elf" $(OBJS) $(USER_OBJS) $(LIBS)
 	@echo 'Finished building target: $@'
 	@echo ' '
 	$(MAKE) --no-print-directory post-build
 
-8271_ble_remote.lst: GoogleRCU_8271_v2p06.elf
+8271_ble_remote.lst: GoogleRCU_8271.elf
 	@echo 'Invoking: TC32 Create Extended Listing'
-	tc32-elf-objdump -x -D -l -S GoogleRCU_8271_v2p06.elf  >"8271_ble_remote.lst"
+	tc32-elf-objdump -x -D -l -S GoogleRCU_8271.elf  >"8271_ble_remote.lst"
 	@echo 'Finished building: $@'
 	@echo ' '
 
-: GoogleRCU_8271_v2p06.elf
+: GoogleRCU_8271.elf
 	@echo 'Create Flash image (binary format)'
-	tc32-elf-objcopy -O binary GoogleRCU_8271_v2p06.elf
+	tc32-elf-objcopy -O binary GoogleRCU_8271.elf
 	@echo 'Finished building: $@'
 	@echo ' '
 
-sizedummy: GoogleRCU_8271_v2p06.elf
+sizedummy: GoogleRCU_8271.elf
 	@echo 'Invoking: Print Size'
-	tc32-elf-size -t GoogleRCU_8271_v2p06.elf
+	tc32-elf-size -t GoogleRCU_8271.elf
 	@echo 'Finished building: $@'
 	@echo ' '
 
 # Other Targets
 clean:
-	-$(RM) $(FLASH_IMAGE)$(ELFS)$(OBJS)$(LST)$(SIZEDUMMY) GoogleRCU_8271_v2p06.elf
+	-$(RM) $(FLASH_IMAGE)$(ELFS)$(OBJS)$(LST)$(SIZEDUMMY) GoogleRCU_8271.elf
 	-@echo ' '
 
 post-build:
-	-"../tl_check_fw.sh"   8271_ble_remote   GoogleRCU_8271_v2p06
+	-"../tl_check_fw.sh"   8271_ble_remote   GoogleRCU_8271
 	-@echo ' '
 
 secondary-outputs: $(LST) $(FLASH_IMAGE) $(SIZEDUMMY)
diff --git a/vendor/827x_ble_remote/app.c b/vendor/827x_ble_remote/app.c
index dfa6fdd..21859cc 100644
--- a/vendor/827x_ble_remote/app.c
+++ b/vendor/827x_ble_remote/app.c
@@ -66,7 +66,8 @@
 #define     MY_ADV_INTERVAL_MAX                 ADV_INTERVAL_25MS
 
 #if (MCU_CORE_TYPE == MCU_CORE_8278)
-    #define        MY_RF_POWER_INDEX            RF_POWER_P7p37dBm
+    #define        MY_RF_POWER_INDEX            RF_POWER_P3p50dBm
+
 #else
     #define        MY_RF_POWER_INDEX            RF_POWER_P3p01dBm
 #endif
@@ -147,6 +148,10 @@
 _attribute_data_retention_  u8  detpowerkey=0;              //0:not det powerkey  1:det powerkey
 
 
+_attribute_data_retention_ u8 app_rcu_tx_power = RF_POWER_P3p50dBm;
+
+
+
 u8  mac_public[6];
 
 extern u8 is_pairing_mode;
@@ -173,6 +178,79 @@
 }
 #endif
 
+void app_rcu_set_TxPower(u8 Index){
+
+    switch (Index) {
+        case RF_POWER_P11p26dBm :
+        case RF_POWER_P11p09dBm :
+        case RF_POWER_P10p83dBm :
+        case RF_POWER_P10p62dBm :
+        case RF_POWER_P10p30dBm :
+        case RF_POWER_P10p05dBm :
+        case RF_POWER_P9p79dBm :
+        case RF_POWER_P9p54dBm :
+        case RF_POWER_P9p23dBm :
+        case RF_POWER_P8p92dBm :
+        case RF_POWER_P8p57dBm :
+        case RF_POWER_P8p20dBm :
+        case RF_POWER_P7p80dBm :
+        case RF_POWER_P7p37dBm :
+        case RF_POWER_P6p91dBm :
+        case RF_POWER_P6p45dBm :
+        case RF_POWER_P5p92dBm :
+        case RF_POWER_P5p33dBm :
+        case RF_POWER_P4p69dBm :
+        case RF_POWER_P3p99dBm :
+        case RF_POWER_P3p50dBm :
+        case RF_POWER_P3p33dBm :
+        case RF_POWER_P3p13dBm :
+        case RF_POWER_P2p93dBm :
+        case RF_POWER_P2p60dBm :
+        case RF_POWER_P2p36dBm :
+        case RF_POWER_P2p10dBm :
+        case RF_POWER_P1p83dBm :
+        case RF_POWER_P1p56dBm :
+        case RF_POWER_P1p25dBm :
+        case RF_POWER_P0p71dBm :
+        case RF_POWER_P0p52dBm :
+        case RF_POWER_N0p28dBm :
+        case RF_POWER_N0p51dBm :
+        case RF_POWER_N0p74dBm :
+        case RF_POWER_N1p21dBm :
+        case RF_POWER_N1p69dBm :
+        case RF_POWER_N2p23dBm :
+        case RF_POWER_N2p84dBm :
+        case RF_POWER_N3p48dBm :
+        case RF_POWER_N4p18dBm :
+        case RF_POWER_N4p97dBm :
+        case RF_POWER_N5p85dBm :
+        case RF_POWER_N6p83dBm :
+        case RF_POWER_N7p88dBm :
+        case RF_POWER_N9p14dBm :
+        case RF_POWER_N10p70dBm :
+        case RF_POWER_N12p57dBm :
+        case RF_POWER_N15p01dBm :
+        case RF_POWER_N18p40dBm :
+        case RF_POWER_N24p28dBm :
+            app_rcu_tx_power = Index;
+            break;
+        default:
+            app_rcu_tx_power = RF_POWER_P3p50dBm;
+            break;
+    }
+
+
+    /* set TX power index to hardware revision */
+    extern u8 my_HWRevtrs [];
+    my_HWRevtrs[5] = (app_rcu_tx_power&BIT(7))?'A':'B';
+    my_HWRevtrs[6] = (app_rcu_tx_power&0x3F)/10 + '0';
+    my_HWRevtrs[7] = (app_rcu_tx_power&0x3F)%10 + '0';
+
+    printf("[NOTICE] Set TX power[%c%c%c]\n",my_HWRevtrs[5],my_HWRevtrs[6],my_HWRevtrs[7]);
+
+}
+
+
 void app_enter_deep_timeset(void)
 {
     enterdeep_time = ADV_IDLE_ENTER_DEEP_COUNT;
@@ -646,7 +724,7 @@
         rf_set_power_level_index(RF_POWER_P7p37dBm);
     else
 #endif
-    rf_set_power_level_index (MY_RF_POWER_INDEX);
+    rf_set_power_level_index (app_rcu_tx_power);
 }
 
 
diff --git a/vendor/827x_ble_remote/app_att.c b/vendor/827x_ble_remote/app_att.c
index 2f0efce..ecbce78 100644
--- a/vendor/827x_ble_remote/app_att.c
+++ b/vendor/827x_ble_remote/app_att.c
@@ -104,7 +104,9 @@
 
  _attribute_data_retention_ u8 my_FWRevtrs []     = {'V','1','.','1','1'};
  _attribute_data_retention_ u8 my_SWRevtrs []     = {'V','1','.','0','2'};
- static const u8 my_HWRevtrs []     = {'V','1','.','0'};
+// static const u8 my_HWRevtrs []     = {'V','1','.','0'};
+ _attribute_data_retention_ u8 my_HWRevtrs []     = {'V','1','.','0','_','A','6','3'};
+
  static const u8 my_ManuNametrs []  = {'T','e','l','i','n','k'};
 
 //////////////////////// Battery /////////////////////////////////////////////////
diff --git a/vendor/827x_ble_remote/app_custom.c b/vendor/827x_ble_remote/app_custom.c
index 5b5d3a0..19063ca 100644
--- a/vendor/827x_ble_remote/app_custom.c
+++ b/vendor/827x_ble_remote/app_custom.c
@@ -54,6 +54,13 @@
 }app_custom_data_update_sts;
 
 
+typedef struct{
+    u8 vid_src;
+    u16 vid;
+    u16 pid;
+    u16 prod_ver;
+}app_pnpid_format_t;
+
 #define APP_CUSTOM_CMD_DATA_UPDATE_PREPARE      0xED00
 #define APP_CUSTOM_CMD_DATA_UPDATE_START        0xED01
 #define APP_CUSTOM_CMD_DATA_UPDATE_END          0xED02
@@ -604,15 +611,6 @@
  */
 void app_custom_init(void)
 {
-    /* 2.17 only
-     * Special version, if the address APP_TX_POWER is 0xff, write 0x23 (TX power7.37dBm) */
-    u8 my_TxPoewr = 0x00;
-    flash_read_page(APP_TX_POWER_ADDR, 1 , &my_TxPoewr);
-    if(0xff == my_TxPoewr){
-        my_TxPoewr = RF_POWER_P7p37dBm;
-        flash_write_page(APP_TX_POWER_ADDR, 1 , &my_TxPoewr);
-    }
-
     u8 buffer[80];
     u8 addr_pos=0,i;
     u8 *pREMOTE_B046 = (u8 *)("RemoteB046");
@@ -678,6 +676,26 @@
     my_FWRevtrs[4] = (_custom_data.device_ui_layout) + 0x30;
     app_custom_wakeup_key_load(_custom_data.wakeup_key_1,_custom_data.wakeup_key_2);
     app_custom_param_init(_custom_data.device_ui_layout);
+
+
+    /* 230214 by ken. read TX power settings */
+    extern void app_rcu_set_TxPower(u8 Index);
+
+    app_pnpid_format_t *p_my_pnpid = (app_pnpid_format_t *)_custom_data.pnp_id;
+
+    if((0x01 == p_my_pnpid->vid_src) && (0x0957 == p_my_pnpid->vid) && (0x0005 == p_my_pnpid->pid)){
+        /* Customized settings for special customers */
+        app_rcu_set_TxPower(RF_POWER_P7p37dBm);
+    }else{
+        u8 my_TxPoewr = 0x00;
+        flash_read_page(APP_TX_POWER_ADDR, 1 , &my_TxPoewr);
+        if(0xff != my_TxPoewr){
+            app_rcu_set_TxPower(my_TxPoewr);
+        }
+    }
+
+
+
 }
 
 /**
diff --git a/version.h b/version.h
index d032d13..2910c30 100644
--- a/version.h
+++ b/version.h
@@ -27,6 +27,6 @@
 #ifndef VERSION_H_
 #define VERSION_H_
 
-#define FW_VERSION                  0x34210217//FW:v3.4.2  SW:v2.17
+#define FW_VERSION                  0x34210218//FW:v3.4.2  SW:v2.18
 
 #endif /* VERSION_H_ */