Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi, I get error when I try to get local time offset from ISettings (/BREW/DeviceSettings/sysclock/localtime_offset/nSecs). It is described in brew dev net (https://developer.brewmp.com/resources/tech-guides/time-services-technology-guide/helper-functions) that we can get local time offset in such way: ISettings_Get( piSettings, "/BREW/DeviceSettings/sysclock/localtime_offset/nSecs", pszLocalTimeOffset, sizeof(pszLocalTimeOffset), &nSize ); But it always returns error code. I'm using HTC Freestyle F5151 phone with BMP 1.0.2.507. Simulator returns error code too. How can I get local time offset in MOD1 then?

Hi Vlad, Please use "secs" instead of "nSec" under "/BREW/DeviceSettings/sysclock/localtime_offset/secs" , I checked it using my sample MOD1 application and it worked on both HTC F5151 and simulator. Below is the sample code: 
static void GetSettings(c_basicmod1app *pMe)
{
int nErr, nRead, nSize, nSizeReq;
char *buf = NULL;

nRead= nErr = ISettings_Get(pMe->piSettings, "/BREW/DeviceSettings/sysclock/localtime_offset/secs",NULL, 0, &nSizeReq);

if (AEE_SUCCESS != nErr) {
dbg_Message("ISettings_Get failed" , DBG_MSG_LEVEL_LOW, __FILE__ , __LINE__);

nSize = nSizeReq;
nErr= IEnv_ErrMalloc(pMe->piEnv,nSize,(void**)&buf);

if (NULL == buf) {
dbg_Message("malloc failed" , DBG_MSG_LEVEL_LOW, __FILE__ , __LINE__);

nErr = ISettings_Get(pMe->piSettings, "/BREW/DeviceSettings/sysclock/localtime_offset/secs", buf, nSize, &nSizeReq);

if (AEE_SUCCESS != nErr) {
dbg_Message("ISettings_Get failed" , DBG_MSG_LEVEL_LOW, __FILE__ , __LINE__);

Please note that you have to call ISettings_Get twice, This function should be called once to determine the required amount of space to buffer the setting value. The caller should then allocate the required amount of memory and call this function again to retrieve the value. Thanks, Mahesh

Hi Vlad, Please use "secs" instead of "nSec" under "/BREW/DeviceSettings/sysclock/localtime_offset/secs" , I checked it using my sample MOD1 application and it worked on both HTC F5151 and simulator. Below is the sample code: 
static void GetSettings(c_basicmod1app *pMe)
{
int nErr, nRead, nSize, nSizeReq;
char *buf = NULL;

nRead= nErr = ISettings_Get(pMe->piSettings, "/BREW/DeviceSettings/sysclock/localtime_offset/secs",NULL, 0, &nSizeReq);

if (AEE_SUCCESS != nErr) {
dbg_Message("ISettings_Get failed" , DBG_MSG_LEVEL_LOW, __FILE__ , __LINE__);

nSize = nSizeReq;
nErr= IEnv_ErrMalloc(pMe->piEnv,nSize,(void**)&buf);

if (NULL == buf) {
dbg_Message("malloc failed" , DBG_MSG_LEVEL_LOW, __FILE__ , __LINE__);

nErr = ISettings_Get(pMe->piSettings, "/BREW/DeviceSettings/sysclock/localtime_offset/secs", buf, nSize, &nSizeReq);

if (AEE_SUCCESS != nErr) {
dbg_Message("ISettings_Get failed" , DBG_MSG_LEVEL_LOW, __FILE__ , __LINE__);

Please note that you have to call ISettings_Get twice, This function should be called once to determine the required amount of space to buffer the setting value. The caller should then allocate the required amount of memory and call this function again to retrieve the value. Thanks, Mahesh