issues with using application specific SMP Group Id

hello Nordic

i am working with nrf52832 (and 52840) with ncs v2.3.0

i am trying to use the SMP service "user" group id to add some functionality according to this link https://docs.zephyrproject.org/latest/services/device_mgmt/smp_protocol.html#:~:text=This%20is%20the%20base%20group%20for%20defining%20an%20application%20specific%20management%20groups.

i have tried to implement the following 

static struct mgmt_callback augu_mgmt_callbacks;

enum augu_mgmt_event_id {

    AUGU_MGMT_EVENT_ID_DELET_FILE = MGMT_DEF_EVT_OP_ID(MGMT_EVT_GRP_USER_CUSTOM_START,0),
};

int32_t mgmt_augu_cb_function(uint32_t event, int32_t rc, bool *abort_more, void *data,
                        size_t data_size)
{
    switch (event)
    {
        case AUGU_MGMT_EVENT_ID_DELET_FILE:
            LOG_INF("DELETE command works");
            break;

        default:
            AUGU_LOG_ERR("unsupported callback event (event %d)", event);
            break;   
    }
    /* Return OK status code to continue with acceptance to underlying handler */
    return MGMT_ERR_EOK;
}

/// this lines are within an init function (also register for mgmt_fs which works)
/// ...
    img_mgmt_dfu_callbacks.callback = mgmt_dfu_cb_function;
    img_mgmt_dfu_callbacks.event_id = MGMT_EVT_OP_IMG_MGMT_DFU_STOPPED | 
                                      MGMT_EVT_OP_IMG_MGMT_DFU_PENDING | 
                                      MGMT_EVT_OP_IMG_MGMT_DFU_CONFIRMED |
                                      MGMT_EVT_OP_IMG_MGMT_DFU_STARTED; 

    mgmt_callback_register(&img_mgmt_dfu_callbacks);                                      

    img_mgmt_fs_callbacks.callback = mgmt_fs_cb_function;
    img_mgmt_fs_callbacks.event_id = MGMT_EVT_OP_FS_MGMT_FILE_ACCESS;                             
    mgmt_callback_register(&img_mgmt_fs_callbacks);
    
    augu_mgmt_callbacks.callback = mgmt_augu_cb_function;
    augu_mgmt_callbacks.event_id = AUGU_MGMT_EVENT_ID_DELET_FILE;
    mgmt_callback_register(&augu_mgmt_callbacks);
///...
////

and send an empty command but i get "not supported" on the other side,

any idea what i am missing?

hope to read from you soon

best regards

Ziv

Parents Reply Children
  • hi Vidar,

    already done that, i actually already using SMP for upload and download files from fs and for dfu.

    i also learned that i was missing the definition of a mgmt_handler which i added,

    int augu_mgmt_handler_0_read(struct smp_streamer *ctxt)
    {
        LOG_INF("in handler 0 read DELETE AND SHIT .. I AM THE BEST");
        return MGMT_ERR_EOK;
    }
    int augu_mgmt_handler_0(struct smp_streamer *ctxt)
    {
        LOG_INF("in handler 0 DELETE AND SHIT .. I AM THE BEST");
        return MGMT_ERR_EOK;
    }
    int augu_mgmt_handler_1(struct smp_streamer *ctxt)
    {
        LOG_INF("in handler 1 DELETE AND SHIT .. I AM THE BEST");
        return MGMT_ERR_EOK;
    }
    
    
    #define AUGU_MGMT_ID_0 0
    #define AUGU_MGMT_ID_1 1
    
    static const struct mgmt_handler augu_mgmt_handlers[] = {
    	[AUGU_MGMT_ID_0] = {
    		.mh_read = augu_mgmt_handler_0_read,
    		.mh_write = augu_mgmt_handler_0,
    	},
    	[AUGU_MGMT_ID_1] = {
    		.mh_read = NULL,
    		.mh_write = augu_mgmt_handler_1
    	},
    };
    
    static const struct mgmt_handler augu_mgmt_handlers[];
    
    #define AUGU_MGMT_HANDLER_CNT ARRAY_SIZE(augu_mgmt_handlers)
    
    static struct mgmt_group augu_mgmt_group = {
    	.mg_handlers = (struct mgmt_handler *)augu_mgmt_handlers,
    	.mg_handlers_count = AUGU_MGMT_HANDLER_CNT,
    	.mg_group_id = MGMT_EVT_GRP_USER_CUSTOM_START,
    };
    
    static void augu_mgmt_register_group(void)
    {
    	mgmt_register_group(&augu_mgmt_group);
    }
    
    MCUMGR_HANDLER_DEFINE(augu_mgmt, augu_mgmt_register_group);

    but right now my handler is empty with just a print to see that i got the vent on the endpoint side, however on the sender side i get some response [191,255] which i am not sure from where or from which mechanism so the question i am facing now is actually if i am implementing my own user smp commands do i need to build a response payload or something like that, and what part of the mcumgr sent the [191,255] and what does it mean ??

    best regards

    Ziv

  • Ok 

    so [191,255] -> [BF,FF] in CBOR is an empty map apparently 

    and it is an automatic (meaning it is sent under the hood by MCUmgr) 

    so seems to be working now

    i am closing the thread Pray

    best regards

    Ziv

Related