本文整理汇总了C++中M2M_ERR函数的典型用法代码示例。如果您正苦于以下问题:C++ M2M_ERR函数的具体用法?C++ M2M_ERR怎么用?C++ M2M_ERR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了M2M_ERR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m2m_wifi_request_scan_ssid
sint8 m2m_wifi_request_scan_ssid(uint8 ch,char* pcssid)
{
sint8 s8Ret = M2M_ERR_SCAN_IN_PROGRESS;
if(!gu8scanInProgress)
{
tstrM2MScan strtmp;
m2m_memset((uint8*)&strtmp,0,sizeof(tstrM2MScan));
strtmp.u8ChNum = ch;
if(pcssid)
{
uint8 len = m2m_strlen((uint8 *)pcssid);
m2m_memcpy(strtmp.au8SSID,(uint8 *)pcssid,len+1);
}
s8Ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SCAN, (uint8*)&strtmp, sizeof(tstrM2MScan),NULL, 0,0);
if(s8Ret == M2M_SUCCESS)
{
gu8scanInProgress = 1;
}
else
{
M2M_ERR("SCAN Failed Ret = %d\n",s8Ret);
}
}
else
{
M2M_ERR("SCAN In Progress\n");
}
return s8Ret;
}
示例2: m2m_validate_scan_options
static sint8 m2m_validate_scan_options(tstrM2MScanOption* ptstrM2MScanOption)
{
sint8 s8Ret = M2M_SUCCESS;
/* Check for incoming pointer */
if(ptstrM2MScanOption == NULL)
{
M2M_ERR("INVALID POINTER\n");
s8Ret = M2M_ERR_FAIL;
}
/* Check for valid No of slots */
if(ptstrM2MScanOption->u8NumOfSlot < 1)
{
M2M_ERR("INVALID No of scan slots!\n");
s8Ret = M2M_ERR_FAIL;
}
/* Check for valid time of slots */
if(ptstrM2MScanOption->u8SlotTime < 1)
{
M2M_ERR("INVALID scan slot time!\n");
s8Ret = M2M_ERR_FAIL;
}
/* Check for valid No of probe requests per slot */
if((ptstrM2MScanOption->u8ProbesPerSlot < 0)||(ptstrM2MScanOption->u8ProbesPerSlot > M2M_SCAN_DEFAULT_NUM_PROBE))
{
M2M_ERR("INVALID No of probe requests per scan slot\n");
s8Ret = M2M_ERR_FAIL;
}
/* Check for valid RSSI threshold */
if((ptstrM2MScanOption->s8RssiThresh < -99) || (ptstrM2MScanOption->s8RssiThresh >= 0))
{
M2M_ERR("INVALID RSSI threshold %d \n",ptstrM2MScanOption->s8RssiThresh);
s8Ret = M2M_ERR_FAIL;
}
return s8Ret;
}
示例3: nm_drv_deinit
/*
* @fn nm_drv_deinit
* @brief Deinitialize NMC1000 driver
* @author M. Abdelmawla
* @date 17 July 2012
* @version 1.0
*/
sint8 nm_drv_deinit(void * arg)
{
(void)arg; // Silence "unused" warning
sint8 ret;
ret = chip_deinit();
if (M2M_SUCCESS != ret) {
M2M_ERR("[nmi stop]: chip_deinit fail\n");
goto ERR1;
}
ret = nm_bus_iface_deinit();
if (M2M_SUCCESS != ret) {
M2M_ERR("[nmi stop]: fail init bus\n");
goto ERR1;
}
#ifdef CONF_WINC_USE_SPI
/* Must do this after global reset to set SPI data packet size. */
nm_spi_deinit();
#endif
ERR1:
return ret;
}
示例4: m2m_wifi_request_scan
sint8 m2m_wifi_request_scan(uint8 ch)
{
sint8 s8Ret = M2M_ERR_SCAN_IN_PROGRESS;
if(!gu8scanInProgress)
{
tstrM2MScan strtmp;
strtmp.u8ChNum = ch;
s8Ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SCAN, (uint8*)&strtmp, sizeof(tstrM2MScan),NULL, 0,0);
if(s8Ret == M2M_SUCCESS)
{
gu8scanInProgress = 1;
}
else
{
M2M_ERR("SCAN Failed Ret = %d\n",s8Ret);
}
}
else
{
M2M_ERR("SCAN In Progress\n");
}
return s8Ret;
}
示例5: sslSetSockOpt
/*********************************************************************
Function
setsockopt
Description
Return
None.
Author
Abdelrahman Diab
Version
1.0
Date
9 September 2014
*********************************************************************/
sint8 sslSetSockOpt(SOCKET sock, uint8 u8Opt, const void *pvOptVal, uint16 u16OptLen)
{
sint8 s8Ret = SOCK_ERR_INVALID_ARG;
if(sock < TCP_SOCK_MAX)
{
if(gastrSockets[sock].u8SSLFlags & SSL_FLAGS_ACTIVE)
{
if(u8Opt == SO_SSL_BYPASS_X509_VERIF)
{
int optVal = *((int*)pvOptVal);
if(optVal)
{
gastrSockets[sock].u8SSLFlags |= SSL_FLAGS_BYPASS_X509;
}
else
{
gastrSockets[sock].u8SSLFlags &= ~SSL_FLAGS_BYPASS_X509;
}
s8Ret = SOCK_ERR_NO_ERROR;
}
else if(u8Opt == SO_SSL_SNI)
{
if(u16OptLen < HOSTNAME_MAX_SIZE)
{
uint8 *pu8SNI = (uint8*)pvOptVal;
tstrSSLSetSockOptCmd strCmd;
strCmd.sock = sock;
strCmd.u16SessionID = gastrSockets[sock].u16SessionID;
strCmd.u8Option = u8Opt;
strCmd.u32OptLen = u16OptLen;
m2m_memcpy(strCmd.au8OptVal, pu8SNI, HOSTNAME_MAX_SIZE);
if(SOCKET_REQUEST(SOCKET_CMD_SSL_SET_SOCK_OPT, (uint8*)&strCmd, sizeof(tstrSSLSetSockOptCmd),
0, 0, 0) == M2M_ERR_MEM_ALLOC)
{
s8Ret = SOCKET_REQUEST(SOCKET_CMD_SSL_SET_SOCK_OPT | M2M_REQ_DATA_PKT,
(uint8*)&strCmd, sizeof(tstrSSLSetSockOptCmd), 0, 0, 0);
}
s8Ret = SOCK_ERR_NO_ERROR;
}
else
{
M2M_ERR("SNI Exceeds Max Length\n");
}
}
else
{
M2M_ERR("Unknown SSL Socket Option %d\n",u8Opt);
}
}
else
{
M2M_ERR("Not SSL Socket\n");
}
}
return s8Ret;
}
示例6: nm_uart_reconfigure
/**
* @fn nm_uart_reconfigure
* @brief Reconfigures the UART interface
* @param [in] ptr
* Pointer to a DWORD containing baudrate at this moment.
* @return M2M_SUCCESS in case of success and M2M_ERR_BUS_FAIL in case of failure
* @author Viswanathan Murugesan
* @date 22 OCT 2014
* @version 1.0
*/
sint8 nm_uart_reconfigure(void *ptr)
{
tstrNmUartDefault strUart;
sint8 s8Ret = M2M_SUCCESS;
uint8 b[HDR_SZ+1];
/*write reg*/
b[0] = 0xa5;
b[1] = 5;
b[2] = 0;
b[3] = 0;
b[4] = 0;
b[5] = 0;
b[6] = 0;
b[7] = 0;
b[8] = 0;
b[9] = (uint8)((*(unsigned long *)ptr) & 0x000000ff);
b[10] = (uint8)(((*(unsigned long *)ptr) & 0x0000ff00)>>8);
b[11] = (uint8)(((*(unsigned long *)ptr) & 0x00ff0000)>>16);
b[12] = (uint8)(((*(unsigned long *)ptr) & 0xff000000)>>24);
b[2] = get_cs(&b[1],HDR_SZ);
get_cs(&b[1],HDR_SZ);
strUart.pu8Buf = b;
strUart.u16Sz = sizeof(b);
if(M2M_SUCCESS != nm_bus_ioctl(NM_BUS_IOCTL_W, &strUart))
{
M2M_ERR("write error\n");
s8Ret = M2M_ERR_BUS_FAIL;
}
else
{
if(!nm_bus_get_chip_type())
{
//check for the ack from the SAMD21 for the packet reception.
strUart.u16Sz = 1;
if(M2M_SUCCESS != nm_bus_ioctl(NM_BUS_IOCTL_R, &strUart))
{
s8Ret = M2M_ERR_BUS_FAIL;
}
if(b[0] == 0xAC)
{
M2M_DBG("Successfully sent the UART reconfigure command\n");
}
else
{
M2M_ERR("write error\n");
s8Ret = M2M_ERR_BUS_FAIL;
}
}
}
return s8Ret;
}
示例7: m2m_ota_test
NMI_API sint8 m2m_ota_test(void)
{
uint32 page = 0;
uint8 buffer[1500];
uint32 u32Sz = 0;
sint8 ret = M2M_SUCCESS;
FILE *fp =NULL;
fp = fopen(M2M_OTA_FILE,"rb");
if(fp)
{
fseek(fp, 0L, SEEK_END);
u32Sz = ftell(fp);
fseek(fp, 0L, SEEK_SET);
while(u32Sz > 0)
{
{
page = (rand()%1400);
if((page<100)||(page>1400)) page = 1400;
}
if(u32Sz>page)
{
u32Sz-=page;
}
else
{
page = u32Sz;
u32Sz = 0;
}
printf("page %d\n", (int)page);
fread(buffer,page,1,fp);
ret = hif_send(M2M_REQ_GROUP_OTA,M2M_OTA_REQ_TEST|M2M_REQ_DATA_PKT,NULL,0,(uint8*)&buffer,page,0);
if(ret != M2M_SUCCESS)
{
M2M_ERR("\n");
}
nm_bsp_sleep(1);
}
}
else
{
M2M_ERR("nO err\n");
}
return ret;
}
示例8: nm_i2c_write_block
/*
* @fn nm_i2c_write_block
* @brief Write block of data
* @param [in] u32Addr
* Start address
* @param [in] puBuf
* Pointer to the buffer holding the data to be written
* @param [in] u16Sz
* Number of bytes to write. The buffer size must be >= u16Sz
* @return M2M_SUCCESS in case of success and M2M_ERR_BUS_FAIL in case of failure
* @author M. Abdelmawla
* @date 11 July 2012
* @version 1.0
*/
sint8 nm_i2c_write_block(uint32 u32Addr, uint8 *pu8Buf, uint16 u16Sz)
{
uint8 au8Buf[7];
tstrNmI2cSpecial strI2c;
sint8 s8Ret = M2M_SUCCESS;
au8Buf[0] = 0x12;
au8Buf[1] = (uint8)(u32Addr >> 24);
au8Buf[2] = (uint8)(u32Addr >> 16);
au8Buf[3] = (uint8)(u32Addr >> 8);
au8Buf[4] = (uint8)(u32Addr);
au8Buf[5] = (uint8)(u16Sz >> 8);
au8Buf[6] = (uint8)(u16Sz);
strI2c.pu8Buf1 = au8Buf;
strI2c.pu8Buf2 = pu8Buf;
strI2c.u16Sz1 = sizeof(au8Buf);
strI2c.u16Sz2 = u16Sz;
if(M2M_SUCCESS != nm_bus_ioctl(NM_BUS_IOCTL_W_SPECIAL, &strI2c))
{
M2M_ERR("write error\n");
s8Ret = M2M_ERR_BUS_FAIL;
}
return s8Ret;
}
示例9: chip_reset_and_cpu_halt
sint8 chip_reset_and_cpu_halt(void)
{
sint8 ret = M2M_SUCCESS;
uint32 reg = 0;
ret = chip_wake();
if(ret != M2M_SUCCESS) {
return ret;
}
chip_reset();
ret = nm_read_reg_with_ret(0x1118, ®);
if (M2M_SUCCESS != ret) {
ret = M2M_ERR_BUS_FAIL;
M2M_ERR("[nmi start]: fail read reg 0x1118 ...\n");
}
reg |= (1 << 0);
ret = nm_write_reg(0x1118, reg);
ret += nm_read_reg_with_ret(NMI_GLB_RESET_0, ®);
if ((reg & (1ul << 10)) == (1ul << 10)) {
reg &= ~(1ul << 10);
ret += nm_write_reg(NMI_GLB_RESET_0, reg);
ret += nm_read_reg_with_ret(NMI_GLB_RESET_0, ®);
}
#if 0
reg |= (1ul << 10);
ret += nm_write_reg(NMI_GLB_RESET_0, reg);
ret += nm_read_reg_with_ret(NMI_GLB_RESET_0, ®);
#endif
nm_write_reg(BOOTROM_REG,0);
nm_write_reg(NMI_STATE_REG,0);
nm_write_reg(NMI_REV_REG,0);
nm_write_reg(NMI_PIN_MUX_0, 0x11111000);
return ret;
}
示例10: m2m_wifi_start_provision_mode
sint8 m2m_wifi_start_provision_mode(tstrM2MAPConfig *pstrAPConfig, char *pcHttpServerDomainName, uint8 bEnableHttpRedirect)
{
sint8 s8Ret = M2M_ERR_FAIL;
if((pstrAPConfig != NULL))
{
tstrM2MProvisionModeConfig strProvConfig;
if(M2M_SUCCESS == m2m_validate_ap_parameters(pstrAPConfig))
{
m2m_memcpy((uint8*)&strProvConfig.strApConfig, (uint8*)pstrAPConfig, sizeof(tstrM2MAPConfig));
if((m2m_strlen((uint8 *)pcHttpServerDomainName) <= 0) || (NULL == pcHttpServerDomainName))
{
M2M_ERR("INVALID DOMAIN NAME\n");
goto ERR1;
}
m2m_memcpy((uint8*)strProvConfig.acHttpServerDomainName, (uint8*)pcHttpServerDomainName, 64);
strProvConfig.u8EnableRedirect = bEnableHttpRedirect;
/* Stop Scan if it is ongoing.
*/
gu8scanInProgress = 0;
s8Ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_START_PROVISION_MODE | M2M_REQ_DATA_PKT,
(uint8*)&strProvConfig, sizeof(tstrM2MProvisionModeConfig), NULL, 0, 0);
}
else
{
/*goto ERR1;*/
}
}
ERR1:
return s8Ret;
}
示例11: nm_i2c_write_reg
/*
* @fn nm_i2c_write_reg
* @brief write register
* @param [in] u32Addr
* Register address
* @param [in] u32Val
* Value to be written to the register
* @return M2M_SUCCESS in case of success and M2M_ERR_BUS_FAIL in case of failure
* @author M. Abdelmawla
* @date 11 July 2012
* @version 1.0
*/
sint8 nm_i2c_write_reg(uint32 u32Addr, uint32 u32Val)
{
tstrNmI2cDefault strI2c;
uint8 b[16];
sint8 s8Ret = M2M_SUCCESS;
if(u32Addr < 0xff) { /* clockless i2c */
b[0] = 0x19;
b[1] = (uint8)(u32Addr);
b[2] = (uint8)(u32Val);
strI2c.u16Sz = 3;
} else {
b[0] = 0x90;
b[1] = (uint8)(u32Addr >> 24);
b[2] = (uint8)(u32Addr >> 16);
b[3] = (uint8)(u32Addr >> 8);
b[4] = (uint8)u32Addr;
b[5] = 0x04;
b[6] = (uint8)u32Val;
b[7] = (uint8)(u32Val >> 8);
b[8] = (uint8)(u32Val >> 16);
b[9] = (uint8)(u32Val >> 24);
strI2c.u16Sz = 10;
}
strI2c.pu8Buf = b;
if(M2M_SUCCESS != nm_bus_ioctl(NM_BUS_IOCTL_W, &strI2c))
{
M2M_ERR("write error\n");
s8Ret = M2M_ERR_BUS_FAIL;
}
return s8Ret;
}
示例12: cpu_start
sint8 cpu_start(void) {
uint32 reg;
sint8 ret;
/**
reset regs
*/
nm_write_reg(BOOTROM_REG,0);
nm_write_reg(NMI_STATE_REG,0);
nm_write_reg(NMI_REV_REG,0);
/**
Go...
**/
ret = nm_read_reg_with_ret(0x1118, ®);
if (M2M_SUCCESS != ret) {
ret = M2M_ERR_BUS_FAIL;
M2M_ERR("[nmi start]: fail read reg 0x1118 ...\n");
}
reg |= (1 << 0);
ret = nm_write_reg(0x1118, reg);
ret = nm_write_reg(0x150014, 0x1);
ret += nm_read_reg_with_ret(NMI_GLB_RESET_0, ®);
if ((reg & (1ul << 10)) == (1ul << 10)) {
reg &= ~(1ul << 10);
ret += nm_write_reg(NMI_GLB_RESET_0, reg);
}
reg |= (1ul << 10);
ret += nm_write_reg(NMI_GLB_RESET_0, reg);
nm_bsp_sleep(1); /* TODO: Why bus error if this delay is not here. */
return ret;
}
示例13: m2m_ota_cb
/**
* @fn m2m_wifi_cb(uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr, uint8 grp)
* @brief WiFi call back function
* @param [in] u8OpCode
* HIF Opcode type.
* @param [in] u16DataSize
* HIF data length.
* @param [in] u32Addr
* HIF address.
* @param [in] grp
* HIF group type.
* @author
* @date
* @version 1.0
*/
static void m2m_ota_cb(uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr)
{
sint8 ret = M2M_SUCCESS;
if(u8OpCode == M2M_OTA_RESP_NOTIF_UPDATE_INFO)
{
tstrOtaUpdateInfo strOtaUpdateInfo;
m2m_memset((uint8*)&strOtaUpdateInfo,0,sizeof(tstrOtaUpdateInfo));
ret = hif_receive(u32Addr,(uint8*)&strOtaUpdateInfo,sizeof(tstrOtaUpdateInfo),0);
if(ret == M2M_SUCCESS)
{
if(gpfOtaNotifCb)
gpfOtaNotifCb(&strOtaUpdateInfo);
}
}
else if (u8OpCode == M2M_OTA_RESP_UPDATE_STATUS)
{
tstrOtaUpdateStatusResp strOtaUpdateStatusResp;
m2m_memset((uint8*)&strOtaUpdateStatusResp,0,sizeof(tstrOtaUpdateStatusResp));
ret = hif_receive(u32Addr, (uint8*) &strOtaUpdateStatusResp,sizeof(tstrOtaUpdateStatusResp), 0);
if(ret == M2M_SUCCESS)
{
if(gpfOtaUpdateCb)
gpfOtaUpdateCb(strOtaUpdateStatusResp.u8OtaUpdateStatusType,strOtaUpdateStatusResp.u8OtaUpdateStatus);
}
}
else
{
M2M_ERR("Invaild OTA resp %d ?\n",u8OpCode);
}
}
示例14: m2m_ota_init
/*!
@fn \
NMI_API sint8 m2m_ota_init(tpfOtaUpdateCb pfOtaUpdateCb, tpfOtaNotifCb pfOtaNotifCb);
@brief
Initialize the OTA layer.
@param [in] pfOtaUpdateCb
OTA Update callback function
@param [in] pfOtaNotifCb
OTA notify callback function
@return
The function SHALL return 0 for success and a negative value otherwise.
*/
NMI_API sint8 m2m_ota_init(tpfOtaUpdateCb pfOtaUpdateCb, tpfOtaNotifCb pfOtaNotifCb)
{
sint8 ret = M2M_SUCCESS;
if(pfOtaUpdateCb){
gpfOtaUpdateCb = pfOtaUpdateCb;
}else{
M2M_ERR("Invaild Ota update cb\n");
}
if(pfOtaNotifCb){
gpfOtaNotifCb = pfOtaNotifCb;
}else{
M2M_ERR("Invaild Ota notify cb\n");
}
hif_register_cb(M2M_REQ_GROUP_OTA,m2m_ota_cb);
return ret;
}
示例15: m2m_wifi_set_scan_list
sint8 m2m_wifi_set_scan_list(tstrM2MScanList* pstrScanList)
{
sint8 s8Ret = M2M_ERR_FAIL;
s8Ret = hif_send(M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_SCAN_LIST, (uint8*)pstrScanList, sizeof(tstrM2MScanList),NULL, 0,0);
if(s8Ret != M2M_SUCCESS)
{
M2M_ERR("SCAN List Ret = %d\n",s8Ret);
}
return s8Ret;
}