Access primary address of ESP-BLE-MESH publishing node in ESP-IDF - visual-studio-code

I have a simple BLE mesh (using Espressif's ESP-BLE-MESH) consisting of two nodes; one containing 3 generic onoff server elements publishing to a group, and one containing a single generic onoff client subscribed to that group. Each node is a little ESP32 dev board with an RGB LED built in. I'm programming in C, using the ESP-IDF extension for Visual Studio Code.
I want the 3 onoff servers to control the R, G and B of the LED, respectively, but all I have to distinguish a server from the others is the address of its element, which is the primary address of the node + some offset. I want to get that offset to determine which of R, G and B are being switched, but I can't figure out how to access the primary address of the publishing node to work that out. I've trawled the documentation and tried every member of the esp_ble_mesh_generic_client_cb_param_t struct passed to the example_ble_mesh_generic_client_cb function, going down such rabbit holes as param->params->model->pub->publish_addr, but have been unsuccessful. Is what I'm trying to achieve even possible?
Server and client code used: ble mesh node

Related

Can a transporter follow an 'material' agent into another agent?

I have an material agent that is moved from the Main agent to inside another agent (simulating a room). I can send the material agent using the Exit and Enter blocks. The 'room' agent contains a network that the material agent is being sent to.
The material agent is initially being moved in Main using a Transporter. However I'm not able to get this Transporter to follow the material agent into the room agent. The main questions is - is it possible to send a Transporter into another agent? Or does it need to remain in the agent that the Transporter Fleet is located?
Thank you.
I will correct benjamin by saying that with setEnvironment you can't do it since that's a function that is called on the agent initialization.
Instead of setEnvironment,something you do normally is to send the agent to a new population (which is the way you dynamically change environment), but it doesn't work with transporters
My answer would be that you can't do it since transporters who follow paths are defined as strict AGVs and can only move on their initial network and you can't change the network, unlike other agents.
But i'm always a bit suspicious of myself when i say something is not possible...
This should be possible with some setEnvironment() calls.
However, it is not a good setup. Think of reality: your rooms are spatially all part of the same environment: your flat (or factory or whatever). Moving from 1 room to the next does not mean you change your flat. You stay in the same environment.
You should setup your room agents like that as well: their spatial representation should reside in Main (or whatever agent they are embedded in).
Use a parameter of type ShapeRectangle or similar in your Room agent to define which rectangle (or else) represents the spatial aspect of the room.
Then, the flow chart blocks in the Room agent simply refer to that parameter for their spatial needs.

How to communicate variables between agent populations in AnyLogic?

I have two populations of agents (only one of which I want to control) and I want to program one agent's actions based on the distance to the agents in the other population. I can get the location of each agent in their own population by using getX() and getY(). However, once these values are stored in a variable, they are not able to be communicated to a different population. Also, using distanceTo (agent other) does not seem to work for agents in a different population. Another issue I am having is how to call up location information for a specific agent (i.e., agent 1 in a population of X agents). When I print the agent names during a model simulation run, I see the agents listed as root.agent[0], etc., however, this syntax does not seem to work for calling up that specific agent when trying to code specific actions based on that agent (i.e., when this agent is so close, do something).
I tried storing locations using getX() and getY() into separate variables. Then using those variables to perform distance calculations. However, these variables, when stored in agent1 agent type, they cannot be communicated to agent2 agent type for variable use. I tried this for distanceTo() as well and got similar errors. I also try calling root.agents[0], root.agent[0] and agent[0] to use for distance calculations (both in and out of that agent's agent type) and get errors for "variable root not recognized" and "variable agent not recognized."
I understand this may be a beginning level programming question, but I cannot find literature on how to solve this problem in AnyLogic help sites online, nor have I been able to find a specific tutorial that works with this type of issue. Thank you for the help.

AB modeling in anylogic (statechart)

I have a problem where the state of one agent depends on the states of its components. Like I have a machine which consists of 10 different components. each one has its own state chart( the states could be; Operating,failed, under manitenance...etc). So the machine will fail if at least one component fails and it will be up if all of them is operating. What I did is to create the 10 agents and create thier statecharts( please note that each component has different failure rate, repair time..etc that is why i seperate them) and i created one agent for the machine with its statechart(that is dependent on the 10 statecharts), I am stuck here, I could not find way to get the state of the machine based on its components' states.
It should be AB modeling
Thanks alot

Automatic edge creation in OrientDB

I'm trying to use OrientDB to map the relationship between servers that are managed by multiple different systems (with some overlap). Suppose that each server from each system was a vertex, is there a way to create an edge automatically between two servers that have the same property (e.g. IP address)
Suppose this is my starting data (in CSV format)
System, Name, IP
---------------------------------
Alpha, compute-1, 192.168.0.1
Alpha, compute-2, 192.168.0.2
Beta, storage-1, 192.168.0.1
Beta, storage-2, 192.168.0.3
Question 1 Can I automatically create edges between the first and third entry?
Question 2 If I added a fifth entry Beta, storage-3, 192.168.0.2 , would the link be efficiently (and preferable automatically) created between the second and fifth entry?
Question 3 What if I added a third system Gamma, where only the last byte is specified, and it is assumed that the first three are 192.168.0, can I concatenate the two together and still automatically create edges against Alpha and Beta entries?
Take a look at the OrientDB ETL tool:
http://orientdb.com/docs/last/ETL-Introduction.html
It can load from CSVs:
http://orientdb.com/docs/last/Extractor.html#csv-extractor
And transform to Vertexes and Endges
http://orientdb.com/docs/last/Transformer.html
Of course, you can write some custom code to load your specific CSV to OrientDB.

Query to work out possible destinations on a set of routes using SQL Server 2008

I'm writing an application that models train routes, which are stored in the database table [TrainStop] as follows:
TrainServiceId
StationCode
StopIndex
IsEnabled
So a given train follows a route and consists of several rows with the StopIndex indicating the order. The problem I am trying to solve is to say which stations a user can get to from a given starting station based on the train services that are available. This would be relatively straightforward BUT it is also possible to disable stops which means that a user cannot get to any destinations after that stop for that train service. It is also possible that multiple trains on different routes can share stations e.g.:
Train Service 1: A, B, C, D, E
Train Service 2: P, Q, B, C, D, R
So if a user is at B they can go to C, D, E and R but if station D is disabled on either service they can get to C only. If station E is disabled on service 1 the user can get to C, D and R.
Solving this problem is fairly straightforward within C# but I am wondering whether it can be solved elegantly and efficiently within SQL? I'm struggling to find a way, for each route, to rule out stations past a row that is not enabled.
I think I might set it up this way. Three tables:
ROUTE
List of routes
STATION
List of stations
ROUTEPATH (or route plan?)
Many-to-many table between route and station, including the StopIndex attribute
Whether a station is enabled or disabled is both an attribute of an individual station (station is closed) AND an attribute of the route path (station before "this" station is closed, so "this" is also closed). That means that IsEnabled should appear in bot the STATION and ROUTEPATH tables.
When a station is to be disabled:
Flag it as disabled in STATION
Flag it as disabled in ROUTEPATH
For each route containing that station, flag all stations with StopIndex greater than that station's as disabled (these last two can be done as one update query)
When a station is to be enabled, reverse the process.
There will of course be problems when more than one station becomes disabled--or rather, when some but not all disabled stations become enabled again. I think it would be better to make ROUTEPATH's attribute "IsDisabled", and make it an integer:
Zero means not disabled
Non-zero means disabled
Increment it by one for each "station disabled" action
Decrement it by one for each "station enabled" action
A system like this should lend itself to relatively simple queries.