原生myGro服务器的HTTP请求接口
<p>[TOC]</p>
<h3>简要描述</h3>
<ul>
<li>通过原生app调用myGro服务器的HTTP请求接口</li>
</ul>
<p>> * myGro服务器即北美为<code>ces.growatt.com</code>,全球其它地区为<code>ces-eu.growatt.com</code>,暂无中国区服务器。具体选择那个服务器,原生app根据用户的使用信息自行判断选择。</p>
<ul>
<li>myGro服务器上主要的api接口为设备数据查询控制及设备更新升级,如查询设备数据<code>/imqtt/app/deviceInfo</code>, 更新相关<code>/imqtt/upgrade/findUpgradeFile</code>等。</li>
<li>myGro服务器相关api请参考便携电源api文档 <a href="http://20.6.1.98:4999/web/#/19/710">http://20.6.1.98:4999/web/#/19/710</a></li>
<li>对应的测试服务器为:ces-test.growatt.com</li>
</ul>
<h3>所属模块</h3>
<p><code>RNNetworkManager</code></p>
<h3>方法详情</h3>
<pre><code>/**
* 调用myGro服务器的HTTP请求接口
* @param {string} method - http方法,如get, post, put等服务器支持的方法
* @param {string} path - 请求的path, 以 / 开头。如接口'设备参数接口03'为: /imqtt/app/deviceInfo
* @param {JSON string} params - 如接口'设备参数接口03'为: {'sn': 'XCM0DCG00Q'}, Object需要使用:JSON.stringify()
* @returns {Promise.&lt;*&gt;}
* @Promise resolver {JSON string} - 请求成功的回调
* @Promise rejecter {string, string, error} 对应为code, message 及error - 请求失败的回调
*/
async function myGroServer(method, path, params) =&gt; {
reurn Promise
};</code></pre>
<h3>使用示例</h3>
<pre><code>
// 引入原生网络模块
const RNNetworkManager = NativeModules.RNNetworkManager;
const deviceInfo = async () =&gt; {
try {
// api 测试 设备参数接口03
const response = await RNNetworkManager.postMygroServer(
'/imqtt/app/deviceInfo',
JSON.stringify({'sn': 'XCM0DCG00Q'}),
);
console.log('====== response ====== \n');
console.log(JSON.stringify(response, null, 4));
} catch (e) {
console.log('====== error ====== \n');
console.error(e);
}
}</code></pre>
<pre><code>打印成功结果为:
[
{
&quot;time&quot;: &quot;2024-01-02 16:53:40&quot;,
&quot;rateWatt&quot;: 0,
&quot;floatChargeVolt&quot;: 564,
&quot;powerBoostEn&quot;: 480,
&quot;otaDeviceTypeCode&quot;: &quot;&quot;,
&quot;wInvHvLvType&quot;: 1,
&quot;ebmOrderNum&quot;: 0,
&quot;ledBrightnessVal&quot;: 0,
&quot;code&quot;: 1,
&quot;datalogSn&quot;: &quot;XCM0DCG00Q&quot;,
&quot;newSerial&quot;: &quot;&quot;,
&quot;ebmCarOutEn&quot;: 0,
&quot;cigarEn&quot;: 0,
&quot;invNomCap&quot;: 18,
&quot;carCaravanOutEn&quot;: 600,
&quot;fwVersion4&quot;: &quot;115.00&quot;,
&quot;ctime&quot;: 1704214420000,
&quot;status&quot;: 0,
&quot;usbEn&quot;: 0,
&quot;powerOff&quot;: 1200,
&quot;smartPvLnkgEn&quot;: 1,
&quot;outputFreqType&quot;: 0,
&quot;bypEnable&quot;: 0,
&quot;maxChargeCurr&quot;: 21,
&quot;addr&quot;: 1,
&quot;audioAlarmEn&quot;: 1,
&quot;silentChgEn&quot;: 2000,
&quot;chgSocHighLimit&quot;: 21,
&quot;screenSleepTime&quot;: 0,
&quot;chgSocLowLimit&quot;: 420,
&quot;backLightEn&quot;: 1,
&quot;dc12VStbyTime&quot;: 0,
&quot;onOff&quot;: 0,
&quot;dtc&quot;: 20502,
&quot;bulkChargeVolt&quot;: 564,
&quot;uwMaxAcChgCurr&quot;: 21,
&quot;acNoLoadStbyTime&quot;: 300,
&quot;dcMemoryAutoOn&quot;: 0,
&quot;carChgInputCurr&quot;: 4,
&quot;acMemoryAutoOn&quot;: 0,
&quot;overTempRestart&quot;: 0,
&quot;ebmUsbOutEn&quot;: 0,
&quot;fwVersion2&quot;: &quot;003.00&quot;,
&quot;outputVoltType&quot;: 1,
&quot;wattPlusEn&quot;: 1200,
&quot;buzzerEnable&quot;: 1,
&quot;usbOutEn&quot;: 0,
&quot;uwFaultResartEn&quot;: 1,
&quot;invSleepTime&quot;: 120,
&quot;modbusVersion&quot;: &quot;&quot;,
&quot;ledState&quot;: 600,
&quot;bLightLumi&quot;: 30,
&quot;usbMemoryAutoOn&quot;: 950,
&quot;uwFaultConcealEn&quot;: 1,
&quot;smartPvLnkgChgPwr&quot;: 0,
&quot;dcNoLoadStbyTime&quot;: 200,
&quot;overLoadRestart&quot;: 0,
&quot;usbStbyTime&quot;: 0,
&quot;fwVersion1&quot;: &quot;005.04&quot;,
&quot;restartFactory&quot;: 0,
&quot;maxChgWatt&quot;: 3,
&quot;uwBatCutOffVolt&quot;: 350,
&quot;fwVersion&quot;: &quot;004.00&quot;,
&quot;firmwareVersion&quot;: &quot;3.3.0.3&quot;,
&quot;id&quot;: 934,
&quot;sysTime&quot;: &quot;2024-01-02 14:53:53&quot;,
&quot;deviceSn&quot;: &quot;XCM0DCG00Q&quot;
}
]
</code></pre>
<h3>备注</h3>
<ul>
<li>更多返回错误代码请看首页的错误代码描述</li>
</ul>