1234567891011121314151617181920212223242526 |
- //
- // Created by 李建 on 2023/12/6.
- //
- #include "channel.h"
- #include <stdio.h>
- #define MAX_CHAN_LEN 8
- struct sparrow_channel
- {
- sparrow_channel_port name;
- channel_recv_callback sub_device_cb;
- };
- static struct sparrow_channel channels[MAX_CHAN_LEN];
- void register_sub_device_channel_recv(sparrow_channel_port name, channel_recv_callback callback) {
- channels[name].sub_device_cb = callback;
- }
- void channel_send_to_sub_device(sparrow_channel_port name, char * payload, sparrow_topic_type topicType ) {
- if(channels[name].sub_device_cb != NULL) {
- channels[name].sub_device_cb(payload, topicType);
- }
- }
|