Ejemplo n.º 1
0
uint8_t custom_nvds_get_func(uint8_t tag, nvds_tag_len_t * lengthPtr, uint8_t *buf)
{
    // declaration of ROM function nvds_get_func()
    uint8_t nvds_get_func(uint8_t tag, nvds_tag_len_t * lengthPtr, uint8_t *buf);
    
    switch (tag)
    {
        case NVDS_TAG_BD_ADDRESS:
        {
#if BLE_JWAOO_TOY_SERVER
			if (bd_address_is_valid(jwaoo_toy_device_data.bd_addr)) {
				int i;

				for (i = 0; i < 6; i++) {
					buf[i] = jwaoo_toy_device_data.bd_addr[5 - i];
				}

				*lengthPtr = NVDS_LEN_BD_ADDRESS;
				return NVDS_OK;
			}
#else
            //check if dev_bdaddr is not zero
            if(memcmp(&dev_bdaddr, &co_null_bdaddr, NVDS_LEN_BD_ADDRESS))
            {
                memcpy(buf,&dev_bdaddr,NVDS_LEN_BD_ADDRESS);
                *lengthPtr = NVDS_LEN_BD_ADDRESS;
                return NVDS_OK;
            }
#endif
            break;
        }
        
        case NVDS_TAG_APP_BLE_SCAN_RESP_DATA:
			if (nvds_data_ptr->NVDS_VALIDATION_FLAG & APP_BLE_SCAN_RESP_DATA_VALID)
			{
				if (*lengthPtr < NVDS_LEN_APP_BLE_SCAN_RESP_DATA)
                {		
					*lengthPtr = 0;
                    return (NVDS_LENGTH_OUT_OF_RANGE);
                }
                else 
                {
                    memcpy(buf,nvds_data_ptr->NVDS_TAG_APP_BLE_SCAN_RESP_DATA,nvds_data_ptr->SCAN_RESP_DATA_TAG_LEN);
                    *lengthPtr = nvds_data_ptr->SCAN_RESP_DATA_TAG_LEN;
                    return(NVDS_OK);
                }
            }
            else 
                return(NVDS_FAIL);
            default: break;
    }

    return nvds_get_func(tag, lengthPtr, buf);

}
Ejemplo n.º 2
0
uint8_t custom_nvds_get_func(uint8_t tag, nvds_tag_len_t * lengthPtr, uint8_t *buf)
{
    // declaration of ROM function nvds_get_func()
    uint8_t nvds_get_func(uint8_t tag, nvds_tag_len_t * lengthPtr, uint8_t *buf);

    if (tag == NVDS_TAG_BD_ADDRESS)
    {
#ifdef BDADDR_FROM_OTP   //check if dev_bdaddr is not zero
        if(memcmp(&dev_bdaddr, &co_null_bdaddr, NVDS_LEN_BD_ADDRESS))
        {
            memcpy(buf,&dev_bdaddr,NVDS_LEN_BD_ADDRESS);
            *lengthPtr = NVDS_LEN_BD_ADDRESS;
            return NVDS_OK;
        }
#endif
    }

    return nvds_get_func(tag, lengthPtr, buf);
}