QUINTIC服务和uuid

想问下这个QN9020如何添加UUID和服务?

在project中名为profile的group下的文件,有许多是以profile名称命名的C文件,这些就是建立服务的数据库的文件,UUID就是在这里定义的。

安安 发表于 2015-4-16 15:45
在project中名为profile的group下的文件,有许多是以profile名称命名的C文件,这些就是建立服务的数据库的 …

有没有这方面的文档或者笔记呢?

thong 发表于 2015-4-17 14:26
有没有这方面的文档或者笔记呢?

暂时还没有这方面的文档,不过我们已经在着手准备这些资料,如果有需要的话,预计下周可以发布一个如何创建server的教程。你可以先参考一下我对QPPS的profile分析理解去理解一下怎么去创建一个服务。

thong 发表于 2015-4-17 14:26
有没有这方面的文档或者笔记呢?

http://blog.csdn.net/haby77/article/details/45095159

谢谢楼主

hi,thong
以下代码为某一项目创建server 关键代码,希望能帮到你

static int fireble_create_db_req_handler(ke_msg_id_t const msgid,
                                      struct fireble_create_db_req const *param,
                                      ke_task_id_t const dest_id,
                                      ke_task_id_t const src_id)
{
    //Service Configuration Flag
   volatile uint64_t cfg_flag = 0;//FIREBLE_MANDATORY_SUM_MASK;
   volatile uint8_t  idx_nb = 0;//FIREBLE_MANDATORY_SUM_NUM;//base size of data base
    //Database Creation Status
   volatile uint8_t  status;

    //Save Application ID
    fireble_env.appid = src_id;

    /*---------------------------------------------------*
     * fireble private Service Creation
     *---------------------------------------------------*/
    int i = 0;
    struct atts_desc *fireble_db = NULL;
    struct atts_char_desc *char_in_desc_def = NULL;
    struct atts_char_desc *char_out_desc_def = NULL;
    atts_svc_desc_t *service_desc_def = NULL;

		uint16_t sizeofdb = sizeof(struct atts_desc)+//for service
							FIREBLE_MANDATORY_IN_INCREASE_NUM * (FirebleRXNum) * sizeof(struct atts_desc)+
							FIREBLE_MANDATORY_OUT_INCREASE_NUM * (FirebleTXNum) * sizeof(struct atts_desc);

    fireble_db = (struct atts_desc *)ke_malloc(sizeofdb);

		/* begin create service db */
    service_desc_def = (atts_svc_desc_t *)ke_malloc(sizeof(atts_svc_desc_t));
		service_desc_def[0] = FIREBLE_SVC_PRIVATE_UUID;
		fireble_db[idx_nb].uuid = ATT_DECL_PRIMARY_SERVICE;
		fireble_db[idx_nb].perm = PERM(RD, ENABLE);
		fireble_db[idx_nb].max_length =	sizeof(service_desc_def[0]);
		fireble_db[idx_nb].length =	sizeof(service_desc_def[0]);
		fireble_db[idx_nb++].value = (uint8_t*)&service_desc_def[0];
		cfg_flag = 1;
		/* end create service db */

    char_in_desc_def = (struct atts_char_desc *)ke_malloc((FirebleRXNum) * sizeof(struct atts_char_desc));
    char_out_desc_def = (struct atts_char_desc *)ke_malloc((FirebleTXNum) * sizeof(struct atts_char_desc));

    for (i = 0; i < FirebleTXNum; i++)
    {
			const struct atts_char_desc value_char = ATTS_CHAR(ATT_CHAR_PROP_NTF , 0,
													 FIREBLE_DATA_OUT_UUID + i);
					char_out_desc_def[i] = value_char;

			fireble_db[idx_nb].uuid = ATT_DECL_CHARACTERISTIC;
			fireble_db[idx_nb].perm =  PERM(RD, ENABLE);
			fireble_db[idx_nb].max_length =  sizeof(char_out_desc_def[i]);
			fireble_db[idx_nb].length =  sizeof(char_out_desc_def[i]);
					fireble_db[idx_nb++].value = (uint8_t*)&char_out_desc_def[i];

			fireble_db[idx_nb].uuid = FIREBLE_DATA_OUT_UUID + i;
			fireble_db[idx_nb].perm = PERM(NTF, ENABLE);
			fireble_db[idx_nb].max_length =  FIREBLE_SEND_DATA_MAX_LEN;
			fireble_db[idx_nb].length =  0;
			fireble_db[idx_nb++].value = NULL;

			fireble_db[idx_nb].uuid = ATT_DESC_CLIENT_CHAR_CFG;
			fireble_db[idx_nb].perm = PERM(RD, ENABLE)|PERM(WR, ENABLE);
			fireble_db[idx_nb].max_length =  sizeof(uint16_t);
			fireble_db[idx_nb].length =  0;
			fireble_db[idx_nb++].value = NULL;

      cfg_flag = (cfg_flag << FIREBLE_MANDATORY_OUT_INCREASE_NUM) | FIREBLE_MANDATORY_OUT_INCREASE_MASK;
    }
    for (i = 0; i < FirebleRXNum; i++)
    {
			const struct atts_char_desc value_char = ATTS_CHAR(ATT_CHAR_PROP_WR | ATT_CHAR_PROP_WR_NO_RESP, 0,
																							 FIREBLE_DATA_IN_UUID + i);
			char_in_desc_def[i] = value_char;

			fireble_db[idx_nb].uuid = ATT_DECL_CHARACTERISTIC;
			fireble_db[idx_nb].perm =  PERM(RD, ENABLE);
			fireble_db[idx_nb].max_length =  sizeof(char_in_desc_def[i]);
			fireble_db[idx_nb].length =  sizeof(char_in_desc_def[i]);
			fireble_db[idx_nb++].value = (uint8_t*)&char_in_desc_def[i];

			fireble_db[idx_nb].uuid = FIREBLE_DATA_IN_UUID + i;
			fireble_db[idx_nb].perm = PERM(WR, ENABLE);
			fireble_db[idx_nb].max_length =  FIREBLE_REC_DATA_MAX_LEN;
			fireble_db[idx_nb].length =  0;
			fireble_db[idx_nb++].value = NULL;

      cfg_flag = (cfg_flag << FIREBLE_MANDATORY_IN_INCREASE_NUM) | FIREBLE_MANDATORY_IN_INCREASE_MASK;
    }

    //Add Service Into Database
    status = atts_svc_create_db(&fireble_env.shdl, (uint8_t *)&cfg_flag, idx_nb, NULL,
                               dest_id, &fireble_db[0]);
    ke_free(fireble_db);
    ke_free(char_in_desc_def);
    ke_free(char_out_desc_def);
	  ke_free(service_desc_def);

    if(fireble_env.rx.pdata == NULL)
        fireble_env.rx.pdata = (uint8_t*)ke_malloc(FirebleRXNum * FIREBLE_RX_CHAR_PER_VOLUME);

    if(fireble_env.tx.pdata == NULL)
        fireble_env.tx.pdata = (uint8_t*)ke_malloc(FirebleTXNum * FIREBLE_TX_CHAR_PER_VOLUME);
    //Disable FIREBLE
    attsdb_svc_set_permission(fireble_env.shdl, PERM(SVC, DISABLE));

    //Go to Idle State
    if (status == ATT_ERR_NO_ERROR)
    {
        //If we are here, database has been fulfilled with success, go to idle test
        ke_state_set(TASK_FIREBLE, FIREBLE_IDLE);
    }

    //Send response to application
    struct fireble_create_db_cfm * cfm = KE_MSG_ALLOC(FIREBLE_CREATE_DB_CFM, fireble_env.appid,
                                                   TASK_FIREBLE, fireble_create_db_cfm);
    cfm->status = status;
    ke_msg_send(cfm);
    return (KE_MSG_CONSUMED);
}

请具体分析,应能对理解UUID和服务有帮助

安安 发表于 2015-4-17 15:33
暂时还没有这方面的文档,不过我们已经在着手准备这些资料,如果有需要的话,预计下周可以发布一个如何创 …

你好,问你你们添加服务和特征值的文档好了没?

thong 发表于 2015-4-23 13:57
你好,问你你们添加服务和特征值的文档好了没?

同问

zhang2005 发表于 2015-7-8 10:22
同问

正在制作中{:3_45:}

话说,社区里面现在有关于添加服务的文档了吗?:o

hiccchen 发表于 2015-8-20 10:33
话说,社区里面现在有关于添加服务的文档了吗?

已经发表上去了哦亲
http://developer.t-firefly.com/thread-2163-1-1.html

:o好的