Exemple #1
0
static void inbox_received_handler(DictionaryIterator *iterator, void *context) {
  // Get the first pair
  Tuple *t = dict_read_first(iterator);

  int key = (int)(t->key / 256);
  int menu_item_section = (int)((t->key % 256) / 16);
  int menu_item = (t->key % 16);
  // Process all pairs present
  while(t != NULL) {
    // Process this pair's key
    switch(key) {
      case KEY_STATUS:
      APP_LOG(APP_LOG_LEVEL_INFO, "STATUS for KEY %d is %d", key, (int)t->value->int32);
        menu_item_statuses[menu_item_section][menu_item] = get_status_text((int)t->value->int32);
        menu_layer_reload_data(s_menu_layer);
        break;
      case KEY_VIBRATE:
        // Trigger vibration
//         text_layer_set_text(s_text_layer, "Vibrate!");
        APP_LOG(APP_LOG_LEVEL_INFO, "Vibrate!");
        vibes_short_pulse();
        break;
      default:
        APP_LOG(APP_LOG_LEVEL_INFO, "Unknown key: %d", (int)t->key);
        break;
    }

    // Get next pair, if any
    t = dict_read_next(iterator);
  }
}
Exemple #2
0
/**
 * @brief Notify the application of the status of its request to start a
 *network.
 *
 * The NLME-START.confirm primitive allows the NLME to notify the application of
 * the status of its request to start a network.
 *
 * @param Status       nwk status
 */
static void nlme_start_confirm(nwk_enum_t Status)
{
	printf("Node start completed - %s (0x%.2X)\r\n",
			get_status_text((nwk_enum_t)Status), Status);
	if (node_status == STARTING) {
		printf("> Press Enter to return to main menu: \r\n");
		node_status = IDLE;
	}

	if (node_status == ALL_IN_ONE_START) {
		printf("\tPush button pairing.\r\n");
		printf(
				"\tPress SEL key then keeping SEL pressed press any FUNC key.\r\n");
		printf(
				"\tThis starts the push button pairing at the remote controller.\r\n");
		sw_timer_start(led_timer,
				500000,
				SW_TIMEOUT_RELATIVE,
				(FUNC_PTR)led_handling,
				NULL);
		LED_On(LED_NWK_SETUP);

		dev_type_t RecDevTypeList[DEVICE_TYPE_LIST_SIZE];
		profile_id_t RecProfileIdList[PROFILE_ID_LIST_SIZE];

		RecDevTypeList[0] = (dev_type_t)SUPPORTED_DEV_TYPE_0;
		RecProfileIdList[0] = SUPPORTED_PROFILE_ID_0;

		pbp_rec_pair_request(APP_CAPABILITIES, RecDevTypeList,
				RecProfileIdList,
				(FUNC_PTR)pbp_rec_pair_confirm
				);
	}
}
Exemple #3
0
void
http_callback_status(httpd *webserver, request *r)
{
	char * status = NULL;
	char * prestatus = NULL;
	status = get_status_text();
	safe_asprintf(&prestatus, "<pre>\n%s\n</pre>", status);
	http_nodogsplash_serve_info(r, "Nodogsplash Status",prestatus);
	free(status);
	free(prestatus);
}
// called by thread_wdctl_handler(), wdctl进程获取wifidog 客户端信息 (执行 wdctl status 命令)
static void
wdctl_status(int fd)
{
	char * status = NULL;
	int len = 0;

	status = get_status_text();
	len = strlen(status);

	write(fd, status, len);

	free(status);
}
Exemple #5
0
static void zrc_cmd_disc_confirm(nwk_enum_t Status, uint8_t PairingRef,
		uint8_t *SupportedCmd)
{
	printf("ZRC command discovery confirm, Status = %s (0x%02X)\r\n",
			get_status_text((nwk_enum_t)Status), Status);

	node_status = IDLE;

	/* Keep compiler happy */
	Status = Status;
	PairingRef = PairingRef;
	SupportedCmd = SupportedCmd;
}
Exemple #6
0
/**
 * @brief Post processing of the vendor data confirm.
 *
 * @param status     nwk status (constants defined by nwk layer)
 * @param PairingRef Pairing reference
 * @param Handle     Network Layer retries
 *
 */
void vendor_data_confirm(nwk_enum_t Status, uint8_t PairingRef,
		profile_id_t ProfileId,
		uint8_t Handle
		)
{
	printf(
			"Vendor data confirm,  Status = %s (0x%.2X), pairing reference %d\r\n",
			get_status_text((nwk_enum_t)Status), Status,
			PairingRef);
	/* Keeps compiler Happy */
	Handle = Handle;
	ProfileId = ProfileId;
}
Exemple #7
0
static void
wdctl_status(int fd)
{
	char * status = NULL;
	int len = 0;

	status = get_status_text();
	len = strlen(status);

	if(write(fd, status, len) == -1)
		debug(LOG_CRIT, "Write error: %s", strerror(errno));

	free(status);
}
Exemple #8
0
/**
 * @brief Notify the application for the previous unpair request.
 *
 * The NLME-UNPAIR.confirm primitive allows the NLME to notify the application
 *of
 * the status of its request to remove a pair with another device.
 *
 * @param Status           nwk status
 * @param PairingRef       Pairing Ref for which entry is removed from pairing
 *table.
 */
