Allow all zeroes for AppEUI/JoinEUI

This commit is contained in:
Manuel Bleichenbacher
2021-07-27 22:37:22 +02:00
parent 7fa43dbbdb
commit 6df4b40122
9 changed files with 82 additions and 66 deletions

View File

@ -210,38 +210,38 @@ public:
/**
* @brief Sets the credentials needed to activate the device via OTAA, without activating it.
*
* The provided device EUI, app EUI and app key are saved in non-volatile memory. Before
* The provided DevEUI, AppEUI/JoinEUI and AppKey are saved in non-volatile memory. Before
* this function is called, `nvs_flash_init()` must have been called once.
*
* Call join() to activate the device.
*
* @param devEui Device EUI (16 character string with hexadecimal data)
* @param appEui Application EUI of the device (16 character string with hexadecimal data)
* @param appKey App Key of the device (32 character string with hexadecimal data)
* @param devEui DevEUI (16 character string with hexadecimal data)
* @param appEui AppEUI/JoinEUI of the device (16 character string with hexadecimal data)
* @param appKey AppKey of the device (32 character string with hexadecimal data)
* @return `true` if the provisioning was successful, `false` if the provisioning failed
*/
bool provision(const char *devEui, const char *appEui, const char *appKey) { return ttn_provision(devEui, appEui, appKey); }
/**
* @brief Sets the information needed to activate the device via OTAA, using the MAC to generate the device EUI
* @brief Sets the information needed to activate the device via OTAA, using the MAC to generate the DevEUI
* and without activating it.
*
* The generated device EUI and the provided app EUI and app key are saved in non-volatile memory. Before
* The generated DevEUI and the provided AppEUI/JoinEUI and AppKey are saved in non-volatile memory. Before
* this function is called, 'nvs_flash_init' must have been called once.
*
* The device EUI is generated by retrieving the ESP32's WiFi MAC address and expanding it into a device EUI
* The DevEUI is generated by retrieving the ESP32's WiFi MAC address and expanding it into a DevEUI
* by adding FFFE in the middle. So the MAC address A0:B1:C2:01:02:03 becomes the EUI A0B1C2FFFE010203.
* This hexadecimal data can be entered into the Device EUI field in the TTN console.
* This hexadecimal data can be entered into the DevEUI field in the TTN console.
*
* Generating the device EUI from the MAC address allows to flash the same app EUI and app key to a batch of
* devices. However, using the same app key for multiple devices is insecure. Only use this approach if
* Generating the DevEUI from the MAC address allows to flash the same AppEUI/JoinEUI and AppKey to a batch of
* devices. However, using the same AppKey for multiple devices is insecure. Only use this approach if
* it is okay for that the LoRa communication of your application can easily be intercepted and that
* forged data can be injected.
*
* Call join() to activate.
*
* @param appEui Application EUI of the device (16 character string with hexadecimal data)
* @param appKey App Key of the device (32 character string with hexadecimal data)
* @param appEui AppEUI/JoinEUI of the device (16 character string with hexadecimal data)
* @param appKey AppKey of the device (32 character string with hexadecimal data)
* @return `true` if the provisioning was successful, `false` if the provisioning failed
*/
bool provisionWithMAC(const char *appEui, const char *appKey) { return ttn_provision_with_mac(appEui, appKey); }
@ -254,7 +254,7 @@ public:
void startProvisioningTask() { ttn_start_provisioning_task(); }
/**
* @brief Waits until the device EUI, app EUI and app key have been provisioned
* @brief Waits until the DevEUI, AppEUI/JoinEUI and AppKey have been provisioned
* by the provisioning task.
*
* If the device has already been provisioned (stored data in NVS, call of provision()
@ -266,7 +266,7 @@ public:
/**
* @brief Activates the device via OTAA.
*
* The app EUI, app key and dev EUI must have already been provisioned by a call to provision().
* The DevEUI, AppEUI/JoinEUI and AppKey must have already been provisioned by a call to provision().
* Before this function is called, `nvs_flash_init()` must have been called once.
*
* The function blocks until the activation has completed or failed.
@ -276,15 +276,15 @@ public:
bool join() { return ttn_join_provisioned(); }
/**
* @brief Sets the device EUI, app EUI and app key and activate the device via OTAA.
* @brief Sets the DevEUI, AppEUI/JoinEUI and AppKey and activate the device via OTAA.
*
* The device EUI, app EUI and app key are NOT saved in non-volatile memory.
* The DevEUI, AppEUI/JoinEUI and AppKey are NOT saved in non-volatile memory.
*
* The function blocks until the activation has completed or failed.
*
* @param devEui Device EUI (16 character string with hexadecimal data)
* @param appEui Application EUI of the device (16 character string with hexadecimal data)
* @param appKey App Key of the device (32 character string with hexadecimal data)
* @param devEui DevEUI (16 character string with hexadecimal data)
* @param appEui AppEUI/JoinEUI of the device (16 character string with hexadecimal data)
* @param appKey AppKey of the device (32 character string with hexadecimal data)
* @return `true` if the activation was succesful, `false` if the activation failed
*/
bool join(const char *devEui, const char *appEui, const char *appKey) { return ttn_join(devEui, appEui, appKey); }
@ -324,7 +324,7 @@ public:
void onMessage(TTNMessageCallback callback) { ttn_on_message(callback); }
/**
* @brief Checks if device EUI, app EUI and app key have been stored in non-volatile storage
* @brief Checks if DevEUI, AppEUI/JoinEUI and AppKey have been stored in non-volatile storage
* or have been provided as by a call to join(const char*, const char*, const char*).
*
* @return `true` if they are stored, complete and of the correct size, `false` otherwise

View File

@ -205,38 +205,38 @@ void ttn_set_subband(int band);
/**
* @brief Sets the credentials needed to activate the device via OTAA, without activating it.
*
* The provided device EUI, app EUI and app key are saved in non-volatile memory. Before
* The provided DevEUI, AppEUI/JoinEUI and AppKey are saved in non-volatile memory. Before
* this function is called, `nvs_flash_init()` must have been called once.
*
* Call join() to activate the device.
*
* @param dev_eui Device EUI (16 character string with hexadecimal data)
* @param app_eui Application EUI of the device (16 character string with hexadecimal data)
* @param app_key App Key of the device (32 character string with hexadecimal data)
* @param dev_eui DevEUI (16 character string with hexadecimal data)
* @param app_eui AppEUI/JoinEUI of the device (16 character string with hexadecimal data)
* @param app_key AppKey of the device (32 character string with hexadecimal data)
* @return `true` if the provisioning was successful, `false` if the provisioning failed
*/
bool ttn_provision(const char *dev_eui, const char *app_eui, const char *app_key);
/**
* @brief Sets the information needed to activate the device via OTAA, using the MAC to generate the device EUI
* @brief Sets the information needed to activate the device via OTAA, using the MAC to generate the DevEUI
* and without activating it.
*
* The generated device EUI and the provided app EUI and app key are saved in non-volatile memory. Before
* The generated DevEUI and the provided AppEUI/JoinEUI and AppKey are saved in non-volatile memory. Before
* this function is called, 'nvs_flash_init' must have been called once.
*
* The device EUI is generated by retrieving the ESP32's WiFi MAC address and expanding it into a device EUI
* The DevEUI is generated by retrieving the ESP32's WiFi MAC address and expanding it into a DevEUI
* by adding FFFE in the middle. So the MAC address A0:B1:C2:01:02:03 becomes the EUI A0B1C2FFFE010203.
* This hexadecimal data can be entered into the Device EUI field in the TTN console.
* This hexadecimal data can be entered into the DevEUI field in the TTN console.
*
* Generating the device EUI from the MAC address allows to flash the same app EUI and app key to a batch of
* devices. However, using the same app key for multiple devices is insecure. Only use this approach if
* Generating the DevEUI from the MAC address allows to flash the same AppEUI/JoinEUI and AppKey to a batch of
* devices. However, using the same AppKey for multiple devices is insecure. Only use this approach if
* it is okay for that the LoRa communication of your application can easily be intercepted and that
* forged data can be injected.
*
* Call join() to activate.
*
* @param app_eui Application EUI of the device (16 character string with hexadecimal data)
* @param app_key App Key of the device (32 character string with hexadecimal data)
* @param app_eui AppEUI/JoinEUI of the device (16 character string with hexadecimal data)
* @param app_key AppKey of the device (32 character string with hexadecimal data)
* @return `true` if the provisioning was successful, `false` if the provisioning failed
*/
bool ttn_provision_with_mac(const char *app_eui, const char *app_key);
@ -249,7 +249,7 @@ bool ttn_provision_with_mac(const char *app_eui, const char *app_key);
void ttn_start_provisioning_task(void);
/**
* @brief Waits until the device EUI, app EUI and app key have been provisioned
* @brief Waits until the DevEUI, AppEUI/JoinEUI and AppKey have been provisioned
* by the provisioning task.
*
* If the device has already been provisioned (stored data in NVS, call of provision()
@ -261,7 +261,7 @@ void ttn_wait_for_provisioning(void);
/**
* @brief Activates the device via OTAA.
*
* The app EUI, app key and dev EUI must have already been provisioned by a call to provision().
* The DevEUI, AppEUI/JoinEUI and AppKey must have already been provisioned by a call to provision().
* Before this function is called, `nvs_flash_init()` must have been called once.
*
* The function blocks until the activation has completed or failed.
@ -271,15 +271,15 @@ void ttn_wait_for_provisioning(void);
bool ttn_join_provisioned(void);
/**
* @brief Sets the device EUI, app EUI and app key and activate the device via OTAA.
* @brief Sets the DevEUI, AppEUI/JoinEUI and AppKey and activate the device via OTAA.
*
* The device EUI, app EUI and app key are NOT saved in non-volatile memory.
* The DevEUI, AppEUI/JoinEUI and AppKey are NOT saved in non-volatile memory.
*
* The function blocks until the activation has completed or failed.
*
* @param dev_eui Device EUI (16 character string with hexadecimal data)
* @param app_eui Application EUI of the device (16 character string with hexadecimal data)
* @param app_key App Key of the device (32 character string with hexadecimal data)
* @param dev_eui DevEUI (16 character string with hexadecimal data)
* @param app_eui AppEUI/JoinEUI of the device (16 character string with hexadecimal data)
* @param app_key AppKey of the device (32 character string with hexadecimal data)
* @return `true` if the activation was succesful, `false` if the activation failed
*/
bool ttn_join(const char *dev_eui, const char *app_eui, const char *app_key);
@ -316,7 +316,7 @@ ttn_response_code_t ttn_transmit_message(const uint8_t *payload, size_t length,
void ttn_on_message(ttn_message_cb callback);
/**
* @brief Checks if device EUI, app EUI and app key have been stored in non-volatile storage
* @brief Checks if DevEUI, AppEUI/JoinEUI and AppKey have been stored in non-volatile storage
* or have been provided as by a call to join(const char*, const char*, const char*).
*
* @return `true` if they are stored, complete and of the correct size, `false` otherwise