| | |
| | | printf(" %s is LingYun studio MQTT daemon program running on RaspberryPi\n", progname); |
| | | |
| | | printf("\nMandatory arguments to long options are mandatory for short options too:\n"); |
| | | printf(" -b[daemon ] Running in daemon mode\n"); |
| | | printf(" -d[debug ] Running in debug mode\n"); |
| | | printf(" -c[conf ] Specify configure file\n"); |
| | | printf(" -h[help ] Display this help information\n"); |
| | |
| | | |
| | | int main (int argc, char **argv) |
| | | { |
| | | int daemon = 1; |
| | | int daemon = 0; |
| | | pthread_t tid; |
| | | mqtt_ctx_t ctx; |
| | | char *conf_file="/etc/mqttd.conf"; |
| | | char *conf_file="/etc/thingsboard.conf"; |
| | | int debug = 0; |
| | | int opt; |
| | | char *progname=NULL; |
| | | |
| | | struct option long_options[] = { |
| | | {"conf", required_argument, NULL, 'c'}, |
| | | {"daemon", no_argument, NULL, 'b'}, |
| | | {"debug", no_argument, NULL, 'd'}, |
| | | {"version", no_argument, NULL, 'v'}, |
| | | {"help", no_argument, NULL, 'h'}, |
| | |
| | | progname = (char *)basename(argv[0]); |
| | | |
| | | /* parser the command line parameters */ |
| | | while ((opt = getopt_long(argc, argv, "c:dvh", long_options, NULL)) != -1) |
| | | while ((opt = getopt_long(argc, argv, "c:bdvh", long_options, NULL)) != -1) |
| | | { |
| | | switch (opt) |
| | | { |
| | |
| | | conf_file = optarg; |
| | | break; |
| | | |
| | | case 'b': /* Set daemon running */ |
| | | daemon = 1; |
| | | break; |
| | | |
| | | case 'd': /* Set debug running */ |
| | | daemon = 0; |
| | | debug = 1; |
| | | break; |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | if( !conf_file ) |
| | | debug = 1; |
| | | |
| | | /* parser configure file */ |
| | | if( mqttd_parser_conf(conf_file, &ctx, debug)<0 ) |
| | | if( parser_conf(conf_file, &ctx, debug)<0 ) |
| | | { |
| | | fprintf(stderr, "Parser mqtted configure file failure\n"); |
| | | fprintf(stderr, "Parser thingsboard configure file failure\n"); |
| | | return -2; |
| | | } |
| | | |