static void nlme_unpair_confirm(uint8_t Status, uint8_t PairingRef)
{
	if (node_status == UNPAIRING) {
		printf("Unpairing completed - %s(0x%.2X)\r\n",
				get_status_text((nwk_enum_t)Status), Status);
		printf("> Press Enter to return to main menu: \r\n");
		node_status = IDLE;
		if (Status != NWK_NO_PAIRING) {
			number_of_paired_dev--;
		}
	}

	/* Keep compiler happy */
	Status = Status;
	PairingRef = PairingRef;
}
Exemple #9
0
/**
 * @brief Notify the application of the status of its request to to change the
 *        value of a NIB attribute.
 *
 * @param Status              nwk status
 * @param NIBAttribute        NIBAttribute
 * @param NIBAttributeIndex   NIBAttributeIndex
 */
static void nlme_set_confirm(nwk_enum_t Status, nib_attribute_t NIBAttribute,
		uint8_t NIBAttributeIndex)
{
	if (Status != NWK_SUCCESS) {
		printf("Set confirm status - %s (0x%.2X)\r\n",
				get_status_text((nwk_enum_t)Status), Status);
		return;
	}

	if (NIBAttribute == nwkBaseChannel) {
		printf(
				"Base channel changed - press Enter to return to main menu.\r\n");
		node_status = IDLE;
		return;
	}

	/* Keep compiler happy */
	NIBAttributeIndex = NIBAttributeIndex;
}
Exemple #10
0
/**
 * @brief Confirms the previous channel agility request, i.e.
 *nwk_ch_agility_req()
 *
 * @param Status           nwk status
 * @param ChannelChanged   whether channel is changed.
 * @param LogicalChannel   changed logical channel.
 */
static void nwk_ch_agility_confirm(nwk_enum_t Status, bool ChannelChanged,
		uint8_t LogicalChannel)
{
	printf("Channel agility confirm: ");
	if (ch_ag_enabled) {
		printf("enabled\r\n");
	} else {
		printf("disabled\r\n");
	}

	printf("Status = %s (0x%.2X), channel ",
			get_status_text((nwk_enum_t)Status), Status);
	if (!ChannelChanged) {
		printf("not ");
	}

	printf("changed, current channel %d\r\n", LogicalChannel);
	printf("> Press Enter to return to main menu: \r\n");
	node_status = IDLE;
}
Exemple #11
0
void
http_callback_status(httpd * webserver, request * r)
{
    const s_config *config = config_get_config();
    char *status = NULL;
    char *buf;

    if (config->httpdusername &&
        (strcmp(config->httpdusername, r->request.authUser) ||
         strcmp(config->httpdpassword, r->request.authPassword))) {
        debug(LOG_INFO, "Status page requested, forcing authentication");
        httpdForceAuthenticate(r, config->httpdrealm);
        return;
    }

    status = get_status_text();
    safe_asprintf(&buf, "<pre>%s</pre>", status);
    send_http_page(r, "WiFiDog Status", buf);
    free(buf);
    free(status);
}
Exemple #12
0
/**
 * @brief Notify the application of the status of its request to reset the NWK
 *        layer.
 *
 * @param Status              nwk status
 */
static void nlme_reset_confirm(nwk_enum_t Status)
{
	printf("Node reset completed - %s (0x%.2X)\r\n",
			get_status_text((nwk_enum_t)Status), Status);
	number_of_paired_dev = 0;

	if ((node_status == RESETTING) || (Status != NWK_SUCCESS)) {
		printf("> Press Enter to return to main menu: \r\n");
		node_status = IDLE;
		number_of_paired_dev = 0;
		return;
	} else if (node_status == WARM_STARTING) {
		nlme_rx_enable_request(RX_DURATION_INFINITY,
				(FUNC_PTR)nlme_rx_enable_confirm
				);
	} else if (node_status == ALL_IN_ONE_START) {
		printf("\tStart RF4CE network layer - \r\n");
		nlme_start_request(
				(FUNC_PTR)nlme_start_confirm
				);
	}
}
Exemple #13
0
/**
 * @brief Prints the status of push button pairing and if status is success,
 *        then send the cmd discovery to controller.
 *
 * @param Status           nwk status
 * @param PairingRef       Pairing Ref of the new entry.
 */
static void pbp_rec_pair_confirm(nwk_enum_t Status, uint8_t PairingRef)
{
	node_status = IDLE;
	printf(
			"Push button pairing completed\r\nStatus - %s (0x%02X), Pairing Ref 0x%02X\r\n",
			get_status_text((nwk_enum_t)Status), Status,
			PairingRef);

	if (Status == NWK_SUCCESS) {
		if (duplicate_pair_entry == false) {
			number_of_paired_dev++;
		}

#ifdef ZRC_CMD_DISCOVERY
		printf("Sending ZRC command discovery request\r\n");
		node_status = CMD_DISCOVERING;
		zrc_cmd_disc_request(PairingRef,
				(FUNC_PTR)zrc_cmd_disc_confirm
				);
#endif
	}
}