Adding Anchors Address Into Remote Pozyx Tag.

Hello everyone, i am doing an indoor position device, which explains the code below. But i am facing a problem and that is, when i set bool remote = false ( meaning i'm using a local device ), everything works out perfectly. But when i set bool remote = true ( meaning i'm using a remote device ), im facing problems adding my anchor address to the device list of the remote tag. ( if i'm not wrong thats the problem that is occurring to me right now). If anyone spots any error in my coding please reply to this post and let me know :slight_smile:

Thank you very much for your help :slight_smile: Much appreciated

#include <Pozyx.h>
#include <Pozyx_definitions.h>
#include <Wire.h>

////////////////////////////////////////////////
////////////////// PARAMETERS //////////////////
////////////////////////////////////////////////

uint16_t remote_id = 0x694F;
boolean use_processing = true;   
boolean remote = true;
boolean serial = true;
                     
const uint8_t num_anchors = 4;                                    // the number of anchors
uint16_t anchors_id[num_anchors] = {0x6923, 0x6961, 0x6969,0x6e6d};     // the network id of the anchors: change these to the network ids of your anchors.
int32_t anchors_x[num_anchors] = {0, 0, 800, 820};               // anchor x-coorindates in mm
int32_t anchors_y[num_anchors] = {0, 730, 0,730};                  // anchor y-coordinates in mm
int32_t heights[num_anchors] = {0, 760,760,760};              // anchor z-coordinates in mm

uint8_t algorithm = POZYX_POS_ALG_UWB_ONLY;             // positioning algorithm to use. try POZYX_POS_ALG_TRACKING for fast moving objects.
uint8_t dimension = POZYX_3D;                           // positioning dimension
int32_t height = 1000;                                   // height of device, required in 2.5D positioning

////////////////////////////////////////////////

void setup(){
  Serial.begin(115200);
   
  while(!Serial); // for the Arduino Leonardo/Micro only

  Pozyx.begin();

  if(!remote){
    remote_id = NULL;
  }

  Serial.println(F("----------POZYX POSITIONING V1.1----------"));
  Serial.println(F("NOTES:"));
  Serial.println(F("- No parameters required."));
  Serial.println();
  Serial.println(F("- System will auto start anchor configuration"));
  Serial.println();
  Serial.println(F("- System will auto start positioning"));
  Serial.println(F("----------POZYX POSITIONING V1.1----------"));
  Serial.println();
  Serial.println(F("Performing manual anchor configuration:"));

  // clear all previous devices in the device list
    Pozyx.clearDevices(remote_id);
  // sets the anchor manually
  setAnchorsManual();

  delay(2000);
  printCalibrationResult();

  Serial.println(F("Starting positioning: "));
  
}



void loop(){


  coordinates_t position;
    int status;
  
  if(remote){
   status = Pozyx.doRemotePositioning(remote_id, &position, dimension, height,algorithm);
  }
  else{
    status = Pozyx.doPositioning(&position, dimension, height, algorithm);
  }
 if (status == POZYX_SUCCESS){
    // prints out the result
    printCoordinates(position);
  }
 
}


// prints the coordinates for either humans or for processing
void printCoordinates(coordinates_t coor){
  if (remote_id == NULL){
    remote_id = 0;
  }

  if(!use_processing){
    Serial.print("POS ID 0x");
    Serial.println(remote_id, HEX);
    Serial.print(", x(mm): ");
    Serial.print(coor.x);
    Serial.print(", y(mm): ");
    Serial.print(coor.y);
    Serial.print(", z(mm): ");
    Serial.println(coor.z);
  }else{
    Serial.print("POS,0x");
    Serial.print(remote_id,HEX);
    Serial.print(",");
    Serial.print(coor.x);
    Serial.print(",");
    Serial.print(coor.y);
    Serial.print(",");
    Serial.println(coor.z);
  }
}


// function to manually set the anchor coordinates
void setAnchorsManual(){
  for(int i = 0; i < num_anchors; i++){
    device_coordinates_t anchor;
    anchor.network_id = anchors_id[i];
    anchor.flag = 0x1;
    anchor.pos.x = anchors_x[i];
    anchor.pos.y = anchors_y[i];
    anchor.pos.z = heights[i];
    Pozyx.addDevice(anchor);
  }

}

void printCalibrationResult(){
  
  uint8_t list_size;
  int status;
  
  status = Pozyx.getDeviceListSize(&list_size, remote_id);
  Serial.print("list size: ");
  Serial.println(status*list_size);


  uint16_t anchors_id[list_size];
  Pozyx.getDeviceIds(anchors_id, list_size, remote_id);
  Serial.println(F("Calibration result:"));
  Serial.print(F("Anchors found: "));
  Serial.println(list_size);
  
  coordinates_t anchor_coor;
  for(int i = 0; i < list_size; i++)
  {
    Serial.print("ANCHOR,");
    Serial.print("0x");
    Serial.print(anchors_id[i], HEX);
    Serial.print(",");
    Pozyx.getDeviceCoordinates(anchors_id[i], &anchor_coor, remote_id);
    Serial.print(anchor_coor.x);
    Serial.print(",");
    Serial.print(anchor_coor.y);
    Serial.print(",");
    Serial.println(anchor_coor.z);
  }
}

[/code]----------POZYX POSITIONING V1.1----------
NOTES:

  • No parameters required.

  • System will auto start anchor configuration

  • System will auto start positioning
    ----------POZYX POSITIONING V1.1----------

Performing manual anchor configuration:
list size: 0
Assertion failed in function : getDeviceIds
Filename: C:\Users\TP STUDENT\Documents\Arduino\libraries\Pozyx-Arduino-library-master\Pozyx_lib.cpp
Line number: 973
[/code]