Example #1
0
static void hl_wireless_set_addr_from_file(void)
{
    uint8_t wireless_node_addr = WIRELESS_NODE_ADDR;
    char nAddrStr[16] = { 0 };

    if (FR_OK == Storage::read(WIRELESS_NODE_ADDR_FILE, nAddrStr, sizeof(nAddrStr)-1, 0)) {
        wireless_node_addr = atoi(nAddrStr);
        bool ok = mesh_set_node_address(wireless_node_addr);
        printf("Set wireless node address to %i from '%s' file: %s\n",
                    wireless_node_addr, WIRELESS_NODE_ADDR_FILE, ok ? "Done!" : "FAILED");
    }
}
static void hl_wireless_set_addr_from_file(void)
{
    uint8_t wireless_node_addr = WIRELESS_NODE_ADDR;
    char nAddrStr[8] = { 0 };

    if (FR_OK == Storage::read(WIRELESS_NODE_ADDR_FILE, nAddrStr, sizeof(nAddrStr)-1, 0)) {
        wireless_node_addr = atoi(nAddrStr);
        if (0 == wireless_node_addr || MESH_BROADCAST_ADDR == wireless_node_addr) {
            printf("Invalid node address (%s) specified in %s\n", nAddrStr, WIRELESS_NODE_ADDR_FILE);
        }
        else {
            printf("Wireless node addr set to %i from '%s' file\n",
                    wireless_node_addr, WIRELESS_NODE_ADDR_FILE);
            mesh_set_node_address(wireless_node_addr);
        }
    }
}
static CMD_HANDLER_FUNC(wsAddrHandler)
{
    int addr = (int) cmdParams;
    output.printf("Set address to %i: %s\n", addr, mesh_set_node_address(addr) ? "OK" : "FAILED");
    return true;
